Package org.springframework.validation
Class AbstractPropertyBindingResult
- java.lang.Object
- org.springframework.validation.AbstractErrors
- org.springframework.validation.AbstractBindingResult
- org.springframework.validation.AbstractPropertyBindingResult
- All Implemented Interfaces:
Serializable,BindingResult,Errors
- Direct Known Subclasses:
BeanPropertyBindingResult,DirectFieldBindingResult
public abstract class AbstractPropertyBindingResult extends AbstractBindingResult
Abstract base class forBindingResultimplementations that work with Spring'sPropertyAccessormechanism. Pre-implements field access through delegation to the corresponding PropertyAccessor methods.- Since:
- 2.0
- Author:
- Juergen Hoeller
- See Also:
getPropertyAccessor(),PropertyAccessor,ConfigurablePropertyAccessor, Serialized Form
Field Summary
Fields inherited from interface org.springframework.validation.BindingResult
MODEL_KEY_PREFIX
Fields inherited from interface org.springframework.validation.Errors
NESTED_PATH_SEPARATOR
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractPropertyBindingResult(String objectName)Create a new AbstractPropertyBindingResult instance.
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected StringcanonicalFieldName(String field)Returns the canonical property name.PropertyEditorfindEditor(String field, Class<?> valueType)This implementation exposes a PropertyEditor adapter for a Formatter, if applicable.protected ObjectformatFieldValue(String field, Object value)Formats the field value based on registered PropertyEditors.protected ObjectgetActualFieldValue(String field)Fetches the field value from the PropertyAccessor.protected PropertyEditorgetCustomEditor(String fixedField)Retrieve the custom PropertyEditor for the given field, if any.Class<?>getFieldType(String field)Determines the field type from the property type.abstract ConfigurablePropertyAccessorgetPropertyAccessor()Provide the PropertyAccessor to work with, according to the concrete strategy of access.PropertyEditorRegistrygetPropertyEditorRegistry()Returns the underlying PropertyAccessor.voidinitConversion(ConversionService conversionService)Methods inherited from class org.springframework.validation.AbstractBindingResult
addAllErrors, addError, equals, getAllErrors, getErrorCount, getFieldError, getFieldError, getFieldErrors, getFieldErrors, getFieldValue, getGlobalError, getGlobalErrors, getMessageCodesResolver, getModel, getObjectName, getRawFieldValue, getSuppressedFields, getTarget, hasErrors, hashCode, recordSuppressedField, reject, rejectValue, resolveMessageCodes, resolveMessageCodes, setMessageCodesResolver
Methods inherited from class org.springframework.validation.AbstractErrors
doSetNestedPath, fixedField, getFieldErrorCount, getFieldErrorCount, getGlobalErrorCount, getNestedPath, hasFieldErrors, hasFieldErrors, hasGlobalErrors, isMatchingFieldError, popNestedPath, pushNestedPath, reject, reject, rejectValue, rejectValue, setNestedPath, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.validation.Errors
getFieldErrorCount, getFieldErrorCount, getGlobalErrorCount, getNestedPath, hasFieldErrors, hasFieldErrors, hasGlobalErrors, popNestedPath, pushNestedPath, reject, reject, rejectValue, rejectValue, setNestedPath
Constructor Detail
AbstractPropertyBindingResult
protected AbstractPropertyBindingResult(String objectName)
Create a new AbstractPropertyBindingResult instance.- Parameters:
objectName- the name of the target object- See Also:
DefaultMessageCodesResolver
Method Detail
initConversion
public void initConversion(ConversionService conversionService)
getPropertyEditorRegistry
public PropertyEditorRegistry getPropertyEditorRegistry()
Returns the underlying PropertyAccessor.- Specified by:
getPropertyEditorRegistryin interfaceBindingResult- Overrides:
getPropertyEditorRegistryin classAbstractBindingResult- Returns:
- the PropertyEditorRegistry, or
nullif none available for this BindingResult - See Also:
getPropertyAccessor()
canonicalFieldName
protected String canonicalFieldName(String field)
Returns the canonical property name.- Overrides:
canonicalFieldNamein classAbstractErrors- Parameters:
field- the original field name- Returns:
- the canonical field name
- See Also:
PropertyAccessorUtils.canonicalPropertyName(java.lang.String)
getFieldType
public Class<?> getFieldType(String field)
Determines the field type from the property type.- Specified by:
getFieldTypein interfaceErrors- Overrides:
getFieldTypein classAbstractBindingResult- Parameters:
field- the field name- Returns:
- the type of the field, or
nullif not determinable - See Also:
getPropertyAccessor()
getActualFieldValue
protected Object getActualFieldValue(String field)
Fetches the field value from the PropertyAccessor.- Specified by:
getActualFieldValuein classAbstractBindingResult- Parameters:
field- the field to check- Returns:
- the current value of the field
- See Also:
getPropertyAccessor()
formatFieldValue
protected Object formatFieldValue(String field, Object value)
Formats the field value based on registered PropertyEditors.- Overrides:
formatFieldValuein classAbstractBindingResult- Parameters:
field- the field to checkvalue- the value of the field (either a rejected value other than from a binding error, or an actual field value)- Returns:
- the formatted value
- See Also:
getCustomEditor(java.lang.String)
getCustomEditor
protected PropertyEditor getCustomEditor(String fixedField)
Retrieve the custom PropertyEditor for the given field, if any.- Parameters:
fixedField- the fully qualified field name- Returns:
- the custom PropertyEditor, or
null
findEditor
public PropertyEditor findEditor(String field, Class<?> valueType)
This implementation exposes a PropertyEditor adapter for a Formatter, if applicable.- Specified by:
findEditorin interfaceBindingResult- Overrides:
findEditorin classAbstractBindingResult- Parameters:
field- the path of the property (name or nested path), ornullif looking for an editor for all properties of the given typevalueType- the type of the property (can benullif a property is given but should be specified in any case for consistency checking)- Returns:
- the registered editor, or
nullif none
getPropertyAccessor
public abstract ConfigurablePropertyAccessor getPropertyAccessor()
Provide the PropertyAccessor to work with, according to the concrete strategy of access.Note that a PropertyAccessor used by a BindingResult should always have its "extractOldValueForEditor" flag set to "true" by default, since this is typically possible without side effects for model objects that serve as data binding target.