Example usage for java.lang CharSequence length

List of usage examples for java.lang CharSequence length

Introduction

In this page you can find the example usage for java.lang CharSequence length.

Prototype

int length();

Source Link

Document

Returns the length of this character sequence.

Usage

From source file:Main.java

private static boolean isUpperCase(CharSequence sequence) {
    for (int i = 0; i < sequence.length(); i++) {
        if (Character.isLowerCase(sequence.charAt(i)))
            return false;
    }// w  w  w . ja v a2  s.c o m

    return true;
}

From source file:Main.java

public static boolean isEmpty(@Nullable CharSequence str) {
    if (str == null || str.length() == 0) {
        return true;
    } else {//w  w w . j a  v  a2 s  .c om
        return false;
    }
}

From source file:Main.java

/**
 * Returns true if the string is null or 0-length.
 * /* w w  w .  jav a 2s  . com*/
 * @param str
 *            the string to be examined
 * @return true if str is null or zero length
 */
public static boolean isEmpty(CharSequence str) {
    if (str == null || str.length() == 0 || "null".equals(str.toString().trim()))
        return true;
    else
        return false;
}

From source file:Main.java

/**
 * Convert the hex string to the integer value.
 * @param str/*from www.j a  va2 s .  c  o  m*/
 * @return the integer value for the specified hex string
 */
public static int intFromHexString(CharSequence str) {
    int n = 0;
    for (int i = 0; i < str.length(); i++) {
        char c = str.charAt(i);
        int v = c <= '9' ? c - '0' : c - 'a' + 10;
        n <<= 4;
        n |= (v & 0x0f);
    }
    return n;
}

From source file:Main.java

public static boolean isValidT9Key(@NonNull CharSequence key) {
    final int LEN = key.length();
    for (int i = 0; i < LEN; i++) {
        if (!isValidT9Key(key.charAt(i))) {
            return false;
        }//from  w  ww  .j  a  v a  2 s  .  c o  m
    }
    return true;
}

From source file:Main.java

/**
 * Test whether the given string matches the given substring
 * at the given index.//  w  w  w  .  j ava 2  s.  com
 * @param str the original string (or StringBuilder)
 * @param index the index in the original string to start matching against
 * @param substring the substring to match at the given index
 */
public static boolean substringMatch(CharSequence str, int index, CharSequence substring) {
    for (int j = 0; j < substring.length(); j++) {
        int i = index + j;
        if (i >= str.length() || str.charAt(i) != substring.charAt(j)) {
            return false;
        }
    }
    return true;
}

From source file:Main.java

/**
 * get from android.util.TextUtils.isEmpty(CharSequence str)
 * copy it from there because since it is in android package asked for
 * androidTest so it's here with another implementation of that method
 * what they do is same nothing extra or special
 * @param str//from  w  w w  . j  av  a 2  s  .co m
 * @return
 */
public static boolean isEmpty(CharSequence str) {
    if (str == null || str.length() == 0)
        return true;
    else
        return false;
}

From source file:Main.java

public static String copyString(CharSequence charSequence) {
    int length = charSequence.length();
    char[] chars = new char[length];

    if (charSequence instanceof GetChars) {
        ((GetChars) charSequence).getChars(0, length, chars, 0);
    } else {//from   w  w  w  .j ava 2s  .c o m
        for (int i = 0; i < length; i++) {
            chars[i] = charSequence.charAt(i);
        }
    }

    return new String(chars);
}

From source file:Main.java

public static boolean isEmpty(CharSequence cs) {
    return cs == null || cs.length() == 0;
}

From source file:Main.java

public static final int clipboardTextLength(Context context) {
    ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
    CharSequence text = cm != null ? cm.getText() : null;
    return text != null ? text.length() : 0;
}