org.apache.ojb.otm.copy
Class ReflectiveObjectCopyStrategy

java.lang.Object
  extended by org.apache.ojb.otm.copy.ReflectiveObjectCopyStrategy
All Implemented Interfaces:
ObjectCopyStrategy

public final class ReflectiveObjectCopyStrategy
extends Object
implements ObjectCopyStrategy

User: matthew.baird Date: Jul 7, 2003 Time: 3:05:22 PM


Nested Class Summary
private static class ReflectiveObjectCopyStrategy.ClassMetadata
           
 
Field Summary
private static SerializeObjectCopyStrategy _serialize
           
private static Class[] EMPTY_CLASS_ARRAY
           
private static Object[] EMPTY_OBJECT_ARRAY
           
private static Set FINAL_IMMUTABLE_CLASSES
           
 
Constructor Summary
ReflectiveObjectCopyStrategy()
           
 
Method Summary
private static Object clone(Object toCopy, Map objMap, Map metadataMap)
           
private static void cloneAndSetFieldValue(Field field, Object src, Object dest, Map objMap, Map metadataMap)
           
 Object copy(Object toCopy, PersistenceBroker broker)
          makes a deep clone of the object, using reflection.
private static void copyClass(Map metadataMap, Class c, Object obj, Object retval, Map objMap)
           
private static Object handleArray(Object obj, Map objMap, Class objClass, Map metadataMap)
           
private static Object handleObjectWithNoArgsConstructor(Map metadataMap, Class objClass, Map objMap, Object toCopy)
           
private static void setFields(Object from, Object to, Field[] fields, boolean accessible, Map objMap, Map metadataMap)
          copy all fields from the "from" object to the "to" object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FINAL_IMMUTABLE_CLASSES

private static final Set FINAL_IMMUTABLE_CLASSES

EMPTY_OBJECT_ARRAY

private static final Object[] EMPTY_OBJECT_ARRAY

EMPTY_CLASS_ARRAY

private static final Class[] EMPTY_CLASS_ARRAY

_serialize

private static final SerializeObjectCopyStrategy _serialize
Constructor Detail

ReflectiveObjectCopyStrategy

public ReflectiveObjectCopyStrategy()
Method Detail

copy

public final Object copy(Object toCopy,
                         PersistenceBroker broker)
makes a deep clone of the object, using reflection.

Specified by:
copy in interface ObjectCopyStrategy
Parameters:
toCopy - the object you want to copy
Returns:

clone

private static Object clone(Object toCopy,
                            Map objMap,
                            Map metadataMap)

handleObjectWithNoArgsConstructor

private static Object handleObjectWithNoArgsConstructor(Map metadataMap,
                                                        Class objClass,
                                                        Map objMap,
                                                        Object toCopy)

copyClass

private static void copyClass(Map metadataMap,
                              Class c,
                              Object obj,
                              Object retval,
                              Map objMap)

handleArray

private static Object handleArray(Object obj,
                                  Map objMap,
                                  Class objClass,
                                  Map metadataMap)

setFields

private static void setFields(Object from,
                              Object to,
                              Field[] fields,
                              boolean accessible,
                              Map objMap,
                              Map metadataMap)
copy all fields from the "from" object to the "to" object.

Parameters:
from - source object
to - from's clone
fields - fields to be populated
accessible - 'true' if all 'fields' have been made accessible during traversal

cloneAndSetFieldValue

private static void cloneAndSetFieldValue(Field field,
                                          Object src,
                                          Object dest,
                                          Map objMap,
                                          Map metadataMap)
                                   throws IllegalAccessException
Throws:
IllegalAccessException


Copyright © 2007-2011 The Kuali Foundation. All Rights Reserved.