Here you can find the source of containsNature(NodeList nodes, String nature)
nature
is represented by at least one node in nodes
.
Parameter | Description |
---|---|
nodes | list of nodes to be considered |
nature | the nature to search for |
true
if the nature is represented by at least one node in nodes
, false
else
private static boolean containsNature(NodeList nodes, String nature)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /**/*from w w w . j a v a 2s .co m*/ * Check whether the given <code>nature</code> is represented by at least one node in <code>nodes</code>. * * @param nodes list of nodes to be considered * @param nature the nature to search for * @return <code>true</code> if the nature is represented by at least one node in <code>nodes</code>, * <code>false</code> else */ private static boolean containsNature(NodeList nodes, String nature) { boolean contains = false; for (int i = 0; !contains && i < nodes.getLength(); i++) { contains = checkNature(nodes.item(i), nature); } return contains; } /** * Checks whether the text content of the given <code>node</code> matches the given <code>nature</code>. * * @param node the node to be checked * @param nature the nature to be considered * @return <code>true</code> if the nature is represented by <code>node</code>, <code>false</code> else */ private static boolean checkNature(Node node, String nature) { return node.getTextContent().trim().equals(nature); } }