org.jdom.Element Java Examples

The following examples show how to use org.jdom.Element. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MapBinding.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void serializeKeyOrValue(@Nonnull Element entry, @Nonnull String attributeName, @Nullable Object value, @Nullable Binding binding, @Nonnull SerializationFilter filter) {
  if (value == null) {
    return;
  }

  if (binding == null) {
    entry.setAttribute(attributeName, XmlSerializerImpl.convertToString(value));
  }
  else {
    Object serialized = binding.serialize(value, entry, filter);
    if (serialized != null) {
      if (myMapAnnotation != null && !myMapAnnotation.surroundKeyWithTag()) {
        entry.addContent((Content)serialized);
      }
      else {
        Element container = new Element(attributeName);
        container.addContent((Content)serialized);
        entry.addContent(container);
      }
    }
  }
}
 
Example #2
Source File: JDOMUtilTest.java    From geoserver-shell with MIT License 6 votes vote down vote up
@Test
public void toPrettyString() throws Exception {
    Element element = JDOMBuilder.buildElement(getResourceString("workspaces.xml"));
    String actual = JDOMUtil.toPrettyString(element);
    String expected = "<workspaces>\r\n" +
            "  <workspace>\r\n" +
            "    <name>it.geosolutions</name>\r\n" +
            "  </workspace>\r\n" +
            "  <workspace>\r\n" +
            "    <name>cite</name>\r\n" +
            "  </workspace>\r\n" +
            "  <workspace>\r\n" +
            "    <name>topp</name>\r\n" +
            "  </workspace>\r\n" +
            "</workspaces>";
    assertEquals(expected, actual);
}
 
Example #3
Source File: JDOMModelConverter.java    From pom-manipulation-ext with Apache License 2.0 6 votes vote down vote up
/**
 * Method updateProfile.
 *  @param profile
 * @param counter
 * @param element
 */
protected void updateProfile( final Profile profile, final IndentationCounter counter, final Element element )
{
    final IndentationCounter innerCount = new IndentationCounter( counter.getDepth() + 1 );
    Utils.findAndReplaceSimpleElement( innerCount, element,
                                       "id", profile.getId(),
                                       "default" );
    updateActivation( profile.getActivation(), innerCount, element );
    updateBuildBase( profile.getBuild(), innerCount, element );
    Utils.findAndReplaceSimpleLists( innerCount, element, profile.getModules(), "modules", "module" );
    updateDistributionManagement( profile.getDistributionManagement(), innerCount,
                                  element );
    Utils.findAndReplaceProperties( innerCount, element, "properties", profile.getProperties() );
    updateDependencyManagement( profile.getDependencyManagement(), innerCount, element );
    iterateDependency( innerCount, element, profile.getDependencies() );
    iterateRepository( innerCount, element, profile.getRepositories(), "repositories", "repository" );
    iterateRepository( innerCount, element, profile.getPluginRepositories(), "pluginRepositories", "pluginRepository" );
    Utils.findAndReplaceXpp3DOM( innerCount, element, "reports", (Xpp3Dom) profile.getReports() );
    updateReporting( profile.getReporting(), innerCount, element );
}
 
Example #4
Source File: CustomActionsSchema.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void readExternal(Element element) throws InvalidDataException {
  DefaultJDOMExternalizer.readExternal(this, element);
  Element schElement = element;
  final String activeName = element.getAttributeValue(ACTIVE);
  if (activeName != null) {
    for (Element toolbarElement : (Iterable<Element>)element.getChildren(ACTIONS_SCHEMA)) {
      for (Object o : toolbarElement.getChildren("option")) {
        if (Comparing.strEqual(((Element)o).getAttributeValue("name"), "myName") && Comparing.strEqual(((Element)o).getAttributeValue("value"), activeName)) {
          schElement = toolbarElement;
          break;
        }
      }
    }
  }
  for (Object groupElement : schElement.getChildren(GROUP)) {
    ActionUrl url = new ActionUrl();
    url.readExternal((Element)groupElement);
    myActions.add(url);
  }
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    System.err.println("read custom actions: " + myActions.toString());
  }
  readIcons(element);
}
 
Example #5
Source File: XmlElementStorage.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
protected final Element getElement(@Nonnull StorageData data, boolean collapsePaths, @Nonnull Map<String, Element> newLiveStates) {
  Element element = data.save(newLiveStates);
  if (element == null || JDOMUtil.isEmpty(element)) {
    return null;
  }

  if (collapsePaths && myPathMacroSubstitutor != null) {
    try {
      myPathMacroSubstitutor.collapsePaths(element);
    }
    finally {
      myPathMacroSubstitutor.reset();
    }
  }

  return element;
}
 
Example #6
Source File: Parser.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
private void 
preProcessResources(Element the_manifest,
  DefaultHandler the_handler) {
 XPath path;
 List<Attribute> results;
 try {
  path = XPath.newInstance(FILE_QUERY);
  path.addNamespace(ns.getNs());
  results = path.selectNodes(the_manifest);
  for (Attribute result : results) {
	  the_handler.preProcessFile(result.getValue()); 
  }
 } catch (JDOMException | ClassCastException e) {
  log.info("Error processing xpath for files", e);
 }
}
 
Example #7
Source File: AddressCorrelatorManager.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public void writeConfigState(SaveState saveState) {
	Element correlatorsRootElement = new Element(ADDRESS_CORRELATORS_ELEMENT_NAME);

	for (AddressCorrelator correlator : correlatorList) {
		Element correlatorSubElement = new Element(ADDRESS_CORRELATOR_SUB_ELEMENT_NAME);
		correlatorSubElement.setAttribute(ADDRESS_CORRELATOR_NAME_KEY,
			correlator.getClass().getName());

		ToolOptions options = correlator.getOptions();
		Element optionsSubElement = new Element(ADDRESS_CORRELATOR_OPTIONS_SUB_ELEMENT);
		Element optionsXMLContent = options.getXmlRoot(true);
		optionsSubElement.addContent(optionsXMLContent);
		correlatorSubElement.addContent(optionsSubElement);
		correlatorsRootElement.addContent(correlatorSubElement);
	}

	saveState.putXmlElement(ADDRESS_CORRELATORS_ELEMENT_NAME, correlatorsRootElement);

}
 
Example #8
Source File: RunnerLayout.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public Element read(@Nonnull Element parentNode) {
  List<Element> tabs = parentNode.getChildren(StringUtil.getShortName(TabImpl.class.getName()));
  for (Element eachTabElement : tabs) {
    TabImpl eachTab = XmlSerializer.deserialize(eachTabElement, TabImpl.class);
    assert eachTab != null;
    XmlSerializer.deserializeInto(getOrCreateTab(eachTab.getIndex()), eachTabElement);
  }

  final List views = parentNode.getChildren(StringUtil.getShortName(ViewImpl.class.getName()));
  for (Object content : views) {
    final ViewImpl state = new ViewImpl(this, (Element)content);
    myViews.put(state.getID(), state);
  }

  XmlSerializer.deserializeInto(myGeneral, parentNode.getChild(StringUtil.getShortName(myGeneral.getClass().getName(), '$')));

  return parentNode;
}
 
Example #9
Source File: CustomActionsSchema.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void readIcons(Element parent) {
  for (Object actionO : parent.getChildren(ELEMENT_ACTION)) {
    Element action = (Element)actionO;
    final String actionId = action.getAttributeValue(ATTRIBUTE_ID);
    final String iconPath = action.getAttributeValue(ATTRIBUTE_ICON);
    if (actionId != null) {
      myIconCustomizations.put(actionId, iconPath);
    }
  }
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
      initActionIcons();
    }
  });
}
 
Example #10
Source File: AbstractFileType.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
static List<Pair<FileNameMatcher, String>> readAssociations(@Nonnull Element element) {
  List<Element> children = element.getChildren(ELEMENT_MAPPING);
  if (children.isEmpty()) {
    return Collections.emptyList();
  }

  List<Pair<FileNameMatcher, String>> result = new SmartList<>();
  for (Element mapping : children) {
    String ext = mapping.getAttributeValue(ATTRIBUTE_EXT);
    String pattern = mapping.getAttributeValue(ATTRIBUTE_PATTERN);

    FileNameMatcher matcher = ext != null ? new ExtensionFileNameMatcher(ext) : FileTypeManager.parseFromString(pattern);
    result.add(Pair.create(matcher, mapping.getAttributeValue(ATTRIBUTE_TYPE)));
  }
  return result;
}
 
Example #11
Source File: JDOMModelConverter.java    From pom-manipulation-ext with Apache License 2.0 6 votes vote down vote up
/**
 * Method updateContributor.
 *  @param contributor
 * @param counter
 * @param element
 */
protected void updateContributor( final Contributor contributor, final IndentationCounter counter, final Element element )
{
    final IndentationCounter innerCount = new IndentationCounter( counter.getDepth() + 1 );
    Utils.findAndReplaceSimpleElement( innerCount, element,
                                       "name", contributor.getName(),
                                       null );
    Utils.findAndReplaceSimpleElement( innerCount, element,
                                       "email", contributor.getEmail(),
                                       null );
    Utils.findAndReplaceSimpleElement( innerCount, element,
                                       "url", contributor.getUrl(),
                                       null );
    Utils.findAndReplaceSimpleElement( innerCount, element, "organization", contributor.getOrganization(), null );
    Utils.findAndReplaceSimpleElement( innerCount, element,
                                       "organizationUrl", contributor.getOrganizationUrl(),
                                       null );
    Utils.findAndReplaceSimpleLists( innerCount, element, contributor.getRoles(), "roles", "role" );
    Utils.findAndReplaceSimpleElement( innerCount, element, "timezone", contributor.getTimezone(), null );
    Utils.findAndReplaceProperties( innerCount, element, "properties", contributor.getProperties() );
}
 
Example #12
Source File: PageModelDOM.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void buildDefaultWidget(Frame frame, Element defaultWidgetElement, int pos, IWidgetTypeManager widgetTypeManager) {
	Widget widget = new Widget();
	String widgetCode = defaultWidgetElement.getAttributeValue(ATTRIBUTE_CODE);
	WidgetType type = widgetTypeManager.getWidgetType(widgetCode);
	if (null == type) {
		_logger.warn("Unknown code of the default widget - '{}'", widgetCode);
		return;
	}
	widget.setType(type);
	Element propertiesElement = defaultWidgetElement.getChild(TAB_PROPERTIES);
	if (null != propertiesElement) {
		ApsProperties prop = this.buildProperties(propertiesElement);
		widget.setConfig(prop);
	}
	frame.setDefaultWidget(widget);
}
 
Example #13
Source File: ThriftPlugin.java    From intellij-thrift with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public Element getState() {
  final Element root = new Element("thrift");

  Element frameWorksList = new Element("compilers");
  if (myConfig != null && StringUtils.isNotBlank(myConfig.getCompilerPath())) {
    Element fw = new Element("compiler");

    fw.setAttribute("url", myConfig.getCompilerPath());
    fw.setAttribute("nowarn", myConfig.isNoWarn() ? "yes" : "no");
    fw.setAttribute("strict", myConfig.isStrict() ? "yes" : "no");
    fw.setAttribute("verbose", myConfig.isVerbose() ? "yes" : "no");
    fw.setAttribute("recurse", myConfig.isRecurse() ? "yes" : "no");
    fw.setAttribute("debug", myConfig.isDebug() ? "yes" : "no");
    fw.setAttribute("allownegkeys", myConfig.isAllowNegKeys() ? "yes" : "no");
    fw.setAttribute("allow64bitconsts", myConfig.isAllow64bitConsts() ? "yes" : "no");

    frameWorksList.addContent(fw);
  }

  root.addContent(frameWorksList);

  return root;
}
 
Example #14
Source File: XmlSerializer.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void serializeInto(@Nonnull Object bean, @Nonnull Element element, @Nullable SerializationFilter filter) {
  if (filter == null) {
    filter = TRUE_FILTER;
  }
  try {
    Binding binding = XmlSerializerImpl.getBinding(bean.getClass());
    assert binding instanceof BeanBinding;
    ((BeanBinding)binding).serializeInto(bean, element, filter);
  }
  catch (XmlSerializationException e) {
    throw e;
  }
  catch (Exception e) {
    throw new XmlSerializationException(e);
  }
}
 
Example #15
Source File: CppHighlightingSettings.java    From CppTools with Apache License 2.0 6 votes vote down vote up
public void readExternal(Element element) throws InvalidDataException {
  String s = element.getAttributeValue(REPORT_IMPLICIT_CAST_TO_BOOL_KEY);
  if (s != null) myReportImplicitCastToBool = Boolean.parseBoolean(s);

  s = element.getAttributeValue(REPORT_NAME_NEVER_REFERENCED_KEY);
  if (s != null) myReportNameNeverReferenced = Boolean.parseBoolean(s);

  s = element.getAttributeValue(REPORT_NAME_REFERENCED_ONCE_KEY);
  if (s != null) myReportNameUsedOnce = Boolean.parseBoolean(s);

  s = element.getAttributeValue(REPORT_REDUNDANT_CAST_KEY);
  if (s != null) myReportRedundantCast = Boolean.parseBoolean(s);

  s = element.getAttributeValue(REPORT_REDUNDANT_QUALIFIER_KEY);
  if (s != null) myReportRedundantQualifier = Boolean.parseBoolean(s);

  s = element.getAttributeValue(REPORT_STATIC_CALL_FROM_INSTANCE_KEY);
  if (s != null) myReportStaticCallFromInstance = Boolean.parseBoolean(s);

  s = element.getAttributeValue(REPORT_UNNEEDED_BRACES_KEY);
  if (s != null) myReportUnneededBraces = Boolean.parseBoolean(s);

  s = element.getAttributeValue(REPORT_DUPLICATED_SYMBOLS_KEY);
  if (s != null) myReportDuplicatedSymbols = Boolean.parseBoolean(s);
}
 
Example #16
Source File: BackgroundTaskByVfsChangeManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public Element getState() {
  Element element = new Element("state");
  for (BackgroundTaskByVfsChangeTaskImpl task : myTasks) {
    Element taskElement = new Element("task");
    element.addContent(taskElement);

    taskElement.setAttribute("url", task.getVirtualFilePointer().getUrl());
    taskElement.setAttribute("provider-name", task.getProviderName());
    taskElement.setAttribute("name", task.getName());
    taskElement.setAttribute("enabled", String.valueOf(task.isEnabled()));

    Element serialize = XmlSerializer.serialize(task.getParameters());

    taskElement.addContent(serialize);

    ExpandMacroToPathMap expandMacroToPathMap = task.createExpandMacroToPathMap();

    expandMacroToPathMap.substitute(serialize, false, true);
  }
  return element;
}
 
Example #17
Source File: SenBotDocumenter.java    From senbot with MIT License 5 votes vote down vote up
private Document generateHtml() {
	Document document = new Document();
	Element html = new Element("html");
	document.setRootElement(html);
	Element head = new Element("head");
	Element body = new Element("body");
	html.addContent(head);
	html.addContent(body);
	
	head.addContent(new Element("title").setText("Step definition documentation"));
	
	body.addContent(new Element("h1").setText("All steps on the classpath"));
	Element list = new Element("ol");
	body.addContent(list);
	
	for(String key : availableStepDefs.keySet()) {
		StepDef stepDef = availableStepDefs.get(key);
		Element listItem = new Element("li");
		list.addContent(listItem);
		
		listItem.addContent(new Element("h3").setText(key));
		listItem.addContent(new Element("br"));
		listItem.addContent("found at: " + stepDef.getFullMethodName());
	}
	
	return document;
}
 
Example #18
Source File: MessageNotifierConfigDOM.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Extract the configuration elements for each message type.
 * @param xml The xml containing the configuration.
 * @return The configuration elements for each message type.
 * @throws ApsSystemException In case of parsing errors.
 */
public Map<String, MessageTypeNotifierConfig> extractConfig(String xml) throws ApsSystemException {
	Map<String, MessageTypeNotifierConfig> config = new HashMap<String, MessageTypeNotifierConfig>();
	Element root = this.getRootElement(xml);
	List<Element> messageTypeElements = root.getChildren(MESSAGETYPE_ELEM);
	for (Element messageTypeElem : messageTypeElements) {
		MessageTypeNotifierConfig messageTypeConfig = this.extractMessageTypeNotifierConfig(messageTypeElem);
		config.put(messageTypeConfig.getTypeCode(), messageTypeConfig);
	}
	return config;
}
 
Example #19
Source File: DAODatabaseConfiguration.java    From Llunatic with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public List<String> loadAuthoritativeSources(Element authoritativeSourcesElement, Scenario scenario) {
    if (authoritativeSourcesElement == null || authoritativeSourcesElement.getChildren().isEmpty()) {
        return new ArrayList<String>();
    }
    List<String> sources = new ArrayList<String>();
    List<Element> sourceElements = authoritativeSourcesElement.getChildren("source");
    for (Element sourceElement : sourceElements) {
        sources.add(sourceElement.getText());
    }
    return sources;
}
 
Example #20
Source File: ScoDocument.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * getElement. A utility method which takes a JDOM element (usually root) and a "cmi" property name (i.e. "cmi.core.student_id") to search for as parameter. The
 * method spilts the cmi value into individual parts and searches down the tree until the correct JDOM element is found. If the element does not exist in the model,
 * then null is returned.
 * 
 * @param element
 * @param propertyName
 * @return the searched element
 */
