Top Description Fields Constructors Methods
org.glassfish.jaxb.core.api.impl

pack-priv Class NameUtil

extends Object
Class Inheritance
Known Direct Subclasses
org.glassfish.jaxb.core.api.impl.NameConverter.Standard
Imports
java.util.ArrayList, .List, .Locale

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

Modifier and TypeField and Description
private static final byte
private static final byte
private static final byte
private static final byte
private static final byte[]
actionTable

Look up table for actions.

protected static final int
protected static final int
protected static final int
protected static final int
protected static final int

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public String
capitalize(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'.

public static void
escape(StringBuilder
StringBuffer that receives escaped string.
sb
,
String
String to be escaped. s.substring(start) will be escaped and copied to the string buffer.
s
,
int start)

Escapes characters is the given string so that they can be printed by only using US-ASCII characters.

private static String
escape(String s)

Escapes characters that are unusable as Java identifiers by replacing unsafe characters with safe characters.

protected static boolean
isDigit(char c)

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(String s, int start)

public String

Returns:

Always return a string but there's no guarantee that the generated code is a valid Java identifier.
toConstantName
(String s)

Formats a string into "THIS_KIND_OF_FORMAT_ABC_DEF".

public String

Returns:

Always return a string but there's no guarantee that the generated code is a valid Java identifier.
toConstantName
(List<String> ss)

Formats a string into "THIS_KIND_OF_FORMAT_ABC_DEF".

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

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

private String
toUpperCase(char c)

private String
public List<String>
toWordList(String s)

Tokenizes a string into words and capitalizes the first character of each word.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ACTION_BREAKback to summary
private static final byte ACTION_BREAK
ACTION_CHECK_C2back to summary
private static final byte ACTION_CHECK_C2
ACTION_CHECK_PUNCTback to summary
private static final byte ACTION_CHECK_PUNCT
ACTION_NOBREAKback to summary
private static final byte ACTION_NOBREAK
actionTableback to summary
private static final byte[] actionTable

Look up table for actions. type0*5+type1 would yield the action to be taken.

DIGITback to summary
protected static final int DIGIT
LOWER_LETTERback to summary
protected static final int LOWER_LETTER
OTHERback to summary
protected static final int OTHER
OTHER_LETTERback to summary
protected static final int OTHER_LETTER
UPPER_LETTERback to summary
protected static final int UPPER_LETTER

Constructor Detail

NameUtilback to summary
pack-priv NameUtil()

Method Detail

capitalizeback to summary
public String capitalize(String s)

Capitalizes the first character of the specified string, and de-capitalize the rest of characters.

classifyback to summary
protected int classify(char c0)

Classify a character into 5 categories that determine the word break.

decideActionback to summary
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'.

escapeback to summary
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:StringBuilder

StringBuffer that receives escaped string.

s:String

String to be escaped. s.substring(start) will be escaped and copied to the string buffer.

escapeback to summary
private static String escape(String s)

Escapes characters that are unusable as Java identifiers by replacing unsafe characters with safe characters.

isDigitback to summary
protected static boolean isDigit(char c)
isLetterback to summary
protected boolean isLetter(char c)
isLowerback to summary
protected static boolean isLower(char c)
isPunctback to summary
protected boolean isPunct(char c)
isUpperback to summary
protected static boolean isUpper(char c)
nextBreakback to summary
private int nextBreak(String s, int start)
toConstantNameback to summary
public String toConstantName(String s)

Formats a string into "THIS_KIND_OF_FORMAT_ABC_DEF".

Returns:String

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

toConstantNameback to summary
public String toConstantName(List<String> ss)

Formats a string into "THIS_KIND_OF_FORMAT_ABC_DEF".

Returns:String

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

toLowerCaseback to summary
private String toLowerCase(String s)
toMixedCaseNameback to summary
protected String toMixedCaseName(List<String> ss, boolean startUpper)
toMixedCaseVariableNameback to summary
protected String toMixedCaseVariableName(String[] ss, boolean startUpper, boolean cdrUpper)
toUpperCaseback to summary
private String toUpperCase(char c)
toUpperCaseback to summary
private String toUpperCase(String s)
toWordListback to summary
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"}.