Example usage for java.lang Character LOWERCASE_LETTER

List of usage examples for java.lang Character LOWERCASE_LETTER

Introduction

In this page you can find the example usage for java.lang Character LOWERCASE_LETTER.

Prototype

byte LOWERCASE_LETTER

To view the source code for java.lang Character LOWERCASE_LETTER.

Click Source Link

Document

General category "Ll" in the Unicode specification.

Usage

From source file:XmlChars.java

private static boolean isLetter2(char c) {
    // [84] Letter ::= BaseChar | Ideographic
    // [85] BaseChar ::= ... too much to repeat
    // [86] Ideographic ::= ... too much to repeat
    // [87] CombiningChar ::= ... too much to repeat

    ///*www.j a v a2 s . c  o  m*/
    // Optimize the typical case.
    //
    if (c >= 'a' && c <= 'z')
        return true;
    if (c == '>')
        return false;
    if (c >= 'A' && c <= 'Z')
        return true;

    //
    // Since the tables are too ridiculous to use in code,
    // we're using the footnotes here to drive this test.
    //
    switch (Character.getType(c)) {
    // app. B footnote says these are 'name start'
    // chars' ...
    case Character.LOWERCASE_LETTER: // Ll
    case Character.UPPERCASE_LETTER: // Lu
    case Character.OTHER_LETTER: // Lo
    case Character.TITLECASE_LETTER: // Lt
    case Character.LETTER_NUMBER: // Nl
        // ... and these are name characters 'other
        // than name start characters'
    case Character.COMBINING_SPACING_MARK: // Mc
    case Character.ENCLOSING_MARK: // Me
    case Character.NON_SPACING_MARK: // Mn
    case Character.MODIFIER_LETTER: // Lm
    case Character.DECIMAL_DIGIT_NUMBER: // Nd

        // OK, here we just have some exceptions to check...
        return !isCompatibilityChar(c)
                // per "5.14 of Unicode", rule out some combiners
                && !(c >= 0x20dd && c <= 0x20e0);

    default:
        // added a character ...
        return c == 0x0387;
    }
}

From source file:org.grails.datastore.bson.json.JsonWriter.java

private void writeStringHelper(final String str) throws IOException {
    writer.write('"');
    for (final char c : str.toCharArray()) {
        switch (c) {
        case '"':
            writer.write("\\\"");
            break;
        case '\\':
            writer.write("\\\\");
            break;
        case '\b':
            writer.write("\\b");
            break;
        case '\f':
            writer.write("\\f");
            break;
        case '\n':
            writer.write("\\n");
            break;
        case '\r':
            writer.write("\\r");
            break;
        case '\t':
            writer.write("\\t");
            break;
        default:// ww w  .  j  ava  2  s  .c o m
            switch (Character.getType(c)) {
            case Character.UPPERCASE_LETTER:
            case Character.LOWERCASE_LETTER:
            case Character.TITLECASE_LETTER:
            case Character.OTHER_LETTER:
            case Character.DECIMAL_DIGIT_NUMBER:
            case Character.LETTER_NUMBER:
            case Character.OTHER_NUMBER:
            case Character.SPACE_SEPARATOR:
            case Character.CONNECTOR_PUNCTUATION:
            case Character.DASH_PUNCTUATION:
            case Character.START_PUNCTUATION:
            case Character.END_PUNCTUATION:
            case Character.INITIAL_QUOTE_PUNCTUATION:
            case Character.FINAL_QUOTE_PUNCTUATION:
            case Character.OTHER_PUNCTUATION:
            case Character.MATH_SYMBOL:
            case Character.CURRENCY_SYMBOL:
            case Character.MODIFIER_SYMBOL:
            case Character.OTHER_SYMBOL:
                writer.write(c);
                break;
            default:
                writer.write("\\u");
                writer.write(Integer.toHexString((c & 0xf000) >> 12));
                writer.write(Integer.toHexString((c & 0x0f00) >> 8));
                writer.write(Integer.toHexString((c & 0x00f0) >> 4));
                writer.write(Integer.toHexString(c & 0x000f));
                break;
            }
            break;
        }
    }
    writer.write('"');
}

From source file:org.apache.slider.common.tools.SliderUtils.java

public static boolean oldIsClusternameValid(String name) {
    if (name == null || name.isEmpty()) {
        return false;
    }/*from   w w w  .  j  av a 2 s .  c om*/
    int first = name.charAt(0);
    if (0 == (Character.getType(first) & Character.LOWERCASE_LETTER)) {
        return false;
    }

    for (int i = 0; i < name.length(); i++) {
        int elt = (int) name.charAt(i);
        int t = Character.getType(elt);
        if (0 == (t & Character.LOWERCASE_LETTER) && 0 == (t & Character.DECIMAL_DIGIT_NUMBER) && elt != '-'
                && elt != '_') {
            return false;
        }
        if (!Character.isLetterOrDigit(elt) && elt != '-' && elt != '_') {
            return false;
        }
    }
    return true;
}

From source file:com.vuze.android.remote.adapter.TorrentListAdapter.java

private static boolean isAlphabetic(int c) {
    // Seems to return symbolic languages
    //      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    //         return Character.isAlphabetic(c);
    //      }//from   w w  w.  j  a v a2s .c  om
    if (!Character.isLetter(c)) {
        return false;
    }
    int type = Character.getType(c);
    return type == Character.UPPERCASE_LETTER || type == Character.LOWERCASE_LETTER;
    // Simple, but doesn't include letters with hats on them ;)
    //return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z');
}

From source file:marytts.util.string.StringUtils.java

/**
 * Determine whether the given codepoint is either a letter or
 * a modifier according to the Unicode standard. More precisely,
 * this returns true if codepoint belongs to one of the following categories
 * as defined at http://unicode.org/Public/UNIDATA/UCD.html#General_Category_Values:
 * <ul>/*from  ww w  .ja v a 2s .com*/
 * <li>Lu   Letter, Uppercase</li>
 * <li>Ll  Letter, Lowercase</li>
 * <li>Lt  Letter, Titlecase</li>
 * <li>Lm  Letter, Modifier</li>
 * <li>Lo  Letter, Other</li>
 * <li>Mn  Mark, Nonspacing</li>
 * <li>Mc  Mark, Spacing Combining</li>
 * <li>Me  Mark, Enclosing</li>
 * </ul>
 * Whether a given character is associated with this category can be looked up
 * at http://unicode.org/Public/UNIDATA/UnicodeData.txt
 * @param codePoint the unicode codepoint as determined e.g. by String.codePointAt().
 * @return true if the above condition is met, false otherwise
 */
public static boolean isLetterOrModifier(int codePoint) {
    int type = Character.getType(codePoint);
    return type == Character.UPPERCASE_LETTER || type == Character.LOWERCASE_LETTER
            || type == Character.TITLECASE_LETTER || type == Character.MODIFIER_LETTER
            || type == Character.OTHER_LETTER || type == Character.NON_SPACING_MARK
            || type == Character.COMBINING_SPACING_MARK || type == Character.ENCLOSING_MARK;
}

From source file:org.apache.orc.impl.mask.RedactMaskFactory.java

/**
 * Given a UTF code point, find the replacement codepoint
 * @param codepoint a UTF character/*  ww w. j a v a  2  s. c om*/
 * @return the replacement codepoint
 */
int getReplacement(int codepoint) {
    switch (Character.getType(codepoint)) {
    case Character.UPPERCASE_LETTER:
        return UPPPER_REPLACEMENT;
    case Character.LOWERCASE_LETTER:
        return LOWER_REPLACEMENT;
    case Character.TITLECASE_LETTER:
    case Character.MODIFIER_LETTER:
    case Character.OTHER_LETTER:
        return OTHER_LETTER_REPLACEMENT;
    case Character.NON_SPACING_MARK:
    case Character.ENCLOSING_MARK:
    case Character.COMBINING_SPACING_MARK:
        return MARK_REPLACEMENT;
    case Character.DECIMAL_DIGIT_NUMBER:
        return DIGIT_CP_REPLACEMENT;
    case Character.LETTER_NUMBER:
    case Character.OTHER_NUMBER:
        return OTHER_NUMBER_REPLACEMENT;
    case Character.SPACE_SEPARATOR:
    case Character.LINE_SEPARATOR:
    case Character.PARAGRAPH_SEPARATOR:
        return SEPARATOR_REPLACEMENT;
    case Character.MATH_SYMBOL:
    case Character.CURRENCY_SYMBOL:
    case Character.MODIFIER_SYMBOL:
    case Character.OTHER_SYMBOL:
        return SYMBOL_REPLACEMENT;
    case Character.DASH_PUNCTUATION:
    case Character.START_PUNCTUATION:
    case Character.END_PUNCTUATION:
    case Character.CONNECTOR_PUNCTUATION:
    case Character.OTHER_PUNCTUATION:
        return PUNCTUATION_REPLACEMENT;
    default:
        return OTHER_REPLACEMENT;
    }
}

From source file:com.yucheng.cmis.pub.util.NewStringUtils.java

/**
 * <p>Splits a String by Character type as returned by
 * <code>java.lang.Character.getType(char)</code>. Groups of contiguous
 * characters of the same type are returned as complete tokens, with the
 * following exception: if <code>camelCase</code> is <code>true</code>,
 * the character of type <code>Character.UPPERCASE_LETTER</code>, if any,
 * immediately preceding a token of type <code>Character.LOWERCASE_LETTER</code>
 * will belong to the following token rather than to the preceding, if any,
 * <code>Character.UPPERCASE_LETTER</code> token. 
 * @param str the String to split, may be <code>null</code>
 * @param camelCase whether to use so-called "camel-case" for letter types
 * @return an array of parsed Strings, <code>null</code> if null String input
 * @since 2.4// w  w w. j a  va  2 s .  co m
 */
private static String[] splitByCharacterType(String str, boolean camelCase) {
    if (str == null) {
        return null;
    }
    if (str.length() == 0) {
        return NewArrayUtils.EMPTY_STRING_ARRAY;
    }
    char[] c = str.toCharArray();
    List list = new ArrayList();
    int tokenStart = 0;
    int currentType = Character.getType(c[tokenStart]);
    for (int pos = tokenStart + 1; pos < c.length; pos++) {
        int type = Character.getType(c[pos]);
        if (type == currentType) {
            continue;
        }
        if (camelCase && type == Character.LOWERCASE_LETTER && currentType == Character.UPPERCASE_LETTER) {
            int newTokenStart = pos - 1;
            if (newTokenStart != tokenStart) {
                list.add(new String(c, tokenStart, newTokenStart - tokenStart));
                tokenStart = newTokenStart;
            }
        } else {
            list.add(new String(c, tokenStart, pos - tokenStart));
            tokenStart = pos;
        }
        currentType = type;
    }
    list.add(new String(c, tokenStart, c.length - tokenStart));
    return (String[]) list.toArray(new String[list.size()]);
}

From source file:com.test.stringtest.StringUtils.java

/**
 * <p>Splits a String by Character type as returned by
 * <code>java.lang.Character.getType(char)</code>. Groups of contiguous
 * characters of the same type are returned as complete tokens, with the
 * following exception: if <code>camelCase</code> is <code>true</code>,
 * the character of type <code>Character.UPPERCASE_LETTER</code>, if any,
 * immediately preceding a token of type <code>Character.LOWERCASE_LETTER</code>
 * will belong to the following token rather than to the preceding, if any,
 * <code>Character.UPPERCASE_LETTER</code> token. 
 * @param str the String to split, may be <code>null</code>
 * @param camelCase whether to use so-called "camel-case" for letter types
 * @return an array of parsed Strings, <code>null</code> if null String input
 * @since 2.4//from  w  w w .  j a  v a  2  s.co m
 */
private static String[] splitByCharacterType(String str, boolean camelCase) {
    if (str == null) {
        return null;
    }
    if (str.length() == 0) {
        return ArrayUtils.EMPTY_STRING_ARRAY;
    }
    char[] c = str.toCharArray();
    List list = new ArrayList();
    int tokenStart = 0;
    int currentType = Character.getType(c[tokenStart]);
    for (int pos = tokenStart + 1; pos < c.length; pos++) {
        int type = Character.getType(c[pos]);
        if (type == currentType) {
            continue;
        }
        if (camelCase && type == Character.LOWERCASE_LETTER && currentType == Character.UPPERCASE_LETTER) {
            int newTokenStart = pos - 1;
            if (newTokenStart != tokenStart) {
                list.add(new String(c, tokenStart, newTokenStart - tokenStart));
                tokenStart = newTokenStart;
            }
        } else {
            list.add(new String(c, tokenStart, pos - tokenStart));
            tokenStart = pos;
        }
        currentType = type;
    }
    list.add(new String(c, tokenStart, c.length - tokenStart));
    return (String[]) list.toArray(new String[list.size()]);
}

From source file:ths.commons.util.StringUtils.java

/**
 * <p>Splits a String by Character type as returned by
 * {@code java.lang.Character.getType(char)}. Groups of contiguous
 * characters of the same type are returned as complete tokens, with the
 * following exception: if {@code camelCase} is {@code true},
 * the character of type {@code Character.UPPERCASE_LETTER}, if any,
 * immediately preceding a token of type {@code Character.LOWERCASE_LETTER}
 * will belong to the following token rather than to the preceding, if any,
 * {@code Character.UPPERCASE_LETTER} token.
 * @param str the String to split, may be {@code null}
 * @param camelCase whether to use so-called "camel-case" for letter types
 * @return an array of parsed Strings, {@code null} if null String input
 * @since 2.4//from w  w w.  ja  v a2 s. c  o m
 */
private static String[] splitByCharacterType(String str, boolean camelCase) {
    if (str == null) {
        return null;
    }
    if (str.length() == 0) {
        return EMPTY_STRING_ARRAY;
    }
    char[] c = str.toCharArray();
    List<String> list = new ArrayList<String>();
    int tokenStart = 0;
    int currentType = Character.getType(c[tokenStart]);
    for (int pos = tokenStart + 1; pos < c.length; pos++) {
        int type = Character.getType(c[pos]);
        if (type == currentType) {
            continue;
        }
        if (camelCase && type == Character.LOWERCASE_LETTER && currentType == Character.UPPERCASE_LETTER) {
            int newTokenStart = pos - 1;
            if (newTokenStart != tokenStart) {
                list.add(new String(c, tokenStart, newTokenStart - tokenStart));
                tokenStart = newTokenStart;
            }
        } else {
            list.add(new String(c, tokenStart, pos - tokenStart));
            tokenStart = pos;
        }
        currentType = type;
    }
    list.add(new String(c, tokenStart, c.length - tokenStart));
    return list.toArray(new String[list.size()]);
}

From source file:com.sjdf.platform.xss.StringUtils.java

/**
 * <p/>/*from w ww  .  j  av  a 2 s. c o  m*/
 * Splits a String by Character type as returned by
 * {@code java.lang.Character.getType(char)}. Groups of contiguous
 * characters of the same type are returned as complete tokens, with the
 * following exception: if {@code camelCase} is {@code true}, the character
 * of type {@code Character.UPPERCASE_LETTER}, if any, immediately preceding
 * a token of type {@code Character.LOWERCASE_LETTER} will belong to the
 * following token rather than to the preceding, if any,
 * {@code Character.UPPERCASE_LETTER} token.
 *
 * @param str       the String to split, may be {@code null}
 * @param camelCase whether to use so-called "camel-case" for letter types
 * @return an array of parsed Strings, {@code null} if null String input
 * @since 2.4
 */
private static String[] splitByCharacterType(String str, boolean camelCase) {
    if (str == null) {
        return new String[0];
    }
    if (str.length() == 0) {
        return EMPTY_STRING_ARRAY;
    }
    char[] c = str.toCharArray();
    List<String> list = new ArrayList<String>();
    int tokenStart = 0;
    int currentType = Character.getType(c[tokenStart]);
    for (int pos = tokenStart + 1; pos < c.length; pos++) {
        int type = Character.getType(c[pos]);
        if (type == currentType) {
            continue;
        }
        if (camelCase && type == Character.LOWERCASE_LETTER && currentType == Character.UPPERCASE_LETTER) {
            int newTokenStart = pos - 1;
            if (newTokenStart != tokenStart) {
                list.add(new String(c, tokenStart, newTokenStart - tokenStart));
                tokenStart = newTokenStart;
            }
        } else {
            list.add(new String(c, tokenStart, pos - tokenStart));
            tokenStart = pos;
        }
        currentType = type;
    }
    list.add(new String(c, tokenStart, c.length - tokenStart));
    return list.toArray(new String[list.size()]);
}