Example usage for java.lang Character toLowerCase

List of usage examples for java.lang Character toLowerCase

Introduction

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

Prototype

public static int toLowerCase(int codePoint) 

Source Link

Document

Converts the character (Unicode code point) argument to lowercase using case mapping information from the UnicodeData file.

Usage

From source file:net.bioclipse.structuredb.persistence.dao.GenericDaoTest.java

private String firstToLowerCase(String daoName) {
    return Character.toLowerCase(daoName.charAt(0)) + daoName.substring(1);
}

From source file:de.mirkosertic.easydav.index.QueryParser.java

public Query parse(String aQuery, String aSearchField) {

    BooleanQuery theResult = new BooleanQuery();

    boolean isStringMode = false;
    boolean isNegated = false;
    StringBuilder theCurrentTerm = new StringBuilder();

    for (int i = 0; i < aQuery.length(); i++) {
        char theCurrentChar = Character.toLowerCase(aQuery.charAt(i));
        if (theCurrentChar == '\"') {
            isStringMode = !isStringMode;
        } else {/*  ww w  .  j  av  a  2 s  .  c  om*/
            if (!isStringMode) {
                switch (theCurrentChar) {
                case '-': {
                    if (theCurrentTerm.length() == 0) {
                        isNegated = true;
                    } else {
                        theCurrentTerm.append(theCurrentChar);
                    }
                    break;
                }
                case '+':
                    if (theCurrentTerm.length() == 0) {
                        isNegated = false;
                    } else {
                        theCurrentTerm.append(theCurrentChar);
                    }
                    break;
                case ' ': {
                    addSubQuery(theResult, theCurrentTerm.toString(), isNegated, aSearchField);
                    theCurrentTerm = new StringBuilder();
                    isNegated = false;
                    break;
                }
                default: {
                    theCurrentTerm.append(theCurrentChar);
                    break;
                }
                }
            } else {
                theCurrentTerm.append(theCurrentChar);
            }
        }
    }

    if (theCurrentTerm.length() > 0) {
        addSubQuery(theResult, theCurrentTerm.toString(), isNegated, aSearchField);
    }

    return theResult;
}

From source file:org.gradle.language.base.internal.DefaultBinaryNamingScheme.java

private void appendUncapitalized(StringBuilder builder, String word) {
    builder.append(Character.toLowerCase(word.charAt(0))).append(word.substring(1));
}

From source file:cern.c2mon.shared.common.datatag.address.impl.HardwareAddressImpl.java

/**
 * Encodes a field name in Java notation (e.g. myFieldName) to an XML field name (e.g. my-field-name).
 */// w  w w. j ava 2 s. co m
private final String encodeFieldName(final String pFieldName) {
    StringBuilder str = new StringBuilder();
    int fieldNameLength = pFieldName.length();

    char currentChar;
    for (int i = 0; i != fieldNameLength; i++) {
        currentChar = pFieldName.charAt(i);
        if (Character.isUpperCase(currentChar)) {
            str.append('-');
            str.append(Character.toLowerCase(currentChar));
        } else {
            str.append(currentChar);
        }
    }
    return str.toString();
}

From source file:com.liferay.cucumber.util.StringUtil.java

public static boolean equalsIgnoreCase(String s1, String s2) {
    if (s1 == s2) {
        return true;
    }/*from   w  w  w  . j  a  v  a  2 s.  com*/

    if ((s1 == null) || (s2 == null)) {
        return false;
    }

    if (s1.length() != s2.length()) {
        return false;
    }

    for (int i = 0; i < s1.length(); i++) {
        char c1 = s1.charAt(i);

        char c2 = s2.charAt(i);

        if (c1 == c2) {
            continue;
        }

        if ((c1 > 127) || (c2 > 127)) {

            // Georgian alphabet needs to check both upper and lower case

            if ((Character.toLowerCase(c1) == Character.toLowerCase(c2))
                    || (Character.toUpperCase(c1) == Character.toUpperCase(c2))) {

                continue;
            }

            return false;
        }

        int delta = c1 - c2;

        if ((delta != 32) && (delta != -32)) {
            return false;
        }
    }

    return true;
}

From source file:org.apache.wiki.util.comparators.HumanComparator.java

