本文整理汇总了Java中org.springframework.core.convert.converter.ConverterRegistry类的典型用法代码示例。如果您正苦于以下问题:Java ConverterRegistry类的具体用法?Java ConverterRegistry怎么用?Java ConverterRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConverterRegistry类属于org.springframework.core.convert.converter包,在下文中一共展示了ConverterRegistry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: registerConverters
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
/**
* Install the converters into the converter registry.
* @param registry the converter registry
*/
@SuppressWarnings("deprecation")
public static void registerConverters(ConverterRegistry registry) {
DateFormatterRegistrar.addDateConverters(registry);
registry.addConverter(new DateTimeToLocalDateConverter());
registry.addConverter(new DateTimeToLocalTimeConverter());
registry.addConverter(new DateTimeToLocalDateTimeConverter());
registry.addConverter(new DateTimeToDateMidnightConverter());
registry.addConverter(new DateTimeToMutableDateTimeConverter());
registry.addConverter(new DateTimeToInstantConverter());
registry.addConverter(new DateTimeToDateConverter());
registry.addConverter(new DateTimeToCalendarConverter());
registry.addConverter(new DateTimeToLongConverter());
registry.addConverter(new DateToReadableInstantConverter());
registry.addConverter(new CalendarToReadableInstantConverter());
registry.addConverter(new LongToReadableInstantConverter());
registry.addConverter(new LocalDateTimeToLocalDateConverter());
registry.addConverter(new LocalDateTimeToLocalTimeConverter());
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:JodaTimeConverters.java
示例2: registerConverters
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
/**
* Install the converters into the converter registry.
* @param registry the converter registry
*/
public static void registerConverters(ConverterRegistry registry) {
DateFormatterRegistrar.addDateConverters(registry);
registry.addConverter(new LocalDateTimeToLocalDateConverter());
registry.addConverter(new LocalDateTimeToLocalTimeConverter());
registry.addConverter(new ZonedDateTimeToLocalDateConverter());
registry.addConverter(new ZonedDateTimeToLocalTimeConverter());
registry.addConverter(new ZonedDateTimeToLocalDateTimeConverter());
registry.addConverter(new ZonedDateTimeToOffsetDateTimeConverter());
registry.addConverter(new ZonedDateTimeToInstantConverter());
registry.addConverter(new OffsetDateTimeToLocalDateConverter());
registry.addConverter(new OffsetDateTimeToLocalTimeConverter());
registry.addConverter(new OffsetDateTimeToLocalDateTimeConverter());
registry.addConverter(new OffsetDateTimeToZonedDateTimeConverter());
registry.addConverter(new OffsetDateTimeToInstantConverter());
registry.addConverter(new CalendarToZonedDateTimeConverter());
registry.addConverter(new CalendarToOffsetDateTimeConverter());
registry.addConverter(new CalendarToLocalDateConverter());
registry.addConverter(new CalendarToLocalTimeConverter());
registry.addConverter(new CalendarToLocalDateTimeConverter());
registry.addConverter(new CalendarToInstantConverter());
registry.addConverter(new LongToInstantConverter());
registry.addConverter(new InstantToLongConverter());
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:DateTimeConverters.java
示例3: registerConverters
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
/**
* Register the given Converter objects with the given target ConverterRegistry.
* @param converters the converter objects: implementing {@link Converter},
* {@link ConverterFactory}, or {@link GenericConverter}
* @param registry the target registry
*/
public static void registerConverters(Set<?> converters, ConverterRegistry registry) {
if (converters != null) {
for (Object converter : converters) {
if (converter instanceof GenericConverter) {
registry.addConverter((GenericConverter) converter);
}
else if (converter instanceof Converter<?, ?>) {
registry.addConverter((Converter<?, ?>) converter);
}
else if (converter instanceof ConverterFactory<?, ?>) {
registry.addConverterFactory((ConverterFactory<?, ?>) converter);
}
else {
throw new IllegalArgumentException("Each converter object must implement one of the " +
"Converter, ConverterFactory, or GenericConverter interfaces");
}
}
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:ConversionServiceFactory.java
示例4: addDefaultConverters
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
/**
* Add converters appropriate for most environments.
* @param converterRegistry the registry of converters to add to (must also be castable to ConversionService,
* e.g. being a {@link ConfigurableConversionService})
* @throws ClassCastException if the given ConverterRegistry could not be cast to a ConversionService
*/
public static void addDefaultConverters(ConverterRegistry converterRegistry) {
addScalarConverters(converterRegistry);
addCollectionConverters(converterRegistry);
converterRegistry.addConverter(new ByteBufferConverter((ConversionService) converterRegistry));
if (jsr310Available) {
Jsr310ConverterRegistrar.registerJsr310Converters(converterRegistry);
}
converterRegistry.addConverter(new ObjectToObjectConverter());
converterRegistry.addConverter(new IdToEntityConverter((ConversionService) converterRegistry));
converterRegistry.addConverter(new FallbackObjectToStringConverter());
if (javaUtilOptionalClassAvailable) {
converterRegistry.addConverter(new ObjectToOptionalConverter((ConversionService) converterRegistry));
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:23,代码来源:DefaultConversionService.java
示例5: addCollectionConverters
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
private static void addCollectionConverters(ConverterRegistry converterRegistry) {
ConversionService conversionService = (ConversionService) converterRegistry;
converterRegistry.addConverter(new ArrayToCollectionConverter(conversionService));
converterRegistry.addConverter(new CollectionToArrayConverter(conversionService));
converterRegistry.addConverter(new ArrayToArrayConverter(conversionService));
converterRegistry.addConverter(new CollectionToCollectionConverter(conversionService));
converterRegistry.addConverter(new MapToMapConverter(conversionService));
converterRegistry.addConverter(new ArrayToStringConverter(conversionService));
converterRegistry.addConverter(new StringToArrayConverter(conversionService));
converterRegistry.addConverter(new ArrayToObjectConverter(conversionService));
converterRegistry.addConverter(new ObjectToArrayConverter(conversionService));
converterRegistry.addConverter(new CollectionToStringConverter(conversionService));
converterRegistry.addConverter(new StringToCollectionConverter(conversionService));
converterRegistry.addConverter(new CollectionToObjectConverter(conversionService));
converterRegistry.addConverter(new ObjectToCollectionConverter(conversionService));
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:22,代码来源:DefaultConversionService.java
示例6: init
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
@PostConstruct
public void init() {
final ConfigurableApplicationContext ctx = applicationContextProvider().getConfigurableApplicationContext();
final DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService(true);
conversionService.setEmbeddedValueResolver(new CasConfigurationEmbeddedValueResolver(ctx));
ctx.getEnvironment().setConversionService(conversionService);
final ConfigurableEnvironment env = (ConfigurableEnvironment) ctx.getParent().getEnvironment();
env.setConversionService(conversionService);
final ConverterRegistry registry = (ConverterRegistry) DefaultConversionService.getSharedInstance();
registry.addConverter(zonedDateTimeToStringConverter());
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:12,代码来源:CasCoreUtilConfiguration.java
示例7: addDateConverters
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
/**
* Add date converters to the specified registry.
* @param converterRegistry the registry of converters to add to
*/
public static void addDateConverters(ConverterRegistry converterRegistry) {
converterRegistry.addConverter(new DateToLongConverter());
converterRegistry.addConverter(new DateToCalendarConverter());
converterRegistry.addConverter(new CalendarToDateConverter());
converterRegistry.addConverter(new CalendarToLongConverter());
converterRegistry.addConverter(new LongToDateConverter());
converterRegistry.addConverter(new LongToCalendarConverter());
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:DateFormatterRegistrar.java
示例8: addDefaultConverters
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
/**
* Add all the default Search API converters to the given registry.
*
* @param registry The registry to add to.
*/
public static void addDefaultConverters(ConverterRegistry registry) {
registry.addConverter(new DateToStringConverter());
registry.addConverter(new OffsetDateTimeToStringConverter());
registry.addConverter(new OffsetDateTimeToDateConverter());
registry.addConverter(new ZonedDateTimeToStringConverter());
registry.addConverter(new ZonedDateTimeToDateConverter());
registry.addConverter(new GeoPointToStringConverter());
}
开发者ID:n15g,项目名称:spring-boot-gae,代码行数:17,代码来源:DefaultSearchConversionService.java
示例9: addCollectionConverters
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
/**
* Add collection converters.
* @param converterRegistry the registry of converters to add to (must also be castable to ConversionService,
* e.g. being a {@link ConfigurableConversionService})
* @throws ClassCastException if the given ConverterRegistry could not be cast to a ConversionService
* @since 4.2.3
*/
public static void addCollectionConverters(ConverterRegistry converterRegistry) {
ConversionService conversionService = (ConversionService) converterRegistry;
converterRegistry.addConverter(new ArrayToCollectionConverter(conversionService));
converterRegistry.addConverter(new CollectionToArrayConverter(conversionService));
converterRegistry.addConverter(new ArrayToArrayConverter(conversionService));
converterRegistry.addConverter(new CollectionToCollectionConverter(conversionService));
converterRegistry.addConverter(new MapToMapConverter(conversionService));
converterRegistry.addConverter(new ArrayToStringConverter(conversionService));
converterRegistry.addConverter(new StringToArrayConverter(conversionService));
converterRegistry.addConverter(new ArrayToObjectConverter(conversionService));
converterRegistry.addConverter(new ObjectToArrayConverter(conversionService));
converterRegistry.addConverter(new CollectionToStringConverter(conversionService));
converterRegistry.addConverter(new StringToCollectionConverter(conversionService));
converterRegistry.addConverter(new CollectionToObjectConverter(conversionService));
converterRegistry.addConverter(new ObjectToCollectionConverter(conversionService));
if (streamAvailable) {
converterRegistry.addConverter(new StreamConverter(conversionService));
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:34,代码来源:DefaultConversionService.java
示例10: addScalarConverters
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
private static void addScalarConverters(ConverterRegistry converterRegistry) {
converterRegistry.addConverterFactory(new NumberToNumberConverterFactory());
converterRegistry.addConverterFactory(new StringToNumberConverterFactory());
converterRegistry.addConverter(Number.class, String.class, new ObjectToStringConverter());
converterRegistry.addConverter(new StringToCharacterConverter());
converterRegistry.addConverter(Character.class, String.class, new ObjectToStringConverter());
converterRegistry.addConverter(new NumberToCharacterConverter());
converterRegistry.addConverterFactory(new CharacterToNumberFactory());
converterRegistry.addConverter(new StringToBooleanConverter());
converterRegistry.addConverter(Boolean.class, String.class, new ObjectToStringConverter());
converterRegistry.addConverterFactory(new StringToEnumConverterFactory());
converterRegistry.addConverter(Enum.class, String.class,
new EnumToStringConverter((ConversionService) converterRegistry));
converterRegistry.addConverter(new StringToLocaleConverter());
converterRegistry.addConverter(Locale.class, String.class, new ObjectToStringConverter());
converterRegistry.addConverter(new StringToCharsetConverter());
converterRegistry.addConverter(Charset.class, String.class, new ObjectToStringConverter());
converterRegistry.addConverter(new StringToCurrencyConverter());
converterRegistry.addConverter(Currency.class, String.class, new ObjectToStringConverter());
converterRegistry.addConverter(new StringToPropertiesConverter());
converterRegistry.addConverter(new PropertiesToStringConverter());
converterRegistry.addConverter(new StringToUUIDConverter());
converterRegistry.addConverter(UUID.class, String.class, new ObjectToStringConverter());
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:35,代码来源:DefaultConversionService.java
示例11: testSpr7766
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
@Test
public void testSpr7766() throws Exception {
ConverterRegistry registry = (conversionService);
registry.addConverter(new ColorConverter());
@SuppressWarnings("unchecked")
List<Color> colors = (List<Color>) conversionService.convert(new String[] { "ffffff", "#000000" },
TypeDescriptor.valueOf(String[].class),
new TypeDescriptor(new MethodParameter(getClass().getMethod("handlerMethod", List.class), 0)));
assertEquals(2, colors.size());
assertEquals(Color.WHITE, colors.get(0));
assertEquals(Color.BLACK, colors.get(1));
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:DefaultConversionServiceTests.java
示例12: addConverters
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
protected void addConverters(ConverterRegistry registry) {
if (configurers == null)
return;
for (FilesystemStoreConfigurer configurer : configurers) {
configurer.configureFilesystemStoreConverters(registry);
}
}
开发者ID:paulcwarren,项目名称:spring-content,代码行数:9,代码来源:FilesystemStoreConfiguration.java
示例13: addScalarConverters
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
private static void addScalarConverters(ConverterRegistry converterRegistry) {
converterRegistry.addConverterFactory(new NumberToNumberConverterFactory());
converterRegistry.addConverterFactory(new StringToNumberConverterFactory());
converterRegistry.addConverter(Number.class, String.class, new ObjectToStringConverter());
converterRegistry.addConverter(new StringToCharacterConverter());
converterRegistry.addConverter(Character.class, String.class, new ObjectToStringConverter());
converterRegistry.addConverter(new NumberToCharacterConverter());
converterRegistry.addConverterFactory(new CharacterToNumberFactory());
converterRegistry.addConverter(new StringToBooleanConverter());
converterRegistry.addConverter(Boolean.class, String.class, new ObjectToStringConverter());
converterRegistry.addConverterFactory(new StringToEnumConverterFactory());
converterRegistry.addConverter(new EnumToStringConverter((ConversionService) converterRegistry));
converterRegistry.addConverterFactory(new IntegerToEnumConverterFactory());
converterRegistry.addConverter(new EnumToIntegerConverter((ConversionService) converterRegistry));
converterRegistry.addConverter(new StringToLocaleConverter());
converterRegistry.addConverter(Locale.class, String.class, new ObjectToStringConverter());
converterRegistry.addConverter(new StringToCharsetConverter());
converterRegistry.addConverter(Charset.class, String.class, new ObjectToStringConverter());
converterRegistry.addConverter(new StringToCurrencyConverter());
converterRegistry.addConverter(Currency.class, String.class, new ObjectToStringConverter());
converterRegistry.addConverter(new StringToPropertiesConverter());
converterRegistry.addConverter(new PropertiesToStringConverter());
converterRegistry.addConverter(new StringToUUIDConverter());
converterRegistry.addConverter(UUID.class, String.class, new ObjectToStringConverter());
}
开发者ID:txazo,项目名称:spring,代码行数:37,代码来源:DefaultConversionService.java
示例14: registerConverters
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
/**
* Install the converters into the converter registry.
* @param registry the converter registry
*/
public static void registerConverters(ConverterRegistry registry) {
DateFormatterRegistrar.addDateConverters(registry);
registry.addConverter(new DateTimeToLocalDateConverter());
registry.addConverter(new DateTimeToLocalTimeConverter());
registry.addConverter(new DateTimeToLocalDateTimeConverter());
registry.addConverter(new DateTimeToDateMidnightConverter());
registry.addConverter(new DateTimeToMutableDateTimeConverter());
registry.addConverter(new DateTimeToInstantConverter());
registry.addConverter(new DateTimeToDateConverter());
registry.addConverter(new DateTimeToCalendarConverter());
registry.addConverter(new DateTimeToLongConverter());
registry.addConverter(new DateToReadableInstantConverter());
registry.addConverter(new CalendarToReadableInstantConverter());
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:19,代码来源:JodaTimeConverters.java
示例15: addScalarConverters
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
private static void addScalarConverters(ConverterRegistry converterRegistry) {
ConversionService conversionService = (ConversionService) converterRegistry;
converterRegistry.addConverter(new StringToBooleanConverter());
converterRegistry.addConverter(Boolean.class, String.class, new ObjectToStringConverter());
converterRegistry.addConverterFactory(new StringToNumberConverterFactory());
converterRegistry.addConverter(Number.class, String.class, new ObjectToStringConverter());
converterRegistry.addConverterFactory(new NumberToNumberConverterFactory());
converterRegistry.addConverter(new StringToCharacterConverter());
converterRegistry.addConverter(Character.class, String.class, new ObjectToStringConverter());
converterRegistry.addConverter(new NumberToCharacterConverter());
converterRegistry.addConverterFactory(new CharacterToNumberFactory());
converterRegistry.addConverterFactory(new StringToEnumConverterFactory());
converterRegistry.addConverter(Enum.class, String.class, new EnumToStringConverter(conversionService));
converterRegistry.addConverter(new StringToLocaleConverter());
converterRegistry.addConverter(Locale.class, String.class, new ObjectToStringConverter());
converterRegistry.addConverter(new PropertiesToStringConverter());
converterRegistry.addConverter(new StringToPropertiesConverter());
converterRegistry.addConverter(new StringToUUIDConverter());
converterRegistry.addConverter(UUID.class, String.class, new ObjectToStringConverter());
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:29,代码来源:DefaultConversionService.java
示例16: testSpr7766
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
@Test
public void testSpr7766() throws Exception {
ConverterRegistry registry = (conversionService);
registry.addConverter(new ColorConverter());
List<Color> colors = (List<Color>) conversionService.convert(new String[] { "ffffff", "#000000" }, TypeDescriptor.valueOf(String[].class), new TypeDescriptor(new MethodParameter(getClass().getMethod("handlerMethod", List.class), 0)));
assertEquals(2, colors.size());
assertEquals(Color.WHITE, colors.get(0));
assertEquals(Color.BLACK, colors.get(1));
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:10,代码来源:DefaultConversionTests.java
示例17: register
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
@PostConstruct
private void register() {
if (conversionService instanceof ConverterRegistry) {
((ConverterRegistry) conversionService).addConverter(this);
} else {
throw new IllegalStateException("Can't register Converter to ConverterRegistry");
}
}
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:9,代码来源:AbstractConversionServiceAwareConverter.java
示例18: registerJsr310Converters
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
public static void registerJsr310Converters(ConverterRegistry converterRegistry) {
converterRegistry.addConverter(new StringToTimeZoneConverter());
converterRegistry.addConverter(new ZoneIdToTimeZoneConverter());
converterRegistry.addConverter(new ZonedDateTimeToCalendarConverter());
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:6,代码来源:DefaultConversionService.java
示例19: addDefaultConverters
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
/**
* Add converters appropriate for most environments.
* @param converterRegistry the registry of converters to add to (must also be castable to ConversionService)
* @throws ClassCastException if the converterRegistry could not be cast to a ConversionService
*/
public static void addDefaultConverters(ConverterRegistry converterRegistry) {
addScalarConverters(converterRegistry);
addCollectionConverters(converterRegistry);
addFallbackConverters(converterRegistry);
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:11,代码来源:DefaultConversionService.java
示例20: addFallbackConverters
import org.springframework.core.convert.converter.ConverterRegistry; //导入依赖的package包/类
private static void addFallbackConverters(ConverterRegistry converterRegistry) {
ConversionService conversionService = (ConversionService) converterRegistry;
converterRegistry.addConverter(new ObjectToObjectConverter());
converterRegistry.addConverter(new IdToEntityConverter(conversionService));
converterRegistry.addConverter(new FallbackObjectToStringConverter());
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:7,代码来源:DefaultConversionService.java
注:本文中的org.springframework.core.convert.converter.ConverterRegistry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论