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


Java BeanUtils.describe方法代碼示例

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


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

示例1: getConditions

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
protected Map getConditions(Object param) throws IllegalAccessException,
        InvocationTargetException, NoSuchMethodException {

    // 靜態條件部分
    Map props = BeanUtils.describe(param);

    // new 動態條件部分 add by hekun
    if (param instanceof DBQueryParam) {
        DBQueryParam listVO = (DBQueryParam) param;
        Map queryConditions = listVO.getQueryConditions();

        if (queryConditions != null && queryConditions.size() > 0) {
            // 將靜態條件加入動態條件中,重複的動態條件及其值將被覆蓋。
            for (Iterator keys = props.keySet().iterator(); keys.hasNext(); ) {
                String key = (String) keys.next();
                Object value = props.get(key);
                if (key.startsWith("_") && value != null)
                    queryConditions.put(key, value);
            }
            props = queryConditions;
        }
    }
    return props;
}
 
開發者ID:jambo-framework,項目名稱:jambo2,代碼行數:25,代碼來源:SQLHelper.java

示例2: toString

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
public String toString()
{
	try
	{
		StringBuffer sb = new StringBuffer( "{" );
		Map properties = BeanUtils.describe( this );
		for ( Iterator it = properties.keySet().iterator(); it.hasNext(); )
		{
			Object key = it.next();
			Object value = properties.get( key );
			sb.append( key.toString() ).append( "=" ).append( value != null ? value.toString() : null ).append( it.hasNext() ? ", " : "") ; 
		}
		sb.append( "}" );
		return sb.toString();
	}
	catch( Exception exc )
	{
		exc.printStackTrace();
		return super.toString();
	}
}
 
開發者ID:GovernIB,項目名稱:sistra,代碼行數:22,代碼來源:ResultadoRegistro.java

示例3: addInnerQueryString

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
/**
 * 拚接URL,參數從obj中通過反射取得。
 *
 * @param url
 *            URL
 * @param obj
 *            對象
 * @return 拚接後的URL
 */
public static String addInnerQueryString(String url, Object obj) {
    List<String> names = new ArrayList<>();
    List<Object> values = new ArrayList<>();

    try {
        Map<String, String> properties = BeanUtils.describe(obj);
        for (Map.Entry<String, String> entry : properties.entrySet()) {
            String name = entry.getKey();
            if ("class".equals(name)) {
                continue;
            }

            names.add(name);
            values.add(entry.getValue());
        }
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
    }

    return addQueryString(url, names.toArray(new String[names.size()]), values.toArray(new Object[values.size()]));
}
 
開發者ID:akuma,項目名稱:meazza,代碼行數:30,代碼來源:URLUtils.java

示例4: initailizeTestValuesToInsert

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
@Override
protected Map<String, Object> initailizeTestValuesToInsert(List<String> testColumns, Object entityToInsert) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {

    logger.info("Starting method: initailizeTestValuesToInsert");

    for(String testColumn : testColumns){
        logger.info("Testing columns: " + testColumn);
    }

    Map<String, Object> valuesToInsert = new HashMap<String, Object>();

    Map<String, String> fieldValues = BeanUtils.describe(entityToInsert);

    for(Map.Entry<String, String> entry : fieldValues.entrySet()){
        logger.info("Preparing entry set entry of: " + entry.getKey() + " : " + entry.getValue());
    }

    for (String testColumnName : testColumns){
        String propertyName = transformSqlColumnNamesToJavaPropertyName(testColumnName);
        String fieldValue = fieldValues.get(propertyName);
        logger.info("Setting field value: " + fieldValue + " from field: " + propertyName + " for column: " + testColumnName);
        if( fieldValues.get(propertyName) != null) {
            valuesToInsert.put(testColumnName, fieldValues.get(propertyName));
        }else{
            valuesToInsert.put(testColumnName, ((SkuEntity) entityToInsert).getSkuVendor().getVendorKey());
        }
    }
    return valuesToInsert;
}
 
開發者ID:opensource-io,項目名稱:training_storefront,代碼行數:30,代碼來源:SkuEntityTestRig.java

示例5: initailizeTestValuesToInsert

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
@Override
protected Map<String, Object> initailizeTestValuesToInsert(List<String> testColumns, Object entityToInsert) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
    Map<String, Object> valuesToInsert = new HashMap<String, Object>();

    Map<String, String> fieldValues = BeanUtils.describe(entityToInsert);

    for (String testColumnName : testColumns){
        valuesToInsert.put(testColumnName, fieldValues.get(transformSqlColumnNamesToJavaPropertyName(testColumnName)));
    }
    return valuesToInsert;
}
 
開發者ID:opensource-io,項目名稱:training_storefront,代碼行數:12,代碼來源:VendorEntityTestRig.java

示例6: po2Map

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
/**
 * 將po對象中有屬性和值轉換成map
 * 
 * @param po
 * @return
 */
public static Map po2Map(Object po) {
	Map poMap = new HashMap();
	Map map = new HashMap();
	try {
		map = BeanUtils.describe(po);
	} catch (Exception ex) {
	}
	Object[] keyArray = map.keySet().toArray();
	for (int i = 0; i < keyArray.length; i++) {
		String str = keyArray[i].toString();
		if (str != null && !str.equals("class")) {
			if (map.get(str) != null) {
				poMap.put(str, map.get(str));
			}
		}
	}

	Method[] ms =po.getClass().getMethods();
	for(Method m:ms){
		String name = m.getName();
		
		if(name.startsWith("get")||name.startsWith("is")){
			if(m.getAnnotation(NotDbField.class)!=null||m.getAnnotation(PrimaryKeyField.class)!=null){
				poMap.remove(getFieldName(name)); 
			} 
		}

	}
	
	/**
	 * 如果此實體為動態字段實體,將動態字段加入
	 */
	if(po instanceof DynamicField){
		DynamicField dynamicField = (DynamicField) po;
		Map fields = dynamicField.getFields();
		poMap.putAll(fields);
	}
	return poMap;
}
 
開發者ID:yulele166,項目名稱:pub-service,代碼行數:46,代碼來源:ReflectionUtil.java

示例7: toString

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
@Override
public String toString() {
  try {
    Map<String, String> properties = BeanUtils.describe(this);
    properties.remove("class");
    return properties.toString();
  } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
    return super.toString();
  }
}
 
開發者ID:Enterprise-Content-Management,項目名稱:infoarchive-sip-sdk,代碼行數:11,代碼來源:JavaBean.java

示例8: po2Map

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
/**
 * 將po對象中有屬性和值轉換成map
 * 
 * @param po
 * @return
 */
public static Map po2Map(Object po) {
	Map poMap = new HashMap();
	Map map = new HashMap();
	try {
		map = BeanUtils.describe(po);
	} catch (Exception ex) {
	}
	Object[] keyArray = map.keySet().toArray();
	for (int i = 0; i < keyArray.length; i++) {
		String str = keyArray[i].toString();
		if (str != null && !str.equals("class")) {
			if (map.get(str) != null) {
				poMap.put(str, map.get(str));
			}
		}
	}

	Method[] ms =po.getClass().getMethods();
	/*for(Method m:ms){
		String name = m.getName();
		
	/*	if(name.startsWith("get")||name.startsWith("is")){
			if(m.getAnnotation(NotDbField.class)!=null||m.getAnnotation(PrimaryKeyField.class)!=null){
				poMap.remove(getFieldName(name)); 
			} 
		}

	}
	
	/**
	 * 如果此實體為動態字段實體,將動態字段加入
	 */
	/*if(po instanceof DynamicField){
		DynamicField dynamicField = (DynamicField) po;
		Map fields = dynamicField.getFields();
		poMap.putAll(fields);
	}*/
	return poMap;
}
 
開發者ID:tzou24,項目名稱:abina-common-util,代碼行數:46,代碼來源:ReflectionUtils.java

示例9: process

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
@SuppressWarnings({ "rawtypes", "unchecked" })
	@Override
    public void process(SysLog sysLog) {
        Map map = null;
        try {
            map = BeanUtils.describe(sysLog);
            map.remove("class");
        } catch (Exception e) {
            e.printStackTrace();
        }
        Record record = new Record();
        record.setColumns(map);
        System.out.println(record);
//        Db.save("syslog", record);
    }
 
開發者ID:gumutianqi,項目名稱:jfinal-plus,代碼行數:16,代碼來源:DefaultLogProccesor.java


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