|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.claritysys.util.JavaBean
public final class JavaBean
Provides methods for setting bean properties using reflection.
Given a bean and a Properties containing name-value pairs, where each name is a property name and each value is a String, the setProperties method will convert each string value into the target data type and invoke the corresponding set<Name> method.
Constructor Summary | |
---|---|
JavaBean()
|
Method Summary | |
---|---|
static java.lang.Object |
convertType(java.lang.String value,
java.lang.Class target)
Convert the given String into the given type and return it as an object. |
static void |
dumpPublicFields(java.lang.Object o)
Dump the given object's public fields to System.out. |
static void |
setProperties(java.lang.Object bean,
java.util.Properties properties)
Set the given beans properties from the given Properties. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JavaBean()
Method Detail |
---|
public static void setProperties(java.lang.Object bean, java.util.Properties properties) throws java.beans.IntrospectionException, java.util.NoSuchElementException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
bean
- The bean to set properties on.properties
- The properties containing name-value pairs.
java.beans.IntrospectionException
java.util.NoSuchElementException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
public static java.lang.Object convertType(java.lang.String value, java.lang.Class target) throws java.lang.IllegalArgumentException
Primitive types are converted to their object counterparts, which is appropriate for reflective method invocation since it will automatically unwrap them.
value
- The String value to convert.target
- The target type as a Class, such as Integer.class or
Integer.TYPE.
java.lang.IllegalArgumentException
- If asked to convert to an unsupported
type.public static void dumpPublicFields(java.lang.Object o) throws java.lang.Exception
o
- The object to inspect.
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |