public class BeanUtils extends Object
Constructor and Description |
---|
BeanUtils() |
Modifier and Type | Method and Description |
---|---|
static Object |
convert(Object origValue,
Class destClass)
Converts the source object to an object of another class.
|
static Map<String,Object> |
getParameters(Object source)
Gets the values returned by the get methods of the given POJO and put
the values in a
Map . |
static Map<String,Object> |
getParametersAsObject(Object source)
This method is similar to
getParameters(Object) except that objects
using classes of org.xins.common.type.* packages will be translated into
standard Java object java.* packages. |
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 . |
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.
|
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.
|
static Object |
setParameters(Map properties,
Object destination)
Puts the values of the
Map in the destination object (POJO). |
static Object |
xmlToObject(Element element,
Object result)
Fills the result object with of the content of the XML element object.
|
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 populate(Object source, Object destination) throws IllegalArgumentException
source
- the source object to get the values from. Cannot be null
.destination
- the destination object to put the values in. Cannot be null
.null
.IllegalArgumentException
- if source == null || destination == null
.public static Object populate(Object source, Object destination, Properties propertiesMapping) throws IllegalArgumentException
source
- the source object to get the values from. Cannot be null
.destination
- the destination object to put the values in. Cannot be null
.propertiesMapping
- the mapping between properties which does not have the same name.null
.IllegalArgumentException
- if source == null || destination == null
.public static Object convert(Object origValue, Class destClass)
origValue
- the original value of the object to be converted, if needed. Cannot be null
.destClass
- the destination class in which the object should be converted, cannot be null
.null
if the object cannot be converted.public static Object xmlToObject(Element element, Object result, Map elementMapping, Map attributeMapping)
element
- the XML element object, can be null
.result
- the object to put the values in, cannot be null
.elementMapping
- a Map<String, String> that maps the name of the source element
to the name of the destination object, can be null
.attributeMapping
- a Map<String, String> that maps the attributes of the elements,
can be null
.null
.public static Object xmlToObject(Element element, Object result)
element
- the XML element object, can be null
.result
- the object to put the values in, cannot be null
.null
.public static Map<String,Object> getParameters(Object source) throws IllegalArgumentException
Map
.
The property names returned start with a lowercase.source
- the object from which the values are extracted and put in the Map, should not be null
null
.IllegalArgumentException
- if source == null
.public static Map getParametersAsString(Object source) throws IllegalArgumentException
Map
.
The property names returned start with a lowercase.source
- the object from which the values are extracted and put in the Map, should not be null
null
.IllegalArgumentException
- if source == null
.public static Map<String,Object> getParametersAsObject(Object source) throws IllegalArgumentException
getParameters(Object)
except that objects
using classes of org.xins.common.type.* packages will be translated into
standard Java object java.* packages.source
- the object from which the values are extracted and put in the Map, should not be null
null
.IllegalArgumentException
- if source == null
.public static Object setParameters(Map properties, Object destination) throws IllegalArgumentException
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.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 be
used to find the set method of the destination object.destination
- the object which should be filled, cannot be null
.null
. This object will
be the same as the input parameter.IllegalArgumentException
- if properties == null || destination == null
.See http://www.xins.org/.