Here you can find the source of isNode(Object value, String nodeName)
Parameter | Description |
---|---|
value | Object that should be examined as a node. |
nodeName | String that specifies the node name. |
public static boolean isNode(Object value, String nodeName)
//package com.java2s; import org.w3c.dom.Element; public class Main { /**/*from w w w . jav a 2 s . c o m*/ * Returns true if the user object is an XML node with the specified type * and and the optional attribute has the specified value or is not * specified. * * @param value * Object that should be examined as a node. * @param nodeName * String that specifies the node name. * @return Returns true if the node name of the user object is equal to the * given type. */ public static boolean isNode(Object value, String nodeName) { return isNode(value, nodeName, null, null); } /** * Returns true if the given value is an XML node with the node name and if * the optional attribute has the specified value. * * @param value * Object that should be examined as a node. * @param nodeName * String that specifies the node name. * @param attributeName * Optional attribute name to check. * @param attributeValue * Optional attribute value to check. * @return Returns true if the value matches the given conditions. */ public static boolean isNode(Object value, String nodeName, String attributeName, String attributeValue) { if (value instanceof Element) { Element element = (Element) value; if (nodeName == null || element.getNodeName().equalsIgnoreCase(nodeName)) { String tmp = (attributeName != null) ? element .getAttribute(attributeName) : null; return attributeName == null || (tmp != null && tmp.equals(attributeValue)); } } return false; } }