Top Description Inners Fields Constructors Methods
org.springframework.beans

public Class PropertyEditorRegistrySupport

extends Object
implements PropertyEditorRegistry
Class Inheritance
All Implemented Interfaces
org.springframework.beans.PropertyEditorRegistry
Known Direct Subclasses
org.springframework.beans.TypeConverterSupport
Imports
java.beans.PropertyEditor, java.io.File, .InputStream, .Reader, java.math.BigDecimal, .BigInteger, java.net.URI, .URL, java.nio.charset.Charset, java.nio.file.Path, java.time.ZoneId, java.util.ArrayList, .Collection, .Currency, .HashMap, .Iterator, .LinkedHashMap, .List, .Locale, .Map, .Properties, .Set, .SortedMap, .SortedSet, .TimeZone, .UUID, java.util.regex.Pattern, org.xml.sax.InputSource, org.springframework.beans.propertyeditors.ByteArrayPropertyEditor, .CharArrayPropertyEditor, .CharacterEditor, .CharsetEditor, .ClassArrayEditor, .ClassEditor, .CurrencyEditor, .CustomBooleanEditor, .CustomCollectionEditor, .CustomMapEditor, .CustomNumberEditor, .FileEditor, .InputSourceEditor, .InputStreamEditor, .LocaleEditor, .PathEditor, .PatternEditor, .PropertiesEditor, .ReaderEditor, .StringArrayPropertyEditor, .TimeZoneEditor, .URIEditor, .URLEditor, .UUIDEditor, .ZoneIdEditor, org.springframework.core.convert.ConversionService, org.springframework.core.io.Resource, org.springframework.core.io.support.ResourceArrayPropertyEditor, org.springframework.lang.Nullable, org.springframework.util.ClassUtils

Base implementation of the PropertyEditorRegistry interface. Provides management of default editors and custom editors. Mainly serves as base class for BeanWrapperImpl.
Authors
Juergen Hoeller, Rob Harrop, Sebastien Deleuze
Since
1.2.6
See Also
java.beans.PropertyEditorManager, java.beans.PropertyEditorSupport#setAsText, java.beans.PropertyEditorSupport#setValue

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
PropertyEditorRegistrySupport.CustomEditorHolder

Holder for a registered custom editor with property name.

Field Summary

Modifier and TypeField and Description
private boolean
private ConversionService
private Map<Class<?>, PropertyEditor>
private Map<Class<?>, PropertyEditor>
private Map<String, PropertyEditorRegistrySupport.CustomEditorHolder>
private Map<Class<?>, PropertyEditor>
private boolean
private Map<Class<?>, PropertyEditor>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
addStrippedPropertyPaths(List<String>
the result list to add to
strippedPaths
,
String
the current nested path
nestedPath
,
String
the property path to check for keys/indexes to strip
propertyPath
)

Add property paths with all variations of stripped keys and/or indexes.

protected void
copyCustomEditorsTo(PropertyEditorRegistry
the target registry to copy to
target
,
String
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.
nestedProperty
)

Copy the custom editors registered in this instance to the given target registry.

protected void
copyDefaultEditorsTo(PropertyEditorRegistrySupport
the target registry to copy to
target
)

Copy the default editors registered in this instance to the given target registry.

private void
createDefaultEditors()

Actually register the default editors for this registry instance.

public PropertyEditor
findCustomEditor(Class<?>
the type of the property (can be null if a property is given but should be specified in any case for consistency checking)
requiredType
,
String
the path of the property (name or nested path), or null if looking for an editor for all properties of the given type
propertyPath
)

Implements org.springframework.beans.PropertyEditorRegistry.findCustomEditor.

Find a custom property editor for the given type and property.
public ConversionService
getConversionService()

Return the associated ConversionService, if any.

private PropertyEditor

Returns:

the custom editor, or null if none specific for this property
getCustomEditor
(String
the property path to look for
propertyName
,
Class<?>
the type to look for
requiredType
)

Get custom editor that has been registered for the given property.

private PropertyEditor

Returns:

the custom editor, or null if none found for this type
getCustomEditor
(Class<?>
the type to look for
requiredType
)

Get custom editor for the given type.

public PropertyEditor

Returns:

the default editor, or null if none found
getDefaultEditor
(Class<?>
type of the property
requiredType
)

Retrieve the default editor for the given property type, if any.

protected Class<?>

Returns:

the type of the property, or null if not determinable
getPropertyType
(String
the property path to determine the type for
propertyPath
)

Determine the property type for the given property path.

protected Class<?>

Returns:

the property type, or null if not determinable
guessPropertyTypeFromEditors
(String
the name of the property
propertyName
)

Guess the property type of the specified property from the registered custom editors (provided that they were registered for a specific type).

public boolean

Returns:

whether a matching custom editor has been found
hasCustomEditorForElement
(Class<?>
the target type of the element (can be null if not known)
elementType
,
String
the property path (typically of the array/collection; can be null if not known)
propertyPath
)

