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:com.gzj.tulip.jade.rowmapper.BeanPropertyRowMapper.java

/**
 * Convert a name in camelCase to an underscored name in lower case.
 * Any upper case letters are converted to lower case with a preceding
 * underscore./*from   w ww.ja va 2s . c  o  m*/
 * 
 * @param camelCaseName the string containing original name
 * @return the converted name
 */
private String[] underscoreName(String camelCaseName) {
    StringBuilder result = new StringBuilder();
    if (camelCaseName != null && camelCaseName.length() > 0) {
        result.append(camelCaseName.substring(0, 1).toLowerCase());
        for (int i = 1; i < camelCaseName.length(); i++) {
            char ch = camelCaseName.charAt(i);
            if (Character.isUpperCase(ch)) {
                result.append("_");
                result.append(Character.toLowerCase(ch));
            } else {
                result.append(ch);
            }
        }
    }
    String name = result.toString();
    // nameuser1_name2name2user_1_name_2
    // user_1_name_2user1Name2
    String name2 = null;
    boolean digitFound = false;
    for (int i = name.length() - 1; i >= 0; i--) {
        if (Character.isDigit(name.charAt(i))) {
            // ??continue,???continue
            digitFound = true;
            continue;
        }
        // ???
        if (digitFound && i < name.length() - 1 && i > 0) {
            if (name2 == null) {
                name2 = name;
            }
            name2 = name2.substring(0, i + 1) + "_" + name2.substring(i + 1);
        }
        digitFound = false;
    }
    return new String[] { name, name2 };
}

From source file:de.hybris.platform.webservices.util.objectgraphtransformer.impl.AbstractNodeConfig.java

/**
 * Creates a lookup map containing all properties of passed type.
 * <p/>//from   w w  w .j ava 2s. co  m
 * Result maps a property name to a {@link PropertyConfig}.
 * </p>
 * Any property which keeps java bean standard is found and used for {@link PropertyConfig} creation. For finding all
 * properties {@link Introspector} is used which returns general {@link PropertyDescriptor}. But read- and write
 * methods provided by {@link PropertyDescriptor} are only used as "suggestion" here and are getting post-processed
 * to assure following criteria:
 * <p/>
 * - no bridge or synthetic methods are allowed <br/>
 * - co-variant return types are handled correctly <br/>
 * 
 * @param type
 * @return
 */
private Map<String, PropertyConfig> createPropertiesFor(Class<?> type) {
    final Map<String, PropertyConfig> result = new TreeMap<String, PropertyConfig>();
    final Set<String> done = new HashSet<String>();
    while (type != null) {
        // we are only interested in declared methods (no bridge/synthetic ones)
        final Method[] methods = type.getDeclaredMethods();
        for (final Method method : methods) {
            // only public, non-bridged methods are of interest
            if (!method.isBridge() && Modifier.isPublic(method.getModifiers())) {
                // potential bean-getter property?
                if (method.getParameterTypes().length == 0 && method.getReturnType() != void.class) {
                    // not processed yet?
                    final String methodName = method.getName();
                    if (!done.contains(methodName)) {
                        done.add(methodName);

                        final Matcher matcher = BEAN_GETTER.matcher(methodName);
                        String propertyName = null;
                        if (matcher.matches()) {
                            propertyName = matcher.group(1);
                        } else {
                            if (method.getReturnType().equals(boolean.class)) {
                                final Matcher matcher2 = BEAN_BOOLEAN_GETTER.matcher(methodName);
                                if (matcher2.matches()) {
                                    propertyName = matcher2.group(1);
                                }
                            }
                        }

                        if (propertyName != null) {
                            propertyName = normalizePropertyName(propertyName);

                            // get or create a PropertyConfig
                            DefaultPropertyConfig pCfg = (DefaultPropertyConfig) result.get(propertyName);
                            if (pCfg == null) {
                                pCfg = new DefaultPropertyConfig(propertyName, null, null);
                                result.put(propertyName, pCfg);
                            }
                            pCfg.setReadMethod(method);
                        }
                    }
                }

                // potential bean-setter property?
                if (method.getParameterTypes().length == 1 && method.getReturnType() == void.class) {
                    // not processed yet?
                    final String methodName = method.getName();
                    if (!done.contains(methodName)) {
                        done.add(methodName);
                        final Matcher setter = BEAN_SETTER.matcher(methodName);
                        if (setter.matches()) {
                            String propertyName = setter.group(1);
                            propertyName = Character.toLowerCase(propertyName.charAt(0))
                                    + propertyName.substring(1);

                            // get or create a PropertyConfig
                            DefaultPropertyConfig pCfg = (DefaultPropertyConfig) result.get(propertyName);
                            if (pCfg == null) {
                                pCfg = new DefaultPropertyConfig(propertyName, null, null);
                                result.put(propertyName, pCfg);
                            }
                            pCfg.setWriteMethod(method);
                        }
                    }
                }
            }

        }
        type = type.getSuperclass();
    }
    return result;
}

From source file:com.intel.ssg.dcst.panthera.parse.sql.SqlParseDriver.java

/**
 * A pre-parse stage to convert the characters in query command (exclude
 * those in quotes) to lower-case, as our SQL Parser does not recognize
 * upper-case keywords. It does no harm to Hive as Hive is case-insensitive.
 *
 * @param command/*from  w ww  .j  a  va 2 s  .  c o m*/
 *          input query command
 * @return the command with all chars turned to lower case except
 *         those in quotes
 */
protected String preparse(String command) {
    Character tag = '\'';
    Stack<Character> singleQuotes = new Stack<Character>();
    Stack<Character> doubleQuotes = new Stack<Character>();
    char[] chars = filterDot(command).toCharArray();
    for (int i = 0; i < chars.length; i++) {
        char c = chars[i];
        if (c == '\'' && (i > 0 ? chars[i - 1] != '\\' : true)) {
            singleQuotes.push(tag);
        } else if (c == '\"' && (i > 0 ? chars[i - 1] != '\\' : true)) {
            doubleQuotes.push(tag);
        }
        if (singleQuotes.size() % 2 == 0 && doubleQuotes.size() % 2 == 0) {
            // if not inside quotes, convert to lower case
            chars[i] = Character.toLowerCase(c);
        }
    }
    return new String(chars);
}

From source file:CharArrayMap.java

private boolean equals(char[] text1, int off, int len, char[] text2) {
    if (len != text2.length)
        return false;
    if (ignoreCase) {
        for (int i = 0; i < len; i++) {
            if (Character.toLowerCase(text1[off + i]) != text2[i])
                return false;
        }/*from  ww w  . j  a  va  2s  . c  o  m*/
    } else {
        for (int i = 0; i < len; i++) {
            if (text1[off + i] != text2[i])
                return false;
        }
    }
    return true;
}

From source file:banner.tagging.dictionary.DictionaryTagger.java

protected String transform(String str) {
    // This has been optimized for very fast operation
    String result = str;//from w w  w  .  j a  va 2 s .c o  m

    if (stemTokens) {
        String stem = stemmer.stem(str);
        // System.out.println("Stemmer; original= " + str + ", stemmed= " + stem);
        str = stem;
    }
    if (normalizeMixedCase || normalizeDigits) {
        char[] chars = str.toCharArray();
        if (normalizeMixedCase) {
            boolean hasUpper = false;
            boolean hasLower = false;
            for (int i = 0; i < chars.length && (!hasUpper || !hasLower); i++) {
                hasUpper |= Character.isUpperCase(chars[i]);
                hasLower |= Character.isLowerCase(chars[i]);
            }
            if (hasUpper && hasLower)
                for (int i = 0; i < chars.length; i++)
                    chars[i] = Character.toLowerCase(chars[i]);
        }
        // Note that this only works on single digits
        if (normalizeDigits)
            for (int i = 0; i < chars.length; i++)
                if (Character.isDigit(chars[i]))
                    chars[i] = '0';
        result = new String(chars);
    }
    return result;
}

From source file:org.batoo.common.util.StringUtils.java

private static String changeFirstCharacterCase(String str, boolean capitalize) {
    if ((str == null) || (str.length() == 0)) {
        return str;
    }//w  ww . ja  va 2s  .c  om
    final StringBuilder sb = new StringBuilder(str.length());
    if (capitalize) {
        sb.append(Character.toUpperCase(str.charAt(0)));
    } else {
        sb.append(Character.toLowerCase(str.charAt(0)));
    }
    sb.append(str.substring(1));
    return sb.toString();
}

From source file:com.kolich.curacao.util.helpers.UrlPathHelper.java

/**
 * Match the given "mapping" to the start of the "requestUri" and if there
 * is a match return the extra part. This method is needed because the
 * context path and the servlet path returned by the HttpServletRequest are
 * stripped of semicolon content unlike the requesUri.
 */// ww  w . j  a  v  a 2  s  .  c om
private final String getRemainingPath(final String requestUri, final String mapping, final boolean ignoreCase) {
    int index1 = 0;
    int index2 = 0;
    for (; (index1 < requestUri.length()) && (index2 < mapping.length()); index1++, index2++) {
        char c1 = requestUri.charAt(index1);
        char c2 = mapping.charAt(index2);
        if (c1 == ';') {
            index1 = requestUri.indexOf('/', index1);
            if (index1 == -1) {
                return null;
            }
            c1 = requestUri.charAt(index1);
        }
        if (c1 == c2) {
            continue;
        }
        if (ignoreCase && (Character.toLowerCase(c1) == Character.toLowerCase(c2))) {
            continue;
        }
        return null;
    }
    if (index2 != mapping.length()) {
        return null;
    }
    if (index1 == requestUri.length()) {
        return "";
    } else if (requestUri.charAt(index1) == ';') {
        index1 = requestUri.indexOf('/', index1);
    }
    return (index1 != -1) ? requestUri.substring(index1) : "";
}

From source file:com.chiralbehaviors.CoRE.workspace.WorkspaceAuthorization.java

public static String getWorkspaceAuthorizationColumnName(Class<?> ruleform) {
    StringBuilder builder = new StringBuilder();
    String simpleName = ruleform.getClass().getSimpleName();
    builder.append(Character.toLowerCase(simpleName.charAt(0)));
    int i = 1;/*from  w ww.ja  v  a 2s .c om*/
    for (char c = simpleName.charAt(i); i < simpleName.length(); i++) {
        if (Character.isUpperCase(c)) {
            builder.append('_');
            builder.append(Character.toLowerCase(c));
        }
    }
    return builder.toString();
}

From source file:mrcg.utils.Utils.java

public static String toDatabaseFormat(String s) {
    StringBuilder b = new StringBuilder(s.length() + 5);
    for (char c : s.toCharArray()) {
        if (Character.isUpperCase(c) && b.length() > 0) {
            b.append('_');
        }//from w w w .java  2  s.c o m
        b.append(Character.toLowerCase(c));
    }
    return b.toString();
}

From source file:org.bonitasoft.engine.bdm.BDMQueryUtil.java

public static String createQueryContentForField(final String businessObjectName, final Field field) {
    if (businessObjectName == null) {
        throw new IllegalArgumentException("businessObjectName is null");
    }//from  ww w .  j ava2 s  .  c  o  m
    if (field == null) {
        throw new IllegalArgumentException("field cannot be null");
    }
    final String simpleName = getSimpleBusinessObjectName(businessObjectName);
    final char var = Character.toLowerCase(simpleName.charAt(0));
    final StringBuilder builder = new StringBuilder();
    builder.append(buildSelectFrom(simpleName, var));
    builder.append(buildWhere(var, field.getName()));
    builder.append(buildOrderBy(var));
    return builder.toString();
}