Sun, 10 Sep 2023 12:52:10 +0200
some more code cleanup
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) { final var v = node.getNodeValue(); return v == null ? "" : v; } } return ""; } public static boolean isNullOrBlank(String s) { return s == null || s.isBlank(); } public static boolean isNotNullOrBlank(String s) { return s != null && !s.isBlank(); } /** * Creates an identifier from the given string that can be used as an identifier in a POSIX shell script. * <p> * If the given string does not contain any character that is illegal in a POSIX shell variable or function name, * the string is returned unmodified. * * @param s the input string * @return the sanitized string */ public static String shId(String s) { // TODO: implement return s; } }