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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<ObjectChangeSet,ObjectChangeSet>addObjectListContains the added values to the collection and their corresponding ChangeSets.protected List<ObjectChangeSet>addOverFlowContains a list of extra adds.protected Map<ObjectChangeSet,Integer>orderedAddObjectIndicesContains the added values index to the collection.protected List<ObjectChangeSet>orderedAddObjectsContains the added values to the collection and their corresponding ChangeSets in order.protected List<OrderedChangeObject>orderedChangeObjectListContains OrderedChangeObjects representing each change made to the collection.protected List<Integer>orderedRemoveObjectIndicesContains the removed values index to the collection.protected Map<Integer,ObjectChangeSet>orderedRemoveObjectsContains the removed values to the collection and their corresponding ChangeSets.protected booleanorderHasBeenRepairedIndicates whether IndirectList's order has been repaired.protected Map<ObjectChangeSet,ObjectChangeSet>removeObjectListContains 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
Constructors Constructor Description CollectionChangeRecord()This default constructor.CollectionChangeRecord(ObjectChangeSet owner)Constructor for the ChangeRecord representing a collection mapping
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAdditionChange(Map objectChanges, ContainerPolicy cp, UnitOfWorkChangeSet changeSet, AbstractSession session)This method takes a Map of objects, converts these into ObjectChangeSets.voidaddOrderedAdditionChange(List<Object> orderedObjectsToAdd, Map<Object,Integer> objectChangesIndices, UnitOfWorkChangeSet changeSet, AbstractSession session)This method takes a list of objects and converts them into ObjectChangeSets.voidaddOrderedRemoveChange(List<Integer> indicesToRemove, Map objectChanges, UnitOfWorkChangeSet changeSet, AbstractSession session)This method takes a map of objects and converts them into ObjectChangeSets.voidaddRemoveChange(Map objectChanges, ContainerPolicy cp, UnitOfWorkChangeSet changeSet, AbstractSession session)This method takes a Map of objects, converts these into ObjectChangeSets.voidclearChanges()Clears info about added / removed objects set by change tracker.Map<ObjectChangeSet,ObjectChangeSet>getAddObjectList()ADVANCED: This method returns the collection of ChangeSets that were added to the collection.List<ObjectChangeSet>getAddOverFlow()Returns a list of extra adds.List<Integer>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);IntegergetOrderedAddObjectIndex(ObjectChangeSet changes)This method returns the index of an object added to the collection.Map<ObjectChangeSet,Integer>getOrderedAddObjectIndices()This method returns the collection of ChangeSets that they were added to the collection.List<ObjectChangeSet>getOrderedAddObjects()This method returns the collection of ChangeSets in the order they were added to the collection.List<OrderedChangeObject>getOrderedChangeObjectList()This method returns the Vector of OrderedChangeObjects.ObjectgetOrderedRemoveObject(Integer index)This method returns the index of an object removed from the collection.List<Integer>getOrderedRemoveObjectIndices()This method returns the ordered list of indices to remove from the collection.Map<Integer,ObjectChangeSet>getOrderedRemoveObjects()This method returns the collection of ChangeSets of objects removed from the collection.Map<ObjectChangeSet,ObjectChangeSet>getRemoveObjectList()PUBLIC: This method returns the Map that contains the removed values from the collection and their corresponding ChangeSets.booleanhasChanges()PUBLIC: Returns true if the change set has changes.voidinternalRecreateOriginalCollection(Object currentCollection, AbstractSession session)Recreates the original state of currentCollection.voidmergeRecord(ChangeRecord mergeFromRecord, UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet)This method will be used to merge one record into another.booleanorderHasBeenRepaired()voidsetAddObjectList(Map<ObjectChangeSet,ObjectChangeSet> objectChangesList)Sets the Added objects list.voidsetOrderedAddObjectIndices(Map<ObjectChangeSet,Integer> orderedAddObjectIndices)Sets collection of ChangeSets (and their respective index) that they were added to the collection.voidsetOrderedAddObjects(List<ObjectChangeSet> orderedAddObjects)Sets collection of ChangeSets that they were added to the collection.voidsetOrderedChangeObjectList(List<OrderedChangeObject> orderedChangeObjectList)voidsetOrderedRemoveObjects(Map<Integer,ObjectChangeSet> orderedRemoveObjects)Sets collection of ChangeSets that they were removed from the collection.voidsetOrderHasBeenRepaired(boolean hasBeenRepaired)voidsetRemoveObjectList(Map<ObjectChangeSet,ObjectChangeSet> objectChangesList)Sets the removed objects list.voidupdateReferences(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 Detail
-
addObjectList
protected Map<ObjectChangeSet,ObjectChangeSet> addObjectList
Contains the added values to the collection and their corresponding ChangeSets.
-
orderedAddObjects
protected List<ObjectChangeSet> orderedAddObjects
Contains the added values to the collection and their corresponding ChangeSets in order.
-
orderedAddObjectIndices
protected Map<ObjectChangeSet,Integer> orderedAddObjectIndices
Contains the added values index to the collection.
-
orderedChangeObjectList
protected List<OrderedChangeObject> orderedChangeObjectList
Contains OrderedChangeObjects representing each change made to the collection.
-
orderedRemoveObjects
protected Map<Integer,ObjectChangeSet> orderedRemoveObjects
Contains the removed values to the collection and their corresponding ChangeSets.
-
orderedRemoveObjectIndices
protected transient List<Integer> orderedRemoveObjectIndices
Contains the removed values index to the collection.
-
addOverFlow
protected transient List<ObjectChangeSet> 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
protected Map<ObjectChangeSet,ObjectChangeSet> removeObjectList
Contains the removed values from the collection and their corresponding ChangeSets.
-
orderHasBeenRepaired
protected boolean orderHasBeenRepaired
Indicates whether IndirectList's order has been repaired.
-
-
Constructor Detail
-
CollectionChangeRecord
public CollectionChangeRecord()
This default constructor.
-
CollectionChangeRecord
public CollectionChangeRecord(ObjectChangeSet owner)
Constructor for the ChangeRecord representing a collection mapping- Parameters:
owner- the changeSet that uses this record
-
-
Method Detail
-
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
public Map<ObjectChangeSet,ObjectChangeSet> getAddObjectList()
ADVANCED: This method returns the collection of ChangeSets that were added to the collection.- Specified by:
getAddObjectListin interfaceCollectionChangeRecord- Returns:
- java.util.Vector
-
getAddOverFlow
public List<ObjectChangeSet> 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 Map<ObjectChangeSet,ObjectChangeSet> getRemoveObjectList()
PUBLIC: This method returns the Map that contains the removed values from the collection and their corresponding ChangeSets.- Specified by:
getRemoveObjectListin interfaceCollectionChangeRecord- Returns:
- java.util.Vector
-
hasChanges
public boolean hasChanges()
PUBLIC: Returns true if the change set has changes.- Specified by:
hasChangesin 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:
mergeRecordin classChangeRecord
-
setAddObjectList
public void setAddObjectList(Map<ObjectChangeSet,ObjectChangeSet> objectChangesList)
Sets the Added objects list.
-
setRemoveObjectList
public void setRemoveObjectList(Map<ObjectChangeSet,ObjectChangeSet> objectChangesList)
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:
updateReferencesin classChangeRecord
-
getOrderedAddObjects
public List<ObjectChangeSet> 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
public Integer getOrderedAddObjectIndex(ObjectChangeSet changes)
This method returns the index of an object added to the collection.
-
getOrderedAddObjectIndices
public Map<ObjectChangeSet,Integer> getOrderedAddObjectIndices()
This method returns the collection of ChangeSets that they were added to the collection.
-
getOrderedChangeObjectList
public List<OrderedChangeObject> 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
public List<Integer> getOrderedRemoveObjectIndices()
This method returns the ordered list of indices to remove from the collection.
-
getOrderedRemoveObject
public Object getOrderedRemoveObject(Integer index)
This method returns the index of an object removed from the collection.
-
getOrderedRemoveObjects
public Map<Integer,ObjectChangeSet> getOrderedRemoveObjects()
This method returns the collection of ChangeSets of objects removed from the collection.
-
setOrderedAddObjectIndices
public void setOrderedAddObjectIndices(Map<ObjectChangeSet,Integer> orderedAddObjectIndices)
Sets collection of ChangeSets (and their respective index) that they were added to the collection.
-
setOrderedAddObjects
public void setOrderedAddObjects(List<ObjectChangeSet> orderedAddObjects)
Sets collection of ChangeSets that they were added to the collection.
-
setOrderedChangeObjectList
public void setOrderedChangeObjectList(List<OrderedChangeObject> orderedChangeObjectList)
-
setOrderedRemoveObjects
public void setOrderedRemoveObjects(Map<Integer,ObjectChangeSet> orderedRemoveObjects)
Sets collection of ChangeSets that they were removed from the collection.
-
getCurrentIndexesOfOriginalObjects
public List<Integer> 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);
-
internalRecreateOriginalCollection
public void internalRecreateOriginalCollection(Object currentCollection, AbstractSession session)
Recreates the original state of currentCollection.- Specified by:
internalRecreateOriginalCollectionin 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:
clearChangesin classDeferrableChangeRecord
-
-