org.sakaiproject.metaobj.utils.mvc.impl
Class BeanWrapperBase

java.lang.Object
  extended byorg.springframework.beans.PropertyEditorRegistrySupport
      extended byorg.springframework.beans.BeanWrapperImpl
          extended byorg.sakaiproject.metaobj.utils.mvc.impl.BeanWrapperBase
All Implemented Interfaces:
BeanWrapper, PropertyAccessor, PropertyEditorRegistry
Direct Known Subclasses:
MapWrapper, MixedBeanWrapper

public abstract class BeanWrapperBase
extends BeanWrapperImpl

Created by IntelliJ IDEA. User: John Ellis Date: Apr 23, 2004 Time: 1:50:42 PM To change this template use File | Settings | File Templates.


Field Summary
protected  List customEditors
           
protected  org.apache.commons.logging.Log logger
           
 
Fields inherited from interface org.springframework.beans.PropertyAccessor
NESTED_PROPERTY_SEPARATOR, NESTED_PROPERTY_SEPARATOR_CHAR, PROPERTY_KEY_PREFIX, PROPERTY_KEY_PREFIX_CHAR, PROPERTY_KEY_SUFFIX, PROPERTY_KEY_SUFFIX_CHAR
 
Constructor Summary
BeanWrapperBase()
           
BeanWrapperBase(Object object)
          Create new BeanWrapperImpl for the given object.
BeanWrapperBase(Object object, String nestedPath, Object rootObject)
          Create new BeanWrapperImpl for the given object, registering a nested path that the object is in.
 
Method Summary
protected abstract  BeanWrapperBase constructWrapper(Object propertyValue, String nestedProperty)
           
protected  BeanWrapperImpl createNestedWrapper(String parentPath, String nestedProperty)
           
 PropertyEditor findCustomEditor(Class requiredType, String propertyPath)
           
protected  BeanWrapperImpl getBeanWrapperForPropertyPath(String propertyPath)
          Recursively navigate to return a BeanWrapper for the nested property path.
protected  String getFinalPath(String nestedPath)
          Get the last component of the path.
protected  BeanWrapperImpl getNestedBeanWrapper(String nestedProperty)
          Retrieve a BeanWrapper for the given nested property.
 Object getPropertyValue(String propertyName)
           
protected  boolean isNestedProperty(String path)
          Is the property nested?
 void registerCustomEditor(Class requiredType, String propertyPath, PropertyEditor propertyEditor)
           
 void setPropertyValue(String propertyName, Object value)
           
 
Methods inherited from class org.springframework.beans.BeanWrapperImpl
doTypeConversionIfNecessary, doTypeConversionIfNecessary, getNestedPath, getPropertyDescriptor, getPropertyDescriptorInternal, getPropertyDescriptors, getPropertyType, getRootClass, getRootInstance, getWrappedClass, getWrappedInstance, isReadableProperty, isWritableProperty, newNestedBeanWrapper, setExtractOldValueForEditor, setIntrospectionClass, setPropertyValue, setPropertyValues, setPropertyValues, setPropertyValues, setWrappedInstance, setWrappedInstance, toString
 
Methods inherited from class org.springframework.beans.PropertyEditorRegistrySupport
copyCustomEditorsTo, copyDefaultEditorsTo, getDefaultEditor, guessPropertyTypeFromEditors, registerCustomEditor, registerDefaultEditors
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.beans.PropertyEditorRegistry
registerCustomEditor
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger

customEditors

protected List customEditors
Constructor Detail

BeanWrapperBase

public BeanWrapperBase()

BeanWrapperBase

public BeanWrapperBase(Object object)
                throws BeansException
Create new BeanWrapperImpl for the given object.

Parameters:
object - object wrapped by this BeanWrapper.
Throws:
BeansException - if the object cannot be wrapped by a BeanWrapper

BeanWrapperBase

public BeanWrapperBase(Object object,
                       String nestedPath,
                       Object rootObject)
                throws BeansException
Create new BeanWrapperImpl for the given object, registering a nested path that the object is in.

Parameters:
object - object wrapped by this BeanWrapper.
nestedPath - the nested path of the object
rootObject - the root object at the top of the path
Throws:
BeansException - if the object cannot be wrapped by a BeanWrapper
Method Detail

getPropertyValue

public Object getPropertyValue(String propertyName)
                        throws BeansException
Throws:
BeansException

getBeanWrapperForPropertyPath

protected BeanWrapperImpl getBeanWrapperForPropertyPath(String propertyPath)
Recursively navigate to return a BeanWrapper for the nested property path.

Parameters:
propertyPath - property property path, which may be nested
Returns:
a BeanWrapper for the target bean

getNestedBeanWrapper

protected BeanWrapperImpl getNestedBeanWrapper(String nestedProperty)
Retrieve a BeanWrapper for the given nested property. Create a new one if not found in the cache.

Note: Caching nested BeanWrappers is necessary now, to keep registered custom editors for nested properties.

Parameters:
nestedProperty - property to create the BeanWrapper for
Returns:
the BeanWrapper instance, either cached or newly created

createNestedWrapper

protected BeanWrapperImpl createNestedWrapper(String parentPath,
                                              String nestedProperty)

constructWrapper

protected abstract BeanWrapperBase constructWrapper(Object propertyValue,
                                                    String nestedProperty)

registerCustomEditor

public void registerCustomEditor(Class requiredType,
                                 String propertyPath,
                                 PropertyEditor propertyEditor)

setPropertyValue

public void setPropertyValue(String propertyName,
                             Object value)
                      throws BeansException
Throws:
BeansException

isNestedProperty

protected boolean isNestedProperty(String path)
Is the property nested? That is, does it contain the nested property separator (usually ".").

Parameters:
path - property path
Returns:
boolean is the property nested

getFinalPath

protected String getFinalPath(String nestedPath)
Get the last component of the path. Also works if not nested.

Parameters:
nestedPath - property path we know is nested
Returns:
last component of the path (the property on the target bean)

findCustomEditor

public PropertyEditor findCustomEditor(Class requiredType,
                                       String propertyPath)