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


Java BeanWrapper.getPropertyValue方法代码示例

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


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

示例1: getObject

import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
@Override
public Object getObject() throws BeansException {
	BeanWrapper target = this.targetBeanWrapper;
	if (target != null) {
		if (logger.isWarnEnabled() && this.targetBeanName != null &&
				this.beanFactory instanceof ConfigurableBeanFactory &&
				((ConfigurableBeanFactory) this.beanFactory).isCurrentlyInCreation(this.targetBeanName)) {
			logger.warn("Target bean '" + this.targetBeanName + "' is still in creation due to a circular " +
					"reference - obtained value for property '" + this.propertyPath + "' may be outdated!");
		}
	}
	else {
		// Fetch prototype target bean...
		Object bean = this.beanFactory.getBean(this.targetBeanName);
		target = PropertyAccessorFactory.forBeanPropertyAccess(bean);
	}
	return target.getPropertyValue(this.propertyPath);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:PropertyPathFactoryBean.java

示例2: getId

import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public ID getId(T entity) {
	Class<?> domainClass = getJavaType();
	while (domainClass != Object.class) {
		for (Field field : domainClass.getDeclaredFields()) {
			if (field.getAnnotation(Id.class) != null) {
				try {
					return (ID) field.get(entity);
				}
				catch (IllegalArgumentException | IllegalAccessException e) {
					BeanWrapper beanWrapper = PropertyAccessorFactory
							.forBeanPropertyAccess(entity);
					return (ID) beanWrapper.getPropertyValue(field.getName());
				}
			}
		}
		domainClass = domainClass.getSuperclass();
	}
	throw new IllegalStateException("id not found");
}
 
开发者ID:tkob,项目名称:spring-data-gclouddatastore,代码行数:22,代码来源:GcloudDatastoreEntityInformation.java

示例3: writeObjectEntry

import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
/**
 * Copy & Paste, 无修正.
 */
private void writeObjectEntry(TagWriter tagWriter, String valueProperty, String labelProperty, Object item,
		int itemIndex) throws JspException {

	BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(item);
	Object renderValue;
	if (valueProperty != null) {
		renderValue = wrapper.getPropertyValue(valueProperty);
	} else if (item instanceof Enum) {
		renderValue = ((Enum<?>) item).name();
	} else {
		renderValue = item;
	}
	Object renderLabel = (labelProperty != null ? wrapper.getPropertyValue(labelProperty) : item);
	writeElementTag(tagWriter, item, renderValue, renderLabel, itemIndex);
}
 
开发者ID:pengqiuyuan,项目名称:g2,代码行数:19,代码来源:BSAbstractMultiCheckedElementTag.java

示例4: doRenderFromCollection

import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
/**
 * Renders the inner '{@code option}' tags using the supplied {@link Collection} of
 * objects as the source. The value of the {@link #valueProperty} field is used
 * when rendering the '{@code value}' of the '{@code option}' and the value of the
 * {@link #labelProperty} property is used when rendering the label.
 */
private void doRenderFromCollection(Collection<?> optionCollection, TagWriter tagWriter) throws JspException {
	for (Object item : optionCollection) {
		BeanWrapper wrapper = PropertyAccessorFactory.forBeanPropertyAccess(item);
		Object value;
		if (this.valueProperty != null) {
			value = wrapper.getPropertyValue(this.valueProperty);
		}
		else if (item instanceof Enum) {
			value = ((Enum<?>) item).name();
		}
		else {
			value = item;
		}
		Object label = (this.labelProperty != null ? wrapper.getPropertyValue(this.labelProperty) : item);
		renderOption(tagWriter, item, value, label);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:OptionWriter.java

示例5: handle

import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static <E> E handle(Object obj,Class<E> clz,Map<String,Strategy<?>> targetAndStrategy) throws Exception{
	E bean = null;
	if(clz.isAssignableFrom(obj.getClass())){
		bean = (E)obj;
	}else{
		throw new Exception("Object obj is not an instance of Class clz");
	}
	BeanWrapper bw = new BeanWrapperImpl(bean);
	Set<String> keySet = targetAndStrategy.keySet();
	for (String key : keySet) {
		@SuppressWarnings("rawtypes")
		Strategy s = targetAndStrategy.get(key);
		Object oldVal = bw.getPropertyValue(key);
		Object handledValue = s.handle(oldVal);
		bw.setPropertyValue(key, handledValue);
	}
	return bean;
}
 
开发者ID:wufeisoft,项目名称:ryf_mms2,代码行数:20,代码来源:AuthUtils.java

示例6: getValue

import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
public Object getValue(Object target) {
    BeanWrapper bw = new BeanWrapperImpl(target);
    Object object = bw.getPropertyValue(field.getName());

    if(object == null)
        return null;

    boolean isEnum = object.getClass().isEnum();
    if (object.getClass().isEnum() && IEnumMessage.class.isAssignableFrom(object.getClass())) {
        return ((IEnumMessage) object).getValue();
    }

    if (object instanceof DateTime) {
        DateTime dateTime = (DateTime) object;
        return dateTime.toString("yyyy-MM-dd HH:mm:ss");
    }

    return object;
}
 
开发者ID:gejinlove,项目名称:petapojo,代码行数:20,代码来源:PojoColumn.java

示例7: persist

import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
public void persist(Object entity) {
	// ReflectionUtils.
	BeanWrapper instance = new BeanWrapperImpl(entity);
	try {
		Object obj = instance.getPropertyValue("identification");
		if (obj == null) {
			instance.setPropertyValue("identification", new Identification());
			obj = instance.getPropertyValue("identification");
		}
		if (obj instanceof Identification) {
			Identification ident = (Identification) obj;
			ident.setCreated(new Date());
		}
	} catch (Exception e) {
		log.warn(e.getMessage());
	}
	em.persist(entity);
}
 
开发者ID:eetlite,项目名称:eet.osslite.cz,代码行数:19,代码来源:DaoSupport.java

示例8: getFieldWithAnnotation

import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
public static Object getFieldWithAnnotation(Object domainObj, Class<? extends Annotation> annotationClass)
		throws SecurityException, BeansException {
	Object value = null;

       Field field = findFieldWithAnnotation(domainObj, annotationClass);
       if (field != null && field.getAnnotation(annotationClass) != null) {
           try {
               PropertyDescriptor descriptor = org.springframework.beans.BeanUtils.getPropertyDescriptor(domainObj.getClass(), field.getName());
               if (descriptor != null) {
                   BeanWrapper wrapper = new BeanWrapperImpl(domainObj);
                   value = wrapper.getPropertyValue(field.getName());
               } else {
                   value = ReflectionUtils.getField(field, domainObj);
               }
               return value;
           } catch (IllegalArgumentException iae) {}
       }

	return value;
}
 
开发者ID:paulcwarren,项目名称:spring-content,代码行数:21,代码来源:BeanUtils.java

示例9: getNullPropertyNames

import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
public static String[] getNullPropertyNames(Object source) {
	final BeanWrapper src = new BeanWrapperImpl(source);
	java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors();

	Set<String> emptyNames = new HashSet<String>();
	for (java.beans.PropertyDescriptor pd : pds) {
		Object srcValue = src.getPropertyValue(pd.getName());
		if (srcValue == null)
			emptyNames.add(pd.getName());
	}
	String[] result = new String[emptyNames.size()];
	return emptyNames.toArray(result);
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:14,代码来源:BeanUtils.java

示例10: getNullPropertyNames

import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
public static String[] getNullPropertyNames(Object source, Set<String> notCopiedAttributes) {
  final BeanWrapper src = new BeanWrapperImpl(source);
  java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors();

  Set<String> emptyNames = new HashSet(notCopiedAttributes);
  for (java.beans.PropertyDescriptor pd : pds) {
    Object srcValue = src.getPropertyValue(pd.getName());
    if (srcValue == null) {
      emptyNames.add(pd.getName());
    }
  }

  String[] result = new String[emptyNames.size()];
  return emptyNames.toArray(result);
}
 
开发者ID:JUGIstanbul,项目名称:second-opinion-api,代码行数:16,代码来源:ObjectUtils.java

示例11: getNullPropertyNames

import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
/**
 * Returns an array of fields that have attributes with <i>null</i> value in
 * the desired object.
 *
 * @param source
 *            {@link Object} updated object.
 * @return {@link String} array of fields that have attributes with
 *         <i>null</i> value in the desired object.
 */
private static String[] getNullPropertyNames(Object source) {
	final BeanWrapper src = new BeanWrapperImpl(source);
	java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors();
	Set<String> emptyNames = new HashSet<String>();
	for (java.beans.PropertyDescriptor pd : pds) {
		Object srcValue = src.getPropertyValue(pd.getName());
		if (srcValue == null) {
			emptyNames.add(pd.getName());
		}
	}
	String[] result = new String[emptyNames.size()];
	return emptyNames.toArray(result);
}
 
开发者ID:brianmcca1,项目名称:ResidentialWay,代码行数:23,代码来源:ApplicationHelper.java

示例12: testBeanWrapper

import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
@Test
public void testBeanWrapper(){
    BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this);
    bw.setPropertyValue("name", "haoc");
    Object value = bw.getPropertyValue("name");
    System.out.println(value);
}
 
开发者ID:cbooy,项目名称:cakes,代码行数:8,代码来源:BeanWrapperTest.java

示例13: getNullPropertyNames

import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
public static String[] getNullPropertyNames (Object source) {
    final BeanWrapper src = new BeanWrapperImpl(source);
    java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors();

    Set<String> emptyNames = new HashSet<>();
    for(java.beans.PropertyDescriptor pd : pds) {
        Object srcValue = src.getPropertyValue(pd.getName());
        if (srcValue == null) emptyNames.add(pd.getName());
    }
    String[] result = new String[emptyNames.size()];
    return emptyNames.toArray(result);
}
 
开发者ID:finefuture,项目名称:data-migration,代码行数:13,代码来源:BeanUtil.java

示例14: getNullPropertyNames

import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
private static String[] getNullPropertyNames(Object source) {
  final BeanWrapper src = new BeanWrapperImpl(source);
  PropertyDescriptor[] pds = src.getPropertyDescriptors();

  Set<String> emptyNames = new HashSet<String>();
  for (PropertyDescriptor pd : pds) {
    Object srcValue = src.getPropertyValue(pd.getName());
    if (srcValue == null) emptyNames.add(pd.getName());
  }
  String[] result = new String[emptyNames.size()];
  return emptyNames.toArray(result);
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:13,代码来源:BeanUtils.java

示例15: appendPropertyValues

import org.springframework.beans.BeanWrapper; //导入方法依赖的package包/类
/**
 * Appends all property values on the given {@link StringBuilder}
 */
private void appendPropertyValues(final StringBuilder sb, final Object bean) {
    if (bean == null) {
        sb.append("<null>");
        return;
    } else if (bean instanceof String) {
        sb.append(bean);
        return;
    }
    BeanWrapper bw = new BeanWrapperImpl(bean);
    boolean first = true;
    for (PropertyDescriptor desc : bw.getPropertyDescriptors()) {
        if (desc.getWriteMethod() == null) {
            // Only log readable and writable properties
            continue;
        }
        if (first) {
            first = false;
        } else {
            sb.append(", ");
        }
        String name = desc.getName();
        sb.append(name).append('=');
        Object value = bw.getPropertyValue(name);
        appendValue(sb, FormatObject.maskIfNeeded(name, value));
    }
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:30,代码来源:LoggingHandlerImpl.java


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