Here you can find the source of matches(final Node node, final boolean useNamespaces, final String namespaceURI, final String localName)
Parameter | Description |
---|---|
node | the Node to test (must not be <code>null</code>) |
useNamespaces | <code>true</code> for namespaces mode |
namespaceURI | the namespace URI to match, <code>null</code> to match no namespace, <code>*</code> to match any namespace (ignored if <code>useNamespaces</code> is <code>false</code>) |
localName | <code>null</code> or <code>*</code> to match any node, matches the node name if <code>useNamespaces</code> is <code>false</code>, matches the local name if <code>useNamespaces</code> is <code>true</code> |
true
if the matches the criteria
private static boolean matches(final Node node, final boolean useNamespaces, final String namespaceURI, final String localName)
//package com.java2s; // Licensed under the MIT license. See License.txt in the repository root. import org.w3c.dom.Node; public class Main { /**/*from ww w .j a va 2 s . c om*/ * Tests whether the given {@link Node} matches the specified name. No * <code>null</code> checking is done of the <code>node</code> argument. * * @param node * the {@link Node} to test (must not be <code>null</code>) * @param useNamespaces * <code>true</code> for namespaces mode * @param namespaceURI * the namespace URI to match, <code>null</code> to match no * namespace, <code>*</code> to match any namespace (ignored if * <code>useNamespaces</code> is <code>false</code>) * @param localName * <code>null</code> or <code>*</code> to match any node, matches the * node name if <code>useNamespaces</code> is <code>false</code>, * matches the local name if <code>useNamespaces</code> is * <code>true</code> * @return <code>true</code> if the {@link Node} matches the criteria */ private static boolean matches(final Node node, final boolean useNamespaces, final String namespaceURI, final String localName) { if (useNamespaces) { if (namespaceURI == null && node.getNamespaceURI() != null) { return false; } if (namespaceURI != null && !namespaceURI.equals("*") && !namespaceURI.equals(node.getNamespaceURI())) //$NON-NLS-1$ { return false; } } if (localName == null || localName.equals("*")) //$NON-NLS-1$ { return true; } if (useNamespaces) { return localName.equals(node.getLocalName()); } return localName.equals(node.getNodeName()); } }