org.springframework.binding.support
Class AbstractPropertyAccessStrategy

Show UML class diagram
java.lang.Object
  extended by org.springframework.binding.support.AbstractPropertyAccessStrategy
All Implemented Interfaces:
MutablePropertyAccessStrategy, PropertyAccessStrategy
Direct Known Subclasses:
BeanPropertyAccessStrategy, ClassPropertyAccessStrategy, ObjectPropertyAccessStrategy

public abstract class AbstractPropertyAccessStrategy
extends Object
implements MutablePropertyAccessStrategy

An abstract implementation of MutablePropertyAccessStrategy that provides support for concrete implementations.

As this class delegates to a PropertyAccessor for property access, the support for type resolution and nested properties depends on the implementation of the PropertyAccessor

Author:
Oliver Hutchison, Arne Limburg

Constructor Summary
protected AbstractPropertyAccessStrategy(AbstractPropertyAccessStrategy parent, String basePropertyPath)
          Creates a child instance of AbstractPropertyAccessStrategy that will delegate to its parent for property access.
  AbstractPropertyAccessStrategy(Object object)
          Creates a new instance of AbstractPropertyAccessStrategy that will provide access to the properties of the provided object.
  AbstractPropertyAccessStrategy(ValueModel domainObjectHolder)
          Creates a new instance of AbstractPropertyAccessStrategy that will provide access to the object contained by the provided value model.
 
Method Summary
protected abstract  void domainObjectChanged()
          Called when the domain object is changed.
protected  Map getAllUserMetadataFor(String propertyPath)
          Subclasses may override this method to supply user metadata for the specified propertyPath.
 Object getDomainObject()
          Return the target, backing domain object for which property access requests are targeted against.
 ValueModel getDomainObjectHolder()
          Get the ValueModel used to access the domainObject.
protected  String getFullPropertyPath(String propertyPath)
          Returns a property path that includes the base property path of the class.
protected  int getLastPropertySeparatorIndex(String propertyPath)
          Returns the index of the last nested property separator in the given property path, ignoring dots in keys (like "map[my.key]").
 PropertyMetadataAccessStrategy getMetadataAccessStrategy()
          Get a metadata accessor, which can return meta information about particular properties of the backed domain object.
protected  String getParentPropertyPath(String propertyPath)
          Returns the property name component of the provided property path.
protected abstract  PropertyAccessor getPropertyAccessor()
           
abstract  MutablePropertyAccessStrategy getPropertyAccessStrategyForPath(String propertyPath)
          Get a MutablePropertyAccessStrategy for the given property.
protected  String getPropertyName(String propertyPath)
          Extracts the property name from a propertyPath.
 Object getPropertyValue(String propertyPath)
          Get the value of a property.
 ValueModel getPropertyValueModel(String propertyPath)
          Get the ValueModel to access the given property.
protected  Object getUserMetadataFor(String propertyPath, String key)
          Subclasses may override this method to supply user metadata for the specified propertyPath and key.
abstract  MutablePropertyAccessStrategy newPropertyAccessStrategy(ValueModel domainObjectHolder)
          Return a new MutablePropertyAccessStrategy for the given valueModel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPropertyAccessStrategy

public AbstractPropertyAccessStrategy(Object object)
Creates a new instance of AbstractPropertyAccessStrategy that will provide access to the properties of the provided object.

Parameters:
object - the object to be accessed through this class.

AbstractPropertyAccessStrategy

public AbstractPropertyAccessStrategy(ValueModel domainObjectHolder)
Creates a new instance of AbstractPropertyAccessStrategy that will provide access to the object contained by the provided value model.

Parameters:
domainObjectHolder - value model that holds the object to be accessed through this class

AbstractPropertyAccessStrategy

protected AbstractPropertyAccessStrategy(AbstractPropertyAccessStrategy parent,
                                         String basePropertyPath)
Creates a child instance of AbstractPropertyAccessStrategy that will delegate to its parent for property access.

Parameters:
parent - AbstractPropertyAccessStrategy which will be used to provide property access
basePropertyPath - property path that will as a base when accessing the parent AbstractPropertyAccessStrategy
Method Detail

getUserMetadataFor

protected Object getUserMetadataFor(String propertyPath,
                                    String key)
