Class AbstractNestablePropertyAccessor
- All Implemented Interfaces:
- ConfigurablePropertyAccessor,- PropertyAccessor,- PropertyEditorRegistry,- TypeConverter
- Direct Known Subclasses:
- BeanWrapperImpl,- DirectFieldAccessor
ConfigurablePropertyAccessor that provides the necessary
 infrastructure for all typical use cases.
 This accessor will convert collection and array values to the corresponding
 target collections or arrays, if necessary. Custom property editors that deal
 with collections or arrays can either be written via PropertyEditor's
 setValue, or against a comma-delimited String via setAsText,
 as String arrays are converted in such a format if the array itself is not
 assignable.
- Since:
- 4.2
- Author:
- Juergen Hoeller, Stephane Nicoll, Rod Johnson, Rob Harrop, Sam Brannen
- See Also:
- 
- PropertyEditorRegistrySupport.registerCustomEditor(java.lang.Class<?>, java.beans.PropertyEditor)
- AbstractPropertyAccessor.setPropertyValues(java.util.Map<?, ?>)
- setPropertyValue(java.lang.String, java.lang.Object)
- getPropertyValue(java.lang.String)
- getPropertyType(java.lang.String)
- BeanWrapper
- PropertyEditorRegistrySupport
 
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected static classA handler for a specific property.protected static classHolder class used to store property tokens.
- 
Field SummaryFields inherited from interface org.springframework.beans.PropertyAccessorNESTED_PROPERTY_SEPARATOR, NESTED_PROPERTY_SEPARATOR_CHAR, PROPERTY_KEY_PREFIX, PROPERTY_KEY_PREFIX_CHAR, PROPERTY_KEY_SUFFIX, PROPERTY_KEY_SUFFIX_CHAR
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedCreate a new empty accessor.protectedAbstractNestablePropertyAccessor(boolean registerDefaultEditors) Create a new empty accessor.protectedAbstractNestablePropertyAccessor(Class<?> clazz) Create a new accessor, wrapping a new instance of the specified class.protectedCreate a new accessor for the given object.protectedAbstractNestablePropertyAccessor(Object object, String nestedPath, Object rootObject) Create a new accessor for the given object, registering a nested path that the object is in.protectedAbstractNestablePropertyAccessor(Object object, String nestedPath, AbstractNestablePropertyAccessor parent) Create a new accessor for the given object, registering a nested path that the object is in.
- 
Method SummaryModifier and TypeMethodDescriptionconvertForProperty(String propertyName, @Nullable Object oldValue, @Nullable Object newValue, TypeDescriptor td) protected abstract NotWritablePropertyExceptioncreateNotWritablePropertyException(String propertyName) Create aNotWritablePropertyExceptionfor the specified property.intReturn the limit for array and collection auto-growing.protected StringgetFinalPath(AbstractNestablePropertyAccessor pa, String nestedPath) Get the last component of the path.protected abstract @Nullable AbstractNestablePropertyAccessor.PropertyHandlergetLocalPropertyHandler(String propertyName) Return aAbstractNestablePropertyAccessor.PropertyHandlerfor the specified localpropertyName.final StringReturn the nested path of the object wrapped by this accessor.protected AbstractNestablePropertyAccessorgetPropertyAccessorForPropertyPath(String propertyPath) Recursively navigate to return a property accessor for the nested property path.getPropertyHandler(String propertyName) Return theAbstractNestablePropertyAccessor.PropertyHandlerfor the specifiedpropertyName, navigating if necessary.getPropertyType(String propertyName) Determine the property type for the given property path.getPropertyTypeDescriptor(String propertyName) Return a type descriptor for the specified property: preferably from the read method, falling back to the write method.getPropertyValue(String propertyName) Actually get the value of a property.final Class<?>Return the class of the root object at the top of the path of this accessor.final ObjectReturn the root object at the top of the path of this accessor.final Class<?>final ObjectbooleanisReadableProperty(String propertyName) Determine whether the specified property is readable.booleanisWritableProperty(String propertyName) Determine whether the specified property is writable.protected abstract AbstractNestablePropertyAccessornewNestedPropertyAccessor(Object object, String nestedPath) Create a new nested property accessor instance.voidsetAutoGrowCollectionLimit(int autoGrowCollectionLimit) Specify a limit for array and collection auto-growing.voidsetPropertyValue(String propertyName, @Nullable Object value) Actually set a property value.protected voidvoidSet the specified value as current property value.voidsetWrappedInstance(Object object) Switch the target object, replacing the cached introspection results only if the class of the new object is different to that of the replaced object.voidSwitch the target object, replacing the cached introspection results only if the class of the new object is different to that of the replaced object.toString()Methods inherited from class org.springframework.beans.AbstractPropertyAccessorisAutoGrowNestedPaths, isExtractOldValueForEditor, setAutoGrowNestedPaths, setExtractOldValueForEditor, setPropertyValues, setPropertyValues, setPropertyValues, setPropertyValuesMethods inherited from class org.springframework.beans.TypeConverterSupportconvertIfNecessary, convertIfNecessary, convertIfNecessary, convertIfNecessaryMethods inherited from class org.springframework.beans.PropertyEditorRegistrySupportcopyCustomEditorsTo, copyDefaultEditorsTo, findCustomEditor, getConversionService, getDefaultEditor, guessPropertyTypeFromEditors, hasCustomEditorForElement, overrideDefaultEditor, registerCustomEditor, registerCustomEditor, registerDefaultEditors, setConversionService, setDefaultEditorRegistrar, useConfigValueEditorsMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.beans.ConfigurablePropertyAccessorgetConversionService, setConversionServiceMethods inherited from interface org.springframework.beans.PropertyEditorRegistryfindCustomEditor, registerCustomEditor, registerCustomEditorMethods inherited from interface org.springframework.beans.TypeConverterconvertIfNecessary, convertIfNecessary, convertIfNecessary, convertIfNecessary
- 
Constructor Details- 
AbstractNestablePropertyAccessorprotected AbstractNestablePropertyAccessor()Create a new empty accessor. Wrapped instance needs to be set afterwards. Registers default editors.- See Also:
 
