• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ConfigurablePropertyAccessor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: mapToObject

import org.springframework.beans.ConfigurablePropertyAccessor; //导入依赖的package包/类
public void mapToObject(Object obj) {
	Assert.notEmpty(config);
	boolean hasPrefix = StringUtils.isNotBlank(prefix);
	
	ConfigurablePropertyAccessor bw = beanAccessors.createAccessor(obj);
	Enumeration<?> names = config.propertyNames();
	while(names.hasMoreElements()){
		String propertyName = names.nextElement().toString();
		String value = config.getProperty(propertyName);
		if(value==null){
			continue;
		}
		if(StringUtils.isBlank(value) && ignoreBlankString){
			continue;
		}
		if(hasPrefix){
			if(propertyName.startsWith(prefix)){
				propertyName = propertyName.substring(prefix.length());
				setPropertyValue(obj, bw, propertyName, value);
			}
		}else{
			setPropertyValue(obj, bw, propertyName, value);
		}
	}
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:26,代码来源:BeanPropertiesMapper.java


示例2: canFormat

import org.springframework.beans.ConfigurablePropertyAccessor; //导入依赖的package包/类
/**
 * 判断对象属性是否有格式可以应用。调用format()前必须先调用canFormat()
 * 
 * @param obj
 * @param prop
 * @return
 */
public static boolean canFormat(ConfigurablePropertyAccessor bw,
		Object obj, String prop) {
	String key = obj.getClass().getName() + "_" + prop;

	if (!cache.containsKey(key)) {
		cache.put(key, false);

		TypeDescriptor td = bw.getPropertyTypeDescriptor(prop);
		if (td != null) {
			WinletDefaultFormattingConversionService wcs = get();
			if (wcs != null
					&& wcs.hasFmtAnnotation(td)
					&& wcs.canConvert(td,
							TypeDescriptor.valueOf(String.class)))
				cache.put(key, true);
		}
	}

	return cache.get(key);
}
 
开发者ID:yangjm,项目名称:winlet,代码行数:28,代码来源:WinletDefaultFormattingConversionService.java


示例3: format

import org.springframework.beans.ConfigurablePropertyAccessor; //导入依赖的package包/类
/**
 * 如果有格式可应用则应用
 * 
 * @param bw
 * @param obj
 * @param prop
 * @return
 */
public static String format(ConfigurablePropertyAccessor bw, Object obj,
		String prop) {
	String key = obj.getClass().getName() + "_" + prop;

	if (!cache.containsKey(key))
		canFormat(bw, obj, prop);

	Object val = bw.getPropertyValue(prop);

	if (val == null)
		return null;
	if (val.getClass().isArray())
		return null;

	if (!cache.get(key))
		return val.toString();

	TypeDescriptor td = bw.getPropertyTypeDescriptor(prop);
	val = get().convert(val, td, TypeDescriptor.valueOf(String.class));

	return val == null ? null : val.toString();
}
 
开发者ID:yangjm,项目名称:winlet,代码行数:31,代码来源:WinletDefaultFormattingConversionService.java


示例4: getPropertyAccessor

import org.springframework.beans.ConfigurablePropertyAccessor; //导入依赖的package包/类
/**
 * Returns the DirectFieldAccessor that this instance uses.
 * Creates a new one if none existed before.
 * @see #createDirectFieldAccessor()
 */
@Override
public final ConfigurablePropertyAccessor getPropertyAccessor() {
	if (this.directFieldAccessor == null) {
		this.directFieldAccessor = createDirectFieldAccessor();
		this.directFieldAccessor.setExtractOldValueForEditor(true);
	}
	return this.directFieldAccessor;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:DirectFieldBindingResult.java


示例5: getPropertyAccessor

import org.springframework.beans.ConfigurablePropertyAccessor; //导入依赖的package包/类
/**
 * Returns the {@link BeanWrapper} that this instance uses.
 * Creates a new one if none existed before.
 * @see #createBeanWrapper()
 */
@Override
public final ConfigurablePropertyAccessor getPropertyAccessor() {
	if (this.beanWrapper == null) {
		this.beanWrapper = createBeanWrapper();
		this.beanWrapper.setExtractOldValueForEditor(true);
		this.beanWrapper.setAutoGrowNestedPaths(this.autoGrowNestedPaths);
		this.beanWrapper.setAutoGrowCollectionLimit(this.autoGrowCollectionLimit);
	}
	return this.beanWrapper;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:BeanPropertyBindingResult.java


示例6: getPropertyAccessor

import org.springframework.beans.ConfigurablePropertyAccessor; //导入依赖的package包/类
/**
 * Returns the DirectFieldAccessor that this instance uses.
 * Creates a new one if none existed before.
 * @see #createDirectFieldAccessor()
 */
@Override
public final ConfigurablePropertyAccessor getPropertyAccessor() {
	if (this.directFieldAccessor == null) {
		this.directFieldAccessor = createDirectFieldAccessor();
		this.directFieldAccessor.setExtractOldValueForEditor(true);
		this.directFieldAccessor.setAutoGrowNestedPaths(this.autoGrowNestedPaths);
	}
	return this.directFieldAccessor;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:DirectFieldBindingResult.java


示例7: handleModification

import org.springframework.beans.ConfigurablePropertyAccessor; //导入依赖的package包/类
private List<PropertyChange<?>> handleModification(DescriptorEvent event)
{
	final Class<?> objectClass = event.getSource().getClass();
	
	final WriteObjectQuery writeObjectQuery = (WriteObjectQuery)event.getQuery();
	final ObjectChangeSet changeset = writeObjectQuery.getObjectChangeSet();
	final ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(event.getObject());
	
	final List<ChangeRecord> changes = changeset != null ? changeset.getChanges() : extractManually(writeObjectQuery, fieldFilter);
	final List<PropertyChange<?>> propChanges = new ArrayList<PropertyChange<?>>();
	for (ChangeRecord change : changes)
	{
		final String attrName = change.getAttribute();
		final Object newValue = accessor.getPropertyValue(attrName);
		final Object oldValue = change.getOldValue();
		final Class<?> attrType = accessor.getPropertyType(attrName);
		
		final Field field = ReflectionUtils.findField(objectClass, change.getAttribute());
		if (fieldFilter != null && !fieldFilter.test(field))
		{
		    continue;
		}
		
		entityUtil.extractSingle(field, attrName, attrType, oldValue, newValue, propChanges);
	}
	return propChanges;
}
 
开发者ID:ethlo,项目名称:dachs,代码行数:28,代码来源:EclipseLinkEntityEventListener.java


示例8: setPropertyValue

import org.springframework.beans.ConfigurablePropertyAccessor; //导入依赖的package包/类
protected void setPropertyValue(Object obj, ConfigurablePropertyAccessor bw, String propertyName, Object value){
	if(!bw.isWritableProperty(propertyName)){
		if(!ignoreNotFoundProperty){
			throw new NoSuchElementException("no setter found for property: " + propertyName+", target: " + obj);
		}
		logger.debug("ignore property: {}={} ", propertyName, value);
		return ;
	}
	bw.setPropertyValue(propertyName, value);
	if(logger.isDebugEnabled()){
		logger.debug("set property: {}={} ", propertyName, value);
	}
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:14,代码来源:BeanPropertiesMapper.java


示例9: getBean

import org.springframework.beans.ConfigurablePropertyAccessor; //导入依赖的package包/类
protected Object getBean(String beanName, Map<String, Object> model) {
    Object bean;
    if (model != null) {
        bean = model.get(beanName);
    } else {
        ConfigurablePropertyAccessor bw = PropertyAccessorFactory.forDirectFieldAccess(getRequestContext());
        HttpServletRequest request = (HttpServletRequest) bw.getPropertyValue("request");
        bean = request.getAttribute(beanName);
    }
    return bean;
}
 
开发者ID:arey,项目名称:spring-mvc-toolkit,代码行数:12,代码来源:Html5InputTag.java


示例10: createDirectFieldAccessor

import org.springframework.beans.ConfigurablePropertyAccessor; //导入依赖的package包/类
/**
 * Create a new DirectFieldAccessor for the underlying target object.
 * @see #getTarget()
 */
protected ConfigurablePropertyAccessor createDirectFieldAccessor() {
	Assert.state(this.target != null, "Cannot access fields on null target instance '" + getObjectName() + "'!");
	return PropertyAccessorFactory.forDirectFieldAccess(this.target);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:DirectFieldBindingResult.java


示例11: getPropertyAccessor

import org.springframework.beans.ConfigurablePropertyAccessor; //导入依赖的package包/类
/**
 * Return the underlying PropertyAccessor of this binder's BindingResult.
 */
protected ConfigurablePropertyAccessor getPropertyAccessor() {
	return getInternalBindingResult().getPropertyAccessor();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:DataBinder.java


示例12: extractManually

import org.springframework.beans.ConfigurablePropertyAccessor; //导入依赖的package包/类
private List<ChangeRecord> extractManually(WriteObjectQuery writeObjectQuery, Predicate<Field> filter)
{
	final Object oldObj = writeObjectQuery.getBackupClone();
	final Object newObj = writeObjectQuery.getObject();
	
	final ConfigurablePropertyAccessor accessorOld = PropertyAccessorFactory.forDirectFieldAccess(oldObj);
	final ConfigurablePropertyAccessor accessorNew = PropertyAccessorFactory.forDirectFieldAccess(newObj);
	final BeanWrapper beanAccessor = PropertyAccessorFactory.forBeanPropertyAccess(newObj);
	
	final List<ChangeRecord> retVal = new LinkedList<>();
	for (PropertyDescriptor desc : beanAccessor.getPropertyDescriptors())
	{
		final String propName = desc.getName();
		if (accessorNew.isReadableProperty(propName))
		{
		    final Field field = ReflectionUtils.findField(oldObj.getClass(), propName);
		    if (filter == null || filter.test(field))
		    {
   			    final Object newPropValue = accessorNew.getPropertyValue(propName);
   				final Object oldPropValue = accessorOld.getPropertyValue(propName);
   				if (! Objects.equals(newPropValue, oldPropValue))
   				{
   					final ChangeRecord c = new ChangeRecord()
   					{
   						@Override
   						public ObjectChangeSet getOwner()
   						{
   							return null;
   						}
   						
   						@Override
   						public Object getOldValue()
   						{
   							return oldPropValue;
   						}
   						
   						@Override
   						public String getAttribute()
   						{
   							return propName;
   						}
   					};
   					retVal.add(c);
   				}
		    }
		}
	}
	return retVal;
}
 
开发者ID:ethlo,项目名称:dachs,代码行数:50,代码来源:EclipseLinkEntityEventListener.java


示例13: createAccessor

import org.springframework.beans.ConfigurablePropertyAccessor; //导入依赖的package包/类
@Override
public ConfigurablePropertyAccessor createAccessor(Object obj) {
	ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forBeanPropertyAccess(obj);
	accessor.setAutoGrowNestedPaths(true);
	return accessor;
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:7,代码来源:BeanPropertiesMapper.java


示例14: newPropertyAccessor

import org.springframework.beans.ConfigurablePropertyAccessor; //导入依赖的package包/类
public static ConfigurablePropertyAccessor newPropertyAccessor(Object obj, boolean directFieldAccess){
	ConfigurablePropertyAccessor bw = directFieldAccess?PropertyAccessorFactory.forDirectFieldAccess(obj):PropertyAccessorFactory.forBeanPropertyAccess(obj);
	bw.setAutoGrowNestedPaths(true);
	return bw;
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:6,代码来源:SpringUtils.java


示例15: isNullAndWritableProperty

import org.springframework.beans.ConfigurablePropertyAccessor; //导入依赖的package包/类
private boolean isNullAndWritableProperty(ConfigurablePropertyAccessor accessor, String propertyName) {
	return accessor.isWritableProperty(propertyName) && (accessor.isReadableProperty(propertyName) && accessor.getPropertyValue(propertyName) == null);
}
 
开发者ID:curtiszimmerman,项目名称:AlgoTrader,代码行数:4,代码来源:GrailsDataBinder.java


示例16: getPropertyAccessor

import org.springframework.beans.ConfigurablePropertyAccessor; //导入依赖的package包/类
/**
 * Provide the PropertyAccessor to work with, according to the
 * concrete strategy of access.
 * <p>Note that a PropertyAccessor used by a BindingResult should
 * always have its "extractOldValueForEditor" flag set to "true"
 * by default, since this is typically possible without side effects
 * for model objects that serve as data binding target.
 * @see ConfigurablePropertyAccessor#setExtractOldValueForEditor
 */
public abstract ConfigurablePropertyAccessor getPropertyAccessor();
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:AbstractPropertyBindingResult.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GetBlockLocationsRequestProto类代码示例发布时间:2022-05-22
下一篇:
Java IconDrawable类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap