Package webwork.util

Class BeanUtil

java.lang.Object
webwork.util.BeanUtil

public final class BeanUtil extends Object
JavaBean utility methods
Version:
$Revision: 1.43 $
Author:
Rickard Öberg (rickard@middleware-company.com), Matt Baldree (matt@smallleap.com)
  • Constructor Details

    • BeanUtil

      public BeanUtil()
  • Method Details

    • copy

      public static void copy(Object from, Object to) throws IllegalArgumentException
      Copy JavaBean property values from one object to another.
      Parameters:
      from - the source object
      to - 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 object
      to - the destination object
      includeNull - whether null values are copied or not
      Throws:
      IllegalArgumentException - thrown if the copy fails for some reason
    • setProperties

      public static void setProperties(Map from, Object to) throws IllegalArgumentException
      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 values
      to - 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 subproperty
      val - the value to set
      obj - the object to set the property on.
      Throws:
      IllegalArgumentException
    • getPropertyEditor

      public static PropertyEditor getPropertyEditor(Class clazz)
      Helper method to retrieve a property editor out of cache.
    • getAsValue

      public static Object getAsValue(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 made
    • toStringValue

      public static String toStringValue(Object obj)
      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