本文整理汇总了Java中org.springframework.binding.convert.ConversionExecutor类的典型用法代码示例。如果您正苦于以下问题:Java ConversionExecutor类的具体用法?Java ConversionExecutor怎么用?Java ConversionExecutor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConversionExecutor类属于org.springframework.binding.convert包,在下文中一共展示了ConversionExecutor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMappingToSubflowState
import org.springframework.binding.convert.ConversionExecutor; //导入依赖的package包/类
/**
* Create mapping to subflow state.
*
* @param name the name
* @param value the value
* @param required the required
* @param type the type
* @return the default mapping
*/
protected DefaultMapping createMappingToSubflowState(final String name, final String value,
final boolean required, final Class type) {
final ExpressionParser parser = this.flowBuilderServices.getExpressionParser();
final Expression source = parser.parseExpression(value, new FluentParserContext());
final Expression target = parser.parseExpression(name, new FluentParserContext());
final DefaultMapping mapping = new DefaultMapping(source, target);
mapping.setRequired(required);
final ConversionExecutor typeConverter =
new RuntimeBindingConversionExecutor(type, this.flowBuilderServices.getConversionService());
mapping.setTypeConverter(typeConverter);
return mapping;
}
示例2: createMappingToSubflowState
import org.springframework.binding.convert.ConversionExecutor; //导入依赖的package包/类
/**
* Create mapping to subflow state.
*
* @param name the name
* @param value the value
* @param required the required
* @param type the type
* @return the default mapping
*/
protected DefaultMapping createMappingToSubflowState(final String name, final String value,
final boolean required, final Class type) {
final ExpressionParser parser = this.flowBuilderServices.getExpressionParser();
final Expression source = parser.parseExpression(value, new FluentParserContext());
final Expression target = parser.parseExpression(name, new FluentParserContext());
final DefaultMapping mapping = new DefaultMapping(source, target);
mapping.setRequired(required);
final ConversionExecutor typeConverter =
new RuntimeBindingConversionExecutor(type, this.flowBuilderServices.getConversionService());
mapping.setTypeConverter(typeConverter);
return mapping;
}
示例3: createMappingToSubflowState
import org.springframework.binding.convert.ConversionExecutor; //导入依赖的package包/类
/**
* Create mapping to subflow state.
*
* @param name the name
* @param value the value
* @param required the required
* @param type the type
* @return the default mapping
*/
protected DefaultMapping createMappingToSubflowState(final String name, final String value, final boolean required, final Class type) {
final ExpressionParser parser = this.flowBuilderServices.getExpressionParser();
final Expression source = parser.parseExpression(value, new FluentParserContext());
final Expression target = parser.parseExpression(name, new FluentParserContext());
final DefaultMapping mapping = new DefaultMapping(source, target);
mapping.setRequired(required);
final ConversionExecutor typeConverter =
new RuntimeBindingConversionExecutor(type, this.flowBuilderServices.getConversionService());
mapping.setTypeConverter(typeConverter);
return mapping;
}
示例4: testConvertingValueModels
import org.springframework.binding.convert.ConversionExecutor; //导入依赖的package包/类
public void testConvertingValueModels() {
AbstractFormModel fm = getFormModel(new TestBean());
TestConversionService cs = new TestConversionService();
fm.setConversionService(cs);
ValueModel vm = fm.getValueModel("simpleProperty", String.class);
assertEquals(fm.getValueModel("simpleProperty"), vm);
assertEquals(0, cs.calls);
try {
fm.getValueModel("simpleProperty", Integer.class);
fail("should have throw IllegalArgumentException");
}
catch (IllegalArgumentException e) {
// expected
}
assertEquals(1, cs.calls);
assertEquals(String.class, cs.lastSource);
assertEquals(Integer.class, cs.lastTarget);
cs.executer = new ConversionExecutor(String.class, Integer.class, new CopiedPublicNoOpConverter(String.class,
Integer.class));
ValueModel cvm = fm.getValueModel("simpleProperty", Integer.class);
assertEquals(3, cs.calls);
assertEquals(Integer.class, cs.lastSource);
assertEquals(String.class, cs.lastTarget);
assertEquals(fm.getValueModel("simpleProperty", Integer.class), cvm);
assertEquals(3, cs.calls);
}
示例5: getConversionExecutor
import org.springframework.binding.convert.ConversionExecutor; //导入依赖的package包/类
public ConversionExecutor getConversionExecutor(Class source, Class target) {
calls++;
lastSource = source;
lastTarget = target;
if (executer != null) {
return executer;
}
throw new IllegalArgumentException("no converter found");
}
示例6: testPropertyChangeCausesValidation
import org.springframework.binding.convert.ConversionExecutor; //导入依赖的package包/类
public void testPropertyChangeCausesValidation() {
DefaultFormModel fm = (DefaultFormModel) getFormModel(new TestBean());
TestValidator v = new TestValidator();
fm.setValidator(v);
TestConversionService cs = new TestConversionService();
cs.executer = new ConversionExecutor(String.class, String.class, new CopiedPublicNoOpConverter(String.class, String.class));
fm.setConversionService(cs);
ValueModel vm = fm.getValueModel("simpleProperty");
// starting at 2: constructing a formmodel + creating valueModel
int expectedCount = 2;
assertEquals(expectedCount++, v.count);
vm.setValue("1");
assertEquals(expectedCount, v.count);
// no change in value, no validation triggered.
vm.setValue("1");
assertEquals(expectedCount++, v.count);
vm.setValue(null);
assertEquals(expectedCount++, v.count);
vm = fm.getValueModel("simpleProperty", Integer.class);
vm.setValue("1");
assertEquals(expectedCount++, v.count);
vm.setValue("2");
assertEquals(expectedCount++, v.count);
}
示例7: testTypeConversionThrowsExceptionRaisesValidationMessage
import org.springframework.binding.convert.ConversionExecutor; //导入依赖的package包/类
public void testTypeConversionThrowsExceptionRaisesValidationMessage() {
DefaultFormModel fm = (DefaultFormModel) getFormModel(new TestBean());
TestConversionService cs = new TestConversionService();
cs.executer = new ConversionExecutor(String.class, Integer.class, new ExceptionConverter(String.class,
Integer.class));
fm.setConversionService(cs);
final ValueModel vm = fm.getValueModel("simpleProperty", Integer.class);
vm.setValue("test");
assertEquals(1, fm.getValidationResults().getMessageCount());
}
示例8: getPropertyConversionExecutor
import org.springframework.binding.convert.ConversionExecutor; //导入依赖的package包/类
/**
* Returns a conversion executor which converts a value of the given
* sourceType into the fieldType
*
* @see #getPropertyType()
*/
protected ConversionExecutor getPropertyConversionExecutor() {
if (conversionExecutor == null) {
conversionExecutor = getConversionService().getConversionExecutor(
Object[].class, getPropertyType());
}
return conversionExecutor;
}
示例9: createConvertingValueModel
import org.springframework.binding.convert.ConversionExecutor; //导入依赖的package包/类
protected ValueModel createConvertingValueModel(String formProperty, Class targetClass) {
if (logger.isDebugEnabled()) {
logger.debug("Creating converting value model for form property '" + formProperty
+ "' converting to type '" + targetClass + "'.");
}
final ValueModel sourceValueModel = getValueModel(formProperty);
Assert.notNull(sourceValueModel, "Form does not have a property called '" + formProperty + "'.");
final Class sourceClass = ClassUtils
.convertPrimitiveToWrapper(getFieldMetadata(formProperty).getPropertyType());
// sourceClass can be null when using eg Map, assume that given
// targetClass is the correct one
if ((sourceClass == null) || (sourceClass == targetClass)) {
return sourceValueModel;
}
final ConversionService conversionService = getConversionService();
ConversionExecutor convertTo = null;
ConversionExecutor convertFrom = null;
// Check for locally registered property converters
if (propertyConversionServices.containsKey(formProperty)) {
// TODO - extract ConfigurableConversionService interface...
final GenericConversionService propertyConversionService = (GenericConversionService) propertyConversionServices
.get(formProperty);
if (propertyConversionService != null) {
convertTo = propertyConversionService.getConversionExecutor(sourceClass, targetClass);
convertFrom = propertyConversionService.getConversionExecutor(targetClass, sourceClass);
}
}
// If we have nothing from the property level, then try the conversion
// service
if (convertTo == null) {
convertTo = conversionService.getConversionExecutor(sourceClass, targetClass);
}
Assert.notNull(convertTo, "conversionService returned null ConversionExecutor");
if (convertFrom == null) {
convertFrom = conversionService.getConversionExecutor(targetClass, sourceClass);
}
Assert.notNull(convertFrom, "conversionService returned null ConversionExecutor");
ValueModel convertingValueModel = preProcessNewConvertingValueModel(formProperty, targetClass,
new TypeConverter(sourceValueModel, convertTo, convertFrom));
preProcessNewConvertingValueModel(formProperty, targetClass, convertingValueModel);
return convertingValueModel;
}
示例10: ConversionExecutorClosure
import org.springframework.binding.convert.ConversionExecutor; //导入依赖的package包/类
public ConversionExecutorClosure(ConversionExecutor conversionExecutor) {
this.conversionExecutor = conversionExecutor;
}
示例11: getConversionExecutorByTargetAlias
import org.springframework.binding.convert.ConversionExecutor; //导入依赖的package包/类
public ConversionExecutor getConversionExecutorByTargetAlias(Class arg0, String arg1)
throws IllegalArgumentException {
fail("this method should never be called");
return null;
}
示例12: getConversionExecutorsForSource
import org.springframework.binding.convert.ConversionExecutor; //导入依赖的package包/类
public ConversionExecutor[] getConversionExecutorsForSource(Class sourceClass) throws ConversionException {
fail("this method should never be called");
return null;
}
示例13: getPropertyConversionExecutor
import org.springframework.binding.convert.ConversionExecutor; //导入依赖的package包/类
/**
* Returns a conversion executor which converts a value of the given sourceType into the fieldType
*
* @param sourceType
* the sourceType
* @return true if a converter is available, otherwise false
*
* @see #getPropertyType()
*/
protected ConversionExecutor getPropertyConversionExecutor() {
if (conversionExecutor == null) {
conversionExecutor = getConversionService().getConversionExecutor(Object[].class, getPropertyType());
}
return conversionExecutor;
}
示例14: fromStringTo
import org.springframework.binding.convert.ConversionExecutor; //导入依赖的package包/类
/**
* From string to class type, based on the flow conversion service.
*
* @param targetType the target type
* @return the conversion executor
*/
protected ConversionExecutor fromStringTo(final Class targetType) {
return this.flowBuilderServices.getConversionService().getConversionExecutor(String.class, targetType);
}
示例15: TypeConverter
import org.springframework.binding.convert.ConversionExecutor; //导入依赖的package包/类
/**
* Convenience constructor using conversionExecutors.
*
* @param wrappedModel the inner valueModel
* @param convertTo conversion to use when setting a value.
* @param convertFrom conversion to use when getting a value.
*
* @see #TypeConverter(ValueModel, Closure, Closure)
*/
public TypeConverter(ValueModel wrappedModel, ConversionExecutor convertTo, ConversionExecutor convertFrom) {
this(wrappedModel, new ConversionExecutorClosure(convertTo), new ConversionExecutorClosure(convertFrom));
}