src/main/java/de/unixwork/uwproj/Util.java

changeset 40
b42bfc9e9983
parent 0
38775db5fdf5
child 41
75ee588d5d9e
equal deleted inserted replaced
39:3ca85da78515 40:b42bfc9e9983
1 package de.unixwork.uwproj;
2
3 import org.w3c.dom.Element;
4 import org.w3c.dom.Node;
5 import org.w3c.dom.NodeList;
6
7 public class Util {
8 /**
9 * Returns the text content of the given element.
10 *
11 * @param elm the element
12 * @return the contents or empty string if there are no contents
13 */
14 public static String getContent(Element elm) {
15 NodeList nodes = elm.getChildNodes();
16 for (int i = 0; i < nodes.getLength(); i++) {
17 var node = nodes.item(i);
18 if (node.getNodeType() == Node.TEXT_NODE) {
19 return node.getTextContent();
20 }
21 }
22 return "";
23 }
24
25 public static boolean isNullOrBlank(String s) {
26 return s == null || s.isBlank();
27 }
28
29 public static boolean isNotNullOrBlank(String s) {
30 return s != null && !s.isBlank();
31 }
32 }

mercurial