@NotThreadSafe public class CopyState extends Object implements Cloneable
This class keeps tracks of which objects have already been copied when copying objects between transactions.
In addition, it supports assigning different object ID's to objects as they are copied into the destination transaction.
Instances are not thread safe.
JObject.copyTo()
,
JObject.cascadeCopyTo()
Constructor and Description |
---|
CopyState()
Default constructor.
|
CopyState(ObjIdMap<ObjId> objectIdMap)
Default remapping constructor.
|
CopyState(ObjIdSet copied,
ObjIdMap<ObjId> objectIdMap)
Primary constructor.
|
Modifier and Type | Method and Description |
---|---|
CopyState |
clone() |
ObjId |
getDestinationId(ObjId srcId)
Get the object ID to use in the destination transaction for the copy of the object with the given object ID
in the source transaction.
|
ObjIdMap<ObjId> |
getObjectIdMap()
Get the mapping from object ID in the source transaction to object ID to use in the destination transaction.
|
boolean |
isCopied(ObjId id)
Determine if an object has been marked as copied.
|
boolean |
isSuppressNotifications()
|
boolean |
markCopied(ObjId id)
Determine if an object has already been copied, and if not mark it so.
|
boolean |
markTraversed(ObjId id,
int[] fields)
Determine if the specified reference path has already been traversed starting at the given object, and if not mark it so.
|
void |
setSuppressNotifications(boolean suppressNotifications)
|
public CopyState()
Object ID's will not be remapped.
Equivalent to: CopyState(new ObjIdSet(), null)
.
public CopyState(ObjIdMap<ObjId> objectIdMap)
Object ID's will be remapped based on objectIdMap
.
Equivalent to: CopyState(new ObjIdSet(), objectIdMap)
.
objectIdMap
- mapping from source object ID to destination object ID,
or null to disable object ID remapping (i.e., use the same ID)public CopyState(ObjIdSet copied, ObjIdMap<ObjId> objectIdMap)
This constructor allows an object ID map to be provided via objectIdMap
, which specifies the
destination transaction object ID to use when copying the corresponding source transaction object.
copied
- the ID's of objects that have already been copiedobjectIdMap
- mapping from source object ID to destination object ID,
or null to disable object ID remapping (i.e., use the same ID)IllegalArgumentException
- if copied
is nullpublic boolean markCopied(ObjId id)
id
- object ID (in the source transaction) of the object being copiedid
was not previously marked copied, otherwise falseIllegalArgumentException
- if id
is nullpublic boolean isCopied(ObjId id)
id
- object ID (in the source transaction) of the object being copiedid
has been marked copied, otherwise falseIllegalArgumentException
- if id
is nullpublic boolean isSuppressNotifications()
@OnCreate
and
@OnChange
notifications in the destination transaction.
Note that for notifications to be delivered in a SnapshotJTransaction
, these annotations must
also have snapshotTransactions = true
, even if this property is set to false.
Default is false.
public void setSuppressNotifications(boolean suppressNotifications)
@OnCreate
and
@OnChange
notifications in the destination transaction.
Note that for notifications to be delivered in a SnapshotJTransaction
, these annotations must
also have snapshotTransactions = true
, even if this property is set to false.
public boolean markTraversed(ObjId id, int[] fields)
id
- object ID (in the source transaction) of the object being copiedfields
- reference path storage IDsfields
was not previously marked as traversed from id
, otherwise falseIllegalArgumentException
- if either parameter is nullIllegalArgumentException
- if fields
has length zeropublic ObjIdMap<ObjId> getObjectIdMap()
This method returns the objectIdMap
parameter given to the constructor, if any.
public ObjId getDestinationId(ObjId srcId)
The implementation in CopyState
behaves as follows: if a null objectIdMap
parameter was given
to the constructor, objectIdMap
does not contain srcId
, or the corresponding value is null,
it returns srcId
. Otherwise, the corresponding value from objectIdMap
is returned.
srcId
- source transaction object IDIllegalArgumentException
- if srcId
is nullCopyright © 2019. All rights reserved.