Java 类org.apache.commons.beanutils.WrapDynaClass 实例源码

项目:OLE-INST    文件:ObjectUtil.java   
/**
 * 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;
}
项目:OLE-INST    文件:ObjectUtil.java   
/**
 * 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;
}
项目:OLE-INST    文件:OJBUtility.java   
/**
 * This method builds a map of business object with its property names and values
 *
 * @param businessObject the given business object
 * @return the map of business object with its property names and values
 */
public static LinkedHashMap buildPropertyMap(Object businessObject) {
    DynaClass dynaClass = WrapDynaClass.createDynaClass(businessObject.getClass());
    DynaProperty[] properties = dynaClass.getDynaProperties();
    LinkedHashMap propertyMap = new LinkedHashMap();

    try {
        for (int numOfProperty = 0; numOfProperty < properties.length; numOfProperty++) {
            String propertyName = properties[numOfProperty].getName();
            if (PropertyUtils.isWriteable(businessObject, propertyName)) {
                Object propertyValue = PropertyUtils.getProperty(businessObject, propertyName);
                propertyMap.put(propertyName, propertyValue);
            }
        }
    }
    catch (Exception e) {
        LOG.error("OJBUtility.buildPropertyMap()" + e);
    }
    return propertyMap;
}
项目:kfs    文件:ObjectUtil.java   
/**
 * 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;
}
项目:kfs    文件:ObjectUtil.java   
/**
 * 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;
}
项目:kfs    文件:OJBUtility.java   
/**
 * This method builds a map of business object with its property names and values
 * 
 * @param businessObject the given business object
 * @return the map of business object with its property names and values
 */
public static LinkedHashMap buildPropertyMap(Object businessObject) {
    DynaClass dynaClass = WrapDynaClass.createDynaClass(businessObject.getClass());
    DynaProperty[] properties = dynaClass.getDynaProperties();
    LinkedHashMap propertyMap = new LinkedHashMap();

    try {
        for (int numOfProperty = 0; numOfProperty < properties.length; numOfProperty++) {
            String propertyName = properties[numOfProperty].getName();
            if (PropertyUtils.isWriteable(businessObject, propertyName)) {
                Object propertyValue = PropertyUtils.getProperty(businessObject, propertyName);
                propertyMap.put(propertyName, propertyValue);
            }
        }
    }
    catch (Exception e) {
        LOG.error("OJBUtility.buildPropertyMap()" + e);
    }
    return propertyMap;
}
项目:field-binder    文件:FieldBinder.java   
/**
 * Creates a FieldBinder that will use the given container as the backing
 * for the values of its fields.
 *
 * {@link #getNavigation()} returns a controller on top of that container
 *
 *
 * @param beanClass
 * @param container
 */
public FieldBinder(Class<T> beanClass, Container.Ordered container) {
    super(new FieldGroup());
    this.beanClass = beanClass;
    this.dynaClass = WrapDynaClass.createDynaClass(beanClass);

    BasicDataNavigation nav = new BasicDataNavigation(container);
    nav.setBehaviorFactory(new DefaultBehaviorFactory<>(this));

    this.navigation = nav;

}
项目:OLE-INST    文件:ObjectUtil.java   
/**
 * Populate the target object with the source object
 * 
 * @param targetObject the target object
 * @param sourceObject the source object
 */
public static void buildObject(Object targetObject, Object sourceObject) {
    DynaClass dynaClass = WrapDynaClass.createDynaClass(targetObject.getClass());
    DynaProperty[] properties = dynaClass.getDynaProperties();

    for (DynaProperty property : properties) {
        ObjectUtil.setProperty(targetObject, sourceObject, property, false);
    }
}
项目:OLE-INST    文件:ObjectUtil.java   
/**
 * Populate the target object with the source object
 * 
 * @param targetObject the target object
 * @param sourceObject the source object
 */
public static void buildObjectWithoutReferenceFields(Object targetObject, Object sourceObject) {
    DynaClass dynaClass = WrapDynaClass.createDynaClass(targetObject.getClass());
    DynaProperty[] properties = dynaClass.getDynaProperties();

    for (DynaProperty property : properties) {
        ObjectUtil.setProperty(targetObject, sourceObject, property, true);
    }
}
项目:kfs    文件:ObjectUtil.java   
/**
 * Populate the target object with the source object
 * 
 * @param targetObject the target object
 * @param sourceObject the source object
 */
public static void buildObject(Object targetObject, Object sourceObject) {
    DynaClass dynaClass = WrapDynaClass.createDynaClass(targetObject.getClass());
    DynaProperty[] properties = dynaClass.getDynaProperties();

    for (DynaProperty property : properties) {
        ObjectUtil.setProperty(targetObject, sourceObject, property, false);
    }
}
项目:kfs    文件:ObjectUtil.java   
/**
 * Populate the target object with the source object
 * 
 * @param targetObject the target object
 * @param sourceObject the source object
 */
public static void buildObjectWithoutReferenceFields(Object targetObject, Object sourceObject) {
    DynaClass dynaClass = WrapDynaClass.createDynaClass(targetObject.getClass());
    DynaProperty[] properties = dynaClass.getDynaProperties();

    for (DynaProperty property : properties) {
        ObjectUtil.setProperty(targetObject, sourceObject, property, true);
    }
}
项目:extacrm    文件:JpaPropertyProvider.java   
private Class<?> getNestedPropType(String nestedProp) {
    WrapDynaClass propClass = getDynaClass();
    String prop = null;
    Class<?> propType = Object.class;
    while (resolver.hasNested(nestedProp)) {
        prop = resolver.next(nestedProp);

        propType = propClass.getDynaProperty(prop).getType();
        propClass = WrapDynaClass.createDynaClass(propType);

        nestedProp = resolver.remove(nestedProp);
    }
    return propType;
}
项目:field-binder    文件:FieldBinder.java   
public FieldBinder(Class<T> beanClass) {
    super(new FieldGroup());
    this.beanClass = beanClass;
    this.dynaClass = WrapDynaClass.createDynaClass(beanClass);
    this.navigation = null;
}
项目:extacrm    文件:JpaPropertyProvider.java   
public JpaPropertyProvider(final Class<TEntityType> entityClass) {
    this.entityClass = entityClass;
    dynaClass = WrapDynaClass.createDynaClass(entityClass);
}
项目:extacrm    文件:JpaPropertyProvider.java   
public WrapDynaClass getDynaClass() {
    return dynaClass;
}