public Element getElement(final Element element, final String propertyName) {
    Element current = element;
    final String[] cmiBits = propertyName.split("\\.");
    for (int i = 1; i < cmiBits.length; i++) {
        final Element next = current.getChild(cmiBits[i]);
        if (next != null) {
            current = next;
        } else {
            return null;
        }
    }
    return current;
}
 
Example #21
Source File: JDOMExternalizer.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Saves a pack of strings to some attribute. I.e: [tag attr="value"]
 * @param parent parent element (where to add newly created tags)
 * @param nodeName node name (tag, in our example)
 * @param attrName attribute name (attr, in our example)
 * @param values a pack of values to add
 * @see #loadStringsList(org.jdom.Element, String, String)
 */
public static void saveStringsList(@Nonnull final Element parent,
                                   @Nonnull final String nodeName,
                                   @Nonnull final String attrName,
                                   @Nonnull final String... values) {
  for (final String value : values) {
    final Element node = new Element(nodeName);
    node.setAttribute(attrName, value);
    parent.addContent(node);
  }
}
 
Example #22
Source File: InspectionElementsMerger.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * serialize old inspection settings as they could appear in old profiles
 */
protected Element writeOldSettings(String sourceToolName) throws WriteExternalException {
  final Element sourceElement = new Element(InspectionProfileImpl.INSPECTION_TOOL_TAG);
  sourceElement.setAttribute(InspectionProfileImpl.CLASS_TAG, sourceToolName);
  sourceElement.setAttribute(ToolsImpl.ENABLED_ATTRIBUTE, String.valueOf(isEnabledByDefault(sourceToolName)));
  sourceElement.setAttribute(ToolsImpl.LEVEL_ATTRIBUTE, getDefaultSeverityLevel(sourceToolName));
  sourceElement.setAttribute(ToolsImpl.ENABLED_BY_DEFAULT_ATTRIBUTE, String.valueOf(isEnabledByDefault(sourceToolName)));
  return sourceElement;
}
 
Example #23
Source File: NamedScopesHolder.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Element getState() {
  Element element = new Element("state");
  for (NamedScope myScope : myScopes) {
    element.addContent(writeScope(myScope));
  }
  return element;
}
 
Example #24
Source File: DesktopEditorsSplitters.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public T process(@Nullable Element element, @Nullable T context, UIAccess uiAccess) {
  if (element == null) {
    return null;
  }
  final Element splitterElement = element.getChild("splitter");
  if (splitterElement != null) {
    final Element first = splitterElement.getChild("split-first");
    final Element second = splitterElement.getChild("split-second");
    return processSplitter(splitterElement, first, second, context, uiAccess);
  }

  final Element leaf = element.getChild("leaf");
  if (leaf == null) {
    return null;
  }

  List<Element> fileElements = leaf.getChildren("file");
  final List<Element> children = new ArrayList<>(fileElements.size());

  // trim to EDITOR_TAB_LIMIT, ignoring CLOSE_NON_MODIFIED_FILES_FIRST policy
  int toRemove = fileElements.size() - UISettings.getInstance().EDITOR_TAB_LIMIT;
  for (Element fileElement : fileElements) {
    if (toRemove <= 0 || Boolean.valueOf(fileElement.getAttributeValue(PINNED)).booleanValue()) {
      children.add(fileElement);
    }
    else {
      toRemove--;
    }
  }

  return processFiles(children, context, leaf, uiAccess);
}
 
Example #25
Source File: ProjectFilesViewPane.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void readExternal(@NotNull Element element) throws InvalidDataException {
  super.readExternal(element);
  final String showExcludedOption = JDOMExternalizerUtil.readField(element, SHOW_EXCLUDED_FILES_OPTION);
  myShowExcludedFiles = showExcludedOption == null || Boolean.parseBoolean(showExcludedOption);

  final String showOnlyLoadedOption = JDOMExternalizerUtil.readField(element, SHOW_ONLY_LOADED_FILES_OPTION);
  myShowOnlyLoadedFiles = showOnlyLoadedOption == null || Boolean.parseBoolean(showOnlyLoadedOption);
}
 
Example #26
Source File: JDOMUtils.java    From geowave with Apache License 2.0 5 votes vote down vote up
public static String getStringValIgnoreNamespace(
    final Element parentEl,
    final String childName,
    final Namespace[] namespaces,
    final boolean tryLowerCase) {
  final Element el = getChildIgnoreNamespace(parentEl, childName, namespaces, tryLowerCase);

  if (el != null) {
    return el.getTextTrim();
  } else {
    return null;
  }
}
 
