jodd.bean
Class BeanUtilBean

java.lang.Object
  extended by jodd.bean.BeanUtilBean

public class BeanUtilBean
extends Object

Instantiable version of BeanUtil.


Field Summary
static String THIS_REF
           
protected  TypeConverterManagerBean typeConverterManager
           
 
Constructor Summary
BeanUtilBean()
           
 
Method Summary
protected  Object arrayForcedGet(jodd.bean.BeanProperty bp, Object array, int index)
          Returns the element of an array forced.
protected  void arrayForcedSet(jodd.bean.BeanProperty bp, Object array, int index, Object value)
          Sets the array element forced.
protected  Object convertType(Object value, Class type)
          Converts object to destination type.
protected  Object createBeanProperty(jodd.bean.BeanProperty bp)
          Creates new instance for current property name through its setter.
protected  Object ensureArraySize(jodd.bean.BeanProperty bp, Object array, Class componentType, int index)
           
protected  void ensureListSize(List list, int size)
           
protected  Class extracticGenericType(jodd.bean.BeanProperty bp, int index)
          Extracts generic parameter types.
protected  String extractIndex(jodd.bean.BeanProperty bp)
          Extract index string from non-nested property name.
 String extractThisReference(String propertyName)
          Extract the first name of this reference.
protected  Class extractType(jodd.bean.BeanProperty bp)
          Extracts type of current property.
 Object getDeclaredProperty(Object bean, String name)
          Returns value of declared bean's property.
 Object getDeclaredPropertySilently(Object bean, String name)
          Silently returns value of declared bean's property.
 Class getDeclaredPropertyType(Object bean, String name)
           
protected  Object getField(Object bean, Field f)
          Return value of a field.
protected  Object getIndexProperty(jodd.bean.BeanProperty bp, boolean suppressSecurity)
          Get non-nested property value: either simple or indexed property.
 Object getIndexProperty(Object bean, String property, boolean suppressSecurity, boolean forced)
           
 Object getProperty(Object bean, String name)
          Returns value of bean's property.
 Object getPropertySilently(Object bean, String name)
          Silently returns value of bean's property.
 Class getPropertyType(Object bean, String name)
           
protected  Object getSimpleProperty(jodd.bean.BeanProperty bp, boolean suppressSecurity)
           
 Object getSimpleProperty(Object bean, String property, boolean suppressSecurity)
          Reads simple property.
 Object getSimplePropertyForced(Object bean, String property, boolean suppressSecurity)
          Reads simple property forced: when property value doesn't exist, it will be created.
 boolean hasDeclaredProperty(Object bean, String name)
           
protected  boolean hasIndexProperty(jodd.bean.BeanProperty bp, boolean suppressSecurity)
           
 boolean hasIndexProperty(Object bean, String property, boolean suppressSecurity)
           
 boolean hasProperty(Object bean, String name)
           
protected  boolean hasSimpleProperty(jodd.bean.BeanProperty bp, boolean suppressSecurity)
           
 boolean hasSimpleProperty(Object bean, String property, boolean suppressSecurity)
          Returns true if simple property exist.
protected  int indexOfDot(String name)
          Finds the very first next dot.
protected  Object invokeGetter(Object bean, Method m)
          Invokes getXxx() method of specified bean.
protected  void invokeSetter(Object bean, Method m, Object value)
          Invokes setXxx() method with appropriate conversion if available.
protected  int parseInt(String indexString, jodd.bean.BeanProperty bp)
           
 void populateBean(Object bean, Map<?,?> map)
          Populates bean from a Map.
 void populateProperty(Object bean, String name, List<?> list)
          Populates indexed bean property from a List.
 void populateProperty(Object bean, String name, Map<?,?> map)
          Populates simple bean property from a Map.
protected  boolean resolveExistingNestedProperties(jodd.bean.BeanProperty bp)
           
protected  void resolveNestedProperties(jodd.bean.BeanProperty bp)
          Resolves nested property name to the very last indexed property.
 void setDeclaredProperty(Object bean, String name, Object value)
          Sets declared Java Bean property.
 void setDeclaredPropertyForced(Object bean, String name, Object value)
          Sets declared Java Bean property forced.
 boolean setDeclaredPropertyForcedSilent(Object bean, String name, Object value)
          Silently sets declared Java Bean property forced.
 boolean setDeclaredPropertySilent(Object bean, String name, Object value)
          Silently sets declared Java Bean property.
