|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.sadun.util.ObjectPropertyManager
This class allows to set and retrieve properties, by name, by any object using introspection and JavaBeans conventions.
In particular, it supports automatic value conversion from String denotation.
Nested Class Summary | |
static class |
ObjectPropertyManager.NoSuchPropertyException
An exception thrown when the ObjectPropertyManager cannot
find a property in a bean. |
Constructor Summary | |
ObjectPropertyManager(java.lang.Object targetObject)
Create an object manager which can set or get properties from the given target object |
Method Summary | |
java.lang.String |
describe()
Describe the current object. |
java.lang.String |
describe(boolean recurse)
Describe the current object. |
java.lang.String |
describe(int indent)
Describe the current object. |
java.lang.String |
describe(int indent,
boolean recurse)
Describe the current object. |
boolean |
getBooleanProperty(java.lang.String name)
Return the value of the property as a boolean, operating promotions when possible |
byte |
getByteProperty(java.lang.String name)
Return the value of the property as a byte, operating promotions when possible |
char |
getCharProperty(java.lang.String name)
Return the value of the property as a char |
static java.lang.String |
getDescription(java.lang.Object obj,
int indent,
boolean recurse,
boolean shortForm,
boolean showType)
|
double |
getDoubleProperty(java.lang.String name)
Return the value of the property as a double, operating promotions when possible |
float |
getFloatProperty(java.lang.String name)
Return the value of the property as a float, operating promotions when possible |
int |
getIntProperty(java.lang.String name)
Return the value of the property as an integer, operating promotions when possible |
long |
getLongProperty(java.lang.String name)
Return the value of the property as a long, operating promotions when possible |
java.lang.Object |
getProperty(java.lang.String name)
Return the value of the given property on the wrapped targetObject. |
java.lang.String[] |
getPropertyNames()
Return the names of the available read/write properties of the wrapped targetObject. |
java.lang.String[] |
getPropertyNames(boolean mustBeWritable,
boolean mustBeReadable)
Return the names of the available properties of the wrapped targetObject |
short |
getShortProperty(java.lang.String name)
Return the value of the property as a short, operating promotions when possible |
java.lang.String |
getStringProperty(java.lang.String name)
Return the value of the property as a String |
java.lang.Object |
getTargetObject()
Return the managed object |
boolean |
isShortForm()
|
boolean |
isShowType()
|
void |
setProperties(java.util.Properties properties)
|
void |
setProperty(java.lang.String name,
boolean value)
Set the given property with the given value on the wrapped targetObject. |
void |
setProperty(java.lang.String name,
byte value)
Set the given property with the given value on the wrapped targetObject. |
void |
setProperty(java.lang.String name,
char value)
Set the given property with the given value on the wrapped targetObject. |
void |
setProperty(java.lang.String name,
double value)
Set the given property with the given value on the wrapped targetObject. |
void |
setProperty(java.lang.String name,
float value)
Set the given property with the given value on the wrapped targetObject. |
void |
setProperty(java.lang.String name,
int value)
Set the given property with the given value on the wrapped targetObject. |
void |
setProperty(java.lang.String name,
long value)
Set the given property with the given value on the wrapped targetObject. |
void |
setProperty(java.lang.String name,
java.lang.Object value)
Set the given property with the given value on the wrapped targetObject. |
void |
setProperty(java.lang.String name,
short value)
Set the given property with the given value on the wrapped targetObject. |
void |
setShortForm(boolean shortForm)
|
void |
setShowType(boolean showType)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ObjectPropertyManager(java.lang.Object targetObject)
targetObject
- the managed objectMethod Detail |
public void setProperties(java.util.Properties properties) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
ObjectPropertyManager.NoSuchPropertyException
public void setProperty(java.lang.String name, byte value) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
name
- the name of the property to setvalue
- the value of the property
ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
public void setProperty(java.lang.String name, short value) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
name
- the name of the property to setvalue
- the value of the property
ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
public void setProperty(java.lang.String name, int value) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
name
- the name of the property to setvalue
- the value of the property
ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
public void setProperty(java.lang.String name, long value) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
name
- the name of the property to setvalue
- the value of the property
ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
public void setProperty(java.lang.String name, char value) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
name
- the name of the property to setvalue
- the value of the property
ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
public void setProperty(java.lang.String name, float value) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
name
- the name of the property to setvalue
- the value of the property
ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
public void setProperty(java.lang.String name, double value) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
name
- the name of the property to setvalue
- the value of the property
ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
public void setProperty(java.lang.String name, boolean value) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
name
- the name of the property to setvalue
- the value of the property
ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
public void setProperty(java.lang.String name, java.lang.Object value) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
name
- the name of the property to setvalue
- the value of the property
ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
public java.lang.Object getProperty(java.lang.String name) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
name
- the name of the property to get
ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
public java.lang.String[] getPropertyNames(boolean mustBeWritable, boolean mustBeReadable) throws java.beans.IntrospectionException
mustBeReadable
- excludes properties which have no read methodmustBeWritable
- excludes properties which have no write method
java.beans.IntrospectionException
public java.lang.String[] getPropertyNames() throws java.beans.IntrospectionException
java.beans.IntrospectionException
public boolean getBooleanProperty(java.lang.String name) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
public byte getByteProperty(java.lang.String name) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
public short getShortProperty(java.lang.String name) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
public int getIntProperty(java.lang.String name) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
public long getLongProperty(java.lang.String name) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
public float getFloatProperty(java.lang.String name) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
public double getDoubleProperty(java.lang.String name) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
public java.lang.String getStringProperty(java.lang.String name) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
public char getCharProperty(java.lang.String name) throws java.beans.IntrospectionException, ObjectPropertyManager.NoSuchPropertyException
ObjectPropertyManager.NoSuchPropertyException
java.beans.IntrospectionException
public java.lang.Object getTargetObject()
public java.lang.String describe() throws java.beans.IntrospectionException
java.beans.IntrospectionException
- if introspection failspublic java.lang.String describe(boolean recurse) throws java.beans.IntrospectionException
recurse
- if true, member objects will be described as well
java.beans.IntrospectionException
- if introspection failspublic java.lang.String describe(int indent) throws java.beans.IntrospectionException
indent
- the indentation of the description
java.beans.IntrospectionException
- if introspection failspublic java.lang.String describe(int indent, boolean recurse) throws java.beans.IntrospectionException
indent
- the indentation of the descriptionrecurse
- if true, member objects will be described as well
java.beans.IntrospectionException
- if introspection failspublic boolean isShortForm()
public void setShortForm(boolean shortForm)
public boolean isShowType()
public void setShowType(boolean showType)
public static java.lang.String getDescription(java.lang.Object obj, int indent, boolean recurse, boolean shortForm, boolean showType) throws java.beans.IntrospectionException
java.beans.IntrospectionException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |