Example usage for com.google.common.base CharMatcher JAVA_LOWER_CASE

List of usage examples for com.google.common.base CharMatcher JAVA_LOWER_CASE

Introduction

In this page you can find the example usage for com.google.common.base CharMatcher JAVA_LOWER_CASE.

Prototype

CharMatcher JAVA_LOWER_CASE

To view the source code for com.google.common.base CharMatcher JAVA_LOWER_CASE.

Click Source Link

Document

Determines whether a character is lower case according to Character#isLowerCase(char) Java's definition .

Usage

From source file:org.apache.metamodel.jdbc.dialects.HsqldbQueryRewriter.java

/**
 * HSQL converts all non-escaped characters to uppercases, this is prevented by always escaping
 *///from   w  w  w. j  a  va 2 s.  c om
@Override
public boolean needsQuoting(String alias, String identifierQuoteString) {

    boolean containsLowerCase = CharMatcher.JAVA_LOWER_CASE.matchesAnyOf(identifierQuoteString);

    return containsLowerCase || super.needsQuoting(alias, identifierQuoteString);
}

From source file:org.knight.examples.guava.strings.StringsExamples.java

private void charMatcher() {
    String u = "UPPER CASE LETTER";
    String l = "lower case letter";
    String uld = "LOWER case And Upper Case LETTER and 8912 digits 0000";

    //return false
    log("CharMatcher.JAVA_LOWER_CASE.matches('A'): " + CharMatcher.JAVA_LOWER_CASE.matches('A'));

    //retain only the upper case letters(in this case, spaces will be removed).
    String s1 = CharMatcher.JAVA_UPPER_CASE.retainFrom(u);
    log("s1: " + s1);

    //s2 is "lowr  lttr"(2 spaces)
    String s2 = CharMatcher.anyOf("case").removeFrom(l);
    log(s2);//  www. ja v a 2 s  .  c om

    //replace all digits with "-"
    //result is "LOWER case And Upper Case LETTER and ---- digits ----"
    String s3 = CharMatcher.DIGIT.replaceFrom(uld, '-');
    log(s3);

    //replace all consecutive digits with a single "-"
    //result is "LOWER case And Upper Case LETTER and - digits -"
    String s4 = CharMatcher.DIGIT.collapseFrom(uld, '-');
    log(s4);

    //contains digit, so return false
    boolean b = CharMatcher.inRange('a', 'z').matchesAllOf(uld);
    log("matchesAllOf(a-z): " + b);
}