Class PropertyEditorRegistrySupport
- All Implemented Interfaces:
- PropertyEditorRegistry
- Direct Known Subclasses:
- TypeConverterSupport
PropertyEditorRegistry interface.
 Provides management of default editors and custom editors.
 Mainly serves as base class for BeanWrapperImpl.- Since:
- 1.2.6
- Author:
- Juergen Hoeller, Rob Harrop, Sebastien Deleuze
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidcopyCustomEditorsTo(PropertyEditorRegistry target, String nestedProperty) Copy the custom editors registered in this instance to the given target registry.protected voidCopy the default editors registered in this instance to the given target registry.findCustomEditor(Class<?> requiredType, String propertyPath) Find a custom property editor for the given type and property.Return the associated ConversionService, if any.getDefaultEditor(Class<?> requiredType) Retrieve the default editor for the given property type, if any.protected Class<?>getPropertyType(String propertyPath) Determine the property type for the given property path.protected Class<?>guessPropertyTypeFromEditors(String propertyName) Guess the property type of the specified property from the registered custom editors (provided that they were registered for a specific type).booleanhasCustomEditorForElement(Class<?> elementType, String propertyPath) Determine whether this registry contains a custom editor for the specified array/collection element.voidoverrideDefaultEditor(Class<?> requiredType, PropertyEditor propertyEditor) Override the default editor for the specified type with the given property editor.voidregisterCustomEditor(Class<?> requiredType, PropertyEditor propertyEditor) Register the given custom property editor for all properties of the given type.voidregisterCustomEditor(Class<?> requiredType, String propertyPath, PropertyEditor propertyEditor) Register the given custom property editor for the given type and property, or for all properties of the given type.protected voidActivate the default editors for this registry instance, allowing for lazily registering default editors when needed.voidsetConversionService(ConversionService conversionService) Specify aConversionServiceto use for converting property values, as an alternative to JavaBeans PropertyEditors.voidsetDefaultEditorRegistrar(PropertyEditorRegistrar registrar) Set a registrar for default editors, as a lazy way of overriding default editors.voidActivate config value editors which are only intended for configuration purposes, such asStringArrayPropertyEditor.
- 
Constructor Details- 
PropertyEditorRegistrySupportpublic PropertyEditorRegistrySupport()
 
- 
- 
Method Details- 
setConversionServiceSpecify aConversionServiceto use for converting property values, as an alternative to JavaBeans PropertyEditors.
- 
getConversionServiceReturn the associated ConversionService, if any.
- 
registerDefaultEditorsprotected void registerDefaultEditors()Activate the default editors for this registry instance, allowing for lazily registering default editors when needed.
- 
useConfigValueEditorspublic void useConfigValueEditors()Activate config value editors which are only intended for configuration purposes, such asStringArrayPropertyEditor.Those editors are not registered by default simply because they are in general inappropriate for data binding purposes. Of course, you may register them individually in any case, through registerCustomEditor(java.lang.Class<?>, java.beans.PropertyEditor).
- 
setDefaultEditorRegistrarSet a registrar for default editors, as a lazy way of overriding default editors.This is expected to be a collaborator with PropertyEditorRegistrySupport, downcasting the givenPropertyEditorRegistryaccordingly and callingoverrideDefaultEditor(java.lang.Class<?>, java.beans.PropertyEditor)for registering additional default editors on it.- Parameters:
- registrar- the registrar to call when default editors are actually needed
- Since:
- 6.2.3
- See Also:
 
- 
overrideDefaultEditorOverride the default editor for the specified type with the given property editor.Note that this is different from registering a custom editor in that the editor semantically still is a default editor. A ConversionService will override such a default editor, whereas custom editors usually override the ConversionService. - Parameters:
- requiredType- the type of the property
- propertyEditor- the editor to register
- See Also:
 
- 
getDefaultEditorRetrieve the default editor for the given property type, if any.Lazily registers the default editors, if they are active. - Parameters:
- requiredType- type of the property
- Returns:
- the default editor, or nullif none found
- See Also:
 
- 
copyDefaultEditorsToCopy the default editors registered in this instance to the given target registry.- Parameters:
- target- the target registry to copy to
 
- 
registerCustomEditorDescription copied from interface:PropertyEditorRegistryRegister the given custom property editor for all properties of the given type.- Specified by:
- registerCustomEditorin interface- PropertyEditorRegistry
- Parameters:
- requiredType- the type of the property
- propertyEditor- the editor to register
 
- 
registerCustomEditorpublic void registerCustomEditor(@Nullable Class<?> requiredType, @Nullable String propertyPath, PropertyEditor propertyEditor) Description copied from interface:PropertyEditorRegistryRegister the given custom property editor for the given type and property, or for all properties of the given type.If the property path denotes an array or Collection property, the editor will get applied either to the array/Collection itself (the PropertyEditorhas to create an array or Collection value) or to each element (thePropertyEditorhas to create the element type), depending on the specified required type.Note: Only one single registered custom editor per property path is supported. In the case of a Collection/array, do not register an editor for both the Collection/array and each element on the same property. For example, if you wanted to register an editor for "items[n].quantity" (for all values n), you would use "items.quantity" as the value of the 'propertyPath' argument to this method. - Specified by:
- registerCustomEditorin interface- PropertyEditorRegistry
- Parameters:
- requiredType- the type of the property. This may be- nullif a property is given but should be specified in any case, in particular in case of a Collection - making clear whether the editor is supposed to apply to the entire Collection itself or to each of its entries. So as a general rule: Do not specify- nullhere in case of a Collection/array!
- propertyPath- the path of the property (name or nested path), or- nullif registering an editor for all properties of the given type
- propertyEditor- editor to register
 
- 
findCustomEditor@Nullable public PropertyEditor findCustomEditor(@Nullable Class<?> requiredType, @Nullable String propertyPath) Description copied from interface:PropertyEditorRegistryFind a custom property editor for the given type and property.- Specified by:
- findCustomEditorin interface- PropertyEditorRegistry
- Parameters:
- requiredType- the type of the property (can be- nullif a property is given but should be specified in any case for consistency checking)
- propertyPath- the path of the property (name or nested path), or- nullif looking for an editor for all properties of the given type
- Returns:
- the registered editor, or nullif none
 
- 
hasCustomEditorForElementpublic boolean hasCustomEditorForElement(@Nullable Class<?> elementType, @Nullable String propertyPath) Determine whether this registry contains a custom editor for the specified array/collection element.- Parameters:
- elementType- the target type of the element (can be- nullif not known)
- propertyPath- the property path (typically of the array/collection; can be- nullif not known)
- Returns:
- whether a matching custom editor has been found
 
- 
getPropertyTypeDetermine the property type for the given property path.Called by 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.- Parameters:
- propertyPath- the property path to determine the type for
- Returns:
- the type of the property, or nullif not determinable
- See Also:
 
- 
guessPropertyTypeFromEditorsGuess the property type of the specified property from the registered custom editors (provided that they were registered for a specific type).- Parameters:
- propertyName- the name of the property
- Returns:
- the property type, or nullif not determinable
 
- 
copyCustomEditorsToCopy the custom editors registered in this instance to the given target registry.- Parameters:
- target- the target registry to copy to
- nestedProperty- the nested property path of the target registry, if any. If this is non-null, only editors registered for a path below this nested property will be copied. If this is null, all editors will be copied.
 
 
-