org.jdom.Attribute Java Examples
The following examples show how to use
org.jdom.Attribute.
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: JDOMUtils.java From geowave with Apache License 2.0 | 6 votes |
public static String getAttrStringValIgnoreNamespace( final Element resourceEl, final String attrName) { final List<?> resourceAttr = resourceEl.getAttributes(); if (resourceAttr != null) { for (final Object attrEl : resourceAttr) { final Attribute attr = (Attribute) attrEl; if (attrName.equalsIgnoreCase(attr.getName())) { return attr.getValue(); } } } return null; }
Example #2
Source File: ContentBuilder.java From entando-components with GNU Lesser General Public License v3.0 | 6 votes |
private void setContentDescr(Content content, SyndEntry feedItem, AggregatorConfig aggregatorConfig) throws ApsSystemException { try { String description = ""; Element descr = aggregatorConfig.getDescr(); if (null != descr) { Attribute descrTypeAttr = descr.getAttribute("type"); if (null != descrTypeAttr && descrTypeAttr.getValue().equalsIgnoreCase("expression")) { String filedName = descr.getText(); description = this.extractValue(filedName, feedItem); if (null == description || description.trim().length() == 0) { description = this.getMultiLangDafaultValue(descr, this.getDefaultLangCode()); } } else { description = descr.getText(); } description = this.trimString(description, descr); content.setDescription(description); } } catch (Throwable t) { throw new ApsSystemException("An error occurred setting the content description", t); } }
Example #3
Source File: StateSplitterEx.java From consulo with Apache License 2.0 | 6 votes |
protected static void mergeStateInto(@Nonnull Element target, @Nonnull Element subState, @Nonnull String subStateName) { if (subState.getName().equals(subStateName)) { target.addContent(subState); } else { for (Iterator<Element> iterator = subState.getChildren().iterator(); iterator.hasNext(); ) { Element configuration = iterator.next(); iterator.remove(); target.addContent(configuration); } for (Iterator<Attribute> iterator = subState.getAttributes().iterator(); iterator.hasNext(); ) { Attribute attribute = iterator.next(); iterator.remove(); target.setAttribute(attribute); } } }
Example #4
Source File: Parser.java From sakai with Educational Community License v2.0 | 6 votes |
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 #5
Source File: UnknownRunConfiguration.java From consulo with Apache License 2.0 | 6 votes |
@Override public void writeExternal(final Element element) throws WriteExternalException { if (myStoredElement != null) { final List attributeList = myStoredElement.getAttributes(); for (Object anAttributeList : attributeList) { final Attribute a = (Attribute) anAttributeList; element.setAttribute(a.getName(), a.getValue()); } final List list = myStoredElement.getChildren(); for (Object child : list) { final Element c = (Element) child; element.addContent((Element) c.clone()); } } }
Example #6
Source File: PathMacrosCollectorTest.java From consulo with Apache License 2.0 | 6 votes |
public void testWithFilter() throws Exception { Element root = new Element("root"); final Element testTag = new Element("test"); testTag.setAttribute("path", "$MACRO$"); testTag.setAttribute("ignore", "$PATH$"); root.addContent(testTag); final Set<String> macros = PathMacrosCollectorImpl.getMacroNames(root, null, new PathMacrosImpl()); assertEquals(2, macros.size()); assertTrue(macros.contains("MACRO")); assertTrue(macros.contains("PATH")); final Set<String> filtered = PathMacrosCollectorImpl.getMacroNames(root, new PathMacroFilter() { @Override public boolean skipPathMacros(Attribute attribute) { return "ignore".equals(attribute.getName()); } }, new PathMacrosImpl()); assertEquals(1, filtered.size()); assertTrue(macros.contains("MACRO")); }
Example #7
Source File: PathMacrosCollectorTest.java From consulo with Apache License 2.0 | 6 votes |
public void testWithRecursiveFilter() throws Exception { Element root = new Element("root"); final Element configuration = new Element("configuration"); configuration.setAttribute("value", "some text$macro5$fdsjfhdskjfsd$MACRO$"); root.addContent(configuration); final Set<String> macros = PathMacrosCollectorImpl.getMacroNames(root, new PathMacroFilter() { @Override public boolean recursePathMacros(Attribute attribute) { return "value".equals(attribute.getName()); } }, new PathMacrosImpl()); assertEquals(2, macros.size()); assertTrue(macros.contains("macro5")); assertTrue(macros.contains("MACRO")); }
Example #8
Source File: Parser.java From sakai with Educational Community License v2.0 | 6 votes |
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 #9
Source File: ImmutableSameTypeAttributeList.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull @Override public Iterator<Attribute> iterator() { if (isEmpty()) return EmptyIterator.getInstance(); return new Iterator<Attribute>() { int i; @Override public boolean hasNext() { return i < size(); } @Override public Attribute next() { return get(i++); } @Override public void remove() { throw ImmutableElement.immutableError(ImmutableSameTypeAttributeList.this); } }; }
Example #10
Source File: DAOEGTaskConfiguration.java From BART with MIT License | 6 votes |
private OutlierErrorConfiguration extractOutlierErrorConfiguration(Element outlierErrorsTag) { OutlierErrorConfiguration outlierErrorConfiguration = new OutlierErrorConfiguration(); Element tablesElement = getMandatoryElement(outlierErrorsTag, "tables"); List<Element> tables = getMandatoryElements(tablesElement, "table"); for (Element table : tables) { Attribute tableName = getMandatoryAttribute(table, "name"); Element attributesElement = getMandatoryElement(table, "attributes"); List<Element> attributeElements = getMandatoryElements(attributesElement, "attribute"); for (Element attribute : attributeElements) { Attribute percentageAttribute = getMandatoryAttribute(attribute, "percentage"); Attribute detectableAttribute = getMandatoryAttribute(attribute, "detectable"); String attributeName = attribute.getTextTrim(); double percentage = Double.parseDouble(percentageAttribute.getValue().trim()); boolean detectable = Boolean.parseBoolean(detectableAttribute.getValue().trim()); outlierErrorConfiguration.addAttributes(tableName.getValue().trim(), attributeName, percentage, detectable); } } return outlierErrorConfiguration; }
Example #11
Source File: PersistentFileSetManager.java From consulo with Apache License 2.0 | 6 votes |
@Override public void loadState(Element state) { final VirtualFileManager vfManager = VirtualFileManager.getInstance(); for (Object child : state.getChildren(FILE_ELEMENT)) { if (child instanceof Element) { final Element fileElement = (Element)child; final Attribute filePathAttr = fileElement.getAttribute(PATH_ATTR); if (filePathAttr != null) { final String filePath = filePathAttr.getValue(); VirtualFile vf = vfManager.findFileByUrl(filePath); if (vf != null) { myFiles.add(vf); } } } } }
Example #12
Source File: DefaultArrangementSettingsSerializer.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private List<ArrangementSectionRule> deserializeSectionRules(@Nonnull Element rulesElement, @javax.annotation.Nullable Set<StdArrangementRuleAliasToken> tokens) { final List<ArrangementSectionRule> sectionRules = new ArrayList<ArrangementSectionRule>(); for (Object o : rulesElement.getChildren(SECTION_ELEMENT_NAME)) { final Element sectionElement = (Element)o; final List<StdArrangementMatchRule> rules = deserializeRules(sectionElement, tokens); final Attribute start = sectionElement.getAttribute(SECTION_START_ATTRIBUTE); final String startComment = start != null ? start.getValue().trim() : null; final Attribute end = sectionElement.getAttribute(SECTION_END_ATTRIBUTE); final String endComment = end != null ? end.getValue().trim() : null; sectionRules.add(ArrangementSectionRule.create(startComment, endComment, rules)); } return sectionRules; }
Example #13
Source File: JDOMNodePointer.java From commons-jxpath with Apache License 2.0 | 5 votes |
/** * Get the local name of the specified node. * @param node to check * @return String local name */ public static String getLocalName(Object node) { if (node instanceof Element) { return ((Element) node).getName(); } if (node instanceof Attribute) { return ((Attribute) node).getName(); } return null; }
Example #14
Source File: ImmutableSameTypeAttributeList.java From consulo with Apache License 2.0 | 5 votes |
Attribute get(String name, Namespace namespace) { if (!myNs.equals(namespace)) return null; for (int i = 0; i < myNameValues.length; i+=2) { String aname = myNameValues[i]; if (aname.equals(name)) { return get(i/2); } } return null; }
Example #15
Source File: ImmutableSameTypeAttributeList.java From consulo with Apache License 2.0 | 5 votes |
private List<Attribute> toList() { List<Attribute> list = new ArrayList<Attribute>(size()); for (int i = 0; i < size(); i++) { list.add(get(i)); } return list; }
Example #16
Source File: ParameterNameHintsSettings.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private String attributeValue(Element element, String attr) { Attribute attribute = element.getAttribute(attr); if (attribute == null) { return null; } return attribute.getValue(); }
Example #17
Source File: StructuralSearchPathMacroFilter.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean skipPathMacros(Attribute attribute) { final String parentName = attribute.getParent().getName(); if ("replaceConfiguration".equals(parentName) || "searchConfiguration".equals(parentName)) { return true; } return false; }
Example #18
Source File: PersistentFileSetManager.java From consulo with Apache License 2.0 | 5 votes |
@Override public Element getState() { final Element root = new Element("root"); for (VirtualFile vf : getSortedFiles()) { final Element vfElement = new Element(FILE_ELEMENT); final Attribute filePathAttr = new Attribute(PATH_ATTR, VfsUtilCore.pathToUrl(vf.getPath())); vfElement.setAttribute(filePathAttr); root.addContent(vfElement); } return root; }
Example #19
Source File: RunConfigurationPathMacroFilter.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean skipPathMacros(Attribute attribute) { final Element parent = attribute.getParent(); final String attrName = attribute.getName(); if (parent.getName().equals(EnvironmentVariablesComponent.ENV) && (attrName.equals(EnvironmentVariablesComponent.NAME) || attrName.equals(EnvironmentVariablesComponent.VALUE))) { return true; } return false; }
Example #20
Source File: RunConfigurationPathMacroFilter.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean recursePathMacros(Attribute attribute) { final Element parent = attribute.getParent(); if (parent != null && "option".equals(parent.getName())) { final Element grandParent = parent.getParentElement(); return grandParent != null && "configuration".equals(grandParent.getName()); } return false; }
Example #21
Source File: ProjectLevelVcsManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void loadState(Element state) { mySerialization.readExternalUtil(state, myOptionsAndConfirmations); final Attribute attribute = state.getAttribute(SETTINGS_EDITED_MANUALLY); if (attribute != null) { try { myHaveLegacyVcsConfiguration = attribute.getBooleanValue(); } catch (DataConversionException ignored) { } } }
Example #22
Source File: CompositePathMacroFilter.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean skipPathMacros(Attribute attribute) { for (PathMacroFilter filter : myFilters) { if (filter.skipPathMacros(attribute)) return true; } return false; }
Example #23
Source File: Interrogative.java From nadia with Apache License 2.0 | 5 votes |
protected void addPronoun(Element parent_node, String rel_name, String num, String pers){ Element node=new Element("node"); node.setAttribute(new Attribute("id", getNextW())); node.setAttribute(new Attribute("pred", "pron")); node.setAttribute(new Attribute("num", num)); node.setAttribute(new Attribute("pers", pers)); addRel(parent_node,rel_name,node); }
Example #24
Source File: Interrogative.java From nadia with Apache License 2.0 | 5 votes |
protected Element createNode(String pred, Map<String, String> attributes){ Element node=createNode(pred); for(Map.Entry<String,String> entry:attributes.entrySet()){ node.setAttribute(new Attribute(entry.getKey(), entry.getValue())); } return node; }
Example #25
Source File: N.java From nadia with Apache License 2.0 | 5 votes |
protected Element createN(boolean politeness, boolean opener, String theme){ Element node=createNode(theme); //e.g., destination if (opener) { node.setAttribute(new Attribute("modifier", "connective-opener")); addDeterminer(node, Flags.DEF); } if (politeness) node.setAttribute(new Attribute("politeness", "yes")); return node; }
Example #26
Source File: Request.java From nadia with Apache License 2.0 | 5 votes |
protected Element createRequest(boolean temp_opener, boolean politeness){ Element node=createNode("tell"); if (temp_opener) node.setAttribute(new Attribute("modifier", "temporal-opener")); if (politeness) node.setAttribute(new Attribute("politeness", "yes")); addPronoun(node, "patient", "sg", "1st"); return node; }
Example #27
Source File: SamlHelper.java From secure-data-service with Apache License 2.0 | 5 votes |
/** * * @param samlAssertion * @return */ public LinkedMultiValueMap<String, String> extractAttributesFromResponse(Assertion samlAssertion) { LinkedMultiValueMap<String, String> attributes = new LinkedMultiValueMap<String, String>(); AttributeStatement attributeStatement = samlAssertion.getAttributeStatements().get(0); for (org.opensaml.saml2.core.Attribute attribute : attributeStatement.getAttributes()) { String samlAttributeName = attribute.getName(); List<XMLObject> valueObjects = attribute.getAttributeValues(); for (XMLObject valueXmlObject : valueObjects) { attributes.add(samlAttributeName, valueXmlObject.getDOM().getTextContent()); } } return attributes; }
Example #28
Source File: TestResultsXmlFormatter.java From consulo with Apache License 2.0 | 5 votes |
private void processJDomElement(Element config) throws SAXException { final String name = config.getName(); final LinkedHashMap<String, String> attributes = new LinkedHashMap<>(); for (Attribute attribute : config.getAttributes()) { attributes.put(attribute.getName(), attribute.getValue()); } startElement(name, attributes); for (Element child : config.getChildren()) { processJDomElement(child); } endElement(name); }
Example #29
Source File: UnknownOrderEntryType.java From consulo with Apache License 2.0 | 5 votes |
@Override public void storeOrderEntry(@Nonnull Element element, @Nonnull UnknownOrderEntryImpl orderEntry) { List<Attribute> attributes = myElement.getAttributes(); for (Attribute attribute : attributes) { element.setAttribute(attribute.getName(), attribute.getValue()); } List<Element> children = myElement.getChildren(); for (Element child : children) { element.addContent(child.clone()); } }
Example #30
Source File: CompositePathMacroFilter.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean recursePathMacros(Attribute attribute) { for (PathMacroFilter filter : myFilters) { if (filter.recursePathMacros(attribute)) return true; } return false; }