| java.lang.Object org.xins.common.BeanUtils
BeanUtils | public class BeanUtils (Code) | | This class contains some utility methods that fills an object with values
from another object.
version: $Revision: 1.44 $ $Date: 2007/09/18 08:45:10 $ author: Anthony Goubard since: XINS 1.5.0. |
Method Summary | |
public static Object | convert(Object origValue, Class destClass) Converts the source object to an object of another class.
Parameters: origValue - the original value of the object to be converted, if needed. | public static Map | getParameters(Object source) Gets the values returned by the get methods of the given POJO and put
the values in a Map .
The property names returned start with a lowercase.
Parameters: source - the object from which the values are extracted and put in the Map, should not be null the property values of the source object. | public static Map | getParametersAsObject(Object source) This method is similar to
BeanUtils.getParameters(Object) except that objects
using classes of org.xins.common.type.* packages will be translated into
standard Java object java.* packages.
Parameters: source - the object from which the values are extracted and put in the Map, should not be null the property values of the source object. | public static Map | getParametersAsString(Object source) Gets the values returned by the get methods of the given POJO,
transform it to a String object and put the values in a Map .
The property names returned start with a lowercase.
Parameters: source - the object from which the values are extracted and put in the Map, should not be null the property values of the source object. | public static Object | populate(Object source, Object destination) Get the values returned by the get methods of the source object and
call the set method of the destination object for the same property.
e.g. | public static Object | populate(Object source, Object destination, Properties propertiesMapping) Get the values returned by the get methods of the source object and
call the set method of the destination object for the same property.
e.g. | public static Object | setParameters(Map properties, Object destination) Puts the values of the Map in the destination object (POJO).
If needed the property value is converted to the type needed for the set method.
The property names can start with an uppercase or a lowercase.
Parameters: properties - the map containing the values to fill the destination object, cannot be null The key of the Map should be the property name and will beused to find the set method of the destination object. Parameters: destination - the object which should be filled, cannot be null .the destination object filled, never null . | public static Object | xmlToObject(Element element, Object result, Map elementMapping, Map attributeMapping) Fills the result object with of the content of the XML element object. | public static Object | xmlToObject(Element element, Object result) Fills the result object with of the content of the XML element object. |
convert | public static Object convert(Object origValue, Class destClass)(Code) | | Converts the source object to an object of another class.
Parameters: origValue - the original value of the object to be converted, if needed. Cannot be null . Parameters: destClass - the destination class in which the object should be converted, cannot be null .the converted object or null if the object cannot be converted. since: XINS 2.0. |
getParameters | public static Map getParameters(Object source) throws IllegalArgumentException(Code) | | Gets the values returned by the get methods of the given POJO and put
the values in a Map .
The property names returned start with a lowercase.
Parameters: source - the object from which the values are extracted and put in the Map, should not be null the property values of the source object. The key of the Map isthe name of the property and the value is the value as returned by the get method.Never null . throws: IllegalArgumentException - if source == null . since: XINS 2.0. |
getParametersAsObject | public static Map getParametersAsObject(Object source) throws IllegalArgumentException(Code) | | This method is similar to
BeanUtils.getParameters(Object) except that objects
using classes of org.xins.common.type.* packages will be translated into
standard Java object java.* packages.
Parameters: source - the object from which the values are extracted and put in the Map, should not be null the property values of the source object. The key of the Map isthe name of the property and the value is a standard Java object representation ofthe value as returned by the get method. Never null . throws: IllegalArgumentException - if source == null . since: XINS 2.0. |
getParametersAsString | public static Map getParametersAsString(Object source) throws IllegalArgumentException(Code) | | Gets the values returned by the get methods of the given POJO,
transform it to a String object and put the values in a Map .
The property names returned start with a lowercase.
Parameters: source - the object from which the values are extracted and put in the Map, should not be null the property values of the source object. The key of the Map isthe name of the property and the value is the String representation ofthe value as returned by the get method. Never null . throws: IllegalArgumentException - if source == null . since: XINS 2.0. |
populate | public static Object populate(Object source, Object destination) throws IllegalArgumentException(Code) | | Get the values returned by the get methods of the source object and
call the set method of the destination object for the same property.
e.g. String getFirstName() value of the source object will be used to
invoke setFirstName(String) of the destination object.
If the no matching set method exists or the set method parameter is not the
same type as the object returned by the get method, the property is ignored.
Parameters: source - the source object to get the values from. Cannot be null . Parameters: destination - the destination object to put the values in. Cannot be null .the populated object, never null . throws: IllegalArgumentException - if source == null || destination == null . |
populate | public static Object populate(Object source, Object destination, Properties propertiesMapping) throws IllegalArgumentException(Code) | | Get the values returned by the get methods of the source object and
call the set method of the destination object for the same property.
e.g. String getFirstName() value of the source object will be used to
invoke setFirstName(String) of the destination object.
If the no matching set method exists or the set method parameter is not the
same type as the object returned by the get method, the property is ignored.
Parameters: source - the source object to get the values from. Cannot be null . Parameters: destination - the destination object to put the values in. Cannot be null . Parameters: propertiesMapping - the mapping between properties which does not have the same name.the populated object, never null . throws: IllegalArgumentException - if source == null || destination == null . |
setParameters | public static Object setParameters(Map properties, Object destination) throws IllegalArgumentException(Code) | | Puts the values of the Map in the destination object (POJO).
If needed the property value is converted to the type needed for the set method.
The property names can start with an uppercase or a lowercase.
Parameters: properties - the map containing the values to fill the destination object, cannot be null The key of the Map should be the property name and will beused to find the set method of the destination object. Parameters: destination - the object which should be filled, cannot be null .the destination object filled, never null . This object willbe the same as the input parameter. throws: IllegalArgumentException - if properties == null || destination == null . since: XINS 2.0. |
xmlToObject | public static Object xmlToObject(Element element, Object result, Map elementMapping, Map attributeMapping)(Code) | | Fills the result object with of the content of the XML element object.
Parameters: element - the XML element object, can be null . Parameters: result - the object to put the values in, cannot be null . Parameters: elementMapping - a Map<String, String> that maps the name of the source elementto the name of the destination object, can be null . Parameters: attributeMapping - a Map<String, String> that maps the attributes of the elements,can be null .the result object filled with the values of the element object, never null . since: XINS 2.0. |
xmlToObject | public static Object xmlToObject(Element element, Object result)(Code) | | Fills the result object with of the content of the XML element object.
Parameters: element - the XML element object, can be null . Parameters: result - the object to put the values in, cannot be null .the result object filled with the values of the element object, never null . |
|
|