Module org.eclipse.persistence.core
Class CollectionChangeRecord
java.lang.Object
org.eclipse.persistence.internal.sessions.ChangeRecord
org.eclipse.persistence.internal.sessions.DeferrableChangeRecord
org.eclipse.persistence.internal.sessions.CollectionChangeRecord
- All Implemented Interfaces:
Serializable
,ChangeRecord
,CollectionChangeRecord
- Direct Known Subclasses:
AggregateCollectionChangeRecord
,EISCollectionChangeRecord
,EISOrderedCollectionChangeRecord
public class CollectionChangeRecord
extends DeferrableChangeRecord
implements CollectionChangeRecord
Purpose: This class holds the record of the changes made to a collection attribute of an object.
Description: Collections must be compared to each other and added and removed objects must be recorded separately.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected Map
<ObjectChangeSet, ObjectChangeSet> Contains the added values to the collection and their corresponding ChangeSets.protected List
<ObjectChangeSet> Contains a list of extra adds.protected Map
<ObjectChangeSet, Integer> Contains the added values index to the collection.protected List
<ObjectChangeSet> Contains the added values to the collection and their corresponding ChangeSets in order.protected List
<OrderedChangeObject> Contains OrderedChangeObjects representing each change made to the collection.Contains the removed values index to the collection.protected Map
<Integer, ObjectChangeSet> Contains the removed values to the collection and their corresponding ChangeSets.protected boolean
Indicates whether IndirectList's order has been repaired.protected Map
<ObjectChangeSet, ObjectChangeSet> Contains the removed values from the collection and their corresponding ChangeSets.Fields inherited from class org.eclipse.persistence.internal.sessions.DeferrableChangeRecord
isDeferred, latestCollection, originalCollection
Fields inherited from class org.eclipse.persistence.internal.sessions.ChangeRecord
attribute, mapping, owner
-
Constructor Summary
ConstructorDescriptionThis default constructor.Constructor for the ChangeRecord representing a collection mapping -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAdditionChange
(Map objectChanges, ContainerPolicy cp, UnitOfWorkChangeSet changeSet, AbstractSession session) This method takes a Map of objects, converts these into ObjectChangeSets.void
addOrderedAdditionChange
(List<Object> orderedObjectsToAdd, Map<Object, Integer> objectChangesIndices, UnitOfWorkChangeSet changeSet, AbstractSession session) This method takes a list of objects and converts them into ObjectChangeSets.void
addOrderedRemoveChange
(List<Integer> indicesToRemove, Map objectChanges, UnitOfWorkChangeSet changeSet, AbstractSession session) This method takes a map of objects and converts them into ObjectChangeSets.void
addRemoveChange
(Map objectChanges, ContainerPolicy cp, UnitOfWorkChangeSet changeSet, AbstractSession session) This method takes a Map of objects, converts these into ObjectChangeSets.void
Clears info about added / removed objects set by change tracker.ADVANCED: This method returns the collection of ChangeSets that were added to the collection.Returns a list of extra adds.getCurrentIndexesOfOriginalObjects
(List newList) The same size as original list, at the i-th position holds the index of the i-th original object in the current list (-1 if the object was removed): for example: {0, -1, 1, -1, 3} means that: previous(0) == current(0); previous(1) was removed; previous(2) == current(1); previous(3) was removed; previous(4) == current(3);getOrderedAddObjectIndex
(ObjectChangeSet changes) This method returns the index of an object added to the collection.This method returns the collection of ChangeSets that they were added to the collection.This method returns the collection of ChangeSets in the order they were added to the collection.This method returns the Vector of OrderedChangeObjects.getOrderedRemoveObject
(Integer index) This method returns the index of an object removed from the collection.This method returns the ordered list of indices to remove from the collection.This method returns the collection of ChangeSets of objects removed from the collection.PUBLIC: This method returns the Map that contains the removed values from the collection and their corresponding ChangeSets.boolean
PUBLIC: Returns true if the change set has changes.void
internalRecreateOriginalCollection
(Object currentCollection, AbstractSession session) Recreates the original state of currentCollection.void
mergeRecord
(ChangeRecord mergeFromRecord, UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet) This method will be used to merge one record into another.boolean
void
setAddObjectList
(Map<ObjectChangeSet, ObjectChangeSet> objectChangesList) Sets the Added objects list.void
setOrderedAddObjectIndices
(Map<ObjectChangeSet, Integer> orderedAddObjectIndices) Sets collection of ChangeSets (and their respective index) that they were added to the collection.void
setOrderedAddObjects
(List<ObjectChangeSet> orderedAddObjects) Sets collection of ChangeSets that they were added to the collection.void
setOrderedChangeObjectList
(List<OrderedChangeObject> orderedChangeObjectList) void
setOrderedRemoveObjects
(Map<Integer, ObjectChangeSet> orderedRemoveObjects) Sets collection of ChangeSets that they were removed from the collection.void
setOrderHasBeenRepaired
(boolean hasBeenRepaired) void
setRemoveObjectList
(Map<ObjectChangeSet, ObjectChangeSet> objectChangesList) Sets the removed objects list.void
updateReferences
(UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet) This method will be used to update the objectsChangeSets references.Methods inherited from class org.eclipse.persistence.internal.sessions.DeferrableChangeRecord
getLatestCollection, getOldValue, getOldValue, getOriginalCollection, isDeferred, recreateOriginalCollection, setIsDeferred, setLatestCollection, setOriginalCollection
Methods inherited from class org.eclipse.persistence.internal.sessions.ChangeRecord
getAttribute, getMapping, getOwner, prepareForSynchronization, setAttribute, setMapping, setOwner, toString, updateChangeRecordWithNewValue
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.persistence.sessions.changesets.ChangeRecord
getAttribute, getOldValue, getOwner
-
Field Details
-
addObjectList
Contains the added values to the collection and their corresponding ChangeSets. -
orderedAddObjects
Contains the added values to the collection and their corresponding ChangeSets in order. -
orderedAddObjectIndices
Contains the added values index to the collection. -
orderedChangeObjectList
Contains OrderedChangeObjects representing each change made to the collection. -
orderedRemoveObjects
Contains the removed values to the collection and their corresponding ChangeSets. -
orderedRemoveObjectIndices
Contains the removed values index to the collection. -
addOverFlow
Contains a list of extra adds. These extra adds are used by attribute change tracking to replicate behavior when someone adds the same object to a list and removes it once. In this case the object should still appear once in the change set. -
removeObjectList
Contains the removed values from the collection and their corresponding ChangeSets. -
orderHasBeenRepaired
protected boolean orderHasBeenRepairedIndicates whether IndirectList's order has been repaired.
-
-
Constructor Details
-
CollectionChangeRecord
public CollectionChangeRecord()This default constructor. -
CollectionChangeRecord
Constructor for the ChangeRecord representing a collection mapping- Parameters:
owner
- the changeSet that uses this record
-
-
Method Details
-
addAdditionChange
public void addAdditionChange(Map objectChanges, ContainerPolicy cp, UnitOfWorkChangeSet changeSet, AbstractSession session) This method takes a Map of objects, converts these into ObjectChangeSets. -
addOrderedAdditionChange
public void addOrderedAdditionChange(List<Object> orderedObjectsToAdd, Map<Object, Integer> objectChangesIndices, UnitOfWorkChangeSet changeSet, AbstractSession session) This method takes a list of objects and converts them into ObjectChangeSets. This method should only be called from a ListContainerPolicy. Additions to the list are made by index, hence, the second Map of objectChangesIndices. -
addOrderedRemoveChange
public void addOrderedRemoveChange(List<Integer> indicesToRemove, Map objectChanges, UnitOfWorkChangeSet changeSet, AbstractSession session) This method takes a map of objects and converts them into ObjectChangeSets. This method should only be called from a ListContainerPolicy. Deletions from the list is made by index, hence, the second Vector of indicesToRemove. -
addRemoveChange
public void addRemoveChange(Map objectChanges, ContainerPolicy cp, UnitOfWorkChangeSet changeSet, AbstractSession session) This method takes a Map of objects, converts these into ObjectChangeSets. -
getAddObjectList
ADVANCED: This method returns the collection of ChangeSets that were added to the collection.- Specified by:
getAddObjectList
in interfaceCollectionChangeRecord
- Returns:
- java.util.Vector
-
getAddOverFlow
Returns a list of extra adds. These extra adds are used by attribute change tracking to replicate behavior when someone adds the same object to a list and removes it once. In this case the object should still appear once in the change set. -
getRemoveObjectList
PUBLIC: This method returns the Map that contains the removed values from the collection and their corresponding ChangeSets.- Specified by:
getRemoveObjectList
in interfaceCollectionChangeRecord
- Returns:
- java.util.Vector
-
hasChanges
public boolean hasChanges()PUBLIC: Returns true if the change set has changes.- Specified by:
hasChanges
in interfaceCollectionChangeRecord
- Returns:
- boolean
-
mergeRecord
public void mergeRecord(ChangeRecord mergeFromRecord, UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet) This method will be used to merge one record into another.- Specified by:
mergeRecord
in classChangeRecord
-
setAddObjectList
Sets the Added objects list. -
setRemoveObjectList
Sets the removed objects list. -
updateReferences
public void updateReferences(UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet) This method will be used to update the objectsChangeSets references.- Specified by:
updateReferences
in classChangeRecord
-
getOrderedAddObjects
This method returns the collection of ChangeSets in the order they were added to the collection. This list includes those objects that were moved within the collection. -
getOrderedAddObjectIndex
This method returns the index of an object added to the collection. -
getOrderedAddObjectIndices
This method returns the collection of ChangeSets that they were added to the collection. -
getOrderedChangeObjectList
This method returns the Vector of OrderedChangeObjects. These objects represent all changes made to the collection, and their order in the vector represents the order they were performed. -
getOrderedRemoveObjectIndices
This method returns the ordered list of indices to remove from the collection. -
getOrderedRemoveObject
This method returns the index of an object removed from the collection. -
getOrderedRemoveObjects
This method returns the collection of ChangeSets of objects removed from the collection. -
setOrderedAddObjectIndices
Sets collection of ChangeSets (and their respective index) that they were added to the collection. -
setOrderedAddObjects
Sets collection of ChangeSets that they were added to the collection. -
setOrderedChangeObjectList
-
setOrderedRemoveObjects
Sets collection of ChangeSets that they were removed from the collection. -
getCurrentIndexesOfOriginalObjects
The same size as original list, at the i-th position holds the index of the i-th original object in the current list (-1 if the object was removed): for example: {0, -1, 1, -1, 3} means that: previous(0) == current(0); previous(1) was removed; previous(2) == current(1); previous(3) was removed; previous(4) == current(3); -
internalRecreateOriginalCollection
Recreates the original state of currentCollection.- Specified by:
internalRecreateOriginalCollection
in classDeferrableChangeRecord
-
setOrderHasBeenRepaired
public void setOrderHasBeenRepaired(boolean hasBeenRepaired) -
orderHasBeenRepaired
public boolean orderHasBeenRepaired() -
clearChanges
public void clearChanges()Clears info about added / removed objects set by change tracker.- Specified by:
clearChanges
in classDeferrableChangeRecord
-