当前位置: 首页>>代码示例>>Java>>正文


Java DefaultFormattingConversionService类代码示例

本文整理汇总了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();
}
 
开发者ID:ralscha,项目名称:wampspring,代码行数:25,代码来源:WampAnnotationMethodMessageHandlerTest.java

示例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);
	}
}
 
开发者ID:SmarterApp,项目名称:TechnologyReadinessTool,代码行数:23,代码来源:CoreMappingEvaluationContext.java

示例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();
}
 
开发者ID:CeON,项目名称:saos,代码行数:25,代码来源:JudgmentsControllerTest.java

示例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();

}
 
开发者ID:CeON,项目名称:saos,代码行数:22,代码来源:DumpJudgmentsControllerTest.java

示例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());
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:12,代码来源:CasCoreUtilConfiguration.java

示例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);

}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:8,代码来源:EnvironmentConversionServiceInitializer.java

示例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());
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:16,代码来源:InvocableHandlerMethodTest.java

示例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;
}
 
开发者ID:torgcrm,项目名称:TorgCRM-Server,代码行数:12,代码来源:TestUtil.java

示例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);
}
 
开发者ID:pandboy,项目名称:pingguopai,代码行数:9,代码来源:LongDateTimeFormatter.java

示例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);
}
 
开发者ID:Devskiller,项目名称:friendly-id,代码行数:9,代码来源:MvcTest.java

示例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;
}
 
开发者ID:nailtonvieira,项目名称:pswot-cloud-java-spring-webapp,代码行数:12,代码来源:AppWebConfiguration.java

示例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));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:DataBinderTests.java

示例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;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:WebMvcConfigurationSupport.java

示例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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:RedirectAttributesModelMapTests.java

示例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());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:InitBinderDataBinderFactoryTests.java


注:本文中的org.springframework.format.support.DefaultFormattingConversionService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。