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:org.apache.tomcat.util.IntrospectionUtils.java

public static String unCapitalize(String name) {
    if (name == null || name.length() == 0) {
        return name;
    }/*from w  w  w  . j a  va 2  s . c  o  m*/
    char chars[] = name.toCharArray();
    chars[0] = Character.toLowerCase(chars[0]);
    return new String(chars);
}

From source file:com.hybridbpm.core.util.HybridbpmCoreUtil.java

public static String generateFieldName(String name) {
    String nameValue = name;//w  w  w . j a v a  2  s  . co  m
    StringBuilder result = new StringBuilder();
    for (Character c : nameValue.toCharArray()) {
        if (Character.isJavaIdentifierPart(c)) {
            result.append(c);
        } else {
            result.append("");
        }
    }
    while (!Character.isJavaIdentifierStart(result.charAt(0))) {
        result.deleteCharAt(0);
    }
    return Character.toLowerCase(result.charAt(0)) + result.substring(1);
}

From source file:StringUtil.java

/**
 * Finds last index of a substring in the given source string with ignored
 * case in specified range./*from   w  ww  .  j  ava2 s. c  om*/
 *
 * @param src   source to examine
 * @param sub   substring to find
 * @param startIndex  starting index
 * @param endIndex    end index
 * @return last index of founded substring or -1 if substring is not found
 */
public static int lastIndexOfIgnoreCase(String src, String sub, int startIndex, int endIndex) {
    int sublen = sub.length();
    int srclen = src.length();
    if (sublen == 0) {
        return startIndex > srclen ? srclen : (startIndex < -1 ? -1 : startIndex);
    }
    sub = sub.toLowerCase();
    int total = srclen - sublen;
    if (total < 0) {
        return -1;
    }
    if (startIndex >= total) {
        startIndex = total;
    }
    if (endIndex < 0) {
        endIndex = 0;
    }
    char c = sub.charAt(0);
    mainloop: for (int i = startIndex; i >= endIndex; i--) {
        if (Character.toLowerCase(src.charAt(i)) != c) {
            continue;
        }
        int j = 1;
        int k = i + 1;
        while (j < sublen) {
            char source = Character.toLowerCase(src.charAt(k));
            if (sub.charAt(j) != source) {
                continue mainloop;
            }
            j++;
            k++;
        }
        return i;
    }
    return -1;
}

From source file:com.netspective.commons.text.TextUtils.java

/**
 * Given a text string, return a string that would be suitable for that string to be used
 * as a Java identifier (as a variable or method name). Depending upon whether ucaseInitial
 * is set, the string starts out with a lowercase or uppercase letter. Then, the rule is
 * to convert all periods into underscores and title case any words separated by
 * underscores. This has the effect of removing all underscores and creating mixed case
 * words. For example, Person_Address becomes personAddress or PersonAddress depending upon
 * whether ucaseInitial is set to true or false. Person.Address would become Person_Address.
 *//*  w w w  . ja va  2 s . co m*/
public String xmlTextToJavaIdentifier(String xml, boolean ucaseInitial) {
    if (xml == null || xml.length() == 0)
        return xml;

    String translated = (String) JAVA_RESERVED_WORD_TRANSLATION_MAP.get(xml.toString().toLowerCase());
    if (translated != null)
        xml = translated;

    StringBuffer identifier = new StringBuffer();
    char ch = xml.charAt(0);
    if (Character.isJavaIdentifierStart(ch))
        identifier.append(ucaseInitial ? Character.toUpperCase(ch) : Character.toLowerCase(ch));
    else {
        identifier.append('_');
        if (Character.isJavaIdentifierPart(ch))
            identifier.append(ucaseInitial ? Character.toUpperCase(ch) : Character.toLowerCase(ch));
    }

    boolean uCase = false;
    for (int i = 1; i < xml.length(); i++) {
        ch = xml.charAt(i);
        if (ch == '.') {
            identifier.append('_');
        } else if (ch != '_' && Character.isJavaIdentifierPart(ch)) {
            identifier.append(Character.isUpperCase(ch) ? ch
                    : (uCase ? Character.toUpperCase(ch) : Character.toLowerCase(ch)));
            uCase = false;
        } else
            uCase = true;
    }
    return identifier.toString();
}

From source file:org.geoserver.jdbcconfig.internal.DbMappings.java

/**
 * @param propertyName// w  ww.j  a  v a2 s  .  c  o m
 * @return
 */
private String fixCase(String propertyName) {
    if (propertyName.length() > 1) {
        char first = propertyName.charAt(0);
        char second = propertyName.charAt(1);
        if (!Character.isUpperCase(second)) {
            propertyName = Character.toLowerCase(first) + propertyName.substring(1);
        }
    }
    return propertyName;
}

From source file:org.apache.click.extras.spring.SpringClickServlet.java

/**
 * Return the Spring beanName for the given class.
 *
 * @param aClass the class to get the Spring bean name from
 * @return the class bean name/*from   w  w  w.  jav a 2 s.c o m*/
 */
protected String toBeanName(Class<?> aClass) {
    String className = aClass.getName();
    String beanName = className.substring(className.lastIndexOf(".") + 1);
    return Character.toLowerCase(beanName.charAt(0)) + beanName.substring(1);
}

From source file:com.egt.core.util.STP.java

public static String getCamelCase(String string, String gap) {
    if (string == null) {
        return null;
    }// ww w  .  j  a v a  2 s .  co  m
    String x = string.trim();
    String y = "";
    String z = gap == null ? "" : gap;
    boolean b = false;
    boolean g = false;
    char c;
    for (int i = 0; i < x.length(); i++) {
        c = x.charAt(i);
        switch (c) {
        case '_':
        case '-':
        case '.':
            b = true;
            break;
        default:
            if (b) {
                y += g ? z : "";
                y += Character.toUpperCase(c);
            } else {
                y += Character.toLowerCase(c);
            }
            b = false;
            g = true;
            break;
        }
    }
    return y;
}

From source file:jef.database.DbUtils.java

/**
 * ?????<br>//from  w ww.  ja v a  2s .  co m
 *  you_are_boy -> YouAreBoy
 * 
 * @param name
 *            ??
 * @param capitalize
 *            ???
 * @return ????
 */
public static String underlineToUpper(String name, boolean capitalize) {
    char[] r = new char[name.length()];
    int n = 0;
    boolean nextUpper = capitalize;
    for (char c : name.toCharArray()) {
        if (c == '_') {
            nextUpper = true;
        } else {
            if (nextUpper) {
                r[n] = Character.toUpperCase(c);
                nextUpper = false;
            } else {
                r[n] = Character.toLowerCase(c);
            }

            n++;
        }
    }
    return new String(r, 0, n);
}

From source file:com.adaptc.mws.plugins.testing.transformations.TestMixinTransformation.java

private static String convertPropertyName(String prop) {
    if (Character.isUpperCase(prop.charAt(0)) && Character.isUpperCase(prop.charAt(1))) {
        return prop;
    }//from w  w w.  j  a  v a 2s .c o m
    if (Character.isDigit(prop.charAt(0))) {
        return prop;
    }
    return Character.toLowerCase(prop.charAt(0)) + prop.substring(1);
}

From source file:com.cohort.util.String2.java

/**
 * Finds the first instance of 'find' at or after fromIndex (0..), ignoring case.
 *
 * @param s/*  www . ja v  a2  s. c  om*/
 * @param find
 * @param fromIndex
 * @return the first instance of 'find' at or after fromIndex (0..), ignoring case.
 */
public static int indexOfIgnoreCase(String s, String find, int fromIndex) {
    if (s == null)
        return -1;
    int sLength = s.length();
    if (sLength == 0)
        return -1;
    find = find.toLowerCase();
    int findLength = find.length();
    if (findLength == 0)
        return fromIndex;
    int maxPo = sLength - findLength;
    char ch0 = find.charAt(0);

    int po = fromIndex;
    while (po <= maxPo) {
        if (Character.toLowerCase(s.charAt(po)) == ch0) {
            int f2 = 1;
            while (f2 < findLength && Character.toLowerCase(s.charAt(po + f2)) == find.charAt(f2))
                f2++;
            if (f2 == findLength)
                return po;
        }
        po++;
    }
    return -1;
}