class NameUtil
extends java.lang.Object
What JAX-RPC name binding tells us is that even such basic method like "isLetter" can be different depending on the situation. For this reason, a whole lot of methods are made non-static, even though they look like they should be static.
Modifier and Type | Field and Description |
---|---|
private static byte |
ACTION_BREAK |
private static byte |
ACTION_CHECK_C2 |
private static byte |
ACTION_CHECK_PUNCT |
private static byte |
ACTION_NOBREAK |
private static byte[] |
actionTable
Look up table for actions.
|
protected static int |
DIGIT |
protected static int |
LOWER_LETTER |
protected static int |
OTHER |
protected static int |
OTHER_LETTER |
private static java.util.HashSet<java.lang.String> |
reservedKeywords
All reserved keywords of Java.
|
protected static int |
UPPER_LETTER |
Constructor and Description |
---|
NameUtil() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
capitalize(java.lang.String s)
Capitalizes the first character of the specified string,
and de-capitalize the rest of characters.
|
protected int |
classify(char c0)
Classify a character into 5 categories that determine the word break.
|
private static byte |
decideAction(int t0,
int t1)
Decide the action to be taken given
the classification of the preceding character 't0' and
the classification of the next character 't1'.
|
private static java.lang.String |
escape(java.lang.String s)
Escapes characters that are unusable as Java identifiers
by replacing unsafe characters with safe characters.
|
static void |
escape(java.lang.StringBuilder sb,
java.lang.String s,
int start)
Escapes characters is the given string so that they can be
printed by only using US-ASCII characters.
|
protected static boolean |
isDigit(char c) |
static boolean |
isJavaIdentifier(java.lang.String s)
Checks if a given string is usable as a Java identifier.
|
static boolean |
isJavaPackageName(java.lang.String s)
Checks if the given string is a valid Java package name.
|
protected boolean |
isLetter(char c) |
protected static boolean |
isLower(char c) |
protected boolean |
isPunct(char c) |
protected static boolean |
isUpper(char c) |
private int |
nextBreak(java.lang.String s,
int start) |
java.lang.String |
toConstantName(java.util.List<java.lang.String> ss)
Formats a string into "THIS_KIND_OF_FORMAT_ABC_DEF".
|
java.lang.String |
toConstantName(java.lang.String s)
Formats a string into "THIS_KIND_OF_FORMAT_ABC_DEF".
|
protected java.lang.String |
toMixedCaseName(java.util.List<java.lang.String> ss,
boolean startUpper) |
protected java.lang.String |
toMixedCaseVariableName(java.lang.String[] ss,
boolean startUpper,
boolean cdrUpper) |
java.util.List<java.lang.String> |
toWordList(java.lang.String s)
Tokenizes a string into words and capitalizes the first
character of each word.
|
private static boolean |
xor(boolean x,
boolean y) |
protected static final int UPPER_LETTER
protected static final int LOWER_LETTER
protected static final int OTHER_LETTER
protected static final int DIGIT
protected static final int OTHER
private static final byte[] actionTable
private static final byte ACTION_CHECK_PUNCT
private static final byte ACTION_CHECK_C2
private static final byte ACTION_BREAK
private static final byte ACTION_NOBREAK
private static java.util.HashSet<java.lang.String> reservedKeywords
protected boolean isPunct(char c)
protected static boolean isDigit(char c)
protected static boolean isUpper(char c)
protected static boolean isLower(char c)
protected boolean isLetter(char c)
public java.lang.String capitalize(java.lang.String s)
private int nextBreak(java.lang.String s, int start)
private static byte decideAction(int t0, int t1)
private static boolean xor(boolean x, boolean y)
protected int classify(char c0)
public java.util.List<java.lang.String> toWordList(java.lang.String s)
This method uses a change in character type as a splitter of two words. For example, "abc100ghi" will be splitted into {"Abc", "100","Ghi"}.
protected java.lang.String toMixedCaseName(java.util.List<java.lang.String> ss, boolean startUpper)
protected java.lang.String toMixedCaseVariableName(java.lang.String[] ss, boolean startUpper, boolean cdrUpper)
public java.lang.String toConstantName(java.lang.String s)
public java.lang.String toConstantName(java.util.List<java.lang.String> ss)
public static void escape(java.lang.StringBuilder sb, java.lang.String s, int start)
sb
- StringBuffer that receives escaped string.s
- String to be escaped. s.substring(start)
will be escaped and copied to the string buffer.private static java.lang.String escape(java.lang.String s)
public static boolean isJavaIdentifier(java.lang.String s)
public static boolean isJavaPackageName(java.lang.String s)