Package org.jdom.filter

Examples of org.jdom.filter.ElementFilter


    @SuppressWarnings("unchecked")
    public AnnotationJdom(Element annotationElement) {
        this.annotationElement = annotationElement;
        this.name = annotationElement.getAttribute(JdomTreeAdaptor.ID_ATTR).getValue();
        final Iterator<Element> iterator = annotationElement.getDescendants(
                new ElementFilter(JavaSourceTokenType.ANNOTATION_INIT_DEFAULT_KEY.name()));
        if (iterator.hasNext()) {
            defaultParameter = getAnnotationValueForElement(iterator.next());
            parameterMap = Collections.emptyMap();
        }
        else {
            defaultParameter = null;
            final Iterator<Element> keysIterator = annotationElement.getDescendants(
                    new ElementFilter(JavaSourceTokenType.ANNOTATION_INIT_KEY_LIST.name()));
            if (keysIterator.hasNext()) {
                final List<Element> elementList = keysIterator.next().getChildren(JavaSourceTokenType.IDENT.name());
                parameterMap = new HashMap<String, String>((int) (elementList.size() * 1.5), 0.9f);
                for (Element element : elementList) {
                    String value = getAnnotationValueForElement(element);
View Full Code Here


        return listOfResources;
    }

    @Override
    public Set<String> getAssociatedParentUUIDs(Element metadata) {
        ElementFilter elementFilter = new ElementFilter("parentIdentifier", ISO19139Namespaces.GMD);
        return Xml.filterElementValues(
                metadata,
                elementFilter,
                "CharacterString", ISO19139Namespaces.GCO,
                null);
View Full Code Here

    public Set<String> getAssociatedSourceUUIDs(Element metadata) {
        return getAttributeUuidrefValues(metadata, "source", ISO19139Namespaces.GMD);
    }

    private Set<String> getAttributeUuidrefValues(Element metadata, String tagName, Namespace namespace) {
        ElementFilter elementFilter = new ElementFilter(tagName, namespace);
        return Xml.filterElementValues(
                metadata,
                elementFilter,
                null, null,
                "uuidref");
View Full Code Here

        return null;
    }

    @Override
    public Set<String> getAssociatedParentUUIDs(Element metadata) {
        ElementFilter elementFilter = new ElementFilter("isPartOf", DublinCoreNamespaces.DCT);
        return Xml.filterElementValues(
                metadata,
                elementFilter,
                null, null,
                null);
View Full Code Here

     * @return
     */
    private Element getElement(Document doc, String attr) {
        Element ret = null;
       
        Iterator iter = doc.getDescendants(new ElementFilter("string"));       
        while(iter.hasNext()) {
           
            Element e = (Element) iter.next();
            Attribute a = e.getAttribute("name");
           
View Full Code Here

     * @return
     */
    private Element getElement(Document doc, String name) {
        Element ret = null;
       
        Iterator iter = doc.getDescendants(new ElementFilter(name));
        while(iter.hasNext()) {
           
            Element e = (Element) iter.next();
           
            if (e.getName().equals(name)) {
View Full Code Here

                removeSlaElements(workflowXml);
                String workflowXmlString = XmlUtils.removeComments(XmlUtils.prettyPrint(workflowXml).toString());
                workflowXmlString = context.getELEvaluator().evaluate(workflowXmlString, String.class);
                workflowXml = XmlUtils.parseXml(workflowXmlString);

                Iterator<Element> it = workflowXml.getDescendants(new ElementFilter("job-xml"));

                // Checking all variable substitutions in job-xml files
                while (it.hasNext()) {
                    Element e = it.next();
                    String jobXml = e.getTextTrim();
View Full Code Here

            System.out.println(c);
        }

        System.out.println();
        System.out.println("Only elements:");
        itr = doc.getDescendants(new ElementFilter());
        while (itr.hasNext()) {
            Content c = (Content) itr.next();
            System.out.println(c);
        }

        System.out.println();
        System.out.println("Everything that's not an element:");
        itr = doc.getDescendants(new ElementFilter().negate());
        while (itr.hasNext()) {
            Content c = (Content) itr.next();
            System.out.println(c);
        }

        System.out.println();
        System.out.println("Only elements with localname of servlet:");
        itr = doc.getDescendants(new ElementFilter("servlet"));
        while (itr.hasNext()) {
            Content c = (Content) itr.next();
            System.out.println(c);
        }

        System.out.println();
        System.out.println(
             "Only elements with localname of servlet-name or servlet-class:");
        itr = doc.getDescendants(new ElementFilter("servlet-name")
                                 .or(new ElementFilter("servlet-class")));
        while (itr.hasNext()) {
            Content c = (Content) itr.next();
            System.out.println(c);
        }

        System.out.println();
        System.out.println("Remove elements with localname of servlet:");
        itr = doc.getDescendants(new ElementFilter("servlet"));
        while (itr.hasNext()) {
            itr.next();
            itr.remove();
        }
View Full Code Here

                rootElement.setAttribute( "schemaLocation", "http://maven.apache.org/POM/" + modelVersion
                    + " http://maven.apache.org/maven-v" + modelVersion.replace( '.', '_' ) + ".xsd", xsiNamespace );
            }

            // the empty namespace is considered equal to the POM namespace, so match them up to avoid extra xmlns=""
            ElementFilter elementFilter = new ElementFilter( Namespace.getNamespace( "" ) );
            for ( Iterator<?> i = rootElement.getDescendants( elementFilter ); i.hasNext(); )
            {
                Element e = (Element) i.next();
                e.setNamespace( pomNamespace );
            }
View Full Code Here

                rootElement.setAttribute( "schemaLocation", "http://maven.apache.org/POM/" + modelVersion
                    + " http://maven.apache.org/maven-v" + modelVersion.replace( '.', '_' ) + ".xsd", xsiNamespace );
            }

            // the empty namespace is considered equal to the POM namespace, so match them up to avoid extra xmlns=""
            ElementFilter elementFilter = new ElementFilter( Namespace.getNamespace( "" ) );
            for ( Iterator<?> i = rootElement.getDescendants( elementFilter ); i.hasNext(); )
            {
                Element e = (Element) i.next();
                e.setNamespace( pomNamespace );
            }
View Full Code Here

TOP

Related Classes of org.jdom.filter.ElementFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.