Package org.jibx.schema.codegen.extend
Interface NameConverter
- All Known Implementing Classes:
DefaultNameConverter
public interface NameConverter
Interface for working with Java names during code generation.
- Author:
- Dennis M. Sosnoski
-
Method Summary
Modifier and TypeMethodDescriptiondepluralize
(String name) Convert potentially plural name to singular form.Convert singular name to plural form.String[]
splitXMLWords
(String name) Split an XML name into words.toBaseName
(String xname) Convert an XML name to a Java value base name.toConstantName
(String text) Convert text to constant name.toFieldName
(String base) Convert base name to normal field name.Convert property name to if set access method name (for value in set of alternatives).toJavaClassName
(String xname) Convert a base name to a legal Java class name.toPropertyName
(String base) Convert base name to property name (used for all method names).toReadAccessMethodName
(String prop) Convert property name to read access method name.toStaticFieldName
(String base) Convert base name to static field name.toTestAccessMethodName
(String prop) Convert property name to test access method name (for boolean value).Convert property name to write access method name.Trim specified prefixes and/or suffixes from an XML name.
-
Method Details
-
pluralize
Convert singular name to plural form.- Parameters:
name
- base name- Returns:
- plural name
-
depluralize
Convert potentially plural name to singular form.- Parameters:
name
- base name- Returns:
- singularized name
-
toBaseName
Convert an XML name to a Java value base name. The base name is in normalized camelcase form with leading lower case (unless the first word of the name is all uppercase).- Parameters:
xname
- XML name- Returns:
- converted name
-
toJavaClassName
Convert a base name to a legal Java class name.- Parameters:
xname
- XML name- Returns:
- converted name
-
toConstantName
Convert text to constant name. The constant name must not match a Java keyword.- Parameters:
text
- raw text to be converted- Returns:
- constant name
-
toFieldName
Convert base name to normal field name. The field name must not match a Java keyword.- Parameters:
base
- normalized camelcase base name- Returns:
- field name
-
toStaticFieldName
Convert base name to static field name. The field name must not match a Java keyword.- Parameters:
base
- normalized camelcase base name- Returns:
- field name
-
toPropertyName
Convert base name to property name (used for all method names). The property name is always in initial-upper camelcase form.- Parameters:
base
- normalized camelcase base name- Returns:
- property name in initial-upper camelcase form
-
toReadAccessMethodName
Convert property name to read access method name.- Parameters:
prop
- property name in initial-upper camelcase form- Returns:
- read access method name
-
toWriteAccessMethodName
Convert property name to write access method name.- Parameters:
prop
- property name in initial-upper camelcase form- Returns:
- write access method name
-
toTestAccessMethodName
Convert property name to test access method name (for boolean value).- Parameters:
prop
- property name in initial-upper camelcase form- Returns:
- test access method name
-
toIfSetAccessMethodName
Convert property name to if set access method name (for value in set of alternatives).- Parameters:
prop
- property name in initial-upper camelcase form- Returns:
- if set access method name
-
trimXName
Trim specified prefixes and/or suffixes from an XML name.- Parameters:
xname
- XML name- Returns:
- trimmed name, with specified prefixes and/or suffixes removed
-
splitXMLWords
Split an XML name into words. This splits first on the basis of separator characters ('.', '-', and '_') in the name, and secondly based on case (an uppercase character immediately followed by one or more lowercase characters is considered a word, and multiple uppercase characters not followed immediately by a lowercase character are also considered a word). Characters which are not valid as parts of identifiers in Java are dropped from the XML name before it is split, and words starting with initial uppercase characters have the upper case dropped for consistency. Note that this method is not threadsafe.- Parameters:
name
-- Returns:
- array of words
-