Class BeanUtilsBean2
- java.lang.Object
-
- org.apache.commons.beanutils.BeanUtilsBean
-
- org.apache.commons.beanutils.BeanUtilsBean2
-
public class BeanUtilsBean2 extends BeanUtilsBean
BeanUtilsBean
implementation that creates aConvertUtilsBean2
and delegates conversion toConvertUtilsBean.convert(Object, Class)
.To configure this implementation for the current context ClassLoader invoke
BeanUtilsBean.setInstance(new BeanUtilsBean2());
BeanUtils 1.7.0 delegated all conversion to String to the converter registered for the
String.class
. One of the improvements in BeanUtils 1.8.0 was to upgrade theConverter
implementations so that they could handle conversion to String for their type (e.g. IntegerConverter now handles conversion from an Integer to a String as well as String to Integer).In order to take advantage of these improvements BeanUtils needs to change how it gets the appropriate
Converter
. This functionality has been implemented in the newConvertUtilsBean.lookup(Class, Class)
andConvertUtilsBean.convert(Object, Class)
methods. However changingBeanUtilsBean
to use these methods could create compatibility issues for existing users. In order to avoid that, this newBeanUtilsBean
implementation has been created (and the associatedConvertUtilsBean2
).- Since:
- 1.8.0
- Version:
- $Id: BeanUtilsBean2.java 1540186 2013-11-08 21:08:30Z oheger $
- See Also:
ConvertUtilsBean2
-
-
Constructor Summary
Constructors Constructor Description BeanUtilsBean2()
Constructs an instance using new property and conversion instances.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.Object
convert(java.lang.Object value, java.lang.Class<?> type)
Convert the value to an object of the specified class (if possible).-
Methods inherited from class org.apache.commons.beanutils.BeanUtilsBean
cloneBean, copyProperties, copyProperty, describe, getArrayProperty, getConvertUtils, getIndexedProperty, getIndexedProperty, getInstance, getMappedProperty, getMappedProperty, getNestedProperty, getProperty, getPropertyUtils, getSimpleProperty, initCause, populate, setInstance, setProperty
-
-
-
-
Method Detail
-
convert
protected java.lang.Object convert(java.lang.Object value, java.lang.Class<?> type)
Convert the value to an object of the specified class (if possible).
- Overrides:
convert
in classBeanUtilsBean
- Parameters:
value
- Value to be converted (may be null)type
- Class of the value to be converted to- Returns:
- The converted value
-
-