Package org.springframework.format.support

# Class FormattingConversionService

java.lang.Object
org.springframework.core.convert.support.GenericConversionService
org.springframework.format.support.FormattingConversionService

All Implemented Interfaces:
  `org.springframework.beans.factory.Aware`, `EmbeddedValueResolverAware`, `org.springframework.core.convert.ConversionService`, `org.springframework.core.convert.converter.ConverterRegistry`, `org.springframework.core.convert.support.ConfigurableConversionService`, `FormatterRegistry`

Direct Known Subclasses:
  `DefaultFormattingConversionService`

public class FormattingConversionService extends org.springframework.core.convert.support.GenericConversionService implements FormatterRegistry, EmbeddedValueResolverAware
A `ConversionService` implementation designed to be configured as a `FormatterRegistry`.

Since:
  3.0
Author:
  Keith Donald, Juergen Hoeller

## Constructor Summary

Constructors
Constructor
Description
`FormattingConversionService()`

## Method Summary

Modifier and Type
Method
Description
`void`
`addFormatter(Formatter<?> formatter)`
Adds a Formatter to format fields of a specific type.
`void`
`addFormatterForFieldAnnotation(AnnotationFormatterFactory<? extends Annotation> annotationFormatterFactory)`
Adds a Formatter to format fields annotated with a specific format annotation.
`void`
`addFormatterForFieldType(Class<?> fieldType, Formatter<?> formatter)`
Adds a Formatter to format fields of the given type.
`void`
`addFormatterForFieldType(Class<?> fieldType, Printer<?> printer, Parser<?> parser)`
Adds a Printer/Parser pair to format fields of a specific type.
`void`
`addParser(Parser<?> parser)`
Adds a Parser to parse fields of a specific type.
`void`
`addPrinter(Printer<?> printer)`
Adds a Printer to print fields of a specific type.
`void`
`setEmbeddedValueResolver(org.springframework.util.StringValueResolver resolver)`
Set the StringValueResolver to use for resolving embedded definition values.

### Methods inherited from class org.springframework.core.convert.support.GenericConversionService

`addConverter, addConverter, addConverter, addConverterFactory, canBypassConvert, 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`

### Methods inherited from interface org.springframework.core.convert.ConversionService

`convert`

### Methods inherited from interface org.springframework.core.convert.converter.ConverterRegistry

`addConverter, addConverter, addConverter, addConverterFactory, removeConvertible`

## Constructor Details

### FormattingConversionService

public FormattingConversionService()

## Method Details

### setEmbeddedValueResolver

public void setEmbeddedValueResolver(org.springframework.util.StringValueResolver resolver)
Description copied from interface: `EmbeddedValueResolverAware`
Set the StringValueResolver to use for resolving embedded definition values.

Specified by:
  `setEmbeddedValueResolver` in interface `EmbeddedValueResolverAware`

### addPrinter

public void addPrinter(Printer<?> printer)
Description copied from interface: `FormatterRegistry`
Adds a Printer to print fields of a specific type. The field type is implied by the parameterized Printer instance.

Specified by:
  `addPrinter` in interface `FormatterRegistry`
Parameters:
  `printer` - the printer to add
See Also:
  - `FormatterRegistry.addFormatter(Formatter)`

### addParser

public void addParser(Parser<?> parser)
Description copied from interface: `FormatterRegistry`
Adds a Parser to parse fields of a specific type. The field type is implied by the parameterized Parser instance.

Specified by:
  `addParser` in interface `FormatterRegistry`
Parameters:
  `parser` - the parser to add
See Also:
  - `FormatterRegistry.addFormatter(Formatter)`

### addFormatter

public void addFormatter(Formatter<?> formatter)
Description copied from interface: `FormatterRegistry`
Adds a Formatter to format fields of a specific type. The field type is implied by the parameterized Formatter instance.

Specified by:
  `addFormatter` in interface `FormatterRegistry`
Parameters:
  `formatter` - the formatter to add
See Also:
  - `FormatterRegistry.addFormatterForFieldType(Class, Formatter)`

### addFormatterForFieldType

public void addFormatterForFieldType(Class<?> fieldType, Formatter<?> formatter)
Description copied from interface: `FormatterRegistry`
Adds a Formatter to format fields of the given type.

On print, if the Formatter's type T is declared and `fieldType` is not assignable to T, a coercion 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 coercion 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 format
  `formatter` - the formatter to add

### addFormatterForFieldType

public void addFormatterForFieldType(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 coercion 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 coercion 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 format
  `printer` - the printing part of the formatter
  `parser` - the parsing part of the formatter

### addFormatterForFieldAnnotation

public void addFormatterForFieldAnnotation(AnnotationFormatterFactory<? extends Annotation> 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