org.shept.util
Class BeanUtilsExtended

java.lang.Object
  extended by org.springframework.beans.BeanUtils
      extended by org.shept.util.BeanUtilsExtended

public class BeanUtilsExtended
extends org.springframework.beans.BeanUtils

Version:
$$Id: BeanUtilsExtended.java 70 2010-11-04 17:28:46Z aha $$
Author:
Andi

Constructor Summary
BeanUtilsExtended()
           
 
Method Summary
static Map<String,?> findNestedPaths(Object targetObject, Class<?> targetClass)
           
static Map<String,?> findNestedPaths(Object targetObject, Class<?> targetClass, List<String> ignoreList)
           
static Map<String,?> findNestedPaths(Object targetObject, Class<?> targetClass, String nestedPath, List<String> ignoreList, Set<Object> visited, int maxDepth)
          Find all occurrences of targetClass in targetObject.
private static boolean isInstanceVisited(Collection coll, Object value)
           
static void mergeProperties(Object source, Object target)
          Merge the property values of the given source bean into the target bean.
static void mergeProperties(Object source, Object target, Class<?> editable)
          Merge the property values of the given source bean into the given target bean, only setting properties defined in the given "editable" class (or interface).
private static void mergeProperties(Object source, Object target, Class<?> editable, String[] ignoreProperties)
          Merge the property values of the given source bean into the given target bean.
 
Methods inherited from class org.springframework.beans.BeanUtils
copyProperties, copyProperties, copyProperties, findDeclaredMethod, findDeclaredMethodWithMinimalParameters, findEditorByConvention, findMethod, findMethodWithMinimalParameters, findMethodWithMinimalParameters, findPropertyForMethod, findPropertyType, getPropertyDescriptor, getPropertyDescriptors, getWriteMethodParameter, instantiate, instantiateClass, instantiateClass, isSimpleProperty, isSimpleValueType, resolveSignature
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanUtilsExtended

public BeanUtilsExtended()
Method Detail

mergeProperties

public static void mergeProperties(Object source,
                                   Object target)
                            throws org.springframework.beans.BeansException
Merge the property values of the given source bean into the target bean.

Note: Only not-null values are merged into the given target bean. Note: The source and target classes do not have to match or even be derived from each other, as long as the properties match. Any bean properties that the source bean exposes but the target bean does not will silently be ignored.

This is just a convenience method. For more complex transfer needs, consider using a full BeanWrapper.

Parameters:
source - the source bean
target - the target bean
Throws:
org.springframework.beans.BeansException - if the copying failed
See Also:
BeanWrapper

mergeProperties

public static void mergeProperties(Object source,
                                   Object target,
                                   Class<?> editable)
                            throws org.springframework.beans.BeansException
Merge the property values of the given source bean into the given target bean, only setting properties defined in the given "editable" class (or interface).

Note: Only not-null values are merged into the given target bean. Note: The source and target classes do not have to match or even be derived from each other, as long as the properties match. Any bean properties that the source bean exposes but the target bean does not will silently be ignored.

This is just a convenience method. For more complex transfer needs, consider using a full BeanWrapper.

Parameters:
source - the source bean
target - the target bean
editable - the class (or interface) to restrict property setting to
Throws:
org.springframework.beans.BeansException - if the copying failed
See Also:
BeanWrapper

mergeProperties

private static void mergeProperties(Object source,
                                    Object target,
                                    Class<?> editable,
                                    String[] ignoreProperties)
                             throws org.springframework.beans.BeansException
Merge the property values of the given source bean into the given target bean.

Note: Only not-null values are merged into the given target bean. Note: The source and target classes do not have to match or even be derived from each other, as long as the properties match. Any bean properties that the source bean exposes but the target bean does not will silently be ignored.

Parameters:
source - the source bean
target - the target bean
editable - the class (or interface) to restrict property setting to
ignoreProperties - array of property names to ignore
Throws:
org.springframework.beans.BeansException - if the copying failed
See Also:
BeanWrapper

findNestedPaths

public static Map<String,?> findNestedPaths(Object targetObject,
                                            Class<?> targetClass)
                                     throws Exception
Throws:
Exception

findNestedPaths

public static Map<String,?> findNestedPaths(Object targetObject,
                                            Class<?> targetClass,
                                            List<String> ignoreList)
                                     throws Exception
Throws:
Exception

findNestedPaths

public static Map<String,?> findNestedPaths(Object targetObject,
                                            Class<?> targetClass,
                                            String nestedPath,
                                            List<String> ignoreList,
                                            Set<Object> visited,
                                            int maxDepth)
                                     throws Exception
Find all occurrences of targetClass in targetObject. Be careful. This stuff may be recursive ! Should be improved to prevent endless recursive loops.

Parameters:
-
targetObject -
targetClass -
nestedPath -
Returns:
Throws:
Exception

isInstanceVisited

private static boolean isInstanceVisited(Collection coll,
                                         Object value)
                                  throws Exception
Throws:
Exception


Copyright © 2011. All Rights Reserved.