org.jdom.filter.ElementFilter Java Examples
The following examples show how to use
org.jdom.filter.ElementFilter.
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: PrintHandler.java From sakai with Educational Community License v2.0 | 6 votes |
public void setResourceMetadataXml(Element the_md) { // version 1 and higher are different formats, hence a slightly weird test Iterator mdroles = the_md.getDescendants(new ElementFilter("intendedEndUserRole", ns.lom_ns())); if (mdroles != null) { while (mdroles.hasNext()) { Element role = (Element)mdroles.next(); Iterator values = role.getDescendants(new ElementFilter("value", ns.lom_ns())); if (values != null) { while (values.hasNext()) { if (roles == null) roles = new HashSet<String>(); Element value = (Element)values.next(); String roleName = value.getTextTrim(); roles.add(roleName); } } } } if (log.isDebugEnabled()) log.debug("resource md xml: "+the_md); }
Example #2
Source File: PrintHandler.java From sakai with Educational Community License v2.0 | 6 votes |
public void setResourceMetadataXml(Element the_md) { // version 1 and higher are different formats, hence a slightly weird test Iterator mdroles = the_md.getDescendants(new ElementFilter("intendedEndUserRole", ns.lom_ns())); if (mdroles != null) { while (mdroles.hasNext()) { Element role = (Element)mdroles.next(); Iterator values = role.getDescendants(new ElementFilter("value", ns.lom_ns())); if (values != null) { while (values.hasNext()) { if (roles == null) roles = new HashSet<String>(); Element value = (Element)values.next(); String roleName = value.getTextTrim(); roles.add(roleName); } } } } if (log.isDebugEnabled()) log.debug("resource md xml: "+the_md); }
Example #3
Source File: JDOMUtils.java From geowave with Apache License 2.0 | 5 votes |
public static Element findFirstChild(final Element parentEl, final String childName) { final ElementFilter filter = new ElementFilter(childName); final Iterator<Element> childrenIter = parentEl.getDescendants(filter); if (childrenIter.hasNext()) { return childrenIter.next(); } return null; }
Example #4
Source File: JDOMUtil.java From consulo with Apache License 2.0 | 5 votes |
@SuppressWarnings("unused") @Nullable @Deprecated public static Element cloneElement(@Nonnull Element element, @Nonnull ElementFilter elementFilter) { Element result = new Element(element.getName(), element.getNamespace()); List<Attribute> attributes = element.getAttributes(); if (!attributes.isEmpty()) { ArrayList<Attribute> list = new ArrayList<Attribute>(attributes.size()); for (Attribute attribute : attributes) { list.add(attribute.clone()); } result.setAttributes(list); } for (Namespace namespace : element.getAdditionalNamespaces()) { result.addNamespaceDeclaration(namespace); } boolean hasContent = false; for (Content content : element.getContent()) { if (content instanceof Element) { if (elementFilter.matches(content)) { hasContent = true; } else { continue; } } result.addContent(content.clone()); } return hasContent ? result : null; }
Example #5
Source File: ImmutableElement.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public List<Element> getChildren() { return getContent(new ElementFilter()); }
Example #6
Source File: ImmutableElement.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public List<Element> getChildren(String name, Namespace ns) { return getContent(new ElementFilter(name, ns)); }