Java Code Examples for org.jdom.Element#getName()
The following examples show how to use
org.jdom.Element#getName() .
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: NATO4676Decoder.java From geowave with Apache License 2.0 | 6 votes |
private IDdata readIDdata(final Element element, final Namespace xmlns) { final IDdata id = new IDdata(); 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 ("stationID".equals(childName)) { id.setStationId(childValue); } else if ("nationality".equals(childName)) { id.setNationality(childValue); } } return id; }
Example 2
Source File: SystemParamsUtils.java From entando-core with GNU Lesser General Public License v3.0 | 6 votes |
private static Element searchParamElement(Element currentElement, String paramName) { String elementName = currentElement.getName(); String key = currentElement.getAttributeValue("name"); if (PARAM_ELEMENT.equals(elementName) && paramName.equals(key)) { return currentElement; } else { List<Element> elements = currentElement.getChildren(); for (int i = 0; i < elements.size(); i++) { Element element = elements.get(i); Element result = searchParamElement(element, paramName); if (null != result) { return result; } } } return null; }
Example 3
Source File: DefaultArrangementEntryMatcherSerializer.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private ArrangementMatchCondition deserializeCondition(@Nonnull Element matcherElement) { String name = matcherElement.getName(); if (COMPOSITE_CONDITION_NAME.equals(name)) { ArrangementCompositeMatchCondition composite = new ArrangementCompositeMatchCondition(); for (Object child : matcherElement.getChildren()) { ArrangementMatchCondition deserialised = deserializeCondition((Element)child); if (deserialised != null) { composite.addOperand(deserialised); } } return composite; } else { return deserializeAtomCondition(matcherElement); } }
Example 4
Source File: FeatureSpecification.java From gateplugin-LearningFramework with GNU Lesser General Public License v2.1 | 6 votes |
/** * Return the text of a single child element or a default value. This checks that there is at most * one child of this annType and throws and exception if there are more than one. If there is no * child of this name, then the value elseVal is returned. NOTE: the value returned is trimmed if * it is a string, but case is preserved. * NOTE: this tries both the all-uppercase and the all-lowercase variant of the given name. */ private static String getChildTextOrElse(Element parent, String name, String elseVal) { @SuppressWarnings("unchecked") List<Element> children = parent.getChildren(name); if (children.size() > 1) { throw new GateRuntimeException("Element " + parent.getName() + " has more than one nested " + name + " element"); } if(children.isEmpty()) { return elseVal; } String tmp = parent.getChildTextTrim(name.toUpperCase()); if(tmp == null) { tmp = parent.getChildText(name.toLowerCase()); } if (tmp == null) { return elseVal; } else { return tmp; } }
Example 5
Source File: InspectionProfileConvertor.java From consulo with Apache License 2.0 | 6 votes |
protected boolean processElement(final Element option, final String name) { if (name.equals(DISPLAY_LEVEL_MAP_OPTION)) { final Element levelMap = option.getChild(VALUE_ATT); for (final Object o : levelMap.getChildren()) { Element e = (Element)o; String key = e.getName(); String levelName = e.getAttributeValue(LEVEL_ATT); HighlightSeverity severity = myManager.getSeverityRegistrar().getSeverity(levelName); HighlightDisplayLevel level = severity == null ? null : HighlightDisplayLevel.find(severity); if (level == null) continue; myDisplayLevelMap.put(key, level); } return true; } return false; }
Example 6
Source File: NavigationViewer.java From olat with Apache License 2.0 | 6 votes |
/** * Method to ascertain if an item is a sco, asset or does not have a referenced resource * * @param element * @return */ public String findScoType(final Element element) { if (element.getName() == CP_Core.ITEM) { if (!isReferencingElement(element)) { return NONE; } else { final Element referencedElement = _scormCore.getReferencedElement(element); // does this reference a resource or submanifest if (referencedElement.getName().equals(CP_Core.MANIFEST)) { return CP_Core.MANIFEST; } final String scoType = referencedElement.getAttributeValue(SCORM12_Core.SCORMTYPE, SCORM12_DocumentHandler.ADLCP_NAMESPACE_12); if (scoType != null) { return scoType; } else { return SCORM12_Core.ASSET; } } } return NONE; }
Example 7
Source File: DefaultArrangementEntryMatcherSerializer.java From consulo with Apache License 2.0 | 5 votes |
@javax.annotation.Nullable private ArrangementMatchCondition deserializeAtomCondition(@Nonnull Element matcherElement) { String id = matcherElement.getName(); ArrangementSettingsToken token = StdArrangementTokens.byId(id); boolean processInnerText = true; if (token != null && (StdArrangementTokens.General.TYPE.equals(token) || StdArrangementTokens.General.MODIFIER.equals(token))) { // Backward compatibility with old arrangement settings format. id = matcherElement.getText(); if (StringUtil.isEmpty(id)) { LOG.warn("Can't deserialize match condition at legacy format"); return null; } token = StdArrangementTokens.byId(id); processInnerText = false; } if (token == null) { token = myMixin.deserializeToken(id); } if (token == null) { LOG.warn(String.format("Can't deserialize match condition with id '%s'", id)); return null; } Object value = token; String text = matcherElement.getText(); if (text != null && processInnerText) { text = StringUtil.unescapeStringCharacters(matcherElement.getText()); if (!StringUtil.isEmpty(text)) { value = text; } } return new ArrangementAtomMatchCondition(token, value); }
Example 8
Source File: EntityTypeDOM.java From entando-core with GNU Lesser General Public License v3.0 | 5 votes |
/** * Generate an attribute to insert in an Entity Type. The attribute is * obtained cloning one of the previously defined elements. * * @param attributeElem The element of the Attribute Type to generate. * @return The built attribute. * @throws ApsSystemException If parsing errors are detected. */ private AttributeInterface createAttribute(Element attributeElem) throws ApsSystemException { String typeCode = this.extractXmlAttribute(attributeElem, "attributetype", true); AttributeInterface attr = (AttributeInterface) getAttributeTypes().get(typeCode); if (null == attr) { throw new ApsSystemException("Wrong Attribute Type: " + typeCode + ", " + "found in the tag <" + attributeElem.getName() + ">"); } attr = (AttributeInterface) attr.getAttributePrototype(); attr.setAttributeConfig(attributeElem); if (!attr.isSimple()) { ((AbstractComplexAttribute) attr).setComplexAttributeConfig(attributeElem, this.getAttributeTypes()); } return attr; }
Example 9
Source File: CompositeAttribute.java From entando-core with GNU Lesser General Public License v3.0 | 5 votes |
private void extractAttributeCompositeElement(Map<String, AttributeInterface> attrTypes, Element currentAttrJdomElem) throws ApsSystemException { String typeCode = this.extractXmlAttribute(currentAttrJdomElem, "attributetype", true); AttributeInterface compositeAttrElem = (AttributeInterface) attrTypes.get(typeCode); if (compositeAttrElem == null) { throw new ApsSystemException("The type " + typeCode + " of the attribute element found in the tag <" + currentAttrJdomElem.getName() + "> of the composite attribute is not a valid one"); } compositeAttrElem = (AttributeInterface) compositeAttrElem.getAttributePrototype(); compositeAttrElem.setAttributeConfig(currentAttrJdomElem); compositeAttrElem.setSearchable(false); compositeAttrElem.setDefaultLangCode(this.getDefaultLangCode()); this.addAttribute(compositeAttrElem); }
Example 10
Source File: NATO4676Decoder.java From geowave with Apache License 2.0 | 5 votes |
private Area readCoverageArea(final Element element, final Namespace xmlns) { final Area area = new Area(); 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 ("areaBoundaryPoints".equals(childName)) { final GeodeticPosition pos = readGeodeticPosition(child, xmlns); area.getPoints().add(pos); } } return area; }
Example 11
Source File: NATO4676Decoder.java From geowave with Apache License 2.0 | 5 votes |
private MissionSummaryMessage readMissionSummaryMessage( final Element element, final Namespace xmlns) { final MissionSummaryMessage msg = new MissionSummaryMessage(); final MissionSummary missionSummary = msg.getMissionSummary(); 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 ("missionID".equals(childName)) { missionSummary.setMissionId(childValue); } else if ("Name".equals(childName)) { missionSummary.setName(childValue); } else if ("Security".equals(childName)) { msg.setSecurity(readSecurity(child, xmlns)); missionSummary.setSecurity(msg.getSecurity().getClassification().toString()); } else if ("msgCreatedTime".equals(childName)) { msg.setMessageTime(DateStringToLong(childValue)); } else if ("senderId".equals(childName)) { msg.setSenderID(readIDdata(child, xmlns)); } else if ("StartTime".equals(childName)) { missionSummary.setStartTime(DateStringToLong(childValue)); } else if ("EndTime".equals(childName)) { missionSummary.setEndTime(DateStringToLong(childValue)); } else if ("FrameInformation".equals(childName)) { missionSummary.addFrame(readFrame(child, xmlns)); } else if ("CoverageArea".equals(childName)) { missionSummary.setCoverageArea(readCoverageArea(child, xmlns)); } else if ("ActiveObjectClassifications".equals(childName)) { missionSummary.setClassifications(readObjectClassifications(child, xmlns)); } } return msg; }
Example 12
Source File: AbstractAction.java From microrts with GNU General Public License v3.0 | 5 votes |
public static AbstractAction fromXML(Element e, PhysicalGameState gs, UnitTypeTable utt) { PathFinding pf = null; String pfString = e.getAttributeValue("pathfinding"); if (pfString != null) { if (pfString.equals("AStarPathFinding")) pf = new AStarPathFinding(); if (pfString.equals("BFSPathFinding")) pf = new BFSPathFinding(); if (pfString.equals("FloodFillPathFinding")) pf = new FloodFillPathFinding(); if (pfString.equals("GreedyPathFinding")) pf = new GreedyPathFinding(); } switch (e.getName()) { case "Attack": return new Attack(gs.getUnit(Long.parseLong(e.getAttributeValue("unitID"))), gs.getUnit(Long.parseLong(e.getAttributeValue("target"))), pf); case "Build": return new Build(gs.getUnit(Long.parseLong(e.getAttributeValue("unitID"))), utt.getUnitType(e.getAttributeValue("type")), Integer.parseInt(e.getAttributeValue("x")), Integer.parseInt(e.getAttributeValue("y")), pf); case "Harvest": return new Harvest(gs.getUnit(Long.parseLong(e.getAttributeValue("unitID"))), gs.getUnit(Long.parseLong(e.getAttributeValue("target"))), gs.getUnit(Long.parseLong(e.getAttributeValue("base"))), pf); case "Idle": return new Idle(gs.getUnit(Long.parseLong(e.getAttributeValue("unitID")))); case "Move": return new Move(gs.getUnit(Long.parseLong(e.getAttributeValue("unitID"))), Integer.parseInt(e.getAttributeValue("x")), Integer.parseInt(e.getAttributeValue("y")), pf); case "Train": return new Train(gs.getUnit(Long.parseLong(e.getAttributeValue("unitID"))), utt.getUnitType(e.getAttributeValue("type"))); default: return null; } }
Example 13
Source File: CompactCollectionBinding.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean isBoundTo(@Nonnull Element element) { String elementName = element.getName(); if (isNameEqual(elementName)) { return true; } else if (elementName.equals(Constants.OPTION)) { // JDOMExternalizableStringList format return isNameEqual(element.getAttributeValue(Constants.NAME)); } return false; }
Example 14
Source File: NodesLoader.java From jbt with Apache License 2.0 | 5 votes |
private static void parseElement(String currentPath, Element e) { String nodeType = e.getName(); if (nodeType.equals("Category")) { String categoryName = e.getAttributeValue("name"); List<Element> children = e.getChildren(); for (Element child : children) { String nextPath = currentPath == null ? categoryName : currentPath + ConceptualNodesTree.CATEGORY_SEPARATOR + categoryName; parseElement(nextPath, child); } } else if (nodeType.equals("Node")) { ConceptualBTNode xmlNode = new ConceptualBTNode(); xmlNode.setType(e.getChild("Type").getValue()); String numChildren = e.getChild("Children").getValue(); xmlNode.setNumChildren(numChildren.equals("I") ? -1 : Integer.parseInt(numChildren)); xmlNode.setIcon(e.getChild("Icon").getValue()); xmlNode.setReadableType(e.getChild("ReadableType").getValue()); xmlNode.setHasName(false); parseParameters(xmlNode, e); ConceptualBTNodeItem nodeToInsert = new ConceptualBTNodeItem(xmlNode); standardNodesTree.insertNode(currentPath, nodeToInsert); standardNodes.put(xmlNode.getType(), xmlNode); nodesByCategory.put(xmlNode.getType(), currentPath); } }
Example 15
Source File: NATO4676Decoder.java From geowave with Apache License 2.0 | 5 votes |
private Area readArea(final Element element, final Namespace xmlns) { final Area area = new Area(); 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 ("xxx".equals(childName)) { // area.setXXX(childValue); // TODO: Area , CircularArea, PolygonArea, etc... } } return area; }
Example 16
Source File: NATO4676Decoder.java From geowave with Apache License 2.0 | 5 votes |
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 17
Source File: PatternExpression.java From ghidra with Apache License 2.0 | 4 votes |
public static PatternExpression restoreExpression(Element el, Translate trans) { PatternExpression res; String nm = el.getName(); if (nm.equals("tokenfield")) { res = new TokenField(null); } else if (nm.equals("contextfield")) { res = new ContextField(null); } else if (nm.equals("intb")) { res = new ConstantValue(null); } else if (nm.equals("operand_exp")) { res = new OperandValue(null); } else if (nm.equals("start_exp")) { res = new StartInstructionValue(null); } else if (nm.equals("end_exp")) { res = new EndInstructionValue(null); } else if (nm.equals("plus_exp")) { res = new PlusExpression(null); } else if (nm.equals("sub_exp")) { res = new SubExpression(null); } else if (nm.equals("mult_exp")) { res = new MultExpression(null); } else if (nm.equals("lshift_exp")) { res = new LeftShiftExpression(null); } else if (nm.equals("rshift_exp")) { res = new RightShiftExpression(null); } else if (nm.equals("and_exp")) { res = new AndExpression(null); } else if (nm.equals("or_exp")) { res = new OrExpression(null); } else if (nm.equals("xor_exp")) { res = new XorExpression(null); } else if (nm.equals("div_exp")) { res = new DivExpression(null); } else if (nm.equals("minus_exp")) { res = new MinusExpression(null); } else if (nm.equals("not_exp")) { res = new NotExpression(null); } else { return null; } res.restoreXml(el, trans); return res; }
Example 18
Source File: Story.java From ezScrum with GNU General Public License v2.0 | 4 votes |
private void generateTagReleationHistory() { Long e = 0l; Long i = 0l; Long h = 0l; Long n = 0l; Long s = 0l; Long r = 0l; Long v = 0l; @SuppressWarnings("unchecked") List<Element> tags = mTagRoot.getChildren(); for (Element tag : tags) { @SuppressWarnings("unchecked") List<Element> childTags = tag.getChildren(); for (Element childTag : childTags) { if(tag.getAttributeValue("id") != null) { Long current = Long.parseLong(tag.getAttributeValue("id")); if(e < current && childTag.getName() == ScrumEnum.ESTIMATION) { estimated = childTag.getText(); e = current; } if(i < current && childTag.getName() == ScrumEnum.IMPORTANCE) { importance = childTag.getText(); i = current; } if(h < current && childTag.getName() == ScrumEnum.HOWTODEMO) { howToDemo = childTag.getText(); h = current; } if(n < current && childTag.getName() == ScrumEnum.NOTES) { notes = childTag.getText(); n = current; } if(s <= current && childTag.getName() == ScrumEnum.SPRINT_ID) { sprintId = childTag.getText(); s = current; } if(r < current && childTag.getName() == ScrumEnum.RELEASE_TAG) { releaseId = childTag.getText(); r = current; } if(v < current && childTag.getName() == ScrumEnum.VALUE) { value = childTag.getText(); v = current; } } } } processed = true; }
Example 19
Source File: PCodeTestResults.java From ghidra with Apache License 2.0 | 4 votes |
public PCodeTestResults(Element root) { if (!TAG_NAME.equals(root.getName())) { throw new IllegalArgumentException("Unsupported root element: " + root.getName()); } String ver = root.getAttributeValue("VERSION"); if (!XML_VERSION.equals(ver)) { throw new IllegalArgumentException( "Unsupported XML format version " + ver + ", required format is " + XML_VERSION); } jUnitName = root.getAttributeValue("JUNIT"); time = 0; String timeStr = root.getAttributeValue("TIME"); if (timeStr != null) { try { time = Long.parseLong(timeStr); } catch (NumberFormatException e) { // ignore } } summaryHasIngestErrors = getAttributeValue(root, "INGEST_ERR", false); summaryHasRelocationErrors = getAttributeValue(root, "RELOC_ERR", false); summaryHasDisassemblyErrors = getAttributeValue(root, "DIS_ERR", false); @SuppressWarnings("unchecked") List<Element> elementList = root.getChildren("TestResults"); for (Element element : elementList) { String testName = element.getAttributeValue("NAME"); if (testName == null) { throw new IllegalArgumentException("Invalid TestResults element in XML"); } TestResults testResults = new TestResults(); testResults.totalAsserts = getAttributeValue(element, "TOTAL_ASSERTS", 0); testResults.passCount = getAttributeValue(element, "PASS", 0); testResults.failCount = getAttributeValue(element, "FAIL", 0); testResults.callOtherCount = getAttributeValue(element, "CALLOTHER", 0); testResults.severeFailure = getAttributeValue(element, "SEVERE_FAILURE", false); summaryTotalAsserts += testResults.totalAsserts; summaryPassCount += testResults.passCount; summaryFailCount += testResults.failCount; summaryCallOtherCount += testResults.callOtherCount; if (testResults.severeFailure) { ++summarySevereFailures; } results.put(testName, testResults); } }
Example 20
Source File: JDOMStreamReader.java From cxf with Apache License 2.0 | 4 votes |
public QName getName() { Element el = getCurrentElement(); return new QName(el.getNamespaceURI(), el.getName(), el.getNamespacePrefix()); }