Subclasses may override this method to supply user metadata for the specified propertyPath and key. The default implementation invokes getAllUserMetadataFor(String) and uses the returned Map with the key parameter to find the correlated value.

Parameters:
propertyPath - path of property relative to this bean
key -
Returns:
metadata associated with the specified key for the property or null if there is no custom metadata associated with the property and key.

getAllUserMetadataFor

protected Map getAllUserMetadataFor(String propertyPath)
Subclasses may override this method to supply user metadata for the specified propertyPath. The default implementation always returns null.

Parameters:
propertyPath - path of property relative to this bean
Returns:
all metadata for the specified property in the form of a Map containing String keys and Object values. This method may return null if there is no metadata for the property.

getPropertyAccessor

protected abstract PropertyAccessor getPropertyAccessor()

getDomainObjectHolder

public ValueModel getDomainObjectHolder()
Description copied from interface: MutablePropertyAccessStrategy
Get the ValueModel used to access the domainObject.

Specified by:
getDomainObjectHolder in interface MutablePropertyAccessStrategy
Returns:
the ValueModel of the domainObject.

getPropertyValueModel

public ValueModel getPropertyValueModel(String propertyPath)
                                 throws BeansException
Description copied from interface: MutablePropertyAccessStrategy
Get the ValueModel to access the given property. Possibly creating the valueModel if needed.

Specified by:
getPropertyValueModel in interface MutablePropertyAccessStrategy
Parameters:
propertyPath - property to access.
Returns:
ValueModel that handles the given property.
Throws:
BeansException

getFullPropertyPath

protected String getFullPropertyPath(String propertyPath)
Returns a property path that includes the base property path of the class.


getPropertyName

protected String getPropertyName(String propertyPath)
Extracts the property name from a propertyPath.


getParentPropertyPath

protected String getParentPropertyPath(String propertyPath)
Returns the property name component of the provided property path.


getLastPropertySeparatorIndex

protected int getLastPropertySeparatorIndex(String propertyPath)
Returns the index of the last nested property separator in the given property path, ignoring dots in keys (like "map[my.key]").


getPropertyAccessStrategyForPath

public abstract MutablePropertyAccessStrategy getPropertyAccessStrategyForPath(String propertyPath)
                                                                        throws BeansException
Description copied from interface: MutablePropertyAccessStrategy
Get a MutablePropertyAccessStrategy for the given property. TODO check why this exists and where this is used.

Specified by:
getPropertyAccessStrategyForPath in interface MutablePropertyAccessStrategy
Parameters:
propertyPath - property.
Returns:
MutablePropertyAccessStrategy for the given property.
Throws:
BeansException

newPropertyAccessStrategy

public abstract MutablePropertyAccessStrategy newPropertyAccessStrategy(ValueModel domainObjectHolder)
Description copied from interface: MutablePropertyAccessStrategy
Return a new MutablePropertyAccessStrategy for the given valueModel. TODO check why this exists and where this is used.

Specified by:
newPropertyAccessStrategy in interface MutablePropertyAccessStrategy
Parameters:
domainObjectHolder - a ValueModel containing the domainObject.
Returns:
a newly created MutablePropertyAccessStrategy.

getDomainObject

public Object getDomainObject()
Description copied from interface: PropertyAccessStrategy
Return the target, backing domain object for which property access requests are targeted against.

Specified by:
getDomainObject in interface PropertyAccessStrategy
Returns:
The backing target object.

getMetadataAccessStrategy

public PropertyMetadataAccessStrategy getMetadataAccessStrategy()
Description copied from interface: PropertyAccessStrategy
Get a metadata accessor, which can return meta information about particular properties of the backed domain object.

Specified by:
getMetadataAccessStrategy in interface PropertyAccessStrategy
Returns:
The meta accessor.

getPropertyValue

public Object getPropertyValue(String propertyPath)
                        throws BeansException
Description copied from interface: PropertyAccessStrategy
Get the value of a property.

Specified by:
getPropertyValue in interface PropertyAccessStrategy
Parameters:
propertyPath - name of the property to get the value of
Returns:
the value of the property
Throws:
FatalBeanException - if there is no such property, if the property isn't readable, or if the property getter throws an exception.
BeansException

domainObjectChanged

protected abstract void domainObjectChanged()
Called when the domain object is changed.



Copyright © 2004-2009 The Spring Framework. All Rights Reserved.