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


Java PropertyUtils.getNestedProperty方法代碼示例

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


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

示例1: filterByDate

import org.apache.commons.beanutils.PropertyUtils; //導入方法依賴的package包/類
/**
 * Default String contains filter processing.
 *
 * @param item          Photo to consider for inclusion.
 * @param filterProperty Filter property name used to determine which photo field to compare with.
 * @param filterValue    Value of the filter.
 * @return True if photo should be included in the resultant list to display.
 */
protected boolean filterByDate(T item, String filterProperty, Object filterValue) {
	FastDateFormat dateInstance = FastDateFormat.getInstance(MM_DD_YY_PATTERN);

	try {
		Object fieldValue = PropertyUtils.getNestedProperty(item, filterProperty);
		Date theDate = (Date) fieldValue;
		String dateStr = dateInstance.format((Date) fieldValue);

		if (filterValue == null || (dateInstance.format((Date) fieldValue).contains(filterValue.toString()))) {
			return true;
		}
	} catch (Exception e) {
		log.error("Failed to filter. ", e);
	}

	return false;
}
 
開發者ID:heather92115,項目名稱:photosOpen,代碼行數:26,代碼來源:DataListFilter.java

示例2: compare

import org.apache.commons.beanutils.PropertyUtils; //導入方法依賴的package包/類
@Override
public int compare(T item1, T item2) {
	try {
		Comparable fieldValue1 = (Comparable) PropertyUtils.getNestedProperty(item1, sortField);
		Comparable fieldValue2 = (Comparable)PropertyUtils.getNestedProperty(item2, sortField);

		int retVal = ObjectUtils.compare(fieldValue1, fieldValue2);

		if (SortOrder.DESCENDING.equals(sortOrder)) {
			retVal = -retVal;
		}

		return retVal;
	}
	catch (Exception e) {
		log.error("Failed to sort with sortField " + sortField, e);
	}
	return 0;
}
 
開發者ID:heather92115,項目名稱:photosOpen,代碼行數:20,代碼來源:DeepSorter.java

示例3: getNestedProperty

import org.apache.commons.beanutils.PropertyUtils; //導入方法依賴的package包/類
public static Object getNestedProperty(Object data, String name) {
    try {
        if (!name.contains(".")) {
            return PropertyUtils.getProperty(data, name);
        }
        if (name.contains("[")) {
            String[] names = name.split("\\.", 2);
            Object obj = null;
            try {
                obj = PropertyUtils.getIndexedProperty(data, names[0]);
            } catch (NullPointerException npe) {
                // アクセスする配列オブジェクトがnullの場合
                obj = null;
            }
            if (obj == null) {
                return null;
            }
            return getNestedProperty(obj, names[1]);
        }
        try {
            return PropertyUtils.getNestedProperty(data, name);
        } catch (NestedNullException nne) {
            // ネストしたプロパティの途中がnullの場合はエラーとせず
            // nullを返す
            return null;
        }
    } catch (Exception e) {
        throw new ApplicationFatalRuntimeException("invalid property : " + name, e);
    }
}
 
開發者ID:otsecbsol,項目名稱:linkbinder,代碼行數:31,代碼來源:PropertyGetUtil.java

示例4: filterByStringType

import org.apache.commons.beanutils.PropertyUtils; //導入方法依賴的package包/類
/**
 * Default String contains filter processing.
 *
 * @param item          Photo to consider for inclusion.
 * @param filterProperty Filter property name used to determine which photo field to compare with.
 * @param filterValue    Value of the filter.
 * @return True if photo should be included in the resultant list to display.
 */
protected boolean filterByStringType(T item, String filterProperty, Object filterValue) {

	try {
		Object fieldValue = PropertyUtils.getNestedProperty(item, filterProperty);

		if (filterValue == null || (fieldValue != null && fieldValue.toString().toLowerCase().contains(filterValue.toString().toLowerCase()))) {
			return true;
		}
	} catch (Exception e) {
		log.error("Failed to filter. ", e);
	}

	return false;
}
 
開發者ID:heather92115,項目名稱:photosOpen,代碼行數:23,代碼來源:DataListFilter.java


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