|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.castor.xml.JavaNamingImpl
public class JavaNamingImpl
This class converts XML Names to proper Java names. As Java names are not completely defined this implementation is Castor specific. The first implementation was done by Keith Visco but had been changed radically since.
| Field Summary | |
|---|---|
static boolean |
_upperCaseAfterUnderscore
Used for backward compatibility, if you wish to be backward compatible with 0.9.3.9 and earlier set this boolean to true. |
static String |
UPPER_CASE_AFTER_UNDERSCORE_PROPERTY
The property name to use in the castor.properties file to specify the value of the upperCaseAfterUnderscore variable. |
| Fields inherited from interface org.castor.xml.JavaNaming |
|---|
FIELD_UNDERSCORE_PREFIX, METHOD_PREFIX_ADD, METHOD_PREFIX_CREATE, METHOD_PREFIX_GET, METHOD_PREFIX_IS, METHOD_PREFIX_SET |
| Constructor Summary | |
|---|---|
JavaNamingImpl()
private constructor. |
|
| Method Summary | |
|---|---|
String |
extractFieldNameFromField(Field field)
Extracts the field name part from the Field. |
String |
extractFieldNameFromMethod(Method method)
Extracts the filed name part from the methods name. |
String |
getAddMethodNameForField(String fieldName)
Generates the name of an add method for the given field name. |
String |
getClassName(Class clazz)
Gets the class name without package part. |
String |
getCreateMethodNameForField(String fieldName)
Generates the name of a set method for the given field name. |
String |
getGetMethodNameForField(String fieldName)
Generates the name of a get method for the given field name. |
String |
getIsMethodNameForField(String fieldName)
Generates the name of an is method for the given field name. |
String |
getPackageName(String className)
Gets the package name of the given class name. |
String |
getQualifiedFileName(String fileName,
String packageName)
Qualifies the given fileName with the given
packageName and returns the resulting file path. |
String |
getSetMethodNameForField(String fieldName)
Generates the name of a create 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 a 'is' method. |
boolean |
isKeyword(String name)
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 pacckage name is valid or not. |
String |
packageToPath(String packageName)
Converts the given Package name to it's corresponding Path. |
String |
toJavaClassName(String name)
Cuts away a leading namespace prefix (if there is one in place). |
String |
toJavaMemberName(String name)
Appends a leading '_' and converts the given name to a java name. |
String |
toJavaMemberName(String name,
boolean useKeywordSubstitutions)
Appends a leading '_' and converts the given name to a java name. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String UPPER_CASE_AFTER_UNDERSCORE_PROPERTY
upperCaseAfterUnderscore variable.
public static boolean _upperCaseAfterUnderscore
| Constructor Detail |
|---|
public JavaNamingImpl()
| Method Detail |
|---|
public final boolean isKeyword(String name)
isKeyword in interface JavaNamingname - the name to check
JavaNaming.isKeyword(java.lang.String)public final boolean isValidJavaIdentifier(String string)
isValidJavaIdentifier in interface JavaNamingstring - The String to check the production of.
JavaNaming.isValidJavaIdentifier(java.lang.String)public final String toJavaClassName(String name)
toJavaClassName in interface JavaNamingname - the XML name to convert to a Java name
JavaNaming.toJavaClassName(java.lang.String)public final String toJavaMemberName(String name)
toJavaMemberName in interface JavaNamingname - the XML name to convert
JavaNaming.toJavaMemberName(java.lang.String)
public final String toJavaMemberName(String name,
boolean useKeywordSubstitutions)
toJavaMemberName in interface JavaNamingname - the XML name to convertuseKeywordSubstitutions - set to true to turn on keyword substitution
JavaNaming.toJavaMemberName(java.lang.String,boolean)public final boolean isValidPackageName(String packageName)
isValidPackageName in interface JavaNamingpackageName - name of package as String with periods
JavaNaming.isValidPackageName(java.lang.String)public final String packageToPath(String packageName)
packageToPath in interface JavaNamingpackageName - the package name to convert
JavaNaming.packageToPath(java.lang.String)
public final String getQualifiedFileName(String fileName,
String packageName)
fileName with the given
packageName and returns the resulting file path.packageName is null or a zero-length
String, this method will return fileName.
getQualifiedFileName in interface JavaNamingfileName - The file name to be qualified.packageName - The package name to be used for qualifying.
JavaNaming.getQualifiedFileName(java.lang.String,java.lang.String)public final String getPackageName(String className)
getPackageName in interface JavaNamingclassName - The class name to retrieve the package name from.
className
is null or does not contain a package.JavaNaming.getPackageName(java.lang.String)public final String extractFieldNameFromMethod(Method method)
extractFieldNameFromMethod in interface JavaNamingmethod - the Method to process
JavaNaming.extractFieldNameFromMethod(java.lang.reflect.Method)public final String extractFieldNameFromField(Field field)
extractFieldNameFromField in interface JavaNamingfield - the Field to process
JavaNaming.extractFieldNameFromField(java.lang.reflect.Field)public final boolean isSetMethod(Method method)
isSetMethod in interface JavaNamingmethod - the Method to check
JavaNaming.isSetMethod(java.lang.reflect.Method)public final boolean isCreateMethod(Method method)
isCreateMethod in interface JavaNamingmethod - the Method to check
JavaNaming.isCreateMethod(java.lang.reflect.Method)public final boolean isGetMethod(Method method)
isGetMethod in interface JavaNamingmethod - the Method to check
JavaNaming.isGetMethod(java.lang.reflect.Method)public final boolean isIsMethod(Method method)
isIsMethod in interface JavaNamingmethod - the Method to check
JavaNaming.isIsMethod(java.lang.reflect.Method)public final boolean isAddMethod(Method method)
isAddMethod in interface JavaNamingmethod - the Method to check
JavaNaming.isAddMethod(java.lang.reflect.Method)public final String getAddMethodNameForField(String fieldName)
getAddMethodNameForField in interface JavaNamingfieldName - the field name to generate a method name for
public final String getCreateMethodNameForField(String fieldName)
getCreateMethodNameForField in interface JavaNamingfieldName - the field name to generate a method name for
public final String getGetMethodNameForField(String fieldName)
getGetMethodNameForField in interface JavaNamingfieldName - the field name to generate a method name for
public final String getIsMethodNameForField(String fieldName)
getIsMethodNameForField in interface JavaNamingfieldName - the field name to generate a method name for
public final String getSetMethodNameForField(String fieldName)
getSetMethodNameForField in interface JavaNamingfieldName - the field name to generate a method name for
public String getClassName(Class clazz)
getClassName in interface JavaNamingclazz - The class to retrieve the name from
JavaNaming.getClassName(java.lang.Class)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||