本文整理汇总了Java中org.apache.commons.beanutils.DynaClass.getDynaProperties方法的典型用法代码示例。如果您正苦于以下问题:Java DynaClass.getDynaProperties方法的具体用法?Java DynaClass.getDynaProperties怎么用?Java DynaClass.getDynaProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.beanutils.DynaClass
的用法示例。
在下文中一共展示了DynaClass.getDynaProperties方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toString
import org.apache.commons.beanutils.DynaClass; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public String toString()
{
StringBuilder result = new StringBuilder();
DynaClass type = getDynaClass();
DynaProperty[] props = type.getDynaProperties();
result.append(type.getName());
result.append(": ");
for (int idx = 0; idx < props.length; idx++)
{
if (idx > 0)
{
result.append(", ");
}
result.append(props[idx].getName());
result.append(" = ");
result.append(get(props[idx].getName()));
}
return result.toString();
}
示例2: buildPropertyMap
import org.apache.commons.beanutils.DynaClass; //导入方法依赖的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;
}
示例3: hasNullValueField
import org.apache.commons.beanutils.DynaClass; //导入方法依赖的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;
}
示例4: buildPropertyMap
import org.apache.commons.beanutils.DynaClass; //导入方法依赖的package包/类
/**
* 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;
}
示例5: buildPropertyMap
import org.apache.commons.beanutils.DynaClass; //导入方法依赖的package包/类
/**
* 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;
}
示例6: toString
import org.apache.commons.beanutils.DynaClass; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public String toString()
{
StringBuffer result = new StringBuffer();
DynaClass type = getDynaClass();
DynaProperty[] props = type.getDynaProperties();
result.append(type.getName());
result.append(": ");
for (int idx = 0; idx < props.length; idx++)
{
if (idx > 0)
{
result.append(", ");
}
result.append(props[idx].getName());
result.append(" = ");
result.append(get(props[idx].getName()));
}
return result.toString();
}
示例7: equals
import org.apache.commons.beanutils.DynaClass; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public boolean equals(Object obj)
{
if (obj instanceof SqlDynaBean)
{
SqlDynaBean other = (SqlDynaBean)obj;
DynaClass dynaClass = getDynaClass();
if (dynaClass.equals(other.getDynaClass()))
{
DynaProperty[] props = dynaClass.getDynaProperties();
for (int idx = 0; idx < props.length; idx++)
{
Object value = get(props[idx].getName());
Object otherValue = other.get(props[idx].getName());
if (value == null)
{
if (otherValue != null)
{
return false;
}
}
else
{
return value.equals(otherValue);
}
}
return true;
}
}
return false;
}
示例8: buildObject
import org.apache.commons.beanutils.DynaClass; //导入方法依赖的package包/类
/**
* 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);
}
}
示例9: buildObjectWithoutReferenceFields
import org.apache.commons.beanutils.DynaClass; //导入方法依赖的package包/类
/**
* 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);
}
}
示例10: Wrap
import org.apache.commons.beanutils.DynaClass; //导入方法依赖的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;
}
示例11: getIds
import org.apache.commons.beanutils.DynaClass; //导入方法依赖的package包/类
public Object[] getIds() {
DynaClass clazz = _bean.getDynaClass();
DynaProperty[] props = clazz.getDynaProperties();
Set set = new HashSet();
for (int i = 0; i < props.length; i++) {
set.add(props[i].getName());
}
Object[] ids = super.getIds();
for (int i = 0; i < ids.length; i++) {
if(set.contains(ids[i]) == false) {
set.add(ids[i]);
}
}
return set.toArray();
}