E
- the type of objects stored in this listpublic class TransactionList<E>
extends java.util.AbstractList<E>
implements java.util.List<E>
Constructor and Description |
---|
TransactionList(java.util.List<E> list)
Creates a new instance of TransactionList with the encapsulated list.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E o)
Appends the specified element to the end of this list (optional
operation).
|
void |
add(int index,
E element)
Inserts the specified element at the specified position in this list
(optional operation).
|
boolean |
addAll(java.util.Collection<? extends E> c)
Appends all of the elements in the specified collection to the end of
this list, in the order that they are returned by the specified
collection's iterator (optional operation).
|
boolean |
addAll(int index,
java.util.Collection<? extends E> c)
Inserts all of the elements in the specified collection into this
list at the specified position (optional operation).
|
boolean |
beginTransaction()
Start a new transaction.
|
boolean |
beginTransaction(boolean blocking)
Start a new transaction.
|
void |
clear()
Removes all of the elements from this list (optional operation).
|
void |
commitTransaction()
End transaction of pivot processing, commiting changes
|
boolean |
contains(java.lang.Object o)
Returns true if this list contains the specified element.
|
boolean |
containsAll(java.util.Collection<?> c)
Returns true if this list contains all of the elements of the
specified collection.
|
boolean |
equals(java.lang.Object o)
Compares the specified object with this list for equality.
|
E |
get(int index)
Returns the element at the specified position in this list.
|
int |
hashCode()
Returns the hash code value for this list.
|
boolean |
changedDuringTransaction()
Reports whether the list was changed during the last transaction or not.
|
int |
indexOf(java.lang.Object o)
Returns the index in this list of the first occurrence of the specified
element, or -1 if this list does not contain this element.
|
boolean |
isEmpty()
Returns true if this list contains no elements.
|
boolean |
isTransactionRunning()
Returns the current transaction state.
|
java.util.Iterator<E> |
iterator()
Returns an iterator over the elements in this list in proper sequence.
|
int |
lastIndexOf(java.lang.Object o)
Returns the index in this list of the last occurrence of the specified
element, or -1 if this list does not contain this element.
|
java.util.ListIterator<E> |
listIterator()
Returns a list iterator of the elements in this list (in proper
sequence).
|
java.util.ListIterator<E> |
listIterator(int index)
Returns a list iterator of the elements in this list (in proper
sequence), starting at the specified position in this list.
|
E |
remove(int index)
Removes the element at the specified position in this list (optional
operation).
|
boolean |
remove(java.lang.Object o)
Removes the first occurrence in this list of the specified element
(optional operation).
|
boolean |
removeAll(java.util.Collection<?> c)
Removes from this list all the elements that are contained in the
specified collection (optional operation).
|
boolean |
retainAll(java.util.Collection<?> c)
Retains only the elements in this list that are contained in the
specified collection (optional operation).
|
void |
rollbackTransaction()
End transaction of pivot processing, undoing changes
|
E |
set(int index,
E element)
Replaces the element at the specified position in this list with the
specified element (optional operation).
|
int |
size()
Returns the number of elements in this list.
|
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this list in proper
sequence.
|
<T> T[] |
toArray(T[] a)
Returns an array containing all of the elements in this list in proper
sequence; the runtime type of the returned array is that of the
specified array.
|
public TransactionList(java.util.List<E> list) throws java.lang.NullPointerException
list
- the list to encapsulatejava.lang.NullPointerException
- if the given list is nullpublic boolean beginTransaction(boolean blocking)
blocking
- Flag whether the start of a new transaction is blocking. We cannot run more transactions at a time.public boolean beginTransaction()
public boolean isTransactionRunning()
public void commitTransaction()
public void rollbackTransaction()
public boolean changedDuringTransaction()
public int size()
public boolean isEmpty()
public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection<E>
contains
in interface java.util.List<E>
contains
in class java.util.AbstractCollection<E>
o
- element whose presence in this list is to be tested.java.lang.ClassCastException
- if the type of the specified element
is incompatible with this list (optional).java.lang.NullPointerException
- if the specified element is null and this
list does not support null elements (optional).public java.util.Iterator<E> iterator()
public java.lang.Object[] toArray()
public <T> T[] toArray(T[] a)
toArray
in interface java.util.Collection<E>
toArray
in interface java.util.List<E>
toArray
in class java.util.AbstractCollection<E>
T
- the type of the returned arraya
- the array into which the elements 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.java.lang.ArrayStoreException
- if the runtime type of the specified array
is not a supertype of the runtime type of every element in
this list.java.lang.NullPointerException
- if the specified array is null.public boolean add(E o)
Lists that support this operation may place limitations on what elements may be added to this list. In particular, some lists will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. List classes should clearly specify in their documentation any restrictions on what elements may be added.
add
in interface java.util.Collection<E>
add
in interface java.util.List<E>
add
in class java.util.AbstractList<E>
o
- element to be appended to this list.java.lang.UnsupportedOperationException
- if the add method is not
supported by this list.java.lang.ClassCastException
- if the class of the specified element
prevents it from being added to this list.java.lang.NullPointerException
- if the specified element is null and this
list does not support null elements.java.lang.IllegalArgumentException
- if some aspect of this element
prevents it from being added to this list.public boolean remove(java.lang.Object o)
remove
in interface java.util.Collection<E>
remove
in interface java.util.List<E>
remove
in class java.util.AbstractCollection<E>
o
- element to be removed from this list, if present.java.lang.ClassCastException
- if the type of the specified element
is incompatible with this list (optional).java.lang.NullPointerException
- if the specified element is null and this
list does not support null elements (optional).java.lang.UnsupportedOperationException
- if the remove method is
not supported by this list.public boolean containsAll(java.util.Collection<?> c)
containsAll
in interface java.util.Collection<E>
containsAll
in interface java.util.List<E>
containsAll
in class java.util.AbstractCollection<E>
c
- collection to be checked for containment in this list.java.lang.ClassCastException
- if the types of one or more elements
in the specified collection are incompatible with this
list (optional).java.lang.NullPointerException
- if the specified collection contains one
or more null elements and this list does not support null
elements (optional).contains(Object)
public boolean addAll(java.util.Collection<? extends E> c)
addAll
in interface java.util.Collection<E>
addAll
in interface java.util.List<E>
addAll
in class java.util.AbstractCollection<E>
c
- collection whose elements are to be added to this list.java.lang.UnsupportedOperationException
- if the addAll method is
not supported by this list.java.lang.ClassCastException
- if the class of an element in the specified
collection prevents it from being added to this list.java.lang.NullPointerException
- if the specified collection contains one
or more null elements and this list does not support null
elements, or if the specified collection is null.java.lang.IllegalArgumentException
- if some aspect of an element in the
specified collection prevents it from being added to this
list.add(Object)
public boolean addAll(int index, java.util.Collection<? extends E> c)
addAll
in interface java.util.List<E>
addAll
in class java.util.AbstractList<E>
index
- index at which to insert first element from the specified
collection.c
- elements to be inserted into this list.java.lang.UnsupportedOperationException
- if the addAll method is
not supported by this list.java.lang.ClassCastException
- if the class of one of elements of the
specified collection prevents it from being added to this
list.java.lang.NullPointerException
- if the specified collection contains one
or more null elements and this list does not support null
elements, or if the specified collection is null.java.lang.IllegalArgumentException
- if some aspect of one of elements of
the specified collection prevents it from being added to
this list.java.lang.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index > size()).public boolean removeAll(java.util.Collection<?> c)
removeAll
in interface java.util.Collection<E>
removeAll
in interface java.util.List<E>
removeAll
in class java.util.AbstractCollection<E>
c
- collection that defines which elements will be removed from
this list.java.lang.UnsupportedOperationException
- if the removeAll method
is not supported by this list.java.lang.ClassCastException
- if the types of one or more elements
in this list are incompatible with the specified
collection (optional).java.lang.NullPointerException
- if this list contains one or more
null elements and the specified collection does not support
null elements (optional).remove(Object)
,
contains(Object)
public boolean retainAll(java.util.Collection<?> c)
retainAll
in interface java.util.Collection<E>
retainAll
in interface java.util.List<E>
retainAll
in class java.util.AbstractCollection<E>
c
- collection that defines which elements this set will retain.java.lang.UnsupportedOperationException
- if the retainAll method
is not supported by this list.java.lang.ClassCastException
- if the types of one or more elements
in this list are incompatible with the specified
collection (optional).java.lang.NullPointerException
- if this list contains one or more
null elements and the specified collection does not support
null elements (optional).remove(Object)
,
contains(Object)
public void clear()
public boolean equals(java.lang.Object o)
public int hashCode()
hashCode = 1; Iterator i = list.iterator(); while (i.hasNext()) { Object obj = i.next(); hashCode = 31*hashCode + (obj==null ? 0 : obj.hashCode()); }This ensures that list1.equals(list2) implies that list1.hashCode()==list2.hashCode() for any two lists, list1 and list2, as required by the general contract of Object.hashCode.
hashCode
in interface java.util.Collection<E>
hashCode
in interface java.util.List<E>
hashCode
in class java.util.AbstractList<E>
Object.hashCode()
,
Object.equals(Object)
,
equals(Object)
public E get(int index)
get
in interface java.util.List<E>
get
in class java.util.AbstractList<E>
index
- index of element to return.java.lang.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public E set(int index, E element)
set
in interface java.util.List<E>
set
in class java.util.AbstractList<E>
index
- index of element to replace.element
- element to be stored at the specified position.java.lang.UnsupportedOperationException
- if the set method is not
supported by this list.java.lang.ClassCastException
- if the class of the specified element
prevents it from being added to this list.java.lang.NullPointerException
- if the specified element is null and
this list does not support null elements.java.lang.IllegalArgumentException
- if some aspect of the specified
element prevents it from being added to this list.java.lang.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size()).public void add(int index, E element)
add
in interface java.util.List<E>
add
in class java.util.AbstractList<E>
index
- index at which the specified element is to be inserted.element
- element to be inserted.java.lang.UnsupportedOperationException
- if the add method is not
supported by this list.java.lang.ClassCastException
- if the class of the specified element
prevents it from being added to this list.java.lang.NullPointerException
- if the specified element is null and
this list does not support null elements.java.lang.IllegalArgumentException
- if some aspect of the specified
element prevents it from being added to this list.java.lang.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size()).public E remove(int index)
remove
in interface java.util.List<E>
remove
in class java.util.AbstractList<E>
index
- the index of the element to removed.java.lang.UnsupportedOperationException
- if the remove method is
not supported by this list.java.lang.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= size()).public int indexOf(java.lang.Object o)
indexOf
in interface java.util.List<E>
indexOf
in class java.util.AbstractList<E>
o
- element to search for.java.lang.ClassCastException
- if the type of the specified element
is incompatible with this list (optional).java.lang.NullPointerException
- if the specified element is null and this
list does not support null elements (optional).public int lastIndexOf(java.lang.Object o)
lastIndexOf
in interface java.util.List<E>
lastIndexOf
in class java.util.AbstractList<E>
o
- element to search for.java.lang.ClassCastException
- if the type of the specified element
is incompatible with this list (optional).java.lang.NullPointerException
- if the specified element is null and this
list does not support null elements (optional).public java.util.ListIterator<E> listIterator()
public java.util.ListIterator<E> listIterator(int index)
listIterator
in interface java.util.List<E>
listIterator
in class java.util.AbstractList<E>
index
- index of first element to be returned from the
list iterator (by a call to the next method).java.lang.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index > size()).