List of usage examples for java.lang String isEmpty
public boolean isEmpty()
From source file:Main.java
public static Image getImage(String name) { if (name == null || name.isEmpty()) { return null; }/* w ww. j a v a 2s .com*/ URL imageURL = Main.class.getResource(name); if (imageURL == null) { return null; } return Toolkit.getDefaultToolkit().createImage(imageURL); }
From source file:Main.java
/** * Make a guess for the correct code value for the provided vat rate. Guessing is necessary as * the correct code is not part of the XML invoice. * /*from w w w. jav a 2s . co m*/ * @param vatRate * @return */ public static int guessVatCode(String vatRate) { if (vatRate != null && !vatRate.isEmpty()) { double scale = Double.parseDouble(vatRate); // make a guess for the correct code if (scale == 0) return 0; else if (scale < 7) return 2; else return 1; } return 0; }
From source file:Main.java
public static String getDexClassName(String dottedClassName) { if (dottedClassName == null || dottedClassName.isEmpty()) throw new RuntimeException("Empty class name detected"); String slashedName = dottedClassName.replace('.', '/'); if (slashedName.startsWith("L") && slashedName.endsWith(";")) return slashedName; return "L" + slashedName + ";"; }
From source file:gov.nyc.doitt.gis.geoclient.parser.token.TextUtils.java
public static String sanitize(String s) { if (s == null || s.isEmpty()) { return s; }/*from w w w. j a va 2s . c o m*/ // Remove leading and trailing spaces or punctuation (except for trailing //period characters (eg, N.Y.) String clean = StringUtils.removePattern(s, "^(?:\\s|\\p{Punct})+|(?:\\s|[\\p{Punct}&&[^.]])+$"); // Make sure ampersand is surrounded by spaces but allow double ampersand clean = clean.replaceAll("([^\\s&])\\&", "$1 &"); clean = clean.replaceAll("\\&([^\\s&])", "& $1"); // Normalize whitespace clean = StringUtils.normalizeSpace(clean); return clean; }
From source file:Main.java
public static String breakList(String divider, List<String> list) { String result = ""; for (int i = 0; i < list.size(); ++i) { String val = (String) list.get(i); if (!val.isEmpty()) { result = result + val + (i == list.size() - 1 ? "" : divider); }/* www.jav a2s. com*/ } return result; }
From source file:Main.java
public static String getFbUsername(Context context) { SharedPreferences fbInfo = context.getSharedPreferences(FB_VARIABLES, 0); String username = fbInfo.getString(FB_NAME, ""); if (username.isEmpty()) { return ""; }//from w w w .j a v a 2s . c o m return username; }
From source file:Main.java
public static List<String> split(String input, String delimiter) { if (input == null || input.isEmpty()) { return Collections.emptyList(); }//from www .j a v a 2s . c o m return new ArrayList<String>(Arrays.asList(input.split(delimiter))); }
From source file:Main.java
private static String[] lineToStrs(String line) { String[] ret = new String[2]; if ((line != null)) { String[] strs = line.trim().split("\t+"); ret[0] = strs[0].trim();//from www . ja va 2s .c om for (int i = 1; i < strs.length; i++) { String str = strs[i].trim(); if (!str.isEmpty()) { if (!str.startsWith("#")) { ret[1] = str; } break; } } } return ret; }
From source file:Main.java
private static List<String> split(String input, String delimiter) { if (input == null || input.isEmpty()) { return Collections.emptyList(); }/*from w w w. j av a 2 s . com*/ return new ArrayList<String>(Arrays.asList(input.split(delimiter))); }
From source file:Main.java
public static boolean isStringEmptyPrefer(String s) { return (s == null || s.equals("{}") || s.equals("\"\"") || s.isEmpty()); }