public int compare(String str1, String str2) {
    // Some quick and easy checks
    if (StringUtils.equals(str1, str2)) {
        // they're identical, possibly both null
        return 0;
    } else if (str1 == null) {
        // str1 is null and str2 isn't so str1 is smaller
        return -1;
    } else if (str2 == null) {
        // str2 is null and str1 isn't so str1 is bigger
        return 1;
    }//from   w ww. j av  a  2  s.co m

    char[] s1 = str1.toCharArray();
    char[] s2 = str2.toCharArray();
    int len1 = s1.length;
    int len2 = s2.length;
    int idx = 0;
    // caseComparison used to defer a case sensitive comparison
    int caseComparison = 0;

    while (idx < len1 && idx < len2) {
        char c1 = s1[idx];
        char c2 = s2[idx++];

        // Convert to lower case
        char lc1 = Character.toLowerCase(c1);
        char lc2 = Character.toLowerCase(c2);

        // If case makes a difference, note the difference the first time
        // it's encountered
        if (caseComparison == 0 && c1 != c2 && lc1 == lc2) {
            if (Character.isLowerCase(c1))
                caseComparison = 1;
            else if (Character.isLowerCase(c2))
                caseComparison = -1;
        }
        // Do the rest of the tests in lower case
        c1 = lc1;
        c2 = lc2;

        // leading zeros are a special case
        if (c1 != c2 || c1 == '0') {
            // They might be different, now we can do a comparison
            CharType type1 = mapCharTypes(c1);
            CharType type2 = mapCharTypes(c2);

            // Do the character class check
            int result = compareCharTypes(type1, type2);
            if (result != 0) {
                // different character classes so that's sufficient
                return result;
            }

            // If they're not digits, use character to character comparison
            if (type1 != CharType.TYPE_DIGIT) {
                Character ch1 = Character.valueOf(c1);
                Character ch2 = Character.valueOf(c2);
                return ch1.compareTo(ch2);
            }

            // The only way to get here is both characters are digits
            assert (type1 == CharType.TYPE_DIGIT && type2 == CharType.TYPE_DIGIT);
            result = compareDigits(s1, s2, idx - 1);
            if (result != 0) {
                // Got a result so return it
                return result;
            }

            // No result yet, spin through the digits and continue trying
            while (idx < len1 && idx < len2 && Character.isDigit(s1[idx])) {
                idx++;
            }
        }
    }

    if (len1 == len2) {
        // identical so return any case dependency
        return caseComparison;
    }

    // Shorter String is less
    return len1 - len2;
}

From source file:com.manydesigns.elements.util.Util.java

public static String letterOrDigitToWords(String s) {
    if (s == null) {
        return null;
    }//from   www  .j  a v  a2s  . c o  m
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < s.length(); i++) {
        char c = s.charAt(i);
        if (Character.isLetterOrDigit(c)) {
            sb.append(Character.toLowerCase(c));
        } else {
            sb.append(' ');
        }
    }
    return sb.toString();
}

From source file:com.emc.ecs.sync.config.ConfigUtil.java

public static String hyphenate(String name) {
    StringBuilder hyphenated = new StringBuilder();
    for (char c : name.toCharArray()) {
        if (Character.isUpperCase(c) && hyphenated.length() > 0)
            hyphenated.append('-');
        hyphenated.append(Character.toLowerCase(c));
    }//w w w  .jav a2  s. c o  m
    return hyphenated.toString();
}

From source file:ar.com.allium.rules.core.service.AlliumCoreRuleManager.java

private String buildCorrectClassName(String className) {
    return Character.toLowerCase(className.charAt(0)) + className.substring(1);
}

From source file:com.comphenix.xp.messages.MessageFormatter.java

private static String translateAlternateColorCodes(char altColorChar, String textToTranslate) {

    boolean hasEscape = false;
    char[] b = textToTranslate.toCharArray();

    // Handle Java escaping as well
    for (int i = 0; i < b.length - 1; i++) {
        if (!hasEscape && b[i] == '\\') {
            hasEscape = true;//  w w  w  .ja v a2  s .c  o m
        } else if (!hasEscape && b[i] == altColorChar
                && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i + 1]) > -1) {
            b[i] = ChatColor.COLOR_CHAR;
            b[i + 1] = Character.toLowerCase(b[i + 1]);

        } else {
            hasEscape = false;
        }
    }
    return new String(b);
}