org.springframework.format.support
Class FormattingConversionService
java.lang.Object
org.springframework.core.convert.support.GenericConversionService
org.springframework.format.support.FormattingConversionService
- All Implemented Interfaces:
- EmbeddedValueResolverAware, ConversionService, ConverterRegistry, FormatterRegistry
public class FormattingConversionService
- extends GenericConversionService
- implements FormatterRegistry, EmbeddedValueResolverAware
A ConversionService implementation
designed to be configured as a FormatterRegistry.
- Since:
- 3.0
- Author:
- Keith Donald, Juergen Hoeller
| Methods inherited from class org.springframework.core.convert.support.GenericConversionService |
addConverter, addConverter, addConverterFactory, canConvert, canConvert, convert, convert, convertNullSource, getConverter, getDefaultConverter, removeConvertible, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
embeddedValueResolver
private StringValueResolver embeddedValueResolver
cachedPrinters
private final java.util.Map<FormattingConversionService.FieldFormatterKey,GenericConverter> cachedPrinters
cachedParsers
private final java.util.Map<FormattingConversionService.FieldFormatterKey,GenericConverter> cachedParsers
FormattingConversionService
public FormattingConversionService()
setEmbeddedValueResolver
public void setEmbeddedValueResolver(StringValueResolver resolver)
- Description copied from interface:
EmbeddedValueResolverAware
- Set the StringValueResolver to use for resolving embedded definition values.
- Specified by:
setEmbeddedValueResolver in interface EmbeddedValueResolverAware
addFormatter
public void addFormatter(Formatter<?> formatter)
addFormatterForFieldType
public void addFormatterForFieldType(java.lang.Class<?> fieldType,
Formatter<?> formatter)
- Description copied from interface:
FormatterRegistry
- Adds a Formatter to format fields of a specific type.
On print, if the Formatter's type T is declared and fieldType is not assignable to T,
a coersion to T will be attempted before delegating to formatter to print a field value.
On parse, if the parsed object returned by formatter is not assignable to the runtime field type,
a coersion to the field type will be attempted before returning the parsed field value.
- Specified by:
addFormatterForFieldType in interface FormatterRegistry
- Parameters:
fieldType - the field type to formatformatter - the formatter to add
addFormatterForFieldType
public void addFormatterForFieldType(java.lang.Class<?> fieldType,
Printer<?> printer,
Parser<?> parser)
- Description copied from interface:
FormatterRegistry
- Adds a Printer/Parser pair to format fields of a specific type.
The formatter will delegate to the specified
printer for printing
and the specified parser for parsing.
On print, if the Printer's type T is declared and fieldType is not assignable to T,
a coersion to T will be attempted before delegating to printer to print a field value.
On parse, if the object returned by the Parser is not assignable to the runtime field type,
a coersion to the field type will be attempted before returning the parsed field value.
- Specified by:
addFormatterForFieldType in interface FormatterRegistry
- Parameters:
fieldType - the field type to formatprinter - the printing part of the formatterparser - the parsing part of the formatter
addFormatterForFieldAnnotation
public void addFormatterForFieldAnnotation(AnnotationFormatterFactory annotationFormatterFactory)
- Description copied from interface:
FormatterRegistry
- Adds a Formatter to format fields annotated with a specific format annotation.
- Specified by:
addFormatterForFieldAnnotation in interface FormatterRegistry
- Parameters:
annotationFormatterFactory - the annotation formatter factory to add