Package org.jibx.schema.codegen
Class NameUtils
java.lang.Object
org.jibx.schema.codegen.NameUtils
Support methods for working with Java names.
- Author:
- Dennis M. Sosnoski
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
convertReserved
(String name) Convert name if it is reserved in Java.static boolean
isDefaultImport
(String name) Check if a class name is a default import in Java.static boolean
isReserved
(String name) Check if a name is reserved in Java.static String
Convert a raw package name to a legal Java package name.static String
toNameLead
(String word) Convert a word to a leading name component.static String
toNameWord
(String word) Convert a word to a name component.
-
Field Details
-
s_reservedWords
Reserved words for Java (keywords and literals). -
s_defaultImportClassNames
Java default import class names (not exhaustive, but anything that might represent generated code conflict).
-
-
Constructor Details
-
NameUtils
public NameUtils()
-
-
Method Details
-
isReserved
Check if a name is reserved in Java.- Parameters:
name
-- Returns:
- is reserved
-
convertReserved
Convert name if it is reserved in Java.- Parameters:
name
-- Returns:
- non-reserved name
-
isDefaultImport
Check if a class name is a default import in Java.- Parameters:
name
-- Returns:
- is reserved
-
sanitizePackageName
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
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
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
-