Class SDOCopyHelper
- java.lang.Object
-
- org.eclipse.persistence.sdo.helper.SDOCopyHelper
-
- All Implemented Interfaces:
CopyHelper
public class SDOCopyHelper extends Object implements CopyHelper
Purpose:- A helper class for making deep or shallow copies of DataObjects.
Responsibilities:
- Perform shallow and deep copy operations on
DataObject
s.
- See Also:
SDODataObject
- Since:
- Oracle TopLink 11.1.1.0.0
-
-
Field Summary
-
Fields inherited from interface commonj.sdo.helper.CopyHelper
INSTANCE
-
-
Constructor Summary
Constructors Constructor Description 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.
This is the recommended constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DataObject
copy(DataObject dataObject)
Create a deep copy of the DataObject tree: Copies the dataObject and all itscontained
DataObjects recursively.DataObject
copy(DataObject dataObject, SDOChangeSummary cs)
Create a deep copy of the DataObject tree: Copies the dataObject and all itscontained
DataObjects recursively.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.HelperContext
getHelperContext()
INTERNAL: Return the helperContext containing this copyHelper.void
setHelperContext(HelperContext helperContext)
INTERNAL: Set the helperContext if this copyHelper was created using the default constructor.
-
-
-
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.- Specified by:
copyShallow
in interfaceCopyHelper
- Parameters:
dataObject
- to be copied- Returns:
- copy of dataObject
-
copy
public DataObject copy(DataObject dataObject) throws IllegalArgumentException
Create a deep copy of the DataObject tree: Copies the dataObject and all itscontained
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.- Specified by:
copy
in interfaceCopyHelper
- Parameters:
dataObject
- to be copied.- Returns:
- copy of dataObject
- Throws:
IllegalArgumentException
- if any referenced DataObject is not part of the containment tree.
-
copy
public DataObject copy(DataObject dataObject, SDOChangeSummary cs) throws IllegalArgumentException
Create a deep copy of the DataObject tree: Copies the dataObject and all itscontained
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:
IllegalArgumentException
- if any referenced DataObject is not part of the containment tree.
-
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
-
-
-