|
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 } |