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


Java SimpleTypeConverter类代码示例

本文整理汇总了Java中org.springframework.beans.SimpleTypeConverter的典型用法代码示例。如果您正苦于以下问题:Java SimpleTypeConverter类的具体用法?Java SimpleTypeConverter怎么用?Java SimpleTypeConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SimpleTypeConverter类属于org.springframework.beans包,在下文中一共展示了SimpleTypeConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: afterPropertiesSet

import org.springframework.beans.SimpleTypeConverter; //导入依赖的package包/类
/**
 * Look up the JNDI object and store it.
 */
@Override
public void afterPropertiesSet() throws IllegalArgumentException, NamingException {
	super.afterPropertiesSet();

	if (this.proxyInterfaces != null || !this.lookupOnStartup || !this.cache || this.exposeAccessContext) {
		// We need to create a proxy for this...
		if (this.defaultObject != null) {
			throw new IllegalArgumentException(
					"'defaultObject' is not supported in combination with 'proxyInterface'");
		}
		// We need a proxy and a JndiObjectTargetSource.
		this.jndiObject = JndiObjectProxyFactory.createJndiObjectProxy(this);
	}
	else {
		if (this.defaultObject != null && getExpectedType() != null &&
				!getExpectedType().isInstance(this.defaultObject)) {
			TypeConverter converter = (this.beanFactory != null ?
					this.beanFactory.getTypeConverter() : new SimpleTypeConverter());
			try {
				this.defaultObject = converter.convertIfNecessary(this.defaultObject, getExpectedType());
			}
			catch (TypeMismatchException ex) {
				throw new IllegalArgumentException("Default object [" + this.defaultObject + "] of type [" +
						this.defaultObject.getClass().getName() + "] is not of expected type [" +
						getExpectedType().getName() + "] and cannot be converted either", ex);
			}
		}
		// Locate specified JNDI object.
		this.jndiObject = lookupWithFallback();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:35,代码来源:JndiObjectFactoryBean.java

示例2: getMethodArgument

import org.springframework.beans.SimpleTypeConverter; //导入依赖的package包/类
/**
 * Gets properly typed method argument.
 * @param parameterType
 * @param value
 * @return
 */
private <T> T getMethodArgument(Class<T> parameterType, Object value) {
    if (parameterType.isInstance(value)) {
        return parameterType.cast(value);
    }

    try {
        return new SimpleTypeConverter().convertIfNecessary(value, parameterType);
    } catch (ConversionNotSupportedException e) {
        if (String.class.equals(parameterType)) {
            return (T) String.valueOf(value);
        }

        throw new ApplicationRuntimeException("Unable to convert method argument type", e);
    }
}
 
开发者ID:christophd,项目名称:citrus-admin,代码行数:22,代码来源:AbstractTestActionConverter.java

示例3: DirectFieldAccessor

import org.springframework.beans.SimpleTypeConverter; //导入依赖的package包/类
/**
 * Create a new DirectFieldAccessor for the given target object.
 * @param target the target object to access
 */
public DirectFieldAccessor(final Object target) {
	Assert.notNull(target, "Target object must not be null");
	this.target = target;
	ReflectionUtils.doWithFields(this.target.getClass(), new ReflectionUtils.FieldCallback() {
		public void doWith(Field field) {
			// jlm - FIX SPR-8398: avoid to overwrite shadowed fileds
			if (!fieldMap.containsKey(field.getName())) {
				fieldMap.put(field.getName(), field);
			}
		}
	});
	this.typeConverterDelegate = new SimpleTypeConverter();
	registerDefaultEditors();
	setExtractOldValueForEditor(true);
}
 
开发者ID:chelu,项目名称:jdal,代码行数:20,代码来源:DirectFieldAccessor.java

示例4: getConverter

import org.springframework.beans.SimpleTypeConverter; //导入依赖的package包/类
private TypeConverter getConverter() {
	if (typeConverter == null) {
		SimpleTypeConverter simpleConverter = new SimpleTypeConverter();
		beanFactory.copyRegisteredEditorsTo(simpleConverter);
		simpleConverter.setConversionService(beanFactory.getConversionService());
		typeConverter = simpleConverter;
	}
	return typeConverter;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:10,代码来源:SpringBlueprintConverter.java

示例5: getSimpleTypeConverter

import org.springframework.beans.SimpleTypeConverter; //导入依赖的package包/类
/**
 * Return this binder's underlying SimpleTypeConverter.
 */
protected SimpleTypeConverter getSimpleTypeConverter() {
	if (this.typeConverter == null) {
		this.typeConverter = new SimpleTypeConverter();
		if (this.conversionService != null) {
			this.typeConverter.setConversionService(this.conversionService);
		}
	}
	return this.typeConverter;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:DataBinder.java

示例6: checkQualifiers

import org.springframework.beans.SimpleTypeConverter; //导入依赖的package包/类
/**
 * Match the given qualifier annotations against the candidate bean definition.
 */
protected boolean checkQualifiers(BeanDefinitionHolder bdHolder, Annotation[] annotationsToSearch) {
	if (ObjectUtils.isEmpty(annotationsToSearch)) {
		return true;
	}
	SimpleTypeConverter typeConverter = new SimpleTypeConverter();
	for (Annotation annotation : annotationsToSearch) {
		Class<? extends Annotation> type = annotation.annotationType();
		boolean checkMeta = true;
		boolean fallbackToMeta = false;
		if (isQualifier(type)) {
			if (!checkQualifier(bdHolder, annotation, typeConverter)) {
				fallbackToMeta = true;
			}
			else {
				checkMeta = false;
			}
		}
		if (checkMeta) {
			boolean foundMeta = false;
			for (Annotation metaAnn : type.getAnnotations()) {
				Class<? extends Annotation> metaType = metaAnn.annotationType();
				if (isQualifier(metaType)) {
					foundMeta = true;
					// Only accept fallback match if @Qualifier annotation has a value...
					// Otherwise it is just a marker for a custom qualifier annotation.
					if ((fallbackToMeta && StringUtils.isEmpty(AnnotationUtils.getValue(metaAnn))) ||
							!checkQualifier(bdHolder, metaAnn, typeConverter)) {
						return false;
					}
				}
			}
			if (fallbackToMeta && !foundMeta) {
				return false;
			}
		}
	}
	return true;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:42,代码来源:QualifierAnnotationAutowireCandidateResolver.java

示例7: getTypeConverter

import org.springframework.beans.SimpleTypeConverter; //导入依赖的package包/类
@Override
public TypeConverter getTypeConverter() {
	TypeConverter customConverter = getCustomTypeConverter();
	if (customConverter != null) {
		return customConverter;
	}
	else {
		// Build default TypeConverter, registering custom editors.
		SimpleTypeConverter typeConverter = new SimpleTypeConverter();
		typeConverter.setConversionService(getConversionService());
		registerCustomEditors(typeConverter);
		return typeConverter;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:AbstractBeanFactory.java

示例8: getBeanTypeConverter

import org.springframework.beans.SimpleTypeConverter; //导入依赖的package包/类
/**
 * Obtain a bean type converter from the BeanFactory that this bean
 * runs in. This is typically a fresh instance for each call,
 * since TypeConverters are usually <i>not</i> thread-safe.
 * <p>Falls back to a SimpleTypeConverter when not running in a BeanFactory.
 * @see ConfigurableBeanFactory#getTypeConverter()
 * @see org.springframework.beans.SimpleTypeConverter
 */
protected TypeConverter getBeanTypeConverter() {
	BeanFactory beanFactory = getBeanFactory();
	if (beanFactory instanceof ConfigurableBeanFactory) {
		return ((ConfigurableBeanFactory) beanFactory).getTypeConverter();
	}
	else {
		return new SimpleTypeConverter();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:AbstractFactoryBean.java

示例9: typeConverter

import org.springframework.beans.SimpleTypeConverter; //导入依赖的package包/类
@Bean
public TypeConverter typeConverter() {
    SimpleTypeConverter tc = new SimpleTypeConverter();
    tc.registerCustomEditor(LocalDateTime.class, new LocalDateTimePropertyEditor("yyyyMMdd_HHmmss"));
    tc.registerCustomEditor(LocalDate.class, new LocalDatePropertyEditor("yyyyMMdd"));
    return tc;
}
 
开发者ID:taboola,项目名称:taboola-cronyx,代码行数:8,代码来源:CronyxAutoConfiguration.java

示例10: setBeanFactory

import org.springframework.beans.SimpleTypeConverter; //导入依赖的package包/类
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
	if (beanFactory instanceof ConfigurableBeanFactory) {
		Object typeConverter = ((ConfigurableBeanFactory) beanFactory).getTypeConverter();
		if (typeConverter instanceof SimpleTypeConverter) {
			delegate = (SimpleTypeConverter) typeConverter;
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:BeanFactoryTypeConverter.java

示例11: JpqQueryRSQLVisitor

import org.springframework.beans.SimpleTypeConverter; //导入依赖的package包/类
private JpqQueryRSQLVisitor(final Root<T> root, final CriteriaBuilder cb, final Class<A> enumType,
        final VirtualPropertyReplacer virtualPropertyReplacer) {
    this.root = root;
    this.cb = cb;
    this.enumType = enumType;
    this.virtualPropertyReplacer = virtualPropertyReplacer;
    simpleTypeConverter = new SimpleTypeConverter();
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:9,代码来源:RSQLUtility.java

示例12: setFieldValue

import org.springframework.beans.SimpleTypeConverter; //导入依赖的package包/类
public static void setFieldValue(Field field, Object bean, Object value)
		throws IllegalAccessException {
	// Set it on the field
	field.setAccessible(true);

	// Perform type conversion if possible..
	SimpleTypeConverter converter = new SimpleTypeConverter();
	try {
		value = converter.convertIfNecessary(value, field.getType());
	}
	catch (ConversionNotSupportedException e) {
		// If conversion isn't supported, ignore and try and set anyway.
	}
	field.set(bean, value);
}
 
开发者ID:conversant,项目名称:mara,代码行数:16,代码来源:DistributedResourceManager.java

示例13: getTypeConverter

import org.springframework.beans.SimpleTypeConverter; //导入依赖的package包/类
public TypeConverter getTypeConverter() {
	TypeConverter customConverter = getCustomTypeConverter();
	if (customConverter != null) {
		return customConverter;
	}
	else {
		// Build default TypeConverter, registering custom editors.
		SimpleTypeConverter typeConverter = new SimpleTypeConverter();
		typeConverter.setConversionService(getConversionService());
		registerCustomEditors(typeConverter);
		return typeConverter;
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:14,代码来源:AbstractBeanFactory.java

示例14: GoConfigFieldWriter

import org.springframework.beans.SimpleTypeConverter; //导入依赖的package包/类
public GoConfigFieldWriter(Field declaredField, Object value, SimpleTypeConverter converter, ConfigCache configCache, final ConfigElementImplementationRegistry registry) {
    this.configField = declaredField;
    this.value = value;
    this.configField.setAccessible(true);
    this.typeConverter = converter;
    this.configCache = configCache;
    this.registry = registry;
}
 
开发者ID:gocd,项目名称:gocd,代码行数:9,代码来源:GoConfigFieldWriter.java

示例15: SpringBlueprintConverterService

import org.springframework.beans.SimpleTypeConverter; //导入依赖的package包/类
public SpringBlueprintConverterService(ConversionService delegate, ConfigurableBeanFactory cbf) {
	this.delegate = delegate;
	this.cbf = cbf;
	this.typeConverter = new SimpleTypeConverter();
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:6,代码来源:SpringBlueprintConverterService.java


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