|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.c2_tech.reflect.PropertyManager
This class provides facilities for managing runtime property settings on objects, using the BeanInfo notion of properties. The Introspector class is used to evaluate which properties an object has. The two methods, setViaReflection() and getPropertiesForObject() provide the interfaces to set and get, respectively, property values.
Introspector
,
The information contained in this document is Copyright 2001-2003, Gregg Wonderly,
all rights reserved.
Field Summary | |
protected boolean |
cacheBeanInfos
setCacheBeanInfos property value |
protected java.util.Hashtable |
infos
Cached BeanInfos |
protected boolean |
numAsString
setNumAsString property value |
protected java.io.PrintWriter |
out
setExceptionReportPrintWriter property value |
protected boolean |
retAllObjects
setReturnAllObjects property value |
Constructor Summary | |
PropertyManager()
|
Method Summary | |
boolean |
getCacheBeanInfos()
Returns the current setting of the cacheBeanInfos property. |
java.io.PrintWriter |
getExceptionReportPrintWriter()
Gets the PrintWriter currently be used for exception reporting. |
java.util.Properties |
getPropertiesForObject(java.lang.Object cls)
This method uses introspection to find the properties for the passed object and turn them into a Properties object. |
boolean |
getReturnAllObjects()
Returns the setting of the returnAllObjects property |
boolean |
getReturnNumericsAsStrings()
Returns the setting of the returnNumericsAsStrings property |
protected void |
reportException(java.lang.reflect.InvocationTargetException ex)
Return an exception by printing out the stack dump |
protected void |
reportException(java.lang.RuntimeException ex)
Return an exception by printing out the stack dump |
void |
setCacheBeanInfos(boolean how)
Establishes whether BeanInfo instances returned from the Introspector are cached. |
void |
setExceptionReportPrintWriter(java.io.PrintWriter repOut)
If set to a non-null value, then exceptions will be reported via the passed Writer rather than thrown back to the caller. |
void |
setReturnAllObjects(boolean how)
Establishes with the returned Property objects will just have Strings (false) or the actual Objects (true). |
void |
setReturnNumericsAsStrings(boolean how)
Establishes whether Number.class implementing classes and the native numeric typed property values are converted to strings on return from getPropertiesForObject(), or if they are left as the original Object value returned. |
void |
setViaReflection(java.lang.Object cls,
java.util.Properties props)
This method takes the passed object and a set of properties and uses reflection to set the property values for the object to the values inside the property object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected boolean numAsString
protected boolean retAllObjects
protected java.io.PrintWriter out
protected boolean cacheBeanInfos
protected java.util.Hashtable infos
Constructor Detail |
public PropertyManager()
Method Detail |
public void setCacheBeanInfos(boolean how)
how
- true to cache BeanInfo objects, false to not.getCacheBeanInfos()
public boolean getCacheBeanInfos()
setCacheBeanInfos(boolean)
public void setExceptionReportPrintWriter(java.io.PrintWriter repOut)
repOut
- the Writer to write to, or null (default) if exceptions should be thrown
back to the caller.getExceptionReportPrintWriter()
public java.io.PrintWriter getExceptionReportPrintWriter()
setExceptionReportPrintWriter(PrintWriter)
public void setReturnAllObjects(boolean how)
how
- Strings (false) or the actual Objects (true)setReturnNumericsAsStrings(boolean)
,
getReturnAllObjects()
public boolean getReturnAllObjects()
setReturnAllObjects(boolean)
public void setReturnNumericsAsStrings(boolean how)
how
- true to get String representations, false to get
the Number implementing ObjectsgetReturnNumericsAsStrings()
public boolean getReturnNumericsAsStrings()
setReturnNumericsAsStrings(boolean)
protected void reportException(java.lang.reflect.InvocationTargetException ex) throws java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException
protected void reportException(java.lang.RuntimeException ex)
public void setViaReflection(java.lang.Object cls, java.util.Properties props) throws java.beans.IntrospectionException, java.beans.PropertyVetoException, java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
cls
- an object to set properties onprops
- the property values to set on cls.
java.beans.IntrospectionException
- if an error occurs during introspection.
java.beans.PropertyVetoException
- if a boolean property value is not one of
(0,1,"yes","no","true","false")
java.lang.reflect.InvocationTargetException
- if there is a problem invoking the
property setting method.
java.lang.IllegalAccessException
- if the property setting method can not
be accessed.getPropertiesForObject(Object)
,
setReturnAllObjects(boolean)
,
getReturnAllObjects()
public java.util.Properties getPropertiesForObject(java.lang.Object cls) throws java.beans.IntrospectionException, java.lang.reflect.InvocationTargetException, java.lang.IllegalAccessException
cls
- the object to get the properties for
java.beans.IntrospectionException
- if there are problems accessing the object
java.lang.reflect.InvocationTargetException
- if the property reader can not be invoked
java.lang.IllegalAccessException
- if the object is not accessible,setViaReflection(Object,Properties)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |