Java String Underscore to underscoresToCamelCaseImpl(String input, boolean capNextLetter)

Here you can find the source of underscoresToCamelCaseImpl(String input, boolean capNextLetter)

Description

underscores To Camel Case Impl

License

Apache License

Declaration

public static String underscoresToCamelCaseImpl(String input,
        boolean capNextLetter) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static String underscoresToCamelCaseImpl(String input,
            boolean capNextLetter) {
        StringBuilder result = new StringBuilder();
        char[] chars = input.toCharArray();
        for (int i = 0; i < chars.length; ++i) {
            if ('a' <= chars[i] && chars[i] <= 'z') {
                if (capNextLetter) {
                    result.append((char) (chars[i] + ('A' - 'a')));
                } else {
                    result.append(chars[i]);
                }//from w w w. j  a v  a2 s. c o  m
                capNextLetter = false;
            } else if ('A' <= chars[i] && chars[i] <= 'Z') {
                if (i == 0 && !capNextLetter) {
                    // Force first letter to lower-case unless explicitly told to
                    // capitalize it.
                    result.append((char) (chars[i] + ('a' - 'A')));
                } else {
                    // Capital letters after the first are left as-is.
                    result.append(chars[i]);
                }
                capNextLetter = false;
            }
        }
        return result.toString();
    }
}

Related

  1. underscore2camel(String underscoreName)
  2. underScore2CamelCase(String strs)
  3. underscoreDashToCamelCase(String s)
  4. underscoresToSpaces(String value)
  5. underscoreToCamel(String input, boolean firstLetterUppercase)
  6. underscoreToCamelCase(String wordConstruct)
  7. underscoreToPascalCase(final String str)