List of usage examples for java.lang String isEmpty
public boolean isEmpty()
From source file:Main.java
/** * Returns a path that can be safely concatenated with {@code authority}. If * the authority is null or empty, this can be any path. Otherwise the paths * run together like {@code http://android.comindex.html}. *///www . ja v a2 s.c o m public static String authoritySafePath(String authority, String path) { if (authority != null && !authority.isEmpty() && !path.isEmpty() && !path.startsWith("/")) { return "/" + path; } return path; }
From source file:Main.java
static public double getDoubleTextContent(Element element) { String s = getTrimmedTextContent(element); return s == null || s.isEmpty() ? 0 : Double.parseDouble(s); }
From source file:Main.java
private static Boolean currentGreaterThenOld(String currentDate, String oldDate) { if (currentDate.isEmpty() || oldDate.isEmpty()) return false; try {/*from w ww. j a v a2s.co m*/ SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy", Locale.getDefault()); Date current = formatter.parse(currentDate); Date old = formatter.parse(oldDate); if (old.compareTo(current) < 0) { Log.d(TAG, "compareDate current Date : " + current.toString() + " is greater then Old Date : " + old.toString()); return true; } } catch (ParseException e1) { e1.printStackTrace(); } return false; }
From source file:Main.java
public static JSONObject extractObject(HttpResponse resp) throws IOException, JSONException { BufferedReader rd = new BufferedReader(new InputStreamReader(resp.getEntity().getContent())); StringBuilder s = new StringBuilder(); String line;/*from w ww. j a va 2 s. co m*/ while ((line = rd.readLine()) != null) { s.append(line); } rd.close(); String str = s.toString(); if (str == null || str.isEmpty()) { return null; } return new JSONObject(str); }
From source file:Main.java
public static void setCallDeflectNumber(ContentResolver contentResolver, String value) { String deflectNum = value;//from w w w.j a va 2 s. c o m if (value == null || value.isEmpty()) { deflectNum = ""; } android.provider.Settings.Global.putString(contentResolver, QTI_IMS_CALL_DEFLECT_NUMBER, deflectNum); }
From source file:org.graylog.plugins.usagestatistics.dto.MacAddress.java
public static MacAddress create(String macAddress) { if (macAddress == null || macAddress.isEmpty()) { return EMPTY; }//from w ww .ja v a 2s. co m checkArgument(PATTERN.matcher(macAddress).matches()); return new AutoValue_MacAddress(macAddress.substring(0, 8)); }
From source file:Main.java
public static boolean checkString(String s) { boolean isEmpty; try {//from w w w. ja va 2s .c o m isEmpty = s.isEmpty(); } catch (NullPointerException ex) { Log.e("checkString", "String is NULL !!"); return false; } return !isEmpty; }
From source file:io.datenwelt.cargo.rest.utils.Strings.java
public static boolean isBlank(String input) { return input == null || input.isEmpty(); }
From source file:Main.java
public static String getUserCountryCode(Context context) { String country = Locale.getDefault().getCountry(); if (country.isEmpty()) { country = SERVER_VALUE_FOR_UNDEFINED_COUNTRY; }//from w w w. j a v a 2s . c om return country; }
From source file:Main.java
public static String getFacebookUserName(Context context) { if (facebookUserName != null) return facebookUserName; else {/*from ww w. j a va 2 s. c o m*/ SharedPreferences prefs = context.getSharedPreferences("profilo", Context.MODE_PRIVATE); String name = prefs.getString("reg_username", ""); if (name.isEmpty()) { Log.e("HELPER_FACEBOOK", "username facebook not found."); return null; } else { facebookUserName = name; return facebookUserName; } } }