- 
AbstractNestablePropertyAccessorprotected AbstractNestablePropertyAccessor(boolean registerDefaultEditors) Create a new empty accessor. Wrapped instance needs to be set afterwards.- Parameters:
- registerDefaultEditors- whether to register default editors (can be suppressed if the accessor won't need any type conversion)
- See Also:
 
- 
AbstractNestablePropertyAccessorCreate a new accessor for the given object.- Parameters:
- object- the object wrapped by this accessor
 
- 
AbstractNestablePropertyAccessorCreate a new accessor, wrapping a new instance of the specified class.- Parameters:
- clazz- class to instantiate and wrap
 
- 
AbstractNestablePropertyAccessorCreate a new accessor for the given object, registering a nested path that the object is in.- Parameters:
- object- the object wrapped by this accessor
- nestedPath- the nested path of the object
- rootObject- the root object at the top of the path
 
- 
AbstractNestablePropertyAccessorprotected AbstractNestablePropertyAccessor(Object object, String nestedPath, AbstractNestablePropertyAccessor parent) Create a new accessor for the given object, registering a nested path that the object is in.- Parameters:
- object- the object wrapped by this accessor
- nestedPath- the nested path of the object
- parent- the containing accessor (must not be- null)
 
 
- 
- 
Method Details- 
setAutoGrowCollectionLimitpublic void setAutoGrowCollectionLimit(int autoGrowCollectionLimit) Specify a limit for array and collection auto-growing.Default is unlimited on a plain accessor. 
- 
getAutoGrowCollectionLimitpublic int getAutoGrowCollectionLimit()Return the limit for array and collection auto-growing.
- 
setWrappedInstanceSwitch the target object, replacing the cached introspection results only if the class of the new object is different to that of the replaced object.- Parameters:
- object- the new target object
 
- 
setWrappedInstancepublic void setWrappedInstance(Object object, @Nullable String nestedPath, @Nullable Object rootObject) Switch the target object, replacing the cached introspection results only if the class of the new object is different to that of the replaced object.- Parameters:
- object- the new target object
- nestedPath- the nested path of the object
- rootObject- the root object at the top of the path
 
- 
getWrappedInstance
- 
getWrappedClass
- 
getNestedPathReturn the nested path of the object wrapped by this accessor.
- 
getRootInstanceReturn the root object at the top of the path of this accessor.- See Also:
 
- 
getRootClassReturn the class of the root object at the top of the path of this accessor.- See Also:
 
- 
setPropertyValueDescription copied from class:AbstractPropertyAccessorActually set a property value.- Specified by:
- setPropertyValuein interface- PropertyAccessor
- Specified by:
- setPropertyValuein class- AbstractPropertyAccessor
- Parameters:
- propertyName- name of the property to set value of
- value- the new value
- Throws:
- InvalidPropertyException- if there is no such property or if the property isn't writable
- PropertyAccessException- if the property was valid but the accessor method failed or a type mismatch occurred
- BeansException
 
- 
setPropertyValueDescription copied from interface:PropertyAccessorSet the specified value as current property value.- Specified by:
- setPropertyValuein interface- PropertyAccessor
- Overrides:
- setPropertyValuein class- AbstractPropertyAccessor
- Parameters:
- pv- an object containing the new property value
- Throws:
- InvalidPropertyException- if there is no such property or if the property isn't writable
- PropertyAccessException- if the property was valid but the accessor method failed or a type mismatch occurred
- BeansException
 
- 
setPropertyValueprotected void setPropertyValue(AbstractNestablePropertyAccessor.PropertyTokenHolder tokens, PropertyValue pv) throws BeansException - Throws:
- BeansException
 
- 
getPropertyTypeDescription copied from class:PropertyEditorRegistrySupportDetermine the property type for the given property path.Called by PropertyEditorRegistrySupport.findCustomEditor(java.lang.Class<?>, java.lang.String)if no required type has been specified, to be able to find a type-specific editor even if just given a property path.The default implementation always returns null. BeanWrapperImpl overrides this with the standardgetPropertyTypemethod as defined by the BeanWrapper interface.- Specified by:
- getPropertyTypein interface- PropertyAccessor
- Overrides:
- getPropertyTypein class- AbstractPropertyAccessor
- Parameters:
- propertyName- the property path to determine the type for
- Returns:
- the type of the property, or nullif not determinable
- Throws:
- PropertyAccessException- if the property was valid but the accessor method failed
- BeansException
- See Also:
 
- 
getPropertyTypeDescriptorpublic @Nullable TypeDescriptor getPropertyTypeDescriptor(String propertyName) throws BeansException Description copied from interface:PropertyAccessorReturn a type descriptor for the specified property: preferably from the read method, falling back to the write method.- Parameters:
- propertyName- the property to check (may be a nested path and/or an indexed/mapped property)
- Returns:
- the property type for the particular property,
 or nullif not determinable
- Throws:
- PropertyAccessException- if the property was valid but the accessor method failed
- BeansException
 
- 
isReadablePropertyDescription copied from interface:PropertyAccessorDetermine whether the specified property is readable.Returns falseif the property doesn't exist.- Parameters:
- propertyName- the property to check (may be a nested path and/or an indexed/mapped property)
- Returns:
- whether the property is readable
 
- 
isWritablePropertyDescription copied from interface:PropertyAccessorDetermine whether the specified property is writable.Returns falseif the property doesn't exist.- Parameters:
- propertyName- the property to check (may be a nested path and/or an indexed/mapped property)
- Returns:
- whether the property is writable
 
- 
convertForPropertyprotected @Nullable Object convertForProperty(String propertyName, @Nullable Object oldValue, @Nullable Object newValue, TypeDescriptor td) throws TypeMismatchException - Throws:
- TypeMismatchException
 
- 
getPropertyValueDescription copied from class:AbstractPropertyAccessorActually get the value of a property.- Specified by:
- getPropertyValuein interface- PropertyAccessor
- Specified by:
- getPropertyValuein class- AbstractPropertyAccessor
- Parameters:
- propertyName- name of the property to get the value of
- Returns:
- the value of the property
- Throws:
- InvalidPropertyException- if there is no such property or if the property isn't readable
- PropertyAccessException- if the property was valid but the accessor method failed
- BeansException
 
- 
getPropertyValueprotected @Nullable Object getPropertyValue(AbstractNestablePropertyAccessor.PropertyTokenHolder tokens) throws BeansException - Throws:
- BeansException
 
- 
getPropertyHandlerprotected @Nullable AbstractNestablePropertyAccessor.PropertyHandler getPropertyHandler(String propertyName) throws BeansException Return theAbstractNestablePropertyAccessor.PropertyHandlerfor the specifiedpropertyName, navigating if necessary. Returnnullif not found rather than throwing an exception.- Parameters:
- propertyName- the property to obtain the descriptor for
- Returns:
- the property descriptor for the specified property,
 or nullif not found
- Throws:
- BeansException- in case of introspection failure
 
- 
getLocalPropertyHandlerprotected abstract @Nullable AbstractNestablePropertyAccessor.PropertyHandler getLocalPropertyHandler(String propertyName) Return aAbstractNestablePropertyAccessor.PropertyHandlerfor the specified localpropertyName. Only used to reach a property available in the current context.- Parameters:
- propertyName- the name of a local property
- Returns:
- the handler for that property, or nullif it has not been found
 
- 
newNestedPropertyAccessorprotected abstract AbstractNestablePropertyAccessor newNestedPropertyAccessor(Object object, String nestedPath) Create a new nested property accessor instance. Can be overridden in subclasses to create a PropertyAccessor subclass.- Parameters:
- object- the object wrapped by this PropertyAccessor
- nestedPath- the nested path of the object
- Returns:
- the nested PropertyAccessor instance
 
- 
createNotWritablePropertyExceptionprotected abstract NotWritablePropertyException createNotWritablePropertyException(String propertyName) Create aNotWritablePropertyExceptionfor the specified property.
- 
getFinalPathGet the last component of the path. Also works if not nested.- Parameters:
- pa- property accessor to work on
- nestedPath- property path we know is nested
- Returns:
- last component of the path (the property on the target bean)
 
- 
getPropertyAccessorForPropertyPathRecursively navigate to return a property accessor for the nested property path.- Parameters:
- propertyPath- property path, which may be nested
- Returns:
- a property accessor for the target bean
 
- 
toString
 
-