Package org.openxava.util
Class PropertiesManager
java.lang.Object
org.openxava.util.PropertiesManager
- All Implemented Interfaces:
Serializable
Manages with reflection the properties of a object.
Excludes automatically the property class of Object
and the indexed properties with no indexed access.
- Author:
- Javier Paniza
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPropertiesManager(Class theClass) Constructor from a the class of the object to manage.PropertiesManager(Object object) Constructor from the object to manage. -
Method Summary
Modifier and TypeMethodDescriptionexecuteGet(String propertyName) Gets the value of the indicated property.executeGets(String properties) Gets a group of property values in a map.voidexecuteSet(String propertyName, Object value) Update property.voidexecuteSetFromString(String propertyName, Object value) Update property from a string, making needed conversions.voidexecuteSets(Map properties) Sets property values from a map.voidexecuteSetsFromStrings(Map properties) Sets property values from a map, trying to convert strings to value of valid type for properties.booleanIf the property exists.Object of which the properties are handled.String[]Names of all properties managed bythis.getPropertyDescriptor(String propertyName) String[]Names of all properties managed bythiswith getter method.String[]Names of all properties managed bythiswith setter method.booleanIf the property has getter.booleanIf the property has setter.voidObject of which the properties are handled.
-
Constructor Details
-
PropertiesManager
public PropertiesManager() -
PropertiesManager
Constructor from a the class of the object to manage.This initial value can change in the life of this. -
PropertiesManager
Constructor from the object to manage.- Parameters:
object- Object to manage
-
-
Method Details
-
executeGet
public Object executeGet(String propertyName) throws InvocationTargetException, PropertiesManagerException Gets the value of the indicated property.- Parameters:
propertyName- Property name to obtain its value, can be qualified (that is: 'customer.address.street' for example)- Returns:
- Value of the property
- Throws:
InvocationTargetException- Exception originated by the original access methodPropertiesManagerException- Some unexpected problem
-
executeGets
public Map executeGets(String properties) throws InvocationTargetException, PropertiesManagerException Gets a group of property values in a map.Precondition
- this.object != null
- Parameters:
properties- Names of properties to get, separated by colon (:). The properties must to exist in the object. If properties is null a empty map is returned.- Returns:
- Map with String propertyName:Object value. Not null.
- Throws:
InvocationTargetException- Exception originated by original access methodPropertiesManagerException- Some unexpected problem
-
executeSet
public void executeSet(String propertyName, Object value) throws InvocationTargetException, PropertiesManagerException Update property.Precondition
- this.object != null
- Parameters:
propertyName- Property name to updatevalue- New value for property. Has to be of compatible type. If value is a Map and the property type is not a map then convert the map in an object of the property type.- Throws:
InvocationTargetException- Excepction originated from original access methodPropertiesManagerException- Any unexpected problem
-
executeSetFromString
public void executeSetFromString(String propertyName, Object value) throws InvocationTargetException, PropertiesManagerException Update property from a string, making needed conversions.Precondition
- this.object != null
- Parameters:
propertyName- Name of property to updatevalue- New value for property. Must to be a compatible type or a string parseable to a compatible type.- Throws:
InvocationTargetException- Exception from original access methodPropertiesManagerException- Any unexpected problem
-
executeSets
public void executeSets(Map properties) throws InvocationTargetException, PropertiesManagerException Sets property values from a map.Precondition
- this.object != null
- this.hasSetter(propertyName)
- Parameters:
properties- Map with String propertyName:Object value. Null is assumed as empty map- Throws:
InvocationTargetException- Excepcion from original access methodPropertiesManagerException- Any unexpected method
-
executeSetsFromStrings
public void executeSetsFromStrings(Map properties) throws InvocationTargetException, PropertiesManagerException Sets property values from a map, trying to convert strings to value of valid type for properties.Precondition
- this.object != null
- this.hasSetter(propertyName)
- Parameters:
properties- Map with String propertyName:Object value. Null is assumed as empty map- Throws:
InvocationTargetException- Excepcion from original access methodPropertiesManagerException- Any unexpected method
-
exists
If the property exists.- Throws:
PropertiesManagerException
-
getPropertiesNames
Names of all properties managed bythis.- Returns:
- Not null
- Throws:
PropertiesManagerException
-
getWritablesPropertiesNames
Names of all properties managed bythiswith setter method.- Returns:
- Not null
- Throws:
PropertiesManagerException
-
getReadablesPropertiesNames
Names of all properties managed bythiswith getter method.- Returns:
- Not null
- Throws:
PropertiesManagerException
-
getObject
Object of which the properties are handled. -
getPropertyDescriptor
public PropertyDescriptor getPropertyDescriptor(String propertyName) throws PropertiesManagerException - Throws:
PropertiesManagerException
-
setObject
Object of which the properties are handled. -
hasGetter
If the property has getter.- Throws:
PropertiesManagerException
-
hasSetter
If the property has setter.- Throws:
PropertiesManagerException
-