类 ApplicationConversionService
- 所有已实现的接口:
Aware,EmbeddedValueResolverAware,cn.taketoday.core.conversion.ConversionService,cn.taketoday.core.conversion.ConverterRegistry,cn.taketoday.core.conversion.support.ConfigurableConversionService,FormatterRegistry
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
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static voidaddApplicationConverters(cn.taketoday.core.conversion.ConverterRegistry registry) Add converters useful for most applications.static voidaddApplicationFormatters(FormatterRegistry registry) Add formatters useful for most applications.static voidaddBeans(FormatterRegistry registry, BeanFactory beanFactory) voidaddConverter(cn.taketoday.core.conversion.Converter<?, ?> converter) voidaddConverter(cn.taketoday.core.conversion.GenericConverter converter) <S,T> void addConverter(Class<S> sourceType, Class<T> targetType, cn.taketoday.core.conversion.Converter<? super S, ? extends T> converter) voidaddConverterFactory(cn.taketoday.core.conversion.ConverterFactory<?, ?> factory) static voidaddDelimitedStringConverters(cn.taketoday.core.conversion.ConverterRegistry registry) Add converters to support delimited strings.voidaddFormatter(Formatter<?> formatter) Adds a Formatter to format fields of a specific type.voidaddFormatterForFieldAnnotation(AnnotationFormatterFactory<? extends Annotation> annotationFormatterFactory) Adds a Formatter to format fields annotated with a specific format annotation.voidaddFormatterForFieldType(Class<?> fieldType, Formatter<?> formatter) Adds a Formatter to format fields of the given type.voidaddFormatterForFieldType(Class<?> fieldType, Printer<?> printer, Parser<?> parser) Adds a Printer/Parser pair to format fields of a specific type.voidAdds a Parser to parse fields of a specific type.voidaddPrinter(Printer<?> printer) Adds a Printer to print fields of a specific type.static voidconfigure(FormatterRegistry registry) Configure the givenFormatterRegistrywith formatters and converters appropriate for most applications.static cn.taketoday.core.conversion.ConversionServiceReturn a shared default applicationConversionServiceinstance, lazily building it once needed.booleanisConvertViaObjectSourceType(cn.taketoday.core.TypeDescriptor sourceType, cn.taketoday.core.TypeDescriptor targetType) Returntrueif objects ofsourceTypecan be converted to thetargetTypeand the converter hasObject.classas a supported source type.voidremoveConvertible(Class<?> sourceType, Class<?> targetType) 从类继承的方法 cn.taketoday.format.support.FormattingConversionService
setEmbeddedValueResolver从类继承的方法 cn.taketoday.core.conversion.support.GenericConversionService
canBypassConvert, canConvert, canConvert, convert, convert, convert, convertNullSource, getConverter, getDefaultConverter, toString从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait从接口继承的方法 cn.taketoday.core.conversion.ConversionService
getConverter, getConverter, getConverter, getConverter
-
构造器详细资料
-
ApplicationConversionService
public ApplicationConversionService() -
ApplicationConversionService
public ApplicationConversionService(@Nullable cn.taketoday.core.StringValueResolver embeddedValueResolver)
-
-
方法详细资料
-
addPrinter
从接口复制的说明:FormatterRegistryAdds 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
从接口复制的说明:FormatterRegistryAdds 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
从接口复制的说明:FormatterRegistryAdds 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
从接口复制的说明:FormatterRegistryAdds a Formatter to format fields of the given type.On print, if the Formatter's type T is declared and
fieldTypeis not assignable to T, a coercion to T will be attempted before delegating toformatterto print a field value. On parse, if the parsed object returned byformatteris 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 formatformatter- 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
从接口复制的说明:FormatterRegistryAdds a Printer/Parser pair to format fields of a specific type. The formatter will delegate to the specifiedprinterfor printing and the specifiedparserfor parsing.On print, if the Printer's type T is declared and
fieldTypeis not assignable to T, a coercion to T will be attempted before delegating toprinterto 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 formatprinter- the printing part of the formatterparser- the parsing part of the formatter
-
addFormatterForFieldAnnotation
public void addFormatterForFieldAnnotation(AnnotationFormatterFactory<? extends Annotation> annotationFormatterFactory) 从接口复制的说明:FormatterRegistryAdds 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
- 指定者:
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) Returntrueif objects ofsourceTypecan be converted to thetargetTypeand the converter hasObject.classas a supported source type.- 参数:
sourceType- the source type to testtargetType- the target type to test- 返回:
- if conversion happens via an
ObjectTo...converter
-
configure
Configure the givenFormatterRegistrywith formatters and converters appropriate for most applications.- 参数:
registry- the registry of converters to add to (must also be castable to ConversionService, e.g. being aConfigurableConversionService)- 抛出:
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 aConfigurableConversionService)- 抛出:
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 aConfigurableConversionService)- 抛出:
ClassCastException- if the given ConverterRegistry could not be cast to a ConversionService
-
addApplicationFormatters
Add formatters useful for most applications.- 参数:
registry- the service to register default formatters with
-
addBeans
- 参数:
registry- the service to register beans withbeanFactory- the bean factory to get the beans from
-