org.springframework.richclient.beans
Class AbstractMemberPropertyAccessor

java.lang.Object
  extended by org.springframework.beans.PropertyEditorRegistrySupport
      extended by org.springframework.beans.AbstractPropertyAccessor
          extended by org.springframework.richclient.beans.AbstractMemberPropertyAccessor
All Implemented Interfaces:
ConfigurablePropertyAccessor, PropertyAccessor, PropertyEditorRegistry, TypeConverter
Direct Known Subclasses:
AbstractNestedMemberPropertyAccessor

public abstract class AbstractMemberPropertyAccessor
extends AbstractPropertyAccessor

PropertyAccessor implementation that determines property types by field, if available. Otherwise methods are used. Actual access to properties is left for implementation for subclasses. This implementation does not support nested properties. Use AbstractNestedMemberPropertyAccessor, if you need nested property-support.

Author:
Arne Limburg

Field Summary
 
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
protected AbstractMemberPropertyAccessor(Class targetClass, boolean fieldAccessEnabled)
          Creates a new AbstractMemberPropertyAccessor.
 
Method Summary
protected  boolean checkKeyTypes(String propertyName)
           
protected  NotReadablePropertyException createNotReadablePropertyException(String propertyName, Exception e)
           
 Class getIndexedPropertyKeyType(String propertyName)
          Determine the type of the key used to index the collection/map.
protected abstract  Object getIndexedPropertyValue(String propertyName)
          Retrieve the value of an indexed property.
protected  Object[] getIndices(String propertyName)
           
protected  String getParentPropertyName(String propertyName)
          Return the parent property name of an indexed property or the empty string.
protected  Member getPropertyAccessor(String propertyName)
          Return any accessor, be it read or write, for the given property.
protected  String getPropertyName(String methodName, int prefixLength)
          Returns the propertyName based on the methodName.
 Class getPropertyType(String propertyName)
          
 Object getPropertyValue(String propertyName)
          
protected  Member getReadPropertyAccessor(String propertyName)
          Return the read accessor for the given property.
protected  String getRootPropertyName(String propertyName)
          Returns the root property of an indexed property.
protected abstract  Object getSimplePropertyValue(String propertyName)
          Retrieve the value of a simple property (non-indexed).
 Class getTargetClass()
          Returns the class used to introspect members.
protected  Member getWritePropertyAccessor(String propertyName)
          Return the write accessor for the given property.
 boolean isFieldAccessEnabled()
          Returns whether this PropertyAccessor should inspect fields.
 boolean isReadableProperty(String propertyName)
          
 boolean isWritableProperty(String propertyName)
          
protected  Object setAssemblageValue(Class assemblageType, Object assemblage, Object index, Object value)
          Helper method for subclasses to set values of indexed properties, like map-values, collection-values or array-values.
protected abstract  void setIndexedPropertyValue(String propertyName, Object value)
          Set the value of an indexed property.
 void setPropertyValue(String propertyName, Object value)
          
protected abstract  void setSimplePropertyValue(String propertyName, Object value)
          Set the value of a simple property (non-indexed).
protected  void setTargetClass(Class targetClass)
          Clears all cached members and introspect methods again.
 
Methods inherited from class org.springframework.beans.AbstractPropertyAccessor
convertIfNecessary, isExtractOldValueForEditor, setExtractOldValueForEditor, setPropertyValue, setPropertyValues, setPropertyValues, setPropertyValues, setPropertyValues
 
Methods inherited from class org.springframework.beans.PropertyEditorRegistrySupport
copyCustomEditorsTo, copyDefaultEditorsTo, findCustomEditor, getDefaultEditor, guessPropertyTypeFromEditors, hasCustomEditorForElement, isSharedEditor, registerCustomEditor, registerCustomEditor, registerDefaultEditors, registerSharedEditor, useConfigValueEditors
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.beans.PropertyEditorRegistry
findCustomEditor, registerCustomEditor, registerCustomEditor
 
Methods inherited from interface org.springframework.beans.TypeConverter
convertIfNecessary
 

Constructor Detail

AbstractMemberPropertyAccessor

protected AbstractMemberPropertyAccessor(Class targetClass,
                                         boolean fieldAccessEnabled)
Creates a new AbstractMemberPropertyAccessor.

Parameters:
targetClass - the target class.
fieldAccessEnabled - whether field access should be used for property type determination.
Method Detail

