diff -r 3ca85da78515 -r b42bfc9e9983 src/main/java/de/unixwork/uwproj/Util.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/unixwork/uwproj/Util.java Wed Sep 06 22:55:42 2023 +0200 @@ -0,0 +1,32 @@ +package de.unixwork.uwproj; + +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +public class Util { + /** + * Returns the text content of the given element. + * + * @param elm the element + * @return the contents or empty string if there are no contents + */ + public static String getContent(Element elm) { + NodeList nodes = elm.getChildNodes(); + for (int i = 0; i < nodes.getLength(); i++) { + var node = nodes.item(i); + if (node.getNodeType() == Node.TEXT_NODE) { + return node.getTextContent(); + } + } + return ""; + } + + public static boolean isNullOrBlank(String s) { + return s == null || s.isBlank(); + } + + public static boolean isNotNullOrBlank(String s) { + return s != null && !s.isBlank(); + } +}