protected  void setField(Object bean, Field f, Object value)
          Sets field value.
protected  void setIndexProperty(jodd.bean.BeanProperty bp, Object value, boolean suppressSecurity)
          Sets indexed or regular properties (no nested!).
 void setIndexProperty(Object bean, String property, Object value, boolean suppressSecurity, boolean forced)
           
 void setProperty(Object bean, String name, Object value)
          Sets Java Bean property.
 void setPropertyForced(Object bean, String name, Object value)
          Sets Java Bean property forced.
 boolean setPropertyForcedSilent(Object bean, String name, Object value)
          Sets Java Bean property forced, without throwing an exception on non-existing properties.
 boolean setPropertySilent(Object bean, String name, Object value)
          Sets Java Bean property silently, without throwing an exception on non-existing properties.
protected  void setSimpleProperty(jodd.bean.BeanProperty bp, Object value, boolean suppressSecurity)
          Sets a value of simple property.
 void setSimpleProperty(Object bean, String property, Object value, boolean suppressSecurity)
           
 void setTypeConverterManager(TypeConverterManagerBean typeConverterManager)
          Sets custom type converter manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

THIS_REF

public static final String THIS_REF
See Also:
Constant Field Values

typeConverterManager

protected TypeConverterManagerBean typeConverterManager
Constructor Detail

BeanUtilBean

public BeanUtilBean()
Method Detail

resolveNestedProperties

protected void resolveNestedProperties(jodd.bean.BeanProperty bp)
Resolves nested property name to the very last indexed property. If forced, null or non-existing properties will be created.


resolveExistingNestedProperties

protected boolean resolveExistingNestedProperties(jodd.bean.BeanProperty bp)

hasSimpleProperty

public boolean hasSimpleProperty(Object bean,
                                 String property,
                                 boolean suppressSecurity)
Returns true if simple property exist.


hasSimpleProperty

protected boolean hasSimpleProperty(jodd.bean.BeanProperty bp,
                                    boolean suppressSecurity)

getSimpleProperty

public Object getSimpleProperty(Object bean,
                                String property,
                                boolean suppressSecurity)
Reads simple property.


getSimplePropertyForced

public Object getSimplePropertyForced(Object bean,
                                      String property,
                                      boolean suppressSecurity)
Reads simple property forced: when property value doesn't exist, it will be created.


getSimpleProperty

protected Object getSimpleProperty(jodd.bean.BeanProperty bp,
                                   boolean suppressSecurity)

setSimpleProperty

public void setSimpleProperty(Object bean,
                              String property,
                              Object value,
                              boolean suppressSecurity)

setSimpleProperty

protected void setSimpleProperty(jodd.bean.BeanProperty bp,
                                 Object value,
                                 boolean suppressSecurity)
Sets a value of simple property.


hasIndexProperty

public boolean hasIndexProperty(Object bean,
                                String property,
                                boolean suppressSecurity)

hasIndexProperty

protected boolean hasIndexProperty(jodd.bean.BeanProperty bp,
                                   boolean suppressSecurity)

getIndexProperty

public Object getIndexProperty(Object bean,
                               String property,
                               boolean suppressSecurity,
                               boolean forced)

getIndexProperty

protected Object getIndexProperty(jodd.bean.BeanProperty bp,
                                  boolean suppressSecurity)
Get non-nested property value: either simple or indexed property. If forced, missing bean will be created if possible.


setIndexProperty

public void setIndexProperty(Object bean,
                             String property,
                             Object value,
                             boolean suppressSecurity,
                             boolean forced)

setIndexProperty

protected void setIndexProperty(jodd.bean.BeanProperty bp,
                                Object value,
                                boolean suppressSecurity)
Sets indexed or regular properties (no nested!).


setProperty

public void setProperty(Object bean,
                        String name,
                        Object value)
Sets Java Bean property.


setPropertySilent

public boolean setPropertySilent(Object bean,
                                 String name,
                                 Object value)
Sets Java Bean property silently, without throwing an exception on non-existing properties.


setPropertyForced

public void setPropertyForced(Object bean,
                              String name,
                              Object value)
Sets Java Bean property forced.


setPropertyForcedSilent

public boolean setPropertyForcedSilent(Object bean,
                                       String name,
                                       Object value)
Sets Java Bean property forced, without throwing an exception on non-existing properties.


setDeclaredProperty

public void setDeclaredProperty(Object bean,
                                String name,
                                Object value)
Sets declared Java Bean property.


setDeclaredPropertySilent

public boolean setDeclaredPropertySilent(Object bean,
                                         String name,
                                         Object value)
Silently sets declared Java Bean property.


setDeclaredPropertyForced

public void setDeclaredPropertyForced(Object bean,
                                      String name,
                                      Object value)
Sets declared Java Bean property forced.


setDeclaredPropertyForcedSilent

public boolean setDeclaredPropertyForcedSilent(Object bean,
                                               String name,
                                               Object value)
Silently sets declared Java Bean property forced.


getProperty

public Object getProperty(Object bean,
                          String name)
Returns value of bean's property.


getPropertySilently

public Object getPropertySilently(Object bean,
                                  String name)
Silently returns value of bean's property. Return value null is ambiguous: it may means that property name is valid and property value is null or that property name is invalid.


getDeclaredProperty

public Object getDeclaredProperty(Object bean,
                                  String name)
Returns value of declared bean's property.


getDeclaredPropertySilently

public Object getDeclaredPropertySilently(Object bean,
                                          String name)
Silently returns value of declared bean's property. Return value null is ambiguous: it may means that property name is valid and property value is null or that property name is invalid.


hasProperty

public boolean hasProperty(Object bean,
                           String name)

hasDeclaredProperty

public boolean hasDeclaredProperty(Object bean,
                                   String name)

getPropertyType

public Class getPropertyType(Object bean,
                             String name)

getDeclaredPropertyType

public Class getDeclaredPropertyType(Object bean,
                                     String name)

populateBean

public void populateBean(Object bean,
                         Map<?,?> map)
Populates bean from a Map.


populateProperty

public void populateProperty(Object bean,
                             String name,
                             Map<?,?> map)
Populates simple bean property from a Map.


populateProperty

public void populateProperty(Object bean,
                             String name,
                             List<?> list)
Populates indexed bean property from a List.


extractThisReference

public String extractThisReference(String propertyName)
Extract the first name of this reference.


setTypeConverterManager

public void setTypeConverterManager(TypeConverterManagerBean typeConverterManager)
Sets custom type converter manager.


convertType

protected Object convertType(Object value,
                             Class type)
Converts object to destination type. Invoked before the value is set into destination.


invokeSetter

protected void invokeSetter(Object bean,
                            Method m,
                            Object value)
Invokes setXxx() method with appropriate conversion if available. It is assumed that all provided arguments are valid.


invokeGetter

protected Object invokeGetter(Object bean,
                              Method m)
Invokes getXxx() method of specified bean. It is assumed that all provided arguments are valid.


setField

protected void setField(Object bean,
                        Field f,
                        Object value)
Sets field value.


getField

protected Object getField(Object bean,
                          Field f)
Return value of a field.


arrayForcedGet

protected Object arrayForcedGet(jodd.bean.BeanProperty bp,
                                Object array,
                                int index)
Returns the element of an array forced. If value is null, it will be instantiated. If not the last part of indexed bean property, array will be expanded to the index if necessary.


arrayForcedSet

protected void arrayForcedSet(jodd.bean.BeanProperty bp,
                              Object array,
                              int index,
                              Object value)
Sets the array element forced. If index is greater then arrays length, array will be expanded to the index. If speed is critical, it is better to allocate an array with proper size before using this method.


ensureArraySize

protected Object ensureArraySize(jodd.bean.BeanProperty bp,
                                 Object array,
                                 Class componentType,
                                 int index)

ensureListSize

protected void ensureListSize(List list,
                              int size)

indexOfDot

protected int indexOfDot(String name)
Finds the very first next dot. Ignores dots between index brackets.


extractIndex

protected String extractIndex(jodd.bean.BeanProperty bp)
Extract index string from non-nested property name. If index is found, it is stripped from bean property name. If no index is found, it returns null.


parseInt

protected int parseInt(String indexString,
                       jodd.bean.BeanProperty bp)

createBeanProperty

protected Object createBeanProperty(jodd.bean.BeanProperty bp)
Creates new instance for current property name through its setter. It uses default constructor!


extracticGenericType

protected Class extracticGenericType(jodd.bean.BeanProperty bp,
                                     int index)
Extracts generic parameter types.


extractType

protected Class extractType(jodd.bean.BeanProperty bp)
Extracts type of current property.