类 ApplicationConversionService

java.lang.Object
cn.taketoday.core.conversion.support.GenericConversionService
cn.taketoday.format.support.FormattingConversionService
cn.taketoday.format.support.ApplicationConversionService
所有已实现的接口:
Aware, EmbeddedValueResolverAware, cn.taketoday.core.conversion.ConversionService, cn.taketoday.core.conversion.ConverterRegistry, cn.taketoday.core.conversion.support.ConfigurableConversionService, FormatterRegistry

public class ApplicationConversionService extends FormattingConversionService
A specialization of FormattingConversionService configured by default with converters and formatters appropriate for most applications.

Designed for direct instantiation but also exposes the static addApplicationConverters(cn.taketoday.core.conversion.ConverterRegistry) and addApplicationFormatters(FormatterRegistry) utility methods for ad-hoc use against registry instance.

从以下版本开始:
4.0
作者:
Phillip Webb, Harry Yang
  • 构造器详细资料

    • ApplicationConversionService

      public ApplicationConversionService()
    • ApplicationConversionService

      public ApplicationConversionService(@Nullable cn.taketoday.core.StringValueResolver embeddedValueResolver)
  • 方法详细资料

    • addPrinter

      public void addPrinter(Printer<?> printer)
      从接口复制的说明: FormatterRegistry
      Adds a Printer to print fields of a specific type. The field type is implied by the parameterized Printer instance.
      指定者:
      addPrinter 在接口中 FormatterRegistry
      覆盖:
      addPrinter 在类中 FormattingConversionService
      参数:
      printer - the printer to add
      另请参阅:
    • addParser

      public void addParser(Parser<?> parser)
      从接口复制的说明: FormatterRegistry
      Adds a Parser to parse fields of a specific type. The field type is implied by the parameterized Parser instance.
      指定者:
      addParser 在接口中 FormatterRegistry
      覆盖:
      addParser 在类中 FormattingConversionService
      参数:
      parser - the parser to add
      另请参阅:
    • addFormatter

      public void addFormatter(Formatter<?> formatter)
      从接口复制的说明: FormatterRegistry
      Adds a Formatter to format fields of a specific type. The field type is implied by the parameterized Formatter instance.
      指定者:
      addFormatter 在接口中 FormatterRegistry
      覆盖:
      addFormatter 在类中 FormattingConversionService
      参数:
      formatter - the formatter to add
      另请参阅:
    • addFormatterForFieldType

      public void addFormatterForFieldType(Class<?> fieldType, Formatter<?> formatter)
      从接口复制的说明: 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.

      指定者:
      addFormatterForFieldType 在接口中 FormatterRegistry
      覆盖:
      addFormatterForFieldType 在类中 FormattingConversionService
      参数:
      fieldType - the field type to format
      formatter - the formatter to add
    • addConverter

      public void addConverter(cn.taketoday.core.conversion.Converter<?,?> converter)
      指定者:
      addConverter 在接口中 cn.taketoday.core.conversion.ConverterRegistry
      覆盖:
      addConverter 在类中 cn.taketoday.core.conversion.support.GenericConversionService
    • addFormatterForFieldType

      public void addFormatterForFieldType(Class<?> fieldType, Printer<?> printer, Parser<?> parser)
      从接口复制的说明: 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.

      指定者:
      addFormatterForFieldType 在接口中 FormatterRegistry
      覆盖:
      addFormatterForFieldType 在类中 FormattingConversionService
      参数:
      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)
      从接口复制的说明: FormatterRegistry
      Adds a Formatter to format fields annotated with a specific format annotation.
      指定者:
      addFormatterForFieldAnnotation 在接口中 FormatterRegistry
      覆盖:
      addFormatterForFieldAnnotation 在类中 FormattingConversionService
      参数:
      annotationFormatterFactory - the annotation formatter factory to add
    • addConverter

      public <S, T> void addConverter(Class<S> sourceType, Class<T> targetType, cn.taketoday.core.conversion.Converter<? super S,? extends T> converter)
      指定者:
      addConverter 在接口中 cn.taketoday.core.conversion.ConverterRegistry
      覆盖:
      addConverter 在类中 cn.taketoday.core.conversion.support.GenericConversionService
    • addConverter

      public void addConverter(cn.taketoday.core.conversion.GenericConverter converter)
      指定者:
      addConverter 在接口中 cn.taketoday.core.conversion.ConverterRegistry
      覆盖:
      addConverter 在类中 cn.taketoday.core.conversion.support.GenericConversionService
    • addConverterFactory

      public void addConverterFactory(cn.taketoday.core.conversion.ConverterFactory<?,?> factory)
      指定者:
      addConverterFactory 在接口中 cn.taketoday.core.conversion.ConverterRegistry
      覆盖:
      addConverterFactory 在类中 cn.taketoday.core.conversion.support.GenericConversionService
    • removeConvertible

      public void removeConvertible(Class<?> sourceType, Class<?> targetType)
      指定者:
      removeConvertible 在接口中 cn.taketoday.core.conversion.ConverterRegistry
      覆盖:
      removeConvertible 在类中 cn.taketoday.core.conversion.support.GenericConversionService
    • isConvertViaObjectSourceType

      public boolean isConvertViaObjectSourceType(cn.taketoday.core.TypeDescriptor sourceType, cn.taketoday.core.TypeDescriptor targetType)
      Return true if objects of sourceType can be converted to the targetType and the converter has Object.class as a supported source type.
      参数:
      sourceType - the source type to test
      targetType - the target type to test
      返回:
      if conversion happens via an ObjectTo... converter
    • getSharedInstance

      public static cn.taketoday.core.conversion.ConversionService getSharedInstance()
      Return a shared default application ConversionService instance, lazily building it once needed.

      Note: This method actually returns an ApplicationConversionService instance. However, the ConversionService signature has been preserved for binary compatibility.

      返回:
      the shared ApplicationConversionService instance (never null)
    • configure

      public static void configure(FormatterRegistry registry)
      Configure the given FormatterRegistry with formatters and converters appropriate for most applications.
      参数:
      registry - the registry of converters to add to (must also be castable to ConversionService, e.g. being a ConfigurableConversionService)
      抛出:
      ClassCastException - if the given FormatterRegistry could not be cast to a ConversionService
    • addApplicationConverters

      public static void addApplicationConverters(cn.taketoday.core.conversion.ConverterRegistry registry)
      Add converters useful for most applications.
      参数:
      registry - the registry of converters to add to (must also be castable to ConversionService, e.g. being a ConfigurableConversionService)
      抛出:
      ClassCastException - if the given ConverterRegistry could not be cast to a ConversionService
    • addDelimitedStringConverters

      public static void addDelimitedStringConverters(cn.taketoday.core.conversion.ConverterRegistry registry)
      Add converters to support delimited strings.
      参数:
      registry - the registry of converters to add to (must also be castable to ConversionService, e.g. being a ConfigurableConversionService)
      抛出:
      ClassCastException - if the given ConverterRegistry could not be cast to a ConversionService
    • addApplicationFormatters

      public static void addApplicationFormatters(FormatterRegistry registry)
      Add formatters useful for most applications.
      参数:
      registry - the service to register default formatters with
    • addBeans

      public static void addBeans(FormatterRegistry registry, BeanFactory beanFactory)
      Add GenericConverter, Converter, Printer, Parser and Formatter beans from the specified context.
      参数:
      registry - the service to register beans with
      beanFactory - the bean factory to get the beans from