Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle TopLink
11g Release 1 (11.1.1)

E28847-01


org.eclipse.persistence.sdo.helper
Class SDOCopyHelper

java.lang.Object
  extended by org.eclipse.persistence.sdo.helper.SDOCopyHelper


public class SDOCopyHelper
extends java.lang.Object

Purpose:

Responsibilities:

Since:
Oracle TopLink 11.1.1.0.0
See Also:
SDODataObject

Field Summary
private  HelperContext aHelperContext
           

 

Constructor Summary
SDOCopyHelper()
          INTERNAL: This default constructor must be used in conjunction with the setHelperContext() function.
SDOCopyHelper(HelperContext aContext)
          Constructor that takes in a HelperContext instance that contains this copyHelper.

 

Method Summary
 DataObject copy(DataObject dataObject)
          Create a deep copy of the DataObject tree: Copies the dataObject and all its contained DataObjects recursively.
 DataObject copy(DataObject dataObject, SDOChangeSummary cs)
          Create a deep copy of the DataObject tree: Copies the dataObject and all its contained DataObjects recursively.
private  void copyChangeSummary(ChangeSummary anOriginalCS, ChangeSummary aCopyCS, java.util.Map origDOCS1toCopyDOCS2Map)
          INTERNAL: Implement ChangeSummary deep copy Note: a copy with a CS requires the DefautlValueStore implementation because of changes outside the ValueStore interface for the dataObject field DeepCopy the original changeSummary into the copy dataObject.
private  void copyContainmentPropertyValue(SDODataObject copy, SDOProperty property, java.lang.Object value, java.util.HashMap doMap, java.util.HashMap ncPropMap, SDOChangeSummary cs)
          INTERNAL: Recursive function deep copies all contained properties.
private  SDODataObject copyPrivate(SDODataObject dataObject, java.util.HashMap doMap, java.util.HashMap ncPropMap, SDOChangeSummary cs)
          INTERNAL: Build the copy tree and cache all reachable DataObjects with their copy
Cache all non-containment properties - to be set after tree construction
Recurse the tree in preorder traversal (root, child1-n) Scope: We do not have to check the copyTree scope when iterating opposites since we will not enter any opposite property dataTree that is outside of the copyTree scope
 DataObject copyShallow(DataObject dataObject)
          Create a shallow copy of the DataObject dataObject: Creates a new DataObject copiedDataObject with the same values as the source dataObject for each property where property.getType().isDataType() is true.
private  ValueStore createValueStore()
          INTERNAL: Create a new uninitialized ValueStore.
 HelperContext getHelperContext()
          INTERNAL: Return the helperContext containing this copyHelper.
private  java.lang.Object getValue(SDODataObject dataObject, Property property, SDOChangeSummary cs)
          INTERNAL: Used during XML Unmarshal.
private  boolean isSet(SDODataObject dataObject, Property property, SDOChangeSummary cs)
          INTERNAL: Used during XML Unmarshal.
private  void processContainmentSequencesPrivate(java.util.Map doMap, SDOChangeSummary cs)
          INTERNAL: Iterate the map of containment nodes and populate sequenced objects in the copy.
private  void processNonContainmentNodesPrivate(java.util.HashMap doMap, java.util.HashMap ncPropMap)
          INTERNAL: Iterate the non-containment nodes and copy all uni/bi-directional properties on the copy.
private  void replicateAndRereferenceSequenceCopyPrivate(SDOSequence origSequence, SDOSequence copySequence, DataObject dataObject, DataObject copy, java.util.Map doMap, SDOChangeSummary cs)
          INTERNAL: Make a copy of all settings on the original sequence onto the copy sequence while using a cross-reference doMap that relates the original DataObject key to the copy DataObject key.
 void setHelperContext(HelperContext helperContext)
          INTERNAL: Set the helperContext if this copyHelper was created using the default constructor.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

aHelperContext

private HelperContext aHelperContext

Constructor Detail

SDOCopyHelper

public SDOCopyHelper()
INTERNAL: This default constructor must be used in conjunction with the setHelperContext() function. The custom constructor that takes a HelperContext parameter is recommended over this default constructor.

SDOCopyHelper

public SDOCopyHelper(HelperContext aContext)
Constructor that takes in a HelperContext instance that contains this copyHelper.
This is the recommended constructor.
Parameters:
aContext -

Method Detail

copyShallow

public DataObject copyShallow(DataObject dataObject)
Create a shallow copy of the DataObject dataObject: Creates a new DataObject copiedDataObject with the same values as the source dataObject for each property where property.getType().isDataType() is true. The value of such a Property property in copiedDataObject is: dataObject.get(property) for single-valued Properties (copiedDataObject.get(property) equals() dataObject.get(property)), or a List where each member is equal to the member at the same index in dataObject for multi-valued Properties copiedDataObject.getList(property).get(i) equals() dataObject.getList(property).get(i) The copied Object is unset for each Property where property.getType().isDataType() is false since they are not copied. Read-only properties are copied. A copied object shares metadata with the source object sourceDO.getType() == copiedDO.getType() If a ChangeSummary is part of the source DataObject the copy has a new, empty ChangeSummary. Logging state is the same as the source ChangeSummary.
Parameters:
dataObject - to be copied
Returns:
copy of dataObject

copy

public DataObject copy(DataObject dataObject)
                throws java.lang.IllegalArgumentException
Create a deep copy of the DataObject tree: Copies the dataObject and all its contained DataObjects recursively. Values of Properties are copied as in shallow copy, and values of Properties where property.getType().isDataType() is false are copied where each value copied must be a DataObject contained by the source dataObject. If a DataObject is outside the DataObject tree and the property is bidirectional, then the DataObject is skipped. If a DataObject is outside the DataObject tree and the property is unidirectional, then the same DataObject is referenced. Read-only properties are copied. If any DataObject referenced is not in the containment tree an IllegalArgumentException is thrown. If a ChangeSummary is part of the copy tree the new ChangeSummary refers to objects in the new DataObject tree. Logging state is the same as the source ChangeSummary.
Parameters:
dataObject - to be copied.
Returns:
copy of dataObject
Throws:
java.lang.IllegalArgumentException - if any referenced DataObject is not part of the containment tree.

copy

public DataObject copy(DataObject dataObject,
                       SDOChangeSummary cs)
                throws java.lang.IllegalArgumentException
Create a deep copy of the DataObject tree: Copies the dataObject and all its contained DataObjects recursively.

For each Property where property.type.dataType is true, the values of Properties are copied as in shallow copy, and values of Properties where property.getType().isDataType() is false are copied where each value copied must be a DataObject contained by the source dataObject.

If a DataObject is outside the DataObject tree and the property is bidirectional, then the DataObject is not copied and references to the object are also not copied.

If a DataObject is outside the DataObject tree and the property is unidirectional, then the same DataObject is referenced.

Read-only properties are copied.

If any DataObject referenced is not in the containment tree an IllegalArgumentException is thrown.

If a ChangeSummary is part of the copy tree the new ChangeSummary refers to objects in the new DataObject tree. Logging state is the same as the source ChangeSummary.

Parameters:
dataObject - to be copied.
Returns:
copy of dataObject
Throws:
java.lang.IllegalArgumentException - if any referenced DataObject is not part of the containment tree.

processNonContainmentNodesPrivate

private void processNonContainmentNodesPrivate(java.util.HashMap doMap,
                                               java.util.HashMap ncPropMap)
INTERNAL: Iterate the non-containment nodes and copy all uni/bi-directional properties on the copy.
Parameters:
doMap -
ncPropMap -

replicateAndRereferenceSequenceCopyPrivate

private void replicateAndRereferenceSequenceCopyPrivate(SDOSequence origSequence,
                                                        SDOSequence copySequence,
                                                        DataObject dataObject,
                                                        DataObject copy,
                                                        java.util.Map doMap,
                                                        SDOChangeSummary cs)
INTERNAL: Make a copy of all settings on the original sequence onto the copy sequence while using a cross-reference doMap that relates the original DataObject key to the copy DataObject key. This function is used during deep copy and changeSummary copy.
Parameters:
origSequence -
copySequence -
doMap -

processContainmentSequencesPrivate

private void processContainmentSequencesPrivate(java.util.Map doMap,
                                                SDOChangeSummary cs)
INTERNAL: Iterate the map of containment nodes and populate sequenced objects in the copy.
Parameters:
doMap -

createValueStore

private ValueStore createValueStore()
INTERNAL: Create a new uninitialized ValueStore.
Returns:

copyChangeSummary

private void copyChangeSummary(ChangeSummary anOriginalCS,
                               ChangeSummary aCopyCS,
                               java.util.Map origDOCS1toCopyDOCS2Map)
INTERNAL: Implement ChangeSummary deep copy Note: a copy with a CS requires the DefautlValueStore implementation because of changes outside the ValueStore interface for the dataObject field DeepCopy the original changeSummary into the copy dataObject. All deleted keys in originalValueStore, deletedMap, deepCopies are the same original object. We require the following relationships in order to build copies of originals and copies of copies of originals. origDOtoCopyDOMap original object (deleted + current) - in original DO : copy of original object - in copy DO copyDOtoCopyOfDOMap Assumptions: Property objects instances are copied only by reference - metadata is the same in the copy. Deleted objects never exist in the currentValueStore (and are therefore not in the doMap). Created and modified objects are always in the currentValueStore (and are in the doMap).
Parameters:
anOriginalCS -
aCopyCS -
doMap - (map of original do's (CS1) to their copy do's in (CS2))

copyPrivate

private SDODataObject copyPrivate(SDODataObject dataObject,
                                  java.util.HashMap doMap,
                                  java.util.HashMap ncPropMap,
                                  SDOChangeSummary cs)
                           throws java.lang.IllegalArgumentException
INTERNAL: Build the copy tree and cache all reachable DataObjects with their copy
Cache all non-containment properties - to be set after tree construction
Recurse the tree in preorder traversal (root, child1-n) Scope: We do not have to check the copyTree scope when iterating opposites since we will not enter any opposite property dataTree that is outside of the copyTree scope
Parameters:
doMap - (cache original -> copy DataObject instances to set non-containment properties after tree construction)
ncPropMap - (cache original DO:non-containment property values to be set after tree construction)
Throws:
java.lang.IllegalArgumentException

copyContainmentPropertyValue

private void copyContainmentPropertyValue(SDODataObject copy,
                                          SDOProperty property,
                                          java.lang.Object value,
                                          java.util.HashMap doMap,
                                          java.util.HashMap ncPropMap,
                                          SDOChangeSummary cs)
INTERNAL: Recursive function deep copies all contained properties. Requirements: The value object has isSet=true for all callers.
Parameters:
copy -
property -
value -
doMap - (cache original -> copy DataObject instances to set non-containment properties after tree construction)
propMap - (cache original DO:non-containment property values to be set after tree construction)

getHelperContext

public HelperContext getHelperContext()
INTERNAL: Return the helperContext containing this copyHelper.
Returns:

setHelperContext

public void setHelperContext(HelperContext helperContext)
INTERNAL: Set the helperContext if this copyHelper was created using the default constructor.
Parameters:
helperContext -

isSet

private boolean isSet(SDODataObject dataObject,
                      Property property,
                      SDOChangeSummary cs)
INTERNAL: Used during XML Unmarshal.
Parameters:
dataObject -
property -
cs -
Returns:

getValue

private java.lang.Object getValue(SDODataObject dataObject,
                                  Property property,
                                  SDOChangeSummary cs)
INTERNAL: Used during XML Unmarshal.
Parameters:
dataObject -
property -
cs -
Returns:

Skip navigation links

Copyright © 1998, 2012, Oracle. All Rights Reserved.