當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。