List of usage examples for java.lang String isEmpty
public boolean isEmpty()
From source file:Main.java
public static String[] components(String path, String separator) { if (path == null || path.isEmpty()) return null; String[] tmp = path.split(separator + "+"); // multiple separators could be present if (tmp == null) return null; if (tmp.length == 0) return null; if (tmp[0].isEmpty()) tmp[0] = separator;/*from w ww . j a v a2 s . c om*/ return tmp; }
From source file:Main.java
public static Double getDoubleAttr(Element element, String name) { String attr = element.getAttribute(name); if (!attr.isEmpty()) { Double ret = Double.valueOf(attr); return ret; }// ww w .j a v a2s .c o m return null; }
From source file:Main.java
public static String parseString(Element element, String key) { String value = element.getAttribute(key); if (value != null && !value.isEmpty()) { return value; }/* ww w .jav a 2s. c o m*/ return null; }
From source file:Main.java
/** * @param values string values to test/*from w ww. j ava 2 s . c o m*/ * @return true if each string isn't equal to null and isn't empty */ public static boolean isValid(String... values) { if (values == null || values.length == 0) { return false; } for (String value : values) { if (value == null || value.isEmpty()) { return false; } } return true; }
From source file:Main.java
/** * Remove invalid XML characters from a string. * @param text the text to cleanse.// w w w. ja v a2 s. c o m * @return cleansed text or the original string if it is null or empty */ public static String removeInvalidXMLChars(String text) { if (text == null || text.isEmpty()) { return text; } return text.replaceAll(INVALID_XML_CHARACTERS, ""); }
From source file:Main.java
static public float getFloatAttribute(Element element, String name) { String s = getTrimmedAttribute(element, name); return s.isEmpty() ? 0f : Float.parseFloat(s); }
From source file:Main.java
public static boolean delete(String path) { if (path == null || path.isEmpty()) return false; File f = new File(path); if (f.exists()) { if (f.isDirectory()) { return deleteDirectory(f); } else {/*from www.ja v a 2 s. c o m*/ return f.delete(); } } return false; }
From source file:Main.java
static public double getDoubleAttribute(Element element, String name) { String s = getTrimmedAttribute(element, name); return s.isEmpty() ? 0d : Double.parseDouble(s); }
From source file:Main.java
public static String getStringAttr(Element element, String name, String def) { String attr = element.getAttribute(name); if (attr.isEmpty()) { attr = def;/*from w w w. j a va 2 s .c om*/ } return attr; }
From source file:Main.java
static public int getIntegerAttribute(Element element, String name) { String s = getTrimmedAttribute(element, name); return s.isEmpty() ? 0 : Integer.parseInt(s); }