|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.legstar.coxb.util.ClassUtil
public final class ClassUtil
A helper class for dynamic class loading.
| Nested Class Summary | |
|---|---|
static class |
ClassUtil.ClassName
A simple vehicle for class name and package name. |
| Method Summary | |
|---|---|
static Object |
addComplexIndexedProperty(Object objectFactory,
Object parentObject,
String jaxbTypeName,
int index)
This creates a new complex property item, identified by an index in a parent object array. |
static Object |
addComplexProperty(Object objectFactory,
Object parentObject,
String jaxbName,
String jaxbTypeName)
This method creates a new instance of a property type in a parent object using a JAXB ObjectFactory. |
static void |
addSimpleIndexedProperty(Object parentObject,
int index,
Object value)
This creates a new simple property item, identified by an index in a parent object array. |
static Method |
getCreatorMethod(Object objectFactory,
String jaxbTypeName)
The ObjectFactory exports a create method for each complex type in the object tree. |
static Method |
getGetterMethod(Object parentObject,
String getterPrefix,
String jaxbName)
Returns a jaxb property getter method. |
static String |
getGetterName(String getterPrefix,
String fieldName)
Build a conventional bean getter method name from a field name. |
static String |
getGetterPrefix(Class<?> fieldType,
int maxOccurs)
Evaluates the getter method prefix for a field, based on the field type. |
static Method |
getSetterMethod(Object parentObject,
String jaxbName,
Class<?> jaxbType)
Returns a jaxb property setter method. |
static String |
getSetterMethodName(String jaxbName)
Construct a setter method name for a JAXB property. |
static Object |
invokeGetIndexedProperty(Object parentObject,
int index)
This method gets an indexed property object from a parent array object. |
static Object |
invokeGetProperty(Object parentObject,
String jaxbName)
Deprecated. use invokeGetProperty(Object parentObject, String
jaxbName, Class < ? > jaxbType) |
static Object |
invokeGetProperty(Object parentObject,
String jaxbName,
Class<?> jaxbType,
int maxOccurs)
This method gets a property object from a parent object. |
static void |
invokeSetProperty(Object parentObject,
String jaxbName,
Object value,
Class<?> javaType)
This method sets a property from a parent object to a given value. |
static boolean |
isEnum(String type)
This will determine if a type name for a simple element is one of java's native types and assume it is an enum otherwise. |
static Class<?> |
loadClass(String qualifiedClassName)
Rather than using the Class.forName mechanism first, this uses Thread.getContextClassLoader instead. |
static Class<?> |
loadClass(String packageName,
String className)
Rather than using the Class.forName mechanism first, this uses Thread.getContextClassLoader instead. |
static Object |
newObject(String qualifiedClassName)
Dynamically create an instance of a java class. |
static Object |
newObject(String packageName,
String className)
Dynamically create an instance of a java class. |
static ClassUtil.ClassName |
toClassName(String qualifiedClassName)
Separate package name and class name from a qualified class name. |
static String |
toPropertyType(String genericType)
Helper method to extract the type name as used by JAXB create methods. |
static String |
toQualifiedClassName(String packageName,
String className)
Qualifies a class name. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static Class<?> loadClass(String packageName,
String className)
throws ClassNotFoundException
packageName - the package containing the classclassName - the class name
ClassNotFoundException - if class is not accessible from any class
loader
public static Class<?> loadClass(String qualifiedClassName)
throws ClassNotFoundException
qualifiedClassName - the class name to load
ClassNotFoundException - if class is not accessible from any class
loader
public static Object newObject(String packageName,
String className)
throws ClassLoadingException
packageName - the package containing the classclassName - the class name
ClassLoadingException - if object cannot be instantiated
public static Object newObject(String qualifiedClassName)
throws ClassLoadingException
qualifiedClassName - the qualified class name
ClassLoadingException - if object cannot be instantiated
public static String toQualifiedClassName(String packageName,
String className)
packageName - the package name, null if noneclassName - the class name
public static ClassUtil.ClassName toClassName(String qualifiedClassName)
qualifiedClassName - qualified class name
public static Method getCreatorMethod(Object objectFactory,
String jaxbTypeName)
throws ClassMethodException
objectFactory - JAXB ObjectfactoryjaxbTypeName - the jaxb object type name
ClassMethodException - if getter method does not exist
public static Method getGetterMethod(Object parentObject,
String getterPrefix,
String jaxbName)
throws ClassMethodException
parentObject - JAXB Object owning the propertygetterPrefix - the getter method prefix (get or is)jaxbName - the property name to get
ClassMethodException - if getter method does not exist
public static String getGetterName(String getterPrefix,
String fieldName)
getterPrefix - the getter method name prefix (get or is)fieldName - the field name
public static Method getSetterMethod(Object parentObject,
String jaxbName,
Class<?> jaxbType)
throws ClassMethodException
parentObject - JAXB Object owning the propertyjaxbName - the property name to getjaxbType - the property type
ClassMethodException - if getter method does not existpublic static String getSetterMethodName(String jaxbName)
jaxbName - the JAXB property name
public static String toPropertyType(String genericType)
genericType - as returned from hostField.getGenericType()
public static Object invokeGetProperty(Object parentObject,
String jaxbName)
throws ClassInvokeException
invokeGetProperty(Object parentObject, String
jaxbName, Class < ? > jaxbType)
parentObject - JAXB Object owning the propertyjaxbName - the property name to get
ClassInvokeException - if property cannot be accessed
public static Object invokeGetProperty(Object parentObject,
String jaxbName,
Class<?> jaxbType,
int maxOccurs)
throws ClassInvokeException
parentObject - JAXB Object owning the propertyjaxbName - the property name to getmaxOccurs - the maximum number of occurrences
ClassInvokeException - if property cannot be accessed
public static String getGetterPrefix(Class<?> fieldType,
int maxOccurs)
fieldType - the field typemaxOccurs - the maximum number of occurrences
public static void invokeSetProperty(Object parentObject,
String jaxbName,
Object value,
Class<?> javaType)
throws ClassInvokeException
parentObject - JAXB Object owning the propertyjaxbName - the property name to setvalue - value to set property tojavaType - the java class the value belongs to
ClassInvokeException - if property cannot be set
public static Object addComplexProperty(Object objectFactory,
Object parentObject,
String jaxbName,
String jaxbTypeName)
throws ClassInvokeException
objectFactory - a JAXB ObjectFactoryparentObject - instance of the JAXB parent classjaxbName - complex property namejaxbTypeName - complex property type name
ClassInvokeException - if JAXB Object cannot be instanciated
public static Object invokeGetIndexedProperty(Object parentObject,
int index)
throws ClassInvokeException
parentObject - instance of the JAXB parent list classindex - item index in list
ClassInvokeException - if JAXB Object cannot be returned
public static Object addComplexIndexedProperty(Object objectFactory,
Object parentObject,
String jaxbTypeName,
int index)
throws ClassInvokeException
objectFactory - a JAXB ObjectFactoryparentObject - instance of the JAXB parent classjaxbTypeName - complex property type nameindex - item index in list
ClassInvokeException - if JAXB Object cannot be instanciated
public static void addSimpleIndexedProperty(Object parentObject,
int index,
Object value)
throws ClassInvokeException
parentObject - instance of the JAXB parent list classindex - item index in listvalue - value to set item to
ClassInvokeException - if item cannot be setpublic static boolean isEnum(String type)
type - the element java type
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||