Java XML QName matches(Node node, String requiredLocalName, QName requiredNamespace)

Here you can find the source of matches(Node node, String requiredLocalName, QName requiredNamespace)

Description

matches

License

Apache License

Declaration

public static boolean matches(Node node, String requiredLocalName, QName requiredNamespace) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import org.w3c.dom.*;

import javax.xml.namespace.QName;

public class Main {
    public static boolean matches(Node node, String requiredLocalName, QName requiredNamespace) {
        if (node == null) {
            return false;
        }/*from   w w w  .ja v a  2 s. com*/
        boolean matchingNamespace = matchingNamespace(node, requiredNamespace);
        return matchingNamespace && matchingLocalName(node, requiredLocalName);
    }

    private static boolean matchingNamespace(Node node, QName requiredNamespace) {
        if (requiredNamespace == null) {
            return true;
        } else {
            return requiredNamespace.getNamespaceURI().equals(node.getNamespaceURI());
        }
    }

    private static boolean matchingLocalName(Node node, String requiredLocalName) {
        if (requiredLocalName == null) {
            return true;
        } else {
            String localName = node.getLocalName();
            return requiredLocalName.equals(localName);
        }
    }
}

Related

  1. isWildcardType(QName type)
  2. marshal(T value, Class elementClass, String packageName, QName q_name, OutputStream oStream)
  3. marshallJAXBElement(Class declaredType, QName name, Class scope, BoundType v)
  4. marshalToString(T obj, Class clazz, QName qname)
  5. match(XMLStreamReader reader, QName name)
  6. matches(QName qname, Node node)
  7. matchingNamespace(Node node, QName requiredNamespace)
  8. matchNode(Node node, QName name)
  9. moveReaderToTag(XMLStreamReader reader, QName... tags)