public class PropertySetter extends ContextAwareBase
setProperty(name,value) in order to invoke setters on
the Object specified in the constructor. This class relies on reflection
to analyze the given Object Class.
Usage:
PropertySetter ps = new PropertySetter(anObject);
ps.set("name", "Joe");
ps.set("age", "32");
ps.set("isMale", "true");
will cause the invocations anObject.setName("Joe"), anObject.setAge(32), and
setMale(true) if such methods exist with those signatures. Otherwise an
PropertySetterException is thrown.| Modifier and Type | Field and Description |
|---|---|
protected BeanDescription |
beanDescription |
protected Object |
obj |
protected Class<?> |
objClass |
context| Constructor and Description |
|---|
PropertySetter(BeanDescriptionCache beanDescriptionCache,
Object obj)
Create a new PropertySetter for the specified Object.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addBasicProperty(String name,
String strValue) |
void |
addComplexProperty(String name,
Object complexProperty) |
AggregationType |
computeAggregationType(String name) |
Class<?> |
getClassNameViaImplicitRules(String name,
AggregationType aggregationType,
DefaultNestedComponentRegistry registry) |
Object |
getObj() |
Class<?> |
getObjClass() |
void |
setComplexProperty(String name,
Object complexProperty) |
void |
setProperty(String name,
String value)
Set a property on this PropertySetter's Object.
|
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextprotected final Object obj
protected final Class<?> objClass
protected final BeanDescription beanDescription
public PropertySetter(BeanDescriptionCache beanDescriptionCache, Object obj)
setProperty(java.lang.String, java.lang.String) one or more times.obj - the object for which to set propertiespublic void setProperty(String name, String value)
If the setter expects a String no conversion is necessary. If it expects an int, then an attempt is made to convert 'value' to an int using new Integer(value). If the setter expects a boolean, the conversion is by new Boolean(value).
name - name of the propertyvalue - String value of the propertypublic AggregationType computeAggregationType(String name)
public Class<?> getObjClass()
public Object getObj()
public Class<?> getClassNameViaImplicitRules(String name, AggregationType aggregationType, DefaultNestedComponentRegistry registry)
Copyright © 2005–2018 QOS.ch. All rights reserved.