Class OrderedListContainerPolicy

    • Constructor Detail

      • OrderedListContainerPolicy

        public OrderedListContainerPolicy()
        INTERNAL: Construct a new policy.
      • OrderedListContainerPolicy

        public OrderedListContainerPolicy​(java.lang.Class containerClass)
        INTERNAL: Construct a new policy for the specified class.
      • OrderedListContainerPolicy

        public OrderedListContainerPolicy​(java.lang.String containerClassName)
        INTERNAL: Construct a new policy for the specified class name.
    • Method Detail

      • addAll

        public boolean addAll​(java.util.List elements,
                              java.lang.Object container,
                              AbstractSession session,
                              java.util.List<AbstractRecord> dbRows,
                              ObjectBuildingQuery query,
                              CacheKey parentCacheKey,
                              boolean isTargetProtected)
        INTERNAL: Add a list of elements to container. This is used to add to a collection independent of JDK 1.1 and 1.2. The session may be required to wrap for the wrapper policy. The row may be required by subclasses Return whether the container changed
        Overrides:
        addAll in class ContainerPolicy
      • addAll

        public boolean addAll​(java.util.List elements,
                              java.lang.Object container,
                              AbstractSession session,
                              java.util.List<AbstractRecord> dbRows,
                              DataReadQuery query,
                              CacheKey parentCacheKey,
                              boolean isTargetProtected)
        INTERNAL: Add a list of elements to container. This is used to add to a collection independent of JDK 1.1 and 1.2. The session may be required to wrap for the wrapper policy. The row may be required by subclasses Return whether the container changed
        Overrides:
        addAll in class ContainerPolicy
      • addIntoAtIndex

        protected void addIntoAtIndex​(java.lang.Integer index,
                                      java.lang.Object object,
                                      java.lang.Object container,
                                      AbstractSession session)
        INTERNAL: Add element into a container which implements the List interface. Add at a particular index.
      • compareCollectionsForChange

        public void compareCollectionsForChange​(java.lang.Object oldList,
                                                java.lang.Object newList,
                                                CollectionChangeRecord changeRecord,
                                                AbstractSession session,
                                                ClassDescriptor referenceDescriptor)
        INTERNAL: This method is used to calculate the differences between two collections. This algorithm is a work in progress. It works great and all, but like anything, you can always make it better.
        Overrides:
        compareCollectionsForChange in class ContainerPolicy
      • correctOrderList

        public java.util.List correctOrderList​(java.util.List<IndexedObject> indexedObjects)
        PUBLIC: Correct object's order in the list. The method is called only in one case - when the list of order indexes read from db is invalid (contains nulls, duplicates, negative values, values greater/equal list size). Each element of the indexedObjects is a pair of the order index and the corresponding object. The goal of the method is to return back the list of objects (not indexed objects!) in the correct order. The objects should not be altered. The default implementation of the method sorts indexedObjects according to their indexes (null less than any non-null). For example: indexedObjects = {{2, objectA}, {5, ObjectB}} returns {objectA, objectB}; indexedObjects = {{2, objectA}, {-1, ObjectB}} returns {objectB, objectA}; indexedObjects = {{2, objectA}, {null, ObjectB}} returns {objectB, objectA}; This method could be overridden by the user.
      • getChangeValuesFrom

        public java.util.Iterator getChangeValuesFrom​(java.util.Map map)
        INTERNAL: Used to create an iterator on a the Map object passed to CollectionChangeRecord.addRemoveChange() to access the values to be removed. In the case of some container policies the values will actually be the keys.
        Overrides:
        getChangeValuesFrom in class ContainerPolicy
      • setListOrderField

        public void setListOrderField​(DatabaseField field)
      • setOrderCorrectionType

        public void setOrderCorrectionType​(OrderCorrectionType orderCorrectionType)
      • mergeChanges

        public void mergeChanges​(CollectionChangeRecord changeRecord,
                                 java.lang.Object valueOfTarget,
                                 boolean shouldMergeCascadeParts,
                                 MergeManager mergeManager,
                                 AbstractSession targetSession,
                                 boolean isSynchronizeOnMerge)
        INTERNAL: Merge changes from the source to the target object. Because this is a collection mapping, values are added to or removed from the collection based on the change set. Synchronize if system property is specified. If not, default to clone the target collection. No need to synchronize if the collection is new.
        Overrides:
        mergeChanges in class ContainerPolicy
      • mergeChanges

        protected void mergeChanges​(CollectionChangeRecord changeRecord,
                                    java.lang.Object valueOfTarget,
                                    boolean shouldMergeCascadeParts,
                                    MergeManager mergeManager,
                                    AbstractSession targetSession)
        INTERNAL: Merge changes from the source to the target object. Because this is a collection mapping, values are added to or removed from the collection based on the change set.
        Overrides:
        mergeChanges in class ContainerPolicy
      • registerRemoveNewObjectIfRequired

        protected void registerRemoveNewObjectIfRequired​(ObjectChangeSet objectChanges,
                                                         MergeManager mergeManager)
        INTERNAL:
      • removeFromAtIndex

        protected void removeFromAtIndex​(int index,
                                         java.lang.Object container)
        INTERNAL: Remove the element at the specified index.
      • recordAddToCollectionInChangeRecord

        public void recordAddToCollectionInChangeRecord​(ObjectChangeSet changeSetToAdd,
                                                        CollectionChangeRecord collectionChangeRecord)
        This method is used to bridge the behavior between Attribute Change Tracking and deferred change tracking with respect to adding the same instance multiple times. Each ContainerPolicy type will implement specific behavior for the collection type it is wrapping. These methods are only valid for collections containing object references
        Overrides:
        recordAddToCollectionInChangeRecord in class ListContainerPolicy
      • recordRemoveFromCollectionInChangeRecord

        public void recordRemoveFromCollectionInChangeRecord​(ObjectChangeSet changeSetToRemove,
                                                             CollectionChangeRecord collectionChangeRecord)
        Description copied from class: ListContainerPolicy
        This method is used to bridge the behavior between Attribute Change Tracking and deferred change tracking with respect to adding the same instance multiple times. Each ContainerPolicy type will implement specific behavior for the collection type it is wrapping. These methods are only valid for collections containing object references
        Overrides:
        recordRemoveFromCollectionInChangeRecord in class ListContainerPolicy
      • recordUpdateToCollectionInChangeRecord

        public void recordUpdateToCollectionInChangeRecord​(CollectionChangeEvent event,
                                                           ObjectChangeSet changeSet,
                                                           CollectionChangeRecord collectionChangeRecord)
        Description copied from class: ContainerPolicy
        This method is used to bridge the behavior between Attribute Change Tracking and deferred change tracking with respect to adding the same instance multiple times. Each ContainerPolicy type will implement specific behavior for the collection type it is wrapping. These methods are only valid for collections containing object references
        Overrides:
        recordUpdateToCollectionInChangeRecord in class ContainerPolicy
      • shouldAddAll

        public boolean shouldAddAll()
        INTERNAL: Indicates whether addAll method should be called to add entire collection, or it's possible to call addInto multiple times instead.
        Overrides:
        shouldAddAll in class ContainerPolicy
        Returns: