List of usage examples for java.lang String isEmpty
public boolean isEmpty()
From source file:Main.java
public static void launchUrl(String url, Context context) { if (!url.isEmpty() && context != null) { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); }/* w w w . ja va 2 s . c o m*/ }
From source file:Main.java
/** * Strips a string of all white space and replaces with an empty string. * * @param original string that can have any number of spaces. * @return a clean string stripped of white space. *//*from w w w. j a v a2 s. c o m*/ public static String getCleanString(String original) { if (original == null || original.isEmpty()) { return EMPTY_STRING; } return original.replaceAll(REGEX_WHITESPACE, EMPTY_STRING); }
From source file:Main.java
public static String setStringNotNull(String stringRes) { if (stringRes == null || stringRes.isEmpty()) { return ""; }//from w w w . ja v a 2 s . c om //Convert Non_breaking (ASCI 160) to Simple Space. trim() does'nt handle it. stringRes = stringRes.replace(String.valueOf((char) 160), " "); String tempString = stringRes.trim(); return tempString; }
From source file:Main.java
/** * * @param number//from www. j a v a 2 s . co m * @return */ public static Double convertStringToDoubleObject(String number) { if (number == null || number.isEmpty()) { return null; } try { return Double.parseDouble(number); } catch (NumberFormatException e) { return null; } }
From source file:Main.java
public static boolean validateIPAddress(String ip) { if (ip == null || ip.isEmpty()) return false; ip = ip.trim();/*w w w.jav a 2s.co m*/ if ((ip.length() < 6) & (ip.length() > 15)) return false; try { Pattern pattern = Pattern.compile( "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"); Matcher matcher = pattern.matcher(ip); return matcher.matches(); } catch (PatternSyntaxException ex) { return false; } }
From source file:Main.java
public static XMLGregorianCalendar stringAsCalendar(String date) { if (date == null || date.isEmpty()) { return null; }/* ww w .j ava 2s . c om*/ return df.newXMLGregorianCalendar(date); }
From source file:Main.java
/** * Capitalizes the 1st character of the given string * /*from w w w . j a v a 2 s. c o m*/ * @param str the String to capitalize * @return the capitalized String */ public static String capitalize(String str) { if (str == null || str.isEmpty()) return null; return Character.toUpperCase(str.charAt(0)) + str.substring(1); }
From source file:Main.java
static public String replaceNotExpectedPattern(String text, Pattern pattern, String repl) { if (repl == null || repl.isEmpty()) { repl = ""; }//w w w . java 2 s . c om while (!text.isEmpty()) { if (pattern.matcher(text).matches()) { return text; } // replace last position text = text.substring(0, text.length() - 1) + repl; } return text; }
From source file:Main.java
private static String constructLogFileName(String base, String addend) { if (addend == null || addend.isEmpty()) { return base; } else {/*from www.ja v a 2s . com*/ return base + "_" + addend; } }
From source file:Main.java
/** * Returns true if the given MIME type has an entry in the map. * //www.j a v a 2 s . c o m * @param mimeType * A MIME type (i.e. text/plain) * @return True if there is a mimeType entry in the map. */ public static boolean hasMimeType(String mimeType) { if (mimeType == null || mimeType.isEmpty()) { return false; } return mimeTypeToExtensionMap.containsKey(mimeType); }