org.jibx.schema.codegen
Class NameUtils

java.lang.Object
  extended by org.jibx.schema.codegen.NameUtils

public class NameUtils
extends java.lang.Object

Support methods for working with Java names.

Author:
Dennis M. Sosnoski

Field Summary
private static java.util.HashSet s_reservedWords
          Reserved words for Java (keywords and literals).
 
Constructor Summary
NameUtils()
           
 
Method Summary
static boolean isReserved(java.lang.String name)
          Check if a name is reserved in Java.
static java.lang.String sanitizePackageName(java.lang.String raw)
          Convert a raw package name to a legal Java package name.
static java.lang.String toNameLead(java.lang.String word)
          Convert a word to a leading name component.
static java.lang.String toNameWord(java.lang.String word)
          Convert a word to a name component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s_reservedWords

private static final java.util.HashSet s_reservedWords
Reserved words for Java (keywords and literals).

Constructor Detail

NameUtils

public NameUtils()
Method Detail

isReserved

public static boolean isReserved(java.lang.String name)
Check if a name is reserved in Java.

Parameters:
name -
Returns:
is reserved

sanitizePackageName

public static java.lang.String sanitizePackageName(java.lang.String raw)
Convert a raw package name to a legal Java package name. The raw package name must be in standard package name form, with periods separating the individual directory components of the package name.

Parameters:
raw - basic package name, which may include illegal characters
Returns:
sanitized package name

toNameWord

public static java.lang.String toNameWord(java.lang.String word)
Convert a word to a name component. This is intended for use when composing names, as when generating access method names for a property. If the supplied word starts with one or more underscores, this first strips the the underscores. If the resulting text starts with a lower case letter this then converts that character to upper case. Finally, if the result either begins with a digit or is the word "Class" this prepends a leading underscore back on.

Parameters:
word -
Returns:
word with uppercase initial letter

toNameLead

public static java.lang.String toNameLead(java.lang.String word)
Convert a word to a leading name component. If the supplied word starts with an uppercase letter which is not followed by another uppercase letter, this converts the initial uppercase to lowercase.

Parameters:
word -
Returns:
word with lowercase initial letter


Project Web Site