本文整理汇总了Java中org.springframework.format.support.DefaultFormattingConversionService类的典型用法代码示例。如果您正苦于以下问题:Java DefaultFormattingConversionService类的具体用法?Java DefaultFormattingConversionService怎么用?Java DefaultFormattingConversionService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultFormattingConversionService类属于org.springframework.format.support包,在下文中一共展示了DefaultFormattingConversionService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setup
import org.springframework.format.support.DefaultFormattingConversionService; //导入依赖的package包/类
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
when(this.clientOutboundChannel.send(any(WampMessage.class))).thenReturn(true);
DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService();
MethodParameterConverter paramConverter = new MethodParameterConverter(
new ObjectMapper(), conversionService);
this.messageHandler = new WampAnnotationMethodMessageHandler(
this.clientInboundChannel, this.clientOutboundChannel,
this.eventMessenger, conversionService, paramConverter,
new AntPathMatcher(), WampMessageSelectors.ACCEPT_ALL,
new GenericMessageConverter());
@SuppressWarnings("resource")
StaticApplicationContext applicationContext = new StaticApplicationContext();
applicationContext.registerPrototype("annotatedTestService",
AnnotatedTestService.class);
applicationContext.refresh();
this.messageHandler.setApplicationContext(applicationContext);
this.messageHandler.afterPropertiesSet();
this.messageHandler.start();
}
示例2: CoreMappingEvaluationContext
import org.springframework.format.support.DefaultFormattingConversionService; //导入依赖的package包/类
public CoreMappingEvaluationContext(Object root) {
super(root);
try {
// Add functions for use in the mapping expressions.
registerFunction("substring", StringUtils.class.getMethod("substring", String.class, int.class, int.class));
registerFunction("upperCase", StringUtils.class.getMethod("upperCase", String.class));
registerFunction("leftPad", StringUtils.class.getMethod("leftPad", String.class, int.class, String.class));
registerFunction("rightPad", StringUtils.class.getMethod("rightPad", String.class, int.class, String.class));
registerFunction("trim", StringUtils.class.getMethod("trim", String.class));
registerFunction("capitalize", WordUtils.class.getMethod("capitalizeFully", String.class));
registerFunction("isBlank", StringUtils.class.getMethod("isBlank", CharSequence.class));
registerFunction("split", StringUtils.class.getMethod("split", String.class, char.class));
registerFunction("join", StringUtils.class.getMethod("join", Object[].class, char.class));
registerFunction("toBoolean", BooleanUtils.class.getMethod("toBoolean", String.class));
DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService();
conversionService.addFormatterForFieldType(Date.class, new DateFormatter("MM/dd/yyyy"));
setTypeConverter(new StandardTypeConverter(conversionService));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例3: setUp
import org.springframework.format.support.DefaultFormattingConversionService; //导入依赖的package包/类
@Before
public void setUp() throws Exception{
testObjectContext = testPersistenceObjectFactory.createTestObjectContext();
clearAndIndexJudgmentsInSolr(testObjectContext);
JudgmentsController judgmentsController = new JudgmentsController();
judgmentsController.setApiSearchService(apiSearchService);
judgmentsController.setListSuccessRepresentationBuilder(listSuccessRepresentationBuilder);
judgmentsController.setParametersExtractor(parametersExtractor);
judgmentsController.setJsonFormatter(jsonFormatter);
judgmentsController.setMinPageSize(3);
judgmentsController.setMaxPageSize(50);
FormattingConversionService conversionService = new DefaultFormattingConversionService();
conversionService.addFormatterForFieldAnnotation(new LawJournalEntryCodeFormatterFactory(lawJournalEntryCodeExtractor));
mockMvc = standaloneSetup(judgmentsController)
.addInterceptors(new AccessControlHeaderHandlerInterceptor())
.addInterceptors(new RestrictParamsHandlerInterceptor())
.setConversionService(conversionService)
.build();
}
示例4: setUp
import org.springframework.format.support.DefaultFormattingConversionService; //导入依赖的package包/类
@Before
public void setUp(){
testObjectContext = testPersistenceObjectFactory.createTestObjectContext();
DumpJudgmentsController dumpJudgmentsController = new DumpJudgmentsController();
dumpJudgmentsController.setJudgmentEnrichmentDbSearchService(judgmentEnrichmentDbSearchService);
dumpJudgmentsController.setDumpJudgmentsListSuccessRepresentationBuilder(dumpJudgmentsListSuccessRepresentationBuilder);
dumpJudgmentsController.setParametersExtractor(parametersExtractor);
dumpJudgmentsController.setJsonFormatter(jsonFormatter);
FormattingConversionService conversionService = new DefaultFormattingConversionService();
conversionService.addFormatterForFieldAnnotation(new DateTimeWithZoneFormatterFactory());
mockMvc = standaloneSetup(dumpJudgmentsController)
.setConversionService(conversionService)
.addInterceptors(new AccessControlHeaderHandlerInterceptor())
.addInterceptors(new RestrictParamsHandlerInterceptor())
.build();
}
示例5: init
import org.springframework.format.support.DefaultFormattingConversionService; //导入依赖的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());
}
示例6: initialize
import org.springframework.format.support.DefaultFormattingConversionService; //导入依赖的package包/类
@Override
public void initialize(final ConfigurableApplicationContext ctx) {
final DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService(true);
conversionService.setEmbeddedValueResolver(new CasConfigurationEmbeddedValueResolver(ctx));
ctx.getEnvironment().setConversionService(conversionService);
}
示例7: setup
import org.springframework.format.support.DefaultFormattingConversionService; //导入依赖的package包/类
@Before
public void setup() throws Exception {
this.invocableHandlerMethod = new InvocableHandlerMethod(
new HandlerMethod(this, "setup"));
HandlerMethodArgumentResolverComposite argumentResolvers = new HandlerMethodArgumentResolverComposite();
argumentResolvers.addResolver(new WampMessageMethodArgumentResolver());
argumentResolvers.addResolver(new PrincipalMethodArgumentResolver());
this.invocableHandlerMethod.setArgumentResolvers(argumentResolvers);
this.invocableHandlerMethod
.setConversionService(new DefaultFormattingConversionService());
this.invocableHandlerMethod.setObjectMapper(new ObjectMapper());
this.invocableHandlerMethod
.setParameterNameDiscoverer(new DefaultParameterNameDiscoverer());
}
示例8: createFormattingConversionService
import org.springframework.format.support.DefaultFormattingConversionService; //导入依赖的package包/类
/**
* Create a FormattingConversionService which use ISO date format, instead of the localized one.
* @return the FormattingConversionService
*/
public static FormattingConversionService createFormattingConversionService() {
DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService ();
DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
registrar.setUseIsoFormat(true);
registrar.registerFormatters(dfcs);
return dfcs;
}
示例9: main
import org.springframework.format.support.DefaultFormattingConversionService; //导入依赖的package包/类
public static void main(String[] args) {
DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService();
conversionService.addFormatter(new LongDateTimeFormatter());
long milliseconds = System.currentTimeMillis();
Object obj = conversionService.convert(milliseconds, Date.class);
System.out.println(obj);
}
示例10: setup
import org.springframework.format.support.DefaultFormattingConversionService; //导入依赖的package包/类
@Before
public void setup() {
mockMvcBuilder = standaloneSetup(new FooController(mock(EntityLinks.class)));
DefaultFormattingConversionService service = new DefaultFormattingConversionService();
service.addConverter(new StringToUuidConverter());
mockMvcBuilder.setMessageConverters(jackson2HttpMessageConverter()).setConversionService(service);
RestAssuredMockMvc.standaloneSetup(mockMvcBuilder);
}
示例11: mvcConversionService
import org.springframework.format.support.DefaultFormattingConversionService; //导入依赖的package包/类
@Bean
public FormattingConversionService mvcConversionService() { // Método para setar padrões de conversão
DefaultFormattingConversionService conversionService
= new DefaultFormattingConversionService(
true);
DateFormatterRegistrar registrar = new DateFormatterRegistrar();
registrar.setFormatter(new DateFormatter("yyyy-MM-dd"));
registrar.registerFormatters(conversionService);
return conversionService;
}
示例12: testConversionWithInappropriateStringEditor
import org.springframework.format.support.DefaultFormattingConversionService; //导入依赖的package包/类
@Test
public void testConversionWithInappropriateStringEditor() {
DataBinder dataBinder = new DataBinder(null);
DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService();
dataBinder.setConversionService(conversionService);
dataBinder.registerCustomEditor(String.class, new StringTrimmerEditor(true));
NameBean bean = new NameBean("Fred");
assertEquals("ConversionService should have invoked toString()", "Fred", dataBinder.convertIfNecessary(bean, String.class));
conversionService.addConverter(new NameBeanConverter());
assertEquals("Type converter should have been used", "[Fred]", dataBinder.convertIfNecessary(bean, String.class));
}
示例13: mvcConversionService
import org.springframework.format.support.DefaultFormattingConversionService; //导入依赖的package包/类
/**
* Return a {@link FormattingConversionService} for use with annotated
* controller methods and the {@code spring:eval} JSP tag.
* Also see {@link #addFormatters} as an alternative to overriding this method.
*/
@Bean
public FormattingConversionService mvcConversionService() {
FormattingConversionService conversionService = new DefaultFormattingConversionService();
addFormatters(conversionService);
return conversionService;
}
示例14: setup
import org.springframework.format.support.DefaultFormattingConversionService; //导入依赖的package包/类
@Before
public void setup() {
this.conversionService = new DefaultFormattingConversionService();
DataBinder dataBinder = new DataBinder(null);
dataBinder.setConversionService(conversionService);
this.redirectAttributes = new RedirectAttributesModelMap(dataBinder);
}
示例15: createBinderWithGlobalInitialization
import org.springframework.format.support.DefaultFormattingConversionService; //导入依赖的package包/类
@Test
public void createBinderWithGlobalInitialization() throws Exception {
ConversionService conversionService = new DefaultFormattingConversionService();
bindingInitializer.setConversionService(conversionService);
WebDataBinderFactory factory = createBinderFactory("initBinder", WebDataBinder.class);
WebDataBinder dataBinder = factory.createBinder(webRequest, null, null);
assertSame(conversionService, dataBinder.getConversionService());
}