|
02/28/2005 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.vignette.portal.util.ReflectionUtils
Utilities for examining and manipulating classes and objects.
| Constructor Summary | |
ReflectionUtils()
|
|
| Method Summary | |
static Object |
convertToType(Object object,
Class type)
Return the specified object (either an Object or String) in the form of the specified type. |
static Boolean |
getBoolean(Object object)
Convert the specified object into it's Boolean equivalent. |
static Byte |
getByte(Object object)
Convert the specified object into it's Byte equivalent. |
static Character |
getCharacter(Object object)
Convert the specified object into it's Character equivalent. |
static Double |
getDouble(Object object)
Convert the specified object into it's Double equivalent. |
static Float |
getFloat(Object object)
Convert the specified object into it's Float equivalent. |
static Integer |
getInteger(Object object)
Convert the specified object into it's Integer equivalent. |
static Integer |
getInteger(Object object,
int default_value)
Convert the specified object into it's Integer equivalent. |
static Long |
getLong(Object object)
Convert the specified object into it's Long equivalent. |
static Method |
getMethod(Class thisClass,
String methodName,
Class[] paramClasses)
One of a handful of getMethod implementations, designed to get a method to invoke with a single call. |
static Method |
getMethod(Object anyInstance,
String methodName,
Object[] params)
One of a handful of getMethod implementations, designed to get a method to invoke with a single call. |
static Method |
getMethod(String fullClassName,
String methodName,
String[] paramClassNames)
One of a handful of getMethod implementations, designed to get a method to invoke with a single call. |
static String |
getProperty(Object obj,
String property)
Get property from standard accessor method. |
static Short |
getShort(Object object)
Convert the specified object into it's Short equivalent. |
static Class |
getType(String type)
Return the type Class object of the specified type. |
static Method |
lookupReadMethod(Object obj,
String name)
Get the standard accessor given name of property. |
static Method |
lookupReadOrWriteMethod(Object obj,
String name,
boolean isRead)
Lookup either the get or set accessor method for the specified property on the specified object. |
static Method |
lookupWriteMethod(Object obj,
String name)
Get the standard mutator given name of property. |
static void |
setProperty(Object obj,
String property,
Object value)
Use the standard mutator method: set(property) to set the value. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ReflectionUtils()
| Method Detail |
public static String getProperty(Object obj,
String property)
property - if "object", method must be getObject()obj - The object from which to retrieve the specified property.obj.
public static void setProperty(Object obj,
String property,
Object value)
value - is value to set. If the set(property) method's argument
is primitive, it must be wrapped in the corresponding
Object wrapper (e.g. Integer for an int).property - is name, and set(property) must be defined ...
Note that the first character of property will be changed to upper
case to make the name. For details, see JavaBean specification.obj - The object on which to set the specified property with the
designated value.
public static Method lookupReadMethod(Object obj,
String name)
name - if "object", accessor method must be "getObject()"obj - The object for which to retrieve the accessor method for the specified property (name).obj).
public static Method lookupWriteMethod(Object obj,
String name)
name - if "object", mutator method must be "setObject(value)"obj - The object on which to retrieve the write method.name).
public static Method lookupReadOrWriteMethod(Object obj,
String name,
boolean isRead)
obj - The object on which to retrieve an accessor method.name - The name of the property for which to retrieve an accessor method.isRead - true if the read accessor (usually the 'getter') is to be retrieved.name).public static Boolean getBoolean(Object object)
object - The Object to be converted.object.public static Byte getByte(Object object)
object - The Object to be converted.object or 0 if no equalvalent can be determined.public static Short getShort(Object object)
object - The Object to be converted.object.public static Character getCharacter(Object object)
object - The Object to be converted.object or space (' ') if no equivalent can be determined.public static Integer getInteger(Object object)
object - The Object to be converted.object.
public static Integer getInteger(Object object,
int default_value)
object - The Object to be converted.default_value - The value to be returned if the specified object
cannot be converted into an Integer.object or
the specified default_value if convertion results in a
NumberFormatException.public static Long getLong(Object object)
object - The Object to be converted.object.public static Float getFloat(Object object)
object - The Object to be converted.object.public static Double getDouble(Object object)
object - The Object to be converted.object.
public static Object convertToType(Object object,
Class type)
true if the
specified type is either Boolean.class or
Boolean.TYPE.object - The object to be converted into the specified type.type - The type (Class) to which the specified object is to be converted.object in the form of the specified type.public static Class getType(String type)
Class object of the specified type. If the specified type
is not a primitive (e.g. "int", "boolean", "long", etc...), then an attempt to find the type by fully qualified
class name will occur. If this fails, an attempt to find the class in package java.lang will occur. If this
also fails, type java.lang.String will be returned.type - The String representation of a primitive type.type primitive.
public static Method getMethod(Object anyInstance,
String methodName,
Object[] params)
throws NoSuchMethodException
anyInstance - instance upon which to invoke method.methodName - params - An array of objects that form the parameters to the method call.
public static Method getMethod(String fullClassName,
String methodName,
String[] paramClassNames)
throws ClassNotFoundException,
NoSuchMethodException
fullClassName - (must include package)methodName - paramClassNames - full class names of parameters
public static Method getMethod(Class thisClass,
String methodName,
Class[] paramClasses)
throws NoSuchMethodException
thisClass - class upon which to invoke method.methodName - paramClasses - An array of classes that are arguments to the method call.
|
02/28/2005 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||