Package webwork.util
Class BeanUtil
java.lang.Object
webwork.util.BeanUtil
JavaBean utility methods
- Version:
- $Revision: 1.43 $
- Author:
- Rickard Öberg (rickard@middleware-company.com), Matt Baldree (matt@smallleap.com)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidCopy JavaBean property values from one object to another.static voidCopy JavaBean property values from one object to another.static ObjectgetAsValue(PropertyEditor pe, String txt) Helper method that gets the value using a PropertyEditor If the editor is a FastPropertyEditor then getAsValue is called otherwise normal setAsText, getValue calls are madestatic PropertyEditorgetPropertyEditor(Class clazz) Helper method to retrieve a property editor out of cache.static voidsetProperties(Map from, Object to) Set JavaBean property values on an object with values taken from a map.static voidsetProperty(String propertyName, Object val, Object obj) Set a single JavaBean property value on an object.static StringtoStringValue(Object obj) Call toString on object.
-
Constructor Details
-
BeanUtil
public BeanUtil()
-
-
Method Details
-
copy
Copy JavaBean property values from one object to another.- Parameters:
from- the source objectto- the destination object- Throws:
IllegalArgumentException- thrown if the copy fails for some reason
-
copy
public static void copy(Object from, Object to, boolean includeNull) throws IllegalArgumentException Copy JavaBean property values from one object to another.- Parameters:
from- the source objectto- the destination objectincludeNull- whether null values are copied or not- Throws:
IllegalArgumentException- thrown if the copy fails for some reason
-
setProperties
Set JavaBean property values on an object with values taken from a map. If the values in the map are of type String or String[] they may be converted to the actual property type by the use of property editors.- Parameters:
from- map of valuesto- the destination object- Throws:
IllegalArgumentException
-
setProperty
public static void setProperty(String propertyName, Object val, Object obj) throws IllegalArgumentException Set a single JavaBean property value on an object. If the values in the map are of type String or String[] they may be converted to the actual property type by the use of property editors.- Parameters:
propertyName- String representing the property or subpropertyval- the value to setobj- the object to set the property on.- Throws:
IllegalArgumentException
-
getPropertyEditor
Helper method to retrieve a property editor out of cache. -
getAsValue
Helper method that gets the value using a PropertyEditor If the editor is a FastPropertyEditor then getAsValue is called otherwise normal setAsText, getValue calls are made -
toStringValue
Call toString on object. If object has an associated ValidationEditorSupport property editor then its getAsText will be called. This allows you to associate a common toString algorithm to call types. Objects of class String are however only returned
-