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

changeset 41
75ee588d5d9e
parent 40
b42bfc9e9983
child 64
00586d892855
equal deleted inserted replaced
40:b42bfc9e9983 41:75ee588d5d9e
14 public static String getContent(Element elm) { 14 public static String getContent(Element elm) {
15 NodeList nodes = elm.getChildNodes(); 15 NodeList nodes = elm.getChildNodes();
16 for (int i = 0; i < nodes.getLength(); i++) { 16 for (int i = 0; i < nodes.getLength(); i++) {
17 var node = nodes.item(i); 17 var node = nodes.item(i);
18 if (node.getNodeType() == Node.TEXT_NODE) { 18 if (node.getNodeType() == Node.TEXT_NODE) {
19 return node.getTextContent(); 19 final var v = node.getNodeValue();
20 return v == null ? "" : v;
20 } 21 }
21 } 22 }
22 return ""; 23 return "";
23 } 24 }
24 25
27 } 28 }
28 29
29 public static boolean isNotNullOrBlank(String s) { 30 public static boolean isNotNullOrBlank(String s) {
30 return s != null && !s.isBlank(); 31 return s != null && !s.isBlank();
31 } 32 }
33
34 /**
35 * Creates an identifier from the given string that can be used as an identifier in a POSIX shell script.
36 * <p>
37 * If the given string does not contain any character that is illegal in a POSIX shell variable or function name,
38 * the string is returned unmodified.
39 *
40 * @param s the input string
41 * @return the sanitized string
42 */
43 public static String shId(String s) {
44 // TODO: implement
45 return s;
46 }
32 } 47 }

mercurial