Class ListWrapper
- java.lang.Object
-
- org.eclipse.persistence.sdo.helper.ListWrapper
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Iterable,java.util.Collection,java.util.List
- Direct Known Subclasses:
JAXBListWrapper
public class ListWrapper extends java.lang.Object implements java.util.List, java.io.Serializable, java.lang.CloneableINTERNAL:Purpose:
- This class wraps the ArrayList of currentElements that implement the List interface.
Responsibilities:
- Provide access many properties on
dataObjects
- Since:
- Oracle TopLink 11.1.1.0.0
- See Also:
SDODataObject, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ListcurrentElementsWe are maintaining two pointers to potentially two ArrayList objects.protected SDODataObjectdataObjectprotected SDOPropertyproperty
-
Constructor Summary
Constructors Constructor Description ListWrapper()ListWrapper(SDODataObject theDataObject, commonj.sdo.Property theProperty)ListWrapper(SDODataObject theDataObject, commonj.sdo.Property theProperty, java.util.List theList)Constructor for non-default Pluggable ValueStore implementations
Prerequisites: Containment is already set on theList parameter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, java.lang.Object item)Inserts the specified element at the index position in this list.voidadd(int index, java.lang.Object item, boolean updateSequence)INTERNAL:booleanadd(java.lang.Object item)booleanadd(java.lang.Object item, boolean updateSequence)INTERNAL:booleanaddAll(int position, java.util.Collection items)Inserts all of the currentElements in the specified Collection into this list, starting at the specified position.booleanaddAll(int position, java.util.Collection items, boolean updateSequence)booleanaddAll(java.util.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(java.util.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:java.lang.Objectclone()Clone the ListWrapper.booleancontains(java.lang.Object item)booleancontainsAll(java.util.Collection items)protected voidcopyElements()INTERNAL: Shallow copy elementsjava.lang.Objectget(int position)java.util.ListgetCurrentElements()INTERNAL:intindexOf(java.lang.Object item)booleanisEmpty()protected booleanisLogging()INTERNAL:java.util.Iteratoriterator()intlastIndexOf(java.lang.Object item)java.util.ListIteratorlistIterator()java.util.ListIteratorlistIterator(int position)java.lang.Objectremove(int index)Removes the element at the specified position in this list.
Position index starts at 0.java.lang.Objectremove(int index, boolean updateSequence)INTERNAL: Removes the element at the specified position in this list.
Position index starts at 0.booleanremove(java.lang.Object item)booleanremove(java.lang.Object item, boolean fromDelete, boolean updateSequence)INTERNAL: Remove the item or first occurrence of the item.booleanremoveAll(java.util.Collection items)Removes from this collection all of its currentElements that are contained in the specified collection.booleanremoveAll(java.util.Collection items, boolean updateSequence)INTERNAL: Removes from this collection all of its currentElements that are contained in the specified collection.protected voidremoveContainment(int occurrence, java.lang.Object item, boolean fromDelete, boolean updateSequence)INTERNAL:protected voidremoveContainment(java.lang.Object item, boolean fromDelete, boolean updateSequence)INTERNAL:booleanretainAll(java.util.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.java.lang.Objectset(int index, java.lang.Object item)Replaces the element at the specified index in this list with the specified element.voidsetCurrentElements(java.util.List currentElementsList)INTERNAL: bypass containment and changesummary copy of element list on modificationsintsize()java.util.ListsubList(int start, int end)Return a view of the specified portion of the listjava.lang.Object[]toArray()java.lang.Object[]toArray(java.lang.Object[] items)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.voidundoChanges(SDOChangeSummary cs)INTERNAL: Undo any changes and return the original Listprotected voidupdateContainment(java.lang.Object item, boolean updateSequence)INTERNAL:protected voidupdateContainment(java.util.Collection items, boolean updateSequence)protected voidupdateSequence(commonj.sdo.Property aProperty, java.util.Collection items, boolean updateSequence)INTERNAL: Iterate the collection and add settings where appropriate.java.lang.ObjectwriteReplace()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.
-
-
-
Field Detail
-
dataObject
protected SDODataObject dataObject
-
property
protected SDOProperty property
-
currentElements
protected java.util.List 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 Detail
-
ListWrapper
public ListWrapper()
-
ListWrapper
public ListWrapper(SDODataObject theDataObject, commonj.sdo.Property theProperty)
-
ListWrapper
public ListWrapper(SDODataObject theDataObject, commonj.sdo.Property theProperty, java.util.List theList)
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 Detail
-
add
public boolean add(java.lang.Object item)
- Specified by:
addin interfacejava.util.Collection- Specified by:
addin interfacejava.util.List
-
add
public boolean add(java.lang.Object item, boolean updateSequence)INTERNAL:- Parameters:
item-updateSequence-- Returns:
-
add
public void add(int index, java.lang.Object item)Inserts the specified element at the index position in this list.- Specified by:
addin interfacejava.util.List- Parameters:
index- (start at 0 = prepend, length = append)item-
-
add
public void add(int index, java.lang.Object item, boolean updateSequence)INTERNAL:- Parameters:
index-item-updateSequence-
-
isLogging
protected boolean isLogging()
INTERNAL:
-
copyElements
protected void copyElements()
INTERNAL: Shallow copy elements
-
undoChanges
public void undoChanges(SDOChangeSummary cs)
INTERNAL: Undo any changes and return the original List
-
updateSequence
protected void updateSequence(commonj.sdo.Property aProperty, java.util.Collection items, boolean updateSequence)INTERNAL: Iterate the collection and add settings where appropriate.- Parameters:
aProperty-items-updateSequence-
-
updateContainment
protected void updateContainment(java.lang.Object item, boolean updateSequence)INTERNAL:- Parameters:
item-updateSequence-
-
updateContainment
protected void updateContainment(java.util.Collection items, boolean updateSequence)
-
removeContainment
protected void removeContainment(java.lang.Object item, boolean fromDelete, boolean updateSequence)INTERNAL:- Parameters:
item-fromDelete-updateSequence-
-
removeContainment
protected void removeContainment(int occurrence, java.lang.Object item, boolean fromDelete, boolean updateSequence)INTERNAL:- Parameters:
item-fromDelete-updateSequence-
-
remove
public boolean remove(java.lang.Object item, boolean fromDelete, boolean updateSequence)INTERNAL: Remove the item or first occurrence of the item.- Parameters:
item-fromDelete-updateSequence-- Returns:
-
remove
public boolean remove(java.lang.Object item)
- Specified by:
removein interfacejava.util.Collection- Specified by:
removein interfacejava.util.List- Parameters:
item-- Returns:
-
addAll
public boolean addAll(java.util.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. 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 interfacejava.util.Collection- Specified by:
addAllin interfacejava.util.List- Parameters:
items-- Returns:
- boolean
-
addAll
public boolean addAll(java.util.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. This function calls the public addAll(Collection) with a sequence state flag.- Parameters:
items-updateSequence-- Returns:
-
addAll
public boolean addAll(int position, java.util.Collection items)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.- Specified by:
addAllin interfacejava.util.List- Parameters:
position- (start at 0 = prepend, length = append)items-- Returns:
- boolean
-
addAll
public boolean addAll(int position, java.util.Collection items, boolean updateSequence)
-
removeAll
public boolean removeAll(java.util.Collection items)
Removes from this collection all of its currentElements that are contained in the specified collection.- Specified by:
removeAllin interfacejava.util.Collection- Specified by:
removeAllin interfacejava.util.List- Parameters:
items-- Returns:
- boolean
-
removeAll
public boolean removeAll(java.util.Collection items, boolean updateSequence)INTERNAL: Removes from this collection all of its currentElements that are contained in the specified collection.- Parameters:
items-updateSequence-- Returns:
-
retainAll
public boolean retainAll(java.util.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.- Specified by:
retainAllin interfacejava.util.Collection- Specified by:
retainAllin interfacejava.util.List- 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 interfacejava.util.Collection- Specified by:
clearin interfacejava.util.List
-
clear
public void clear(boolean updateSequence)
INTERNAL:- Parameters:
updateSequence-
-
set
public java.lang.Object set(int index, java.lang.Object item)Replaces the element at the specified index in this list with the specified element.- Specified by:
setin interfacejava.util.List- Parameters:
index-item-- Returns:
- Object (the element previously at the specified position)
-
remove
public java.lang.Object remove(int index, boolean updateSequence)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
public java.lang.Object remove(int index)
Removes the element at the specified position in this list.
Position index starts at 0.- Specified by:
removein interfacejava.util.List- Parameters:
index-- Returns:
- Object (the element previously at the specified position)
-
listIterator
public java.util.ListIterator listIterator()
- Specified by:
listIteratorin interfacejava.util.List
-
listIterator
public java.util.ListIterator listIterator(int position)
- Specified by:
listIteratorin interfacejava.util.List
-
subList
public java.util.List subList(int start, int end)Return a view of the specified portion of the list- Specified by:
subListin interfacejava.util.List- Parameters:
start- - low endpoint (inclusive) of the subList.end- - high endpoint (exclusive) of the subList.- Returns:
-
toArray
public java.lang.Object[] toArray()
- Specified by:
toArrayin interfacejava.util.Collection- Specified by:
toArrayin interfacejava.util.List
-
toArray
public java.lang.Object[] toArray(java.lang.Object[] items)
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 interfacejava.util.Collection- Specified by:
toArrayin interfacejava.util.List- 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 interfacejava.util.Collection- Specified by:
sizein interfacejava.util.List
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacejava.util.Collection- Specified by:
isEmptyin interfacejava.util.List
-
contains
public boolean contains(java.lang.Object item)
- Specified by:
containsin interfacejava.util.Collection- Specified by:
containsin interfacejava.util.List
-
containsAll
public boolean containsAll(java.util.Collection items)
- Specified by:
containsAllin interfacejava.util.Collection- Specified by:
containsAllin interfacejava.util.List
-
iterator
public java.util.Iterator iterator()
- Specified by:
iteratorin interfacejava.util.Collection- Specified by:
iteratorin interfacejava.lang.Iterable- Specified by:
iteratorin interfacejava.util.List
-
indexOf
public int indexOf(java.lang.Object item)
- Specified by:
indexOfin interfacejava.util.List
-
lastIndexOf
public int lastIndexOf(java.lang.Object item)
- Specified by:
lastIndexOfin interfacejava.util.List
-
get
public java.lang.Object get(int position)
- Specified by:
getin interfacejava.util.List
-
writeReplace
public java.lang.Object 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:
SDOResolvable
-
getCurrentElements
public java.util.List getCurrentElements()
INTERNAL:- Returns:
-
setCurrentElements
public void setCurrentElements(java.util.List currentElementsList)
INTERNAL: bypass containment and changesummary copy of element list on modifications
-
clone
public java.lang.Object 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- Overrides:
clonein classjava.lang.Object
-
-