Java Java String Format toJavaIdentifierCamelCase(String tmp)

Here you can find the source of toJavaIdentifierCamelCase(String tmp)

Description

to Java Identifier Camel Case

License

Apache License

Declaration

public static String toJavaIdentifierCamelCase(String tmp) 

Method Source Code

//package com.java2s;
/*/*from   w  ww  . ja va2  s  .com*/
Copyright 2016 Goldman Sachs.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    
  http://www.apache.org/licenses/LICENSE-2.0
    
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
*/

public class Main {
    public static String toJavaIdentifierCamelCase(String tmp) {
        StringBuilder builder = new StringBuilder(tmp.length());
        boolean mustUpperCase = true;
        for (int i = 0; i < tmp.length(); i++) {
            char c = tmp.charAt(i);
            if (c == '_') {
                mustUpperCase = true;
            } else if (Character.isJavaIdentifierPart(c)) {
                if (mustUpperCase) {
                    c = Character.toUpperCase(c);
                    mustUpperCase = false;
                }
                builder.append(c);
            } else {
                mustUpperCase = true;
            }
        }
        return builder.toString();
    }
}

Related

  1. toJavaIdentifier(String source)
  2. toJavaIdentifier(String str)
  3. toJavaIdentifier(String str)
  4. toJavaIdentifier(String str, String repl)
  5. toJavaIdentifier(String text, Boolean uppercaseFirst)
  6. toJavaIdentifierString(String className)
  7. toJavaImplClassName(String podName, String typeName)
  8. toJavaImplSig(String jsig)
  9. toJavaMethodName(String sqlNotation)