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


Java DynaProperty.getName方法代码示例

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


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

示例1: buildPropertyMap

import org.apache.commons.beanutils.DynaProperty; //导入方法依赖的package包/类
/**
 * build a map of business object with its specified property names and corresponding values
 * 
 * @param businessObject the given business object
 * @param the specified fields that need to be included in the return map
 * @return the map of business object with its property names and values
 */
public static Map<String, Object> buildPropertyMap(Object object, List<String> keyFields) {
    DynaClass dynaClass = WrapDynaClass.createDynaClass(object.getClass());
    DynaProperty[] properties = dynaClass.getDynaProperties();
    Map<String, Object> propertyMap = new LinkedHashMap<String, Object>();

    for (DynaProperty property : properties) {
        String propertyName = property.getName();

        if (PropertyUtils.isReadable(object, propertyName) && keyFields.contains(propertyName)) {
            try {
                Object propertyValue = PropertyUtils.getProperty(object, propertyName);

                if (propertyValue != null && !StringUtils.isEmpty(propertyValue.toString())) {
                    propertyMap.put(propertyName, propertyValue);
                }
            }
            catch (Exception e) {
                LOG.info(e);
            }
        }
    }
    return propertyMap;
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:31,代码来源:ObjectUtil.java

示例2: hasNullValueField

import org.apache.commons.beanutils.DynaProperty; //导入方法依赖的package包/类
/**
 * determine if the source object has a field with null as its value
 * 
 * @param sourceObject the source object
 */
public static boolean hasNullValueField(Object sourceObject) {
    DynaClass dynaClass = WrapDynaClass.createDynaClass(sourceObject.getClass());
    DynaProperty[] properties = dynaClass.getDynaProperties();

    for (DynaProperty property : properties) {
        String propertyName = property.getName();

        if (PropertyUtils.isReadable(sourceObject, propertyName)) {
            try {
                Object propertyValue = PropertyUtils.getProperty(sourceObject, propertyName);
                if (propertyValue == null) {
                    return true;
                }
            }
            catch (Exception e) {
                LOG.info(e);
                return false;
            }
        }
    }
    return false;
}
 
开发者ID:VU-libtech,项目名称:OLE-INST,代码行数:28,代码来源:ObjectUtil.java

示例3: getValueAt

import org.apache.commons.beanutils.DynaProperty; //导入方法依赖的package包/类
@Override
public Object getValueAt(final int rowIndex, final int columnIndex) {
    final Object value;
    final DynaProperty property = this.properties[rowIndex];
    switch (columnIndex) {
        case 0:
            value = property.getName();
            break;
        case 1:
            value = content.get(property.getName());
            break;
        default:
            throw new IndexOutOfBoundsException("No such column: " + columnIndex);
    }
    return value;
}
 
开发者ID:edouardhue,项目名称:comeon,代码行数:17,代码来源:MediaMetadataTable.java

示例4: getPropertyNames

import org.apache.commons.beanutils.DynaProperty; //导入方法依赖的package包/类
public List<String> getPropertyNames(Object bean) {
    List<String> names = new ArrayList<String>();
    DynaProperty origDescriptors[] =
        ((DynaBean) bean).getDynaClass().getDynaProperties();
    for (DynaProperty dynaProperty : origDescriptors) {
        String name = dynaProperty.getName();
        names.add(name);
    }
    return names;
}
 
开发者ID:azeckoski,项目名称:reflectutils,代码行数:11,代码来源:DynaBeanAdapter.java

示例5: Wrap

import org.apache.commons.beanutils.DynaProperty; //导入方法依赖的package包/类
/**
 * Wrap an object info ObjectMap.
 * 
 * @param object
 * @return 
 */
public static ObjectMap Wrap(Object object){
	Assert.notNull(object);
	
	ObjectMap viewModel = new DefaultObjectMap();
	
	// check object type
	if (object instanceof Map){
		Map m = (Map)object;
		for(Object name : m.keySet()){
			viewModel.add(name.toString(), m.get(name));
		}
		return viewModel;
	}

	// copy all properties (except 'class') to map
	DynaBean dynaBean = new WrapDynaBean(object);
	DynaClass dynaClass = dynaBean.getDynaClass();
	for(DynaProperty property : dynaClass.getDynaProperties()){
		String key = property.getName();
		if (key.equals("class")){
			continue;
		}

		viewModel.add(key, dynaBean.get(key));
	}
	
	return viewModel;
}
 
开发者ID:ivarptr,项目名称:clobaframe,代码行数:35,代码来源:Utils.java


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