Example usage for android.text TextUtils isEmpty

List of usage examples for android.text TextUtils isEmpty

Introduction

In this page you can find the example usage for android.text TextUtils isEmpty.

Prototype

public static boolean isEmpty(@Nullable CharSequence str) 

Source Link

Document

Returns true if the string is null or 0-length.

Usage

From source file:Main.java

public static boolean isMobileNO(String mobiles) {

    String telRegex = "[1][358]\\d{9}";
    if (TextUtils.isEmpty(mobiles))
        return false;
    else/*  w ww  . jav a 2  s . c om*/
        return mobiles.matches(telRegex);
}

From source file:Main.java

public static boolean checkRegNum(CharSequence code) {
    if (TextUtils.isEmpty(code) || code.length() != 4) {
        return false;
    }/*from  ww w.j a  va 2 s . c  om*/
    return true;
}

From source file:Main.java

public static String safeString(String string) {
    if (TextUtils.isEmpty(string)) {
        return EMPTY_STR;
    } else {/*from w  w  w.j a v a  2 s  . co  m*/
        return string;
    }
}

From source file:Main.java

public static final int parseIPAddress(String address) {
    if (TextUtils.isEmpty(address))
        throw new IllegalArgumentException("address cannot be null or empty");
    String[] tokens = address.split("\\.");
    boolean isOk = true;
    int ip = 0;//from  w  w  w . j av  a  2  s.  c  o  m
    if (tokens.length == 4) {
        for (int i = 0; i < 4; i++) {
            try {
                short num = Short.parseShort(tokens[i]);
                if (num < 0 || num > 255) {
                    isOk = false;
                    break;
                }
                ip |= (num << (8 * i));
            } catch (NumberFormatException ex) {
                isOk = false;
                break;
            }
        }
    } else
        isOk = false;

    if (!isOk)
        throw new IllegalArgumentException("address is not in the form X.X.X.X, with X in the range 0-255");

    return ip;
}

From source file:Main.java

public static boolean isMobiPhoneNumber(String telNum) {
    if (TextUtils.isEmpty(telNum)) {
        return false;
    }// w  w w.  ja v a2s  .  c o m
    telNum = telNum.replaceAll("^\\+{0,1}86", "");

    return telNum.matches("^((13[0-9])|(15[0-9])|(17[0-9]))|(18[0-9]))\\d{8}$");
}

From source file:Main.java

public static boolean isMucIdLegal(String mucId) {
    return !TextUtils.isEmpty(mucId) && mucId.endsWith(MUC_TAIL);
}

From source file:Main.java

public static boolean isAppFilesPath(Context context, String path) {
    return !TextUtils.isEmpty(path) && path.contains("/Android/data/" + context.getPackageName() + "/files");
}

From source file:Main.java

public static boolean isAppCachePath(Context context, String path) {
    return !TextUtils.isEmpty(path) && path.contains("/Android/data/" + context.getPackageName() + "/cache");
}

From source file:Main.java

public static void appendAndSeparateIfNotEmpty(StringBuilder stringbuilder, CharSequence charsequence) {
    if (!TextUtils.isEmpty(charsequence))
        stringbuilder.append(charsequence).append(". ");
}

From source file:Main.java

public static String getCachePathByUrl(String url) {
    if (TextUtils.isEmpty(url)) {
        return null;
    }/* www  . ja va2  s. c  om*/
    return uiBufferPath + url.hashCode();
}