Determine whether this registry contains a custom editor for the specified array/collection element.

public void
overrideDefaultEditor(Class<?>
the type of the property
requiredType
,
PropertyEditor
the editor to register
propertyEditor
)

Override the default editor for the specified type with the given property editor.

public void
registerCustomEditor(Class<?>
the type of the property
requiredType
,
PropertyEditor
the editor to register
propertyEditor
)

Implements org.springframework.beans.PropertyEditorRegistry.registerCustomEditor.

Register the given custom property editor for all properties of the given type.
public void
registerCustomEditor(Class<?>
the type of the property. This may be null if 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 null here in case of a Collection/array!
requiredType
,
String
the path of the property (name or nested path), or null if registering an editor for all properties of the given type
propertyPath
,
PropertyEditor
editor to register
propertyEditor
)

Implements org.springframework.beans.PropertyEditorRegistry.registerCustomEditor.

Register the given custom property editor for the given type and property, or for all properties of the given type.
protected void
registerDefaultEditors()

Activate the default editors for this registry instance, allowing for lazily registering default editors when needed.

public void
setConversionService(ConversionService conversionService)

Specify a ConversionService to use for converting property values, as an alternative to JavaBeans PropertyEditors.

public void
useConfigValueEditors()

Activate config value editors which are only intended for configuration purposes, such as org.springframework.beans.propertyeditors.StringArrayPropertyEditor.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

configValueEditorsActiveback to summary
private boolean configValueEditorsActive
conversionServiceback to summary
private ConversionService conversionService
Annotations
@Nullable
customEditorCacheback to summary
private Map<Class<?>, PropertyEditor> customEditorCache
Annotations
@Nullable
customEditorsback to summary
private Map<Class<?>, PropertyEditor> customEditors
Annotations
@Nullable
customEditorsForPathback to summary
private Map<String, PropertyEditorRegistrySupport.CustomEditorHolder> customEditorsForPath
Annotations
@Nullable
defaultEditorsback to summary
private Map<Class<?>, PropertyEditor> defaultEditors
Annotations
@Nullable
defaultEditorsActiveback to summary
private boolean defaultEditorsActive
overriddenDefaultEditorsback to summary
private Map<Class<?>, PropertyEditor> overriddenDefaultEditors
Annotations
@Nullable

Constructor Detail

PropertyEditorRegistrySupportback to summary
public PropertyEditorRegistrySupport()

Method Detail

addStrippedPropertyPathsback to summary
private void addStrippedPropertyPaths(List<String> strippedPaths, String nestedPath, String propertyPath)

Add property paths with all variations of stripped keys and/or indexes. Invokes itself recursively with nested paths.

Parameters
strippedPaths:List<String>

the result list to add to

nestedPath:String

the current nested path

propertyPath:String

the property path to check for keys/indexes to strip

copyCustomEditorsToback to summary
protected void copyCustomEditorsTo(PropertyEditorRegistry target, String nestedProperty)

Copy the custom editors registered in this instance to the given target registry.

Parameters
target:PropertyEditorRegistry

the target registry to copy to

nestedProperty:String

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.

copyDefaultEditorsToback to summary
protected void copyDefaultEditorsTo(PropertyEditorRegistrySupport target)

Copy the default editors registered in this instance to the given target registry.

Parameters
target:PropertyEditorRegistrySupport

the target registry to copy to

createDefaultEditorsback to summary
private void createDefaultEditors()

Actually register the default editors for this registry instance.

findCustomEditorback to summary
public PropertyEditor findCustomEditor(Class<?> requiredType, String propertyPath)

Implements org.springframework.beans.PropertyEditorRegistry.findCustomEditor.

Doc from org.springframework.beans.PropertyEditorRegistry.findCustomEditor.

Find a custom property editor for the given type and property.

Parameters
requiredType:Class<?>

the type of the property (can be null if a property is given but should be specified in any case for consistency checking)

propertyPath:String

the path of the property (name or nested path), or null if looking for an editor for all properties of the given type

Returns:PropertyEditor

the registered editor, or null if none

Annotations
@Override
@Nullable
getConversionServiceback to summary
public ConversionService getConversionService()

Return the associated ConversionService, if any.

Annotations
@Nullable
getCustomEditorback to summary
private PropertyEditor getCustomEditor(String propertyName, Class<?> requiredType)

Get custom editor that has been registered for the given property.

Parameters
propertyName:String

the property path to look for

requiredType:Class<?>

the type to look for

Returns:PropertyEditor

the custom editor, or null if none specific for this property

Annotations
@Nullable
getCustomEditorback to summary
private PropertyEditor getCustomEditor(Class<?> requiredType)

Get custom editor for the given type. If no direct match found, try custom editor for superclass (which will in any case be able to render a value as String via getAsText).

Parameters
requiredType:Class<?>

the type to look for

Returns:PropertyEditor

the custom editor, or null if none found for this type

Annotations
@Nullable
See Also
java.beans.PropertyEditor#getAsText()
getDefaultEditorback to summary
public PropertyEditor getDefaultEditor(Class<?> requiredType)

Retrieve the default editor for the given property type, if any.

Lazily registers the default editors, if they are active.

Parameters
requiredType:Class<?>

type of the property

Returns:PropertyEditor

the default editor, or null if none found

Annotations
@Nullable
See Also
registerDefaultEditors
getPropertyTypeback to summary
protected Class<?> getPropertyType(String propertyPath)

Determine the property type for the given property path.

Called by findCustomEditor 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 standard getPropertyType method as defined by the BeanWrapper interface.

Parameters
propertyPath:String

the property path to determine the type for

Returns:Class<?>

the type of the property, or null if not determinable

Annotations
@Nullable
See Also
BeanWrapper#getPropertyType(String)
guessPropertyTypeFromEditorsback to summary
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).

Parameters
propertyName:String

the name of the property

Returns:Class<?>

the property type, or null if not determinable

Annotations
@Nullable
hasCustomEditorForElementback to summary
public boolean hasCustomEditorForElement(Class<?> elementType, String propertyPath)

Determine whether this registry contains a custom editor for the specified array/collection element.

Parameters
elementType:Class<?>

the target type of the element (can be null if not known)

propertyPath:String

the property path (typically of the array/collection; can be null if not known)

Returns:boolean

whether a matching custom editor has been found

overrideDefaultEditorback to summary
public void overrideDefaultEditor(Class<?> requiredType, PropertyEditor propertyEditor)

Override 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:Class<?>

the type of the property

propertyEditor:PropertyEditor

the editor to register

See Also
registerCustomEditor(Class, PropertyEditor)
registerCustomEditorback to summary
public void registerCustomEditor(Class<?> requiredType, PropertyEditor propertyEditor)

Implements org.springframework.beans.PropertyEditorRegistry.registerCustomEditor.

Doc from org.springframework.beans.PropertyEditorRegistry.registerCustomEditor.

Register the given custom property editor for all properties of the given type.

Parameters
requiredType:Class<?>

the type of the property

propertyEditor:PropertyEditor

the editor to register

Annotations
@Override
registerCustomEditorback to summary
public void registerCustomEditor(Class<?> requiredType, String propertyPath, PropertyEditor propertyEditor)

Implements org.springframework.beans.PropertyEditorRegistry.registerCustomEditor.

Doc from org.springframework.beans.PropertyEditorRegistry.registerCustomEditor.

Register 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 PropertyEditor has to create an array or Collection value) or to each element (the PropertyEditor has 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.

Parameters
requiredType:Class<?>

the type of the property. This may be null if 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 null here in case of a Collection/array!

propertyPath:String

the path of the property (name or nested path), or null if registering an editor for all properties of the given type

propertyEditor:PropertyEditor

editor to register

Annotations
@Override
registerDefaultEditorsback to summary
protected void registerDefaultEditors()

Activate the default editors for this registry instance, allowing for lazily registering default editors when needed.

setConversionServiceback to summary
public void setConversionService(ConversionService conversionService)

Specify a ConversionService to use for converting property values, as an alternative to JavaBeans PropertyEditors.

useConfigValueEditorsback to summary
public void useConfigValueEditors()

Activate config value editors which are only intended for configuration purposes, such as org.springframework.beans.propertyeditors.StringArrayPropertyEditor.

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.

org.springframework.beans back to summary

private final Class PropertyEditorRegistrySupport.CustomEditorHolder

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.beans.PropertyEditorRegistrySupport.CustomEditorHolder

Holder for a registered custom editor with property name. Keeps the PropertyEditor itself plus the type it was registered for.

Field Summary

Modifier and TypeField and Description
private final PropertyEditor
private final Class<?>

Constructor Summary

AccessConstructor and Description
private
CustomEditorHolder(PropertyEditor propertyEditor, Class<?> registeredType)

Method Summary

Modifier and TypeMethod and Description
private PropertyEditor
private PropertyEditor
getPropertyEditor(Class<?> requiredType)

private Class<?>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

propertyEditorback to summary
private final PropertyEditor propertyEditor
registeredTypeback to summary
private final Class<?> registeredType
Annotations
@Nullable

Constructor Detail

CustomEditorHolderback to summary
private CustomEditorHolder(PropertyEditor propertyEditor, Class<?> registeredType)

Method Detail

getPropertyEditorback to summary
private PropertyEditor getPropertyEditor()
getPropertyEditorback to summary
private PropertyEditor getPropertyEditor(Class<?> requiredType)
Annotations
@Nullable
getRegisteredTypeback to summary
private Class<?> getRegisteredType()
Annotations
@Nullable