org.oddjob.arooa.beanutils
Class BeanUtilsPropertyAccessor

java.lang.Object
  extended by org.oddjob.arooa.beanutils.BeanUtilsPropertyAccessor
All Implemented Interfaces:
PropertyAccessor

public class BeanUtilsPropertyAccessor
extends Object
implements PropertyAccessor

BeanUtilsBean with bespoke conversion and ArooaExceptions.


Constructor Summary
BeanUtilsPropertyAccessor()
           
 
Method Summary
 PropertyAccessor accessorWithConversions(ArooaConverter converter)
          Provide an accessor that performs conversions.
 void clear()
           
 BeanOverview getBeanOverview(Class<?> forClass)
          Provide org.oddjob.arooo.BeanOverview.
 ArooaClass getClassName(Object bean)
          Get the ArooaClass for a bean.
 ArooaConverter getConverter()
           
 Object getProperty(Object bean, String property)
          Get a property.
<T> T
getProperty(Object bean, String property, Class<T> required)
          Get a property of a required type.
 void setIndexedProperty(Object bean, String name, int index, Object value)
          Set an indexed property on a bean.
 void setMappedProperty(Object bean, String name, String key, Object value)
          Set a mapped property on a bean.
 void setProperty(Object bean, String name, Object value)
          Set a property on a bean.
 void setSimpleProperty(Object bean, String name, Object value)
          Set a property on a bean.
static void validateSimplePropertyName(String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanUtilsPropertyAccessor

public BeanUtilsPropertyAccessor()
Method Detail

accessorWithConversions

public PropertyAccessor accessorWithConversions(ArooaConverter converter)
Description copied from interface: PropertyAccessor
Provide an accessor that performs conversions.

Specified by:
accessorWithConversions in interface PropertyAccessor
Parameters:
converter - The converter.
Returns:
An accessor that performs conversions.

getConverter

public ArooaConverter getConverter()

setProperty

public void setProperty(Object bean,
                        String name,
                        Object value)
                 throws ArooaPropertyException
Set a property on a bean.

Specified by:
setProperty in interface PropertyAccessor
Parameters:
bean - The bean. Must not be null.
name - The name. Must not be null.
value - The value. Can be null.
Throws:
ArooaPropertyException

setSimpleProperty

public void setSimpleProperty(Object bean,
                              String name,
                              Object value)
                       throws ArooaPropertyException
Set a property on a bean.

Specified by:
setSimpleProperty in interface PropertyAccessor
Parameters:
bean - The bean. Must not be null.
name - The name. Must not be null.
value - The value. Can be null.
Throws:
ArooaPropertyException

setMappedProperty

public void setMappedProperty(Object bean,
                              String name,
                              String key,
                              Object value)
                       throws ArooaPropertyException
Set a mapped property on a bean.

Specified by:
setMappedProperty in interface PropertyAccessor
Parameters:
bean - The bean. Must not be null.
name - The name. Must not be null.
key - The mapped property's key. Must not be null.
value - The value. Can be null.
Throws:
PropertyAccessException
ArooaPropertyException

setIndexedProperty

public void setIndexedProperty(Object bean,
                               String name,
                               int index,
                               Object value)
                        throws ArooaPropertyException
Set an indexed property on a bean.

Specified by:
setIndexedProperty in interface PropertyAccessor
Parameters:
bean - The bean. Must not be null.
name - The name. Must not be null.
index - The indexed property's index. 0 based.
value - The value. Can be null.
Throws:
ArooaPropertyException

getProperty

public Object getProperty(Object bean,
                          String property)
                   throws ArooaPropertyException
Get a property.

Specified by:
getProperty in interface PropertyAccessor
Parameters:
bean - The bean.
The - property.
Returns:
The property value.
Throws:
ArooaPropertyException

getProperty

public <T> T getProperty(Object bean,
                         String property,
                         Class<T> required)
              throws ArooaPropertyException,
                     ArooaConversionException
Get a property of a required type.

Specified by:
getProperty in interface PropertyAccessor
Parameters:
bean - The bean.
The - property.
Returns:
The property value.
Throws:
ArooaPropertyException
ArooaConversionException

validateSimplePropertyName

public static void validateSimplePropertyName(String name)
                                       throws IllegalArgumentException
Throws:
IllegalArgumentException

getClassName

public ArooaClass getClassName(Object bean)
Description copied from interface: PropertyAccessor
Get the ArooaClass for a bean.

Specified by:
getClassName in interface PropertyAccessor
Returns:

getBeanOverview

public BeanOverview getBeanOverview(Class<?> forClass)
                             throws ArooaException
Description copied from interface: PropertyAccessor
Provide org.oddjob.arooo.BeanOverview. Note that this will provide the overview for the Java class. If using a bean that might be a dynabean then use getArooaClass(bean).getBeanOverview() instead.

Specified by:
getBeanOverview in interface PropertyAccessor
Returns:
Throws:
ArooaException

clear

public void clear()