Package org.castor.xml
Interface JavaNaming
- All Known Implementing Classes:
JavaNamingImpl
,JavaNamingNGImpl
public interface JavaNaming
JavaNaming is a service which collects all methods that are related to create (modify) Java
names. E.g. convert from XML name to Java name, get a Java member name or such. These rules can
be exchanged by a different implementation to get a different naming style for e.g. JAXB.
- Version:
- $Id$
- Author:
- Joachim Grueneis
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final char
The underscore field prefix.static final String
Add methods start with: add.static final String
Create methods start with: create.static final String
Get methods start with: get.static final String
Is methods start with: is.static final String
Set methods start with: set. -
Method Summary
Modifier and TypeMethodDescriptionextractFieldNameFromField
(Field field) Extracts the field name part from the Field.extractFieldNameFromMethod
(Method method) Extracts the filed name part from the methods name.getAddMethodNameForField
(String fieldName) Generates the name of an add method for the given field name.getClassName
(Class<?> clazz) Gets the class name without package part.getCreateMethodNameForField
(String fieldName) Generates the name of a create method for the given field name.getGetMethodNameForField
(String fieldName) Generates the name of a get method for the given field name.getIsMethodNameForField
(String fieldName) Generates the name of an is method for the given field name.getPackageName
(String className) Gets the package name of the given class name.getQualifiedFileName
(String fileName, String packageName) Qualifies the givenfileName
with the givenpackageName
and returns the resulting file path.
IfpackageName
isnull
or a zero-length String, this method will returnfileName
.getSetMethodNameForField
(String fieldName) Generates the name of a set method for the given field name.boolean
isAddMethod
(Method method) Checks if the given method is an add method.boolean
isCreateMethod
(Method method) Checks if the given method is a create method.boolean
isGetMethod
(Method method) Checks if the given method is a get method.boolean
isIsMethod
(Method method) Checks if the given method is an is method.boolean
Returns true if the given String is a Java keyword which will cause a problem when used as a variable name.boolean
isSetMethod
(Method method) Checks if the given method is a set method.boolean
isValidJavaIdentifier
(String string) Returns true if the given String matches the production of a valid Java identifier.boolean
isValidPackageName
(String packageName) Checks if the given package name is valid or not.packageToPath
(String packageName) Converts the given Package name to it's corresponding Path.toJavaClassName
(String name) Cuts away a leading namespace prefix (if there is one in place).toJavaMemberName
(String name) Appends a leading '_' and converts the given name to a java name.toJavaMemberName
(String name, boolean useKeywordSubstitutions) Appends a leading '_' and converts the given name to a java name.
-
Field Details
-
METHOD_PREFIX_ADD
-
METHOD_PREFIX_GET
-
METHOD_PREFIX_IS
-
METHOD_PREFIX_SET
-
METHOD_PREFIX_CREATE
-
FIELD_UNDERSCORE_PREFIX
static final char FIELD_UNDERSCORE_PREFIXThe underscore field prefix.- See Also:
-
-
Method Details
-
isKeyword
Returns true if the given String is a Java keyword which will cause a problem when used as a variable name.- Parameters:
name
- The name to check.- Returns:
- true if it is a keyword.
-
isValidJavaIdentifier
Returns true if the given String matches the production of a valid Java identifier.- Parameters:
string
- The String to check the production of.- Returns:
- true if the given String matches the production of a valid Java name, otherwise false.
-
toJavaClassName
-
toJavaMemberName
-
toJavaMemberName
Appends a leading '_' and converts the given name to a java name.- Parameters:
name
- The XML name to convert.useKeywordSubstitutions
- Set to true to turn on keyword substitution.- Returns:
- A Java member name starting with a leading '_'.
-
isValidPackageName
Checks if the given package name is valid or not. Empty package names are considered valid!- Parameters:
packageName
- Name of package as String with periods.- Returns:
- true if package name is valid.
-
packageToPath
-
getQualifiedFileName
Qualifies the givenfileName
with the givenpackageName
and returns the resulting file path.
IfpackageName
isnull
or a zero-length String, this method will returnfileName
.- Parameters:
fileName
- The file name to be qualified.packageName
- The package name to be used for qualifying.- Returns:
- The qualified file path.
-
getClassName
-
getPackageName
-
extractFieldNameFromMethod
-
extractFieldNameFromField
-
isSetMethod
Checks if the given method is a set method.- Parameters:
method
- The Method to check- Returns:
- true if it is a set method
-
isCreateMethod
Checks if the given method is a create method.- Parameters:
method
- The Method to check.- Returns:
- true if it is a create method.
-
isGetMethod
Checks if the given method is a get method.- Parameters:
method
- The Method to check.- Returns:
- true if it is a get method.
-
isIsMethod
Checks if the given method is an is method.- Parameters:
method
- The Method to check.- Returns:
- true if it is an is method.
-
isAddMethod
Checks if the given method is an add method.- Parameters:
method
- The Method to check.- Returns:
- true if it is an add method.
-
getAddMethodNameForField
-
getSetMethodNameForField
-
getGetMethodNameForField
-
getIsMethodNameForField
-
getCreateMethodNameForField
-