Class ListWrapper
java.lang.Object
org.eclipse.persistence.sdo.helper.ListWrapper
- All Implemented Interfaces:
Serializable,Cloneable,Iterable,Collection,List
- Direct Known Subclasses:
JAXBListWrapper
INTERNAL:
Purpose:
- This class wraps the ArrayList of currentElements that implement the List interface.
Responsibilities:
- Provide access many properties on
dataObjects
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ListWe are maintaining two pointers to potentially two ArrayList objects.protected SDODataObjectprotected SDOProperty -
Constructor Summary
ConstructorsConstructorDescriptionListWrapper(SDODataObject theDataObject, Property theProperty) ListWrapper(SDODataObject theDataObject, Property theProperty, List theList) Constructor for non-default Pluggable ValueStore implementations
Prerequisites: Containment is already set on theList parameter. -
Method Summary
Modifier and TypeMethodDescriptionvoidInserts the specified element at the index position in this list.voidINTERNAL:booleanbooleanINTERNAL:booleanaddAll(int position, Collection items) Inserts all of the currentElements in the specified Collection into this list, starting at the specified position.booleanaddAll(int position, Collection items, boolean updateSequence) booleanaddAll(Collection items) Appends all of the currentElements in the specified Collection to the end of this list, in the order that they are returned by the specified Collection's Iterator.booleanaddAll(Collection items, boolean updateSequence) INTERNAL: Appends all of the currentElements in the specified Collection to the end of this list, in the order that they are returned by the specified Collection's Iterator.voidclear()Removes all of the currentElements from this list.voidclear(boolean updateSequence) INTERNAL:clone()Clone the ListWrapper.booleanbooleancontainsAll(Collection items) protected voidINTERNAL: Shallow copy elementsget(int position) INTERNAL:intbooleanisEmpty()protected booleanINTERNAL:iterator()intlastIndexOf(Object item) listIterator(int position) remove(int index) Removes the element at the specified position in this list.
Position index starts at 0.remove(int index, boolean updateSequence) INTERNAL: Removes the element at the specified position in this list.
Position index starts at 0.booleanbooleanINTERNAL: Remove the item or first occurrence of the item.booleanremoveAll(Collection items) Removes from this collection all of its currentElements that are contained in the specified collection.booleanremoveAll(Collection items, boolean updateSequence) INTERNAL: Removes from this collection all of its currentElements that are contained in the specified collection.protected voidremoveContainment(int occurrence, Object item, boolean fromDelete, boolean updateSequence) INTERNAL:protected voidremoveContainment(Object item, boolean fromDelete, boolean updateSequence) INTERNAL:booleanretainAll(Collection itemsToKeep) Retains only the currentElements in this collection that are contained in the specified collection (optional operation).
In other words, removes from this collection all of its currentElements that are not contained in the specified collection.Replaces the element at the specified index in this list with the specified element.voidsetCurrentElements(List currentElementsList) INTERNAL: bypass containment and changesummary copy of element list on modificationsintsize()subList(int start, int end) Return a view of the specified portion of the listObject[]toArray()Object[]Returns an array containing all of the currentElements in this list in proper sequence; the runtime type of the returned array is that of the specified array.voidINTERNAL: Undo any changes and return the original Listprotected voidupdateContainment(Object item, boolean updateSequence) INTERNAL:protected voidupdateContainment(Collection items, boolean updateSequence) protected voidupdateSequence(Property aProperty, Collection items, boolean updateSequence) INTERNAL: Iterate the collection and add settings where appropriate.INTERNAL: Defined in SDO 2.01 spec on page 65 Externalizable function is called by ObjectStream.writeObject() A replacement object for serialization can be called here.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, streamMethods inherited from interface java.util.List
equals, hashCode, replaceAll, sort, spliterator
-
Field Details
-
dataObject
-
property
-
currentElements
We are maintaining two pointers to potentially two ArrayList objects. To implement ChangeSummary undo we require a copy of the original state of our model - with special handling for ListWrapper to maintain object identity of the list The List (originalElements) on ChangeSummary will maintain the current state of our model after logged changes. The List (currentElements) will be a progressively deeper distinct shallow copy of the current list as it changes
-
-
Constructor Details
-
ListWrapper
public ListWrapper() -
ListWrapper
-
ListWrapper
Constructor for non-default Pluggable ValueStore implementations
Prerequisites: Containment is already set on theList parameter. Do not use this constructor for default implementations as containment is not updated. The SDO Objects inside this ListWrapper are special case wrappers with no previous containment We do not call updateContainment on the SDO Wrapper objects surrounding the POJO's otherwise the containment of this list will be removed in the embedded detach() call TestCase: the first get on a list.
-
-
Method Details
-
add
- Specified by:
addin interfaceCollection- Specified by:
addin interfaceList
-
add
INTERNAL:- Parameters:
item-updateSequence-- Returns:
-
add
Inserts the specified element at the index position in this list. -
add
INTERNAL:- Parameters:
index-item-updateSequence-
-
isLogging
protected boolean isLogging()INTERNAL: -
copyElements
protected void copyElements()INTERNAL: Shallow copy elements -
undoChanges
INTERNAL: Undo any changes and return the original List -
updateSequence
INTERNAL: Iterate the collection and add settings where appropriate.- Parameters:
aProperty-items-updateSequence-
-
updateContainment
INTERNAL:- Parameters:
item-updateSequence-
-
updateContainment
-
removeContainment
INTERNAL:- Parameters:
item-fromDelete-updateSequence-
-
removeContainment
protected void removeContainment(int occurrence, Object item, boolean fromDelete, boolean updateSequence) INTERNAL:- Parameters:
item-fromDelete-updateSequence-
-
remove
INTERNAL: Remove the item or first occurrence of the item.- Parameters:
item-fromDelete-updateSequence-- Returns:
-
remove
- Specified by:
removein interfaceCollection- Specified by:
removein interfaceList- Parameters:
item-- Returns:
-
addAll
Appends all of the currentElements in the specified Collection to the end of this list, in the order that they are returned by the specified Collection's Iterator. The behavior of this operation is undefined if the specified Collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified Collection is this list, and this list is nonempty.)
This operation is a special case of the general addAll(int, Collection).
From the SDO Specification: p18 The getList(property) accessor is especially convenient for many-valued properties. If property.many is true then set(property, value) and setList(property, value) require that [value] be a java.util.Collection and List respectively. These methods are equivalent to getList(property).clear() followed by getList(property).addAll(value).- Specified by:
addAllin interfaceCollection- Specified by:
addAllin interfaceList- Parameters:
items-- Returns:
- boolean
-
addAll
INTERNAL: Appends all of the currentElements in the specified Collection to the end of this list, in the order that they are returned by the specified Collection's Iterator. This function calls the public addAll(Collection) with a sequence state flag.- Parameters:
items-updateSequence-- Returns:
-
addAll
Inserts all of the currentElements in the specified Collection into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent currentElements to the right (increases their indices). The new currentElements will appear in the list in the order that they are returned by the specified Collection's iterator. -
addAll
-
removeAll
Removes from this collection all of its currentElements that are contained in the specified collection.- Specified by:
removeAllin interfaceCollection- Specified by:
removeAllin interfaceList- Parameters:
items-- Returns:
- boolean
-
removeAll
INTERNAL: Removes from this collection all of its currentElements that are contained in the specified collection.- Parameters:
items-updateSequence-- Returns:
-
retainAll
Retains only the currentElements in this collection that are contained in the specified collection (optional operation).
In other words, removes from this collection all of its currentElements that are not contained in the specified collection.- Specified by:
retainAllin interfaceCollection- Specified by:
retainAllin interfaceList- Parameters:
itemsToKeep-- Returns:
- boolean
-
clear
public void clear()Removes all of the currentElements from this list. The list will be empty after this call returns.- Specified by:
clearin interfaceCollection- Specified by:
clearin interfaceList
-
clear
public void clear(boolean updateSequence) INTERNAL:- Parameters:
updateSequence-
-
set
Replaces the element at the specified index in this list with the specified element. -
remove
INTERNAL: Removes the element at the specified position in this list.
Position index starts at 0.- Parameters:
index-updateSequence-- Returns:
- Object (the element previously at the specified position)
-
remove
Removes the element at the specified position in this list.
Position index starts at 0. -
listIterator
- Specified by:
listIteratorin interfaceList
-
listIterator
- Specified by:
listIteratorin interfaceList
-
subList
Return a view of the specified portion of the list -
toArray
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceList
-
toArray
Returns an array containing all of the currentElements in this list in proper sequence; the runtime type of the returned array is that of the specified array. Obeys the general contract of the Collection.toArray(Object[]) method.
Specified by: toArray in interface Collection<E>
Throws:
ArrayStoreException - if the runtime type of the specified array is not a supertype of the runtime type of every element in this list.
NullPointerException - if the specified array is null.- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceList- Parameters:
items- -the array into which the currentElements of this list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.- Returns:
- Object[] - an array containing the currentElements of this list.
-
size
public int size()- Specified by:
sizein interfaceCollection- Specified by:
sizein interfaceList
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection- Specified by:
isEmptyin interfaceList
-
contains
- Specified by:
containsin interfaceCollection- Specified by:
containsin interfaceList
-
containsAll
- Specified by:
containsAllin interfaceCollection- Specified by:
containsAllin interfaceList
-
iterator
-
indexOf
-
lastIndexOf
- Specified by:
lastIndexOfin interfaceList
-
get
-
writeReplace
INTERNAL: Defined in SDO 2.01 spec on page 65 Externalizable function is called by ObjectStream.writeObject() A replacement object for serialization can be called here.Security Note: This public function exposes a data replacement vulnerability where an outside client can gain access and modify their non-final constants. We may need to wrap the GZIP streams in some sort of encryption when we are not using HTTPS or SSL/TLS on the wire.
- See Also:
-
getCurrentElements
INTERNAL:- Returns:
-
setCurrentElements
INTERNAL: bypass containment and changesummary copy of element list on modifications -
clone
Clone the ListWrapper. This creates a new ListWrapper with the same contents as the original (shallow clone) Minimal clone operation implemented to support usage in JPA
-