Java Class Name Get className(String underScore)

Here you can find the source of className(String underScore)

Description

class Name

License

Apache License

Declaration

public static String className(String underScore) 

Method Source Code

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

public class Main {
    public static String className(String underScore) {
        String name = fieldName(underScore);
        return Character.toUpperCase(name.charAt(0)) + name.substring(1);
    }//from www .  j  a  va 2s.  c  o  m

    public static String fieldName(String underScore) {
        StringBuilder name = new StringBuilder();

        underScore = underScore.toLowerCase();

        boolean isUnderScore = false;

        for (int i = 0; i < underScore.length(); i++) {
            char spell = underScore.charAt(i);

            if (isUnderScore) {
                name.append(Character.toUpperCase(spell));
                isUnderScore = false;
            } else {
                if (spell == '_') {
                    isUnderScore = true;
                } else {
                    name.append(spell);
                }
            }
        }
        return name.toString();
    }
}

Related

  1. className(String classFile, String pre)
  2. className(String classFullName)
  3. className(String fullyQualifiedName)
  4. className(String nodeName)
  5. className(String path)
  6. classNames(String description)
  7. classNameSubName(String className)
  8. classNameSubPackage(String className)
  9. classNameWithType(String className, String type)