Example #27
Source File: DockManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void readStateFor(String type) {
  if (myLoadedState == null) return;

  List windows = myLoadedState.getChildren("window");
  for (Object window1 : windows) {
    Element eachWindow = (Element)window1;
    if (eachWindow == null) continue;

    String eachId = eachWindow.getAttributeValue("id");

    Element eachContent = eachWindow.getChild("content");
    if (eachContent == null) continue;

    String eachType = eachContent.getAttributeValue("type");
    if (eachType == null || !type.equals(eachType) || !myFactories.containsKey(eachType)) continue;

    DockContainerFactory factory = myFactories.get(eachType);
    if (!(factory instanceof DockContainerFactory.Persistent)) continue;

    DockContainerFactory.Persistent persistentFactory = (DockContainerFactory.Persistent)factory;
    DockContainer container = persistentFactory.loadContainerFrom(eachContent);
    register(container);

    final DockWindow window = createWindowFor(eachId, container);
    UIUtil.invokeLaterIfNeeded(window::show);
  }
}
 
Example #28
Source File: NATO4676Decoder.java    From geowave with Apache License 2.0 5 votes vote down vote up
private TrackClassification readTrackClassification(
    final Element element,
    final Namespace xmlns) {
  final TrackClassification trackClassification = new TrackClassification();
  final List<Element> children = element.getChildren();
  final Iterator<Element> childIter = children.iterator();
  while (childIter.hasNext()) {
    final Element child = childIter.next();
    final String childName = child.getName();
    final String childValue = child.getValue();
    if ("trackItemUUID".equals(childName)) {
      try {
        trackClassification.setUuid(UUID.fromString(childValue));
      } catch (final IllegalArgumentException iae) {
        LOGGER.warn("Unable to set uuid", iae);
        trackClassification.setUuid(null);
      }
    } else if ("trackItemSecurity".equals(childName)) {
      trackClassification.setSecurity(readSecurity(child, xmlns));
    } else if ("trackItemTime".equals(childName)) {
      trackClassification.setTime(DateStringToLong(childValue));
    } else if ("trackItemSource".equals(childName)) {
      trackClassification.setSource(childValue);
    } else if ("classification".equals(childName)) {
      trackClassification.classification = ObjectClassification.fromString(childValue);
    } else if ("classificationCredibility".equals(childName)) {
      trackClassification.credibility = readClassificationCredibility(child, xmlns);
    } else if ("numObjects".equals(childName)) {
      trackClassification.setNumObjects(Integer.parseInt(child.getText()));
    }
  }
  return trackClassification;
}
 
Example #29
Source File: JDOMUtils.java    From geowave with Apache License 2.0 5 votes vote down vote up
public static Point3d readPoint3d(final Element ptEl) {
  if (ptEl == null) {
    return null;
  } else {
    final double x = getDoubleVal(ptEl, JDOMUtils.tagX);
    final double y = getDoubleVal(ptEl, JDOMUtils.tagY);
    final double z = getDoubleVal(ptEl, JDOMUtils.tagZ);

    return new Point3d(x, y, z);
  }
}
 
Example #30
Source File: ManageSQSActionController.java    From TeamCity.SonarQubePlugin with Apache License 2.0 5 votes vote down vote up
private SQSInfo editServerInfo(@NotNull final HttpServletRequest request,
                            @NotNull final SProject project,
                            @NotNull final Element ajaxResponse) {
    if (!validate(request, ajaxResponse)) {
        return null;
    }

    final String serverInfoId = getServerInfoId(request);
    if (serverInfoId == null) {
        ajaxResponse.setAttribute("error", "ID is not set");
        return null;
    }

    final SQSInfo old = mySqsManager.getServer(project, serverInfoId);
    if (old == null) {
        return null;
    }

    final String pass = getPassword(request, old);
    final String jdbcPass = getJDBCPassword(request, old);
    final SQSInfo info = createServerInfo(request, serverInfoId, pass, jdbcPass);
    final SQSManager.SQSActionResult result = mySqsManager.editServer(project, info);
    if (!result.isError()) {
        ajaxResponse.setAttribute("status", "OK");
    } else {
        ajaxResponse.setAttribute("error", result.getReason());
    }
    return result.getAfterAction();
}