com.sun.xml.bind.api.impl

Class NameUtil

class NameUtil extends Object

Methods that convert strings into various formats.

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.

Field Summary
protected static intDIGIT
protected static intLOWER_LETTER
protected static intOTHER
protected static intOTHER_LETTER
protected static intUPPER_LETTER
Method Summary
Stringcapitalize(String s)
Capitalizes the first character of the specified string, and de-capitalize the rest of characters.
protected intclassify(char c0)
Classify a character into 5 categories that determine the word break.
static voidescape(StringBuilder sb, String s, int start)
Escapes characters is the given string so that they can be printed by only using US-ASCII characters.
protected static booleanisDigit(char c)
static booleanisJavaIdentifier(String s)
Checks if a given string is usable as a Java identifier.
static booleanisJavaPackageName(String s)
Checks if the given string is a valid Java package name.
protected booleanisLetter(char c)
protected static booleanisLower(char c)
protected booleanisPunct(char c)
protected static booleanisUpper(char c)
StringtoConstantName(String s)
Formats a string into "THIS_KIND_OF_FORMAT_ABC_DEF".
StringtoConstantName(List<String> ss)
Formats a string into "THIS_KIND_OF_FORMAT_ABC_DEF".
protected StringtoMixedCaseName(List<String> ss, boolean startUpper)
protected StringtoMixedCaseVariableName(String[] ss, boolean startUpper, boolean cdrUpper)
List<String>toWordList(String s)
Tokenizes a string into words and capitalizes the first character of each word.

Field Detail

DIGIT

protected static final int DIGIT

LOWER_LETTER

protected static final int LOWER_LETTER

OTHER

protected static final int OTHER

OTHER_LETTER

protected static final int OTHER_LETTER

UPPER_LETTER

protected static final int UPPER_LETTER

Method Detail

capitalize

public String capitalize(String s)
Capitalizes the first character of the specified string, and de-capitalize the rest of characters.

classify

protected int classify(char c0)
Classify a character into 5 categories that determine the word break.

escape

public static void escape(StringBuilder sb, String s, int start)
Escapes characters is the given string so that they can be printed by only using US-ASCII characters. The escaped characters will be appended to the given StringBuffer.

Parameters: sb StringBuffer that receives escaped string. s String to be escaped. s.substring(start) will be escaped and copied to the string buffer.

isDigit

protected static boolean isDigit(char c)

isJavaIdentifier

public static boolean isJavaIdentifier(String s)
Checks if a given string is usable as a Java identifier.

isJavaPackageName

public static boolean isJavaPackageName(String s)
Checks if the given string is a valid Java package name.

isLetter

protected boolean isLetter(char c)

isLower

protected static boolean isLower(char c)

isPunct

protected boolean isPunct(char c)

isUpper

protected static boolean isUpper(char c)

toConstantName

public String toConstantName(String s)
Formats a string into "THIS_KIND_OF_FORMAT_ABC_DEF".

Returns: Always return a string but there's no guarantee that the generated code is a valid Java identifier.

toConstantName

public String toConstantName(List<String> ss)
Formats a string into "THIS_KIND_OF_FORMAT_ABC_DEF".

Returns: Always return a string but there's no guarantee that the generated code is a valid Java identifier.

toMixedCaseName

protected String toMixedCaseName(List<String> ss, boolean startUpper)

toMixedCaseVariableName

protected String toMixedCaseVariableName(String[] ss, boolean startUpper, boolean cdrUpper)

toWordList

public List<String> toWordList(String s)
Tokenizes a string into words and capitalizes the first character of each word.

This method uses a change in character type as a splitter of two words. For example, "abc100ghi" will be splitted into {"Abc", "100","Ghi"}.