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:br.msf.commons.util.CharSequenceUtils.java

public static String substringAfterFirst(final CharSequence toSearch, final CharSequence sequence,
        final Boolean caseSensitive) {
    final int idx = indexOf(toSearch, sequence, caseSensitive);
    return (idx < 0) ? null
            : CharSequenceUtils.castToString(sequence.subSequence(idx + toSearch.length(), length(sequence)));
}

From source file:com.frostwire.database.sqlite.SQLiteQueryBuilder.java

/**
 * Append a chunk to the WHERE clause of the query. All chunks appended are surrounded
 * by parenthesis and ANDed with the selection passed to {@link #query}. The final
 * WHERE clause looks like:/*w  w w. j a va 2s. co m*/
 *
 * WHERE (&lt;append chunk 1>&lt;append chunk2>) AND (&lt;query() selection parameter>)
 *
 * @param inWhere the chunk of text to append to the WHERE clause.
 */
public void appendWhere(CharSequence inWhere) {
    if (mWhereClause == null) {
        mWhereClause = new StringBuilder(inWhere.length() + 16);
    }
    if (mWhereClause.length() == 0) {
        mWhereClause.append('(');
    }
    mWhereClause.append(inWhere);
}

From source file:br.msf.commons.util.CharSequenceUtils.java

public static String subStringAfterLast(final CharSequence toSearch, final CharSequence sequence,
        final Boolean caseSensitive) {
    final int idx = lastIndexOf(toSearch, sequence, caseSensitive);
    return (idx < 0) ? null
            : CharSequenceUtils.castToString(sequence.subSequence(idx + toSearch.length(), length(sequence)));
}

From source file:br.msf.commons.util.CharSequenceUtils.java

public static String substringAfterLast(final CharSequence toSearch, final CharSequence sequence,
        final Boolean caseSensitive) {
    final int idx = lastIndexOf(toSearch, sequence, caseSensitive);
    return (idx < 0) ? null
            : CharSequenceUtils.castToString(sequence.subSequence(idx + toSearch.length(), length(sequence)));
}

From source file:br.msf.commons.util.CharSequenceUtils.java

public static int countDigitChain(final CharSequence sequence) {
    if (isBlankOrNull(sequence)) {
        return 0;
    } else if (length(sequence) == 1) {
        return hasDigit(sequence) ? 1 : 0;
    }/*w  w w .  ja  v a 2  s  .c o  m*/
    int max = 0;
    int count = 0;
    for (int i = 0; i < sequence.length(); i++) {
        if (Character.isDigit(sequence.charAt(i))) {
            count++;
        } else {
            if (count > max) {
                max = count;
            }
            count = 0;
        }
    }
    if (count > max) {
        max = count;
    }
    return max;
}

From source file:br.msf.commons.util.CharSequenceUtils.java

public static int countVowelChain(final CharSequence sequence) {
    if (isBlankOrNull(sequence)) {
        return 0;
    } else if (length(sequence) == 1) {
        return hasVowel(sequence) ? 1 : 0;
    }/*  w  ww.j  a va 2 s.  co m*/
    int max = 0;
    int count = 0;
    for (int i = 0; i < sequence.length(); i++) {
        if (isVowel(sequence.charAt(i))) {
            count++;
        } else {
            if (count > max) {
                max = count;
            }
            count = 0;
        }
    }
    if (count > max) {
        max = count;
    }
    return max;
}

From source file:com.welfare.common.util.UtilValidate.java

/**
 * Check whether charsequence c is empty.
 *///  www.ja  va 2  s .  c  o m
public static <E> boolean isEmpty(CharSequence c) {
    return (c == null) || c.length() == 0;
}

From source file:com.welfare.common.util.UtilValidate.java

/**
 * Check whether charsequence c is NOT empty.
 *//* w w  w .j a v  a 2  s  .  co m*/
public static <E> boolean isNotEmpty(CharSequence c) {
    return ((c != null) && (c.length() > 0));
}

From source file:br.msf.commons.util.CharSequenceUtils.java

public static int countLowercaseChain(final CharSequence sequence) {
    if (isBlankOrNull(sequence)) {
        return 0;
    } else if (length(sequence) == 1) {
        return hasLowercase(sequence) ? 1 : 0;
    }//ww w  . java  2s . co  m
    int max = 0;
    int count = 0;
    for (int i = 0; i < sequence.length(); i++) {
        if (Character.isLowerCase(sequence.charAt(i))) {
            count++;
        } else {
            if (count > max) {
                max = count;
            }
            count = 0;
        }
    }
    if (count > max) {
        max = count;
    }
    return max;
}

From source file:br.msf.commons.util.CharSequenceUtils.java

public static int countUppercaseChain(final CharSequence sequence) {
    if (isBlankOrNull(sequence)) {
        return 0;
    } else if (length(sequence) == 1) {
        return hasUppercase(sequence) ? 1 : 0;
    }//w ww  .ja va2s  .co  m
    int max = 0;
    int count = 0;
    for (int i = 0; i < sequence.length(); i++) {
        if (Character.isUpperCase(sequence.charAt(i))) {
            count++;
        } else {
            if (count > max) {
                max = count;
            }
            count = 0;
        }
    }
    if (count > max) {
        max = count;
    }
    return max;
}