當前位置: 首頁>>代碼示例>>Java>>正文


Java BeanUtils.getProperty方法代碼示例

本文整理匯總了Java中org.apache.commons.beanutils.BeanUtils.getProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java BeanUtils.getProperty方法的具體用法?Java BeanUtils.getProperty怎麽用?Java BeanUtils.getProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.beanutils.BeanUtils的用法示例。


在下文中一共展示了BeanUtils.getProperty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkPropertiesOfAttachement

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
/**
 * Check properties of Attachement objects.
 * 
 * @param attachements
 * @throws AirtableException
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 * @throws NoSuchMethodException 
 */
private void checkPropertiesOfAttachement(List<Attachment> attachements) throws AirtableException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {

    if (attachements != null) {
        for (int i = 0; i < attachements.size(); i++) {
            if (propertyExists(attachements.get(i), FIELD_ID) || propertyExists(attachements.get(i), "size") 
                    || propertyExists(attachements.get(i), "type") || propertyExists(attachements.get(i), "filename")) {
                
                final Field[] attributesPhotos = attachements.getClass().getDeclaredFields();
                for (Field attributePhoto : attributesPhotos) {
                    final String namePhotoAttribute = attributePhoto.getName();
                    if (FIELD_ID.equals(namePhotoAttribute) || "size".equals(namePhotoAttribute) 
                            || "type".equals(namePhotoAttribute) || "filename".equals(namePhotoAttribute)) {
                        if (BeanUtils.getProperty(attachements.get(i), namePhotoAttribute) != null) {
                            throw new AirtableException("Property " + namePhotoAttribute + " should be null!");
                        }
                    }
                }
            }
        }
    }
}
 
開發者ID:Sybit-Education,項目名稱:airtable.java,代碼行數:31,代碼來源:Table.java

示例2: checkProperties

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
/**
 * Checks if the Property Values of the item are valid for the Request.
 *
 * @param item
 * @throws AirtableException
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 * @throws NoSuchMethodException
 */
private void checkProperties(T item) throws AirtableException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {

    if (propertyExists(item, FIELD_ID) || propertyExists(item, FIELD_CREATED_TIME)) {
        Field[] attributes = item.getClass().getDeclaredFields();
        for (Field attribute : attributes) {
            String attrName = attribute.getName();
            if (FIELD_ID.equals(attrName) || FIELD_CREATED_TIME.equals(attrName)) {
                if (BeanUtils.getProperty(item, attribute.getName()) != null) {
                    throw new AirtableException("Property " + attrName + " should be null!");
                }
            } else if ("photos".equals(attrName)) {
                List<Attachment> obj = (List<Attachment>) BeanUtilsBean.getInstance().getPropertyUtils().getProperty(item, "photos");
                checkPropertiesOfAttachement(obj);
            }
        }
    }

}
 
開發者ID:Sybit-Education,項目名稱:airtable.java,代碼行數:28,代碼來源:Table.java

示例3: getOrderedKeyset

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
protected List getOrderedKeyset(Set keys, Object param) throws Exception {
    List orderedKeyset = new ArrayList();
    if (keys.size() > 0) {
        String firstitems = BeanUtils.getProperty(param,
                "_firstitems");
        String firstitemname = null;
        if (firstitems != null) {
            for (StringTokenizer st = new StringTokenizer(firstitems, ","); st
                    .hasMoreTokens(); ) {
                firstitemname = st.nextToken();
                if (keys.contains(firstitemname)) {
                    orderedKeyset.add(firstitemname);
                }
            }
        }
        for (Iterator it = keys.iterator(); it.hasNext(); ) {
            String key = (String) it.next();
            if (!orderedKeyset.contains(key))
                orderedKeyset.add(key);
        }
    }
    return orderedKeyset;
}
 
開發者ID:jambo-framework,項目名稱:jambo2,代碼行數:24,代碼來源:SQLHelper.java

示例4: isValid

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
@Override
public boolean isValid(Object value, ConstraintValidatorContext context) {
    if (value == null) {
        return true;
    }

    try {
        final String fieldValue = BeanUtils.getProperty(value, fieldName);
        final String notNullFieldValue = BeanUtils.getProperty(value, notNullFieldName);
        if (StringUtils.equals(fieldValue, fieldSetValue) && StringUtils.isEmpty(notNullFieldValue)) {
            context.disableDefaultConstraintViolation();
            context.buildConstraintViolationWithTemplate(context.getDefaultConstraintMessageTemplate())
                    .addPropertyNode(notNullFieldName).addConstraintViolation();
            return false;
        }
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
        throw new RuntimeException(e);
    }

    return true;
}
 
開發者ID:NationalSecurityAgency,項目名稱:qonduit,代碼行數:22,代碼來源:NotEmptyIfFieldSetValidator.java

示例5: doRoute

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
@Before("aopPoint()")
public Object doRoute(JoinPoint jp) throws Throwable {
    boolean result = true;
    Method method = this.getMethod(jp);
    DbRoute dbRoute = method.getAnnotation(DbRoute.class);
    String routeField = dbRoute.field();  // userId
    Object[] args = jp.getArgs();  
    if(args != null && args.length > 0) {  
        for(int i = 0; i < args.length; ++i) {  
            String routeFieldValue = BeanUtils.getProperty(args[i], routeField);
            if(StringUtils.isNotEmpty(routeFieldValue)) {
                if("userId".equals(routeField)) {  
                    this.dbRouter.route(routeField);
                }
                break;  
            }  
        }  
    }  
  
    return Boolean.valueOf(result);
}
 
開發者ID:javahongxi,項目名稱:whatsmars,代碼行數:22,代碼來源:DbRouteInterceptor.java

示例6: extractRecordId

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
private String extractRecordId(MobileBean record)
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
{
	String id = "";
	
	Class recordClazz = record.getClass();
	Field[] declaredFields = recordClazz.getDeclaredFields();		
	for(Field field: declaredFields)
	{		
		Annotation[] annotations = field.getAnnotations();			
		for(Annotation annotation: annotations)
		{								
			if(annotation instanceof MobileBeanId)
			{
				return BeanUtils.getProperty(record, field.getName());										
			}
		}			
	}
	
	return id;
}
 
開發者ID:ZalemSoftware,項目名稱:OpenMobster,代碼行數:22,代碼來源:MobileObjectGateway.java

示例7: isValid

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
@Override
public boolean isValid(Object value, ConstraintValidatorContext context) {
  try {
    final Idtp idtp = (Idtp) PropertyUtils.getProperty(value, typeFieldName);
    final String idno = BeanUtils.getProperty(value, codeFieldName);

    if (idtp.equals(Idtp.IDCARD)) {
      return IdentifierValidation.isIdCardNo(idno);
    }

    if (idtp.equals(Idtp.OCC)) {
      return IdentifierValidation.isOcc(idno);
    }

    if (idtp.equals(Idtp.USCIC)) {
      return IdentifierValidation.isUscic(idno);
    }
  } catch (Exception e) {
    throw new BaseException("E-BASE-000001", e.getMessage()).initCause(e);
  }

  return true;
}
 
開發者ID:ibankapp,項目名稱:ibankapp-base,代碼行數:24,代碼來源:IdentifierValidator.java

示例8: newBeansSource

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
/**
 * Create a new ReplaceSource that handles bean references
 *
 * @param properties
 *            the properties to use for replacing
 * @return the new ReplaceSource instance
 */
public static ReplaceSource newBeansSource ( final Map<?, ?> properties )
{
    return new ReplaceSource () {

        @Override
        public String replace ( final String context, final String key )
        {
            String result = null;
            try
            {
                result = BeanUtils.getProperty ( properties, key );
            }
            catch ( final Exception e )
            {
            }
            if ( result != null )
            {
                return result;
            }
            else
            {
                return context;
            }
        }
    };
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:34,代碼來源:StringReplacer.java

示例9: getIdOfItem

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
/**
 * Get the String Id from the item.
 *
 * @param item
 * @return
 * @throws AirtableException
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 * @throws NoSuchMethodException
 */
private String getIdOfItem(T item) throws AirtableException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {

    if (propertyExists(item, FIELD_ID)) {
        final String id = BeanUtils.getProperty(item, FIELD_ID);
        if (id != null) {
            return id;
        }
    }
    throw new AirtableException("Id of " + item + " not Found!");
}
 
開發者ID:Sybit-Education,項目名稱:airtable.java,代碼行數:21,代碼來源:Table.java

示例10: filterFields

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
/**
 *
 * Filter the Fields of the PostRecord Object. Id and created Time are set
 * to null so Object Mapper doesent convert them to JSON.
 *
 * @param item
 * @return
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 * @throws NoSuchMethodException
 */
private T filterFields(T item) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {

    final Field[] attributes = item.getClass().getDeclaredFields();

    for (Field attribute : attributes) {
        String attrName = attribute.getName();
        if ((FIELD_ID.equals(attrName) || FIELD_CREATED_TIME.equals(attrName)) 
                && (BeanUtils.getProperty(item, attrName) != null)) {
            BeanUtilsBean.getInstance().getPropertyUtils().setProperty(item, attrName, null);
        }
    }

    return item;
}
 
開發者ID:Sybit-Education,項目名稱:airtable.java,代碼行數:26,代碼來源:Table.java

示例11: fetchData

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
protected Object fetchData(Object object,String property){
	try {
		return BeanUtils.getProperty(object, property);
	} catch (Exception e) {
		throw new RuleException(e);
	}
}
 
開發者ID:youseries,項目名稱:urule,代碼行數:8,代碼來源:BaseReteNode.java

示例12: getValueProperty

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
/** Renvoie la valeur de la propriété du bean
 * @param property
 * @return la valeur de la propriété 
 */
public String getValueProperty(String property){
	try {			
		String valueProperty = BeanUtils.getProperty(this, property);
		if (valueProperty!=null){
			return valueProperty.toString();
		}else{
			return "";
		}
	} catch (Exception e) {
		return "";
	}
}
 
開發者ID:EsupPortail,項目名稱:esup-ecandidat,代碼行數:17,代碼來源:MailBean.java

示例13: getIdValue

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
public String getIdValue()  {
	try {
		return  BeanUtils.getProperty(this, id());
	} catch (Exception e) {
		log.catching(e);
	}
	return null;
}
 
開發者ID:jambo-framework,項目名稱:jambo2,代碼行數:9,代碼來源:BaseVO.java

示例14: getOid

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
public static String getOid(MobileBean record)
{
	try
	{
		String id = "";
		
		Class recordClazz = record.getClass();
		Field[] declaredFields = recordClazz.getDeclaredFields();		
		for(Field field: declaredFields)
		{		
			Annotation[] annotations = field.getAnnotations();			
			for(Annotation annotation: annotations)
			{								
				if(annotation instanceof MobileBeanId)
				{
					return BeanUtils.getProperty(record, field.getName());										
				}
			}			
		}
		
		return id;
	}
	catch(Exception e)
	{
		throw new RuntimeException(e);
	}
}
 
開發者ID:ZalemSoftware,項目名稱:OpenMobster,代碼行數:28,代碼來源:Tools.java

示例15: getString

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
/**
 * Get virtual column string value
 */
public static String getString(DatabaseMetadataValue value, String column) throws DatabaseException, IllegalAccessException,
		InvocationTargetException, NoSuchMethodException {
	List<DatabaseMetadataType> types = DatabaseMetadataDAO.findAllTypes(value.getTable());

	for (DatabaseMetadataType emt : types) {
		if (emt.getVirtualColumn().equals(column)) {
			return BeanUtils.getProperty(value, emt.getRealColumn());
		}
	}

	return null;
}
 
開發者ID:openkm,項目名稱:document-management-system,代碼行數:16,代碼來源:DatabaseMetadataUtils.java


注:本文中的org.apache.commons.beanutils.BeanUtils.getProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。