setTargetClass

protected void setTargetClass(Class targetClass)
Clears all cached members and introspect methods again. If fieldAccess is enabled introspect fields as well.

Parameters:
targetClass - the target class.

isFieldAccessEnabled

public boolean isFieldAccessEnabled()
Returns whether this PropertyAccessor should inspect fields.


getTargetClass

public Class getTargetClass()
Returns the class used to introspect members.


getReadPropertyAccessor

protected Member getReadPropertyAccessor(String propertyName)
Return the read accessor for the given property.

Parameters:
propertyName - name of the property.
Returns:
a Member to read the property or null.

getWritePropertyAccessor

protected Member getWritePropertyAccessor(String propertyName)
Return the write accessor for the given property.

Parameters:
propertyName - name of the property.
Returns:
a Member to write the property or null.

getPropertyAccessor

protected Member getPropertyAccessor(String propertyName)
Return any accessor, be it read or write, for the given property.

Parameters:
propertyName - name of the property.
Returns:
an accessor for the property or null

isReadableProperty

public boolean isReadableProperty(String propertyName)


isWritableProperty

public boolean isWritableProperty(String propertyName)


getPropertyType

public Class getPropertyType(String propertyName)

Specified by:
getPropertyType in interface PropertyAccessor
Overrides:
getPropertyType in class AbstractPropertyAccessor

getIndexedPropertyKeyType

public Class getIndexedPropertyKeyType(String propertyName)
Determine the type of the key used to index the collection/map. When jdk is at least 1.5, maps can be specified with generics and their key type can be resolved.

Parameters:
propertyName - name of the property.
Returns:
the type of the key. An integer if it's not a map, String if the jdk is less than 1.5, a specific type if the map was generified.

getPropertyValue

public Object getPropertyValue(String propertyName)
                        throws BeansException

Specified by:
getPropertyValue in interface PropertyAccessor
Specified by:
getPropertyValue in class AbstractPropertyAccessor
Throws:
BeansException

setPropertyValue

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

Specified by:
setPropertyValue in interface PropertyAccessor
Specified by:
setPropertyValue in class AbstractPropertyAccessor
Throws:
BeansException

getIndexedPropertyValue

protected abstract Object getIndexedPropertyValue(String propertyName)
Retrieve the value of an indexed property.

Parameters:
propertyName - name of the property.
Returns:
value of the property.

getSimplePropertyValue

protected abstract Object getSimplePropertyValue(String propertyName)
Retrieve the value of a simple property (non-indexed).

Parameters:
propertyName - name of the property.
Returns:
value of the property.

setIndexedPropertyValue

protected abstract void setIndexedPropertyValue(String propertyName,
                                                Object value)
Set the value of an indexed property.

Parameters:
propertyName - name of the property.
value - new value for the property.

setSimplePropertyValue

protected abstract void setSimplePropertyValue(String propertyName,
                                               Object value)
Set the value of a simple property (non-indexed).

Parameters:
propertyName - name of the property.
value - new value for the property.

getPropertyName

protected String getPropertyName(String methodName,
                                 int prefixLength)
Returns the propertyName based on the methodName. Cuts of the prefix and removes first capital.

Parameters:
methodName - name of method to convert.
prefixLength - length of prefix to cut of.
Returns:
property name.

getRootPropertyName

protected String getRootPropertyName(String propertyName)
Returns the root property of an indexed property. The root property is the property that contains no indices.

Parameters:
propertyName - the name of the property.
Returns:
the root property.

getParentPropertyName

protected String getParentPropertyName(String propertyName)
Return the parent property name of an indexed property or the empty string.

Parameters:
propertyName - the name of the property.
Returns:
the empty string or the parent property name if it was indexed.

checkKeyTypes

protected boolean checkKeyTypes(String propertyName)

getIndices

protected Object[] getIndices(String propertyName)

createNotReadablePropertyException

protected NotReadablePropertyException createNotReadablePropertyException(String propertyName,
                                                                          Exception e)

setAssemblageValue

protected Object setAssemblageValue(Class assemblageType,
                                    Object assemblage,
                                    Object index,
                                    Object value)
Helper method for subclasses to set values of indexed properties, like map-values, collection-values or array-values.

Parameters:
assemblageType - either map or collection or array
assemblage - the assemblage to set the value on
index - the index to set the value at
value - the value to set
Returns:
the assemblage


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