Java ID Value Create toIdentifier(String text)

Here you can find the source of toIdentifier(String text)

Description

to Identifier

License

Open Source License

Declaration

public static String toIdentifier(String text) 

Method Source Code

//package com.java2s;

public class Main {
    public static String toIdentifier(String text) {
        String out = "";

        if (Character.isDigit(text.charAt(0)))
            out += "_";

        for (int i = 0; i < text.length(); i++) {
            if (Character.isJavaIdentifierPart(text.charAt(i)))
                out += text.charAt(i);/* w ww  .  ja va2 s .co m*/
            else if (text.charAt(i) == ' ')
                out += "_";
        }
        return out;
    }
}

Related

  1. toIdableName(String xpath)
  2. toIdentifier(String input)
  3. toIdentifier(String name)
  4. toIdentifier(String name, StringBuffer fieldName)
  5. toIdentifier(String str)
  6. toIdentifierString(long val)
  7. toIdentityEncodedString(byte[] data)
  8. toIdentityHashCodeInteger(Object value)
  9. toIdentityVariableName(String varName)