List of utility methods to do XML NodeList
boolean | isNotEmpty(NodeList nodeList) Null-safe check if the specified nodeList is not empty.
return nodeList != null && nodeList.getLength() > 0;
|
boolean | isNullOrEmpty(NodeList nodeList) is Null Or Empty return nodeList == null || nodeList.getLength() == 0;
|
Iterable | iterable(final NodeList list) iterable if (list == null) return Collections.EMPTY_LIST; return new Iterable<Node>() { int nextPos = 0; public Iterator<Node> iterator() { return new Iterator<Node>() { public Node next() { if (nextPos >= list.getLength()) ... |
Iterable | iterable(NodeList nodeList) iterable return () -> new Iterator<Node>() { private int index = 0; @Override public boolean hasNext() { return index < nodeList.getLength(); @Override public Node next() { ... |
Iterable | iterableNodes(final NodeList nodeList) Iterates over a NodeList. return new Iterable<Node>() { @Override public Iterator<Node> iterator() { return new Iterator<Node>() { int index = 0; @Override public boolean hasNext() { return index < nodeList.getLength(); ... |
Iterable | iterableNodes(final NodeList nodeList) iterable Nodes return new AbstractList<Node>() { @Override public Node get(int index) { return nodeList.item(index); @Override public int size() { return nodeList.getLength(); ... |
List | listOf(final NodeList nodeList) list Of return new AbstractList<Node>() { public Node get(int index) { return nodeList.item(index); public int size() { return nodeList.getLength(); }; ... |
List | listOf(final NodeList nodeList) list Of return new AbstractList<Node>() { public Node get(int index) { return nodeList.item(index); public int size() { return nodeList.getLength(); }; ... |
Map | mapNodeList(NodeList nodeList) map Node List Map<Node, Map> map = new LinkedHashMap<>(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node.hasChildNodes()) { map.put(node, mapNodeList(node.getChildNodes())); } else { map.put(node, Collections.emptyMap()); return map; |
String | mergeTextContent(final NodeList nodes) merge Text Content StringBuffer buf = new StringBuffer(); for (int i = 0; i < nodes.getLength(); i++) { Node n = nodes.item(i); final String text; switch (n.getNodeType()) { case Node.COMMENT_NODE: case Node.PROCESSING_INSTRUCTION_NODE: text = null; ... |