org.garret.perst
Class L2List

java.lang.Object
  extended by org.garret.perst.Persistent
      extended by org.garret.perst.PersistentResource
          extended by org.garret.perst.L2ListElem
              extended by org.garret.perst.L2List
All Implemented Interfaces:
java.util.Collection, java.io.Externalizable, IPersistent, IResource, ITable, java.lang.Iterable, java.io.Serializable

public class L2List
extends L2ListElem
implements ITable

Double linked list.

See Also:
Serialized Form

Constructor Summary
L2List()
           
 
Method Summary
 boolean add(java.lang.Object obj)
          Add object to the list
 boolean addAll(java.util.Collection c)
          Adds all of the elements in the specified collection to this collection (optional operation).
 void append(L2ListElem elem)
          Insert element at the end of the list
 void clear()
          Make list empty.
 boolean contains(java.lang.Object o)
          Check if object is in collection
 boolean containsAll(java.util.Collection c)
          Returns true if this collection contains all of the elements in the specified collection.
 L2ListElem head()
          Get list head element
 boolean isEmpty()
          Check if list is empty
 java.util.Iterator iterator()
          Get list iterator.
 void prepend(L2ListElem elem)
          Insert element at the beginning of the list
 void remove(L2ListElem elem)
          Remove element from the list
 boolean remove(java.lang.Object o)
          Remove object from the list
 boolean removeAll(java.util.Collection c)
          Removes from this collection all of its elements that are contained in the specified collection (optional operation).
 boolean retainAll(java.util.Collection c)
          Retains only the elements in this collection that are contained in the specified collection (optional operation).
 java.util.Iterator select(java.lang.Class cls, java.lang.String predicate)
          Select members of the collection using search predicate This iterator doesn't support remove() method.
 int size()
          Get size of the list
 L2ListElem tail()
          Get list tail element
 java.lang.Object[] toArray()
          Get array of the list elements
 java.lang.Object[] toArray(java.lang.Object[] a)
          Returns an array containing all of the elements in this list in the correct order; the runtime type of the returned array is that of the specified array.
 
Methods inherited from class org.garret.perst.L2ListElem
getNext, getPrev, linkAfter, linkBefore, prune, unlink
 
Methods inherited from class org.garret.perst.PersistentResource
exclusiveLock, exclusiveLock, reset, sharedLock, sharedLock, unlock
 
Methods inherited from class org.garret.perst.Persistent
assignOid, deallocate, equals, getOid, getStorage, hashCode, invalidate, isDeleted, isModified, isPersistent, isRaw, load, loadAndModify, makePersistent, modify, onLoad, onStore, readExternal, recursiveLoading, store, writeExternal
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Collection
add, addAll, containsAll, equals, hashCode, removeAll, retainAll, toArray
 

Constructor Detail

L2List

public L2List()
Method Detail

add

public boolean add(java.lang.Object obj)
Add object to the list

Parameters:
obj - object added to the list
Returns:
always returns true

addAll

public boolean addAll(java.util.Collection c)
Adds all of the elements in the specified collection to this collection (optional operation). 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 collection, and this collection is nonempty.)

This implementation iterates over the specified collection, and adds each object returned by the iterator to this collection, in turn.

Note that this implementation will throw an UnsupportedOperationException unless add is overridden (assuming the specified collection is non-empty).

Parameters:
c - collection whose elements are to be added to this collection.
Returns:
true if this collection changed as a result of the call.
Throws:
java.lang.UnsupportedOperationException - if this collection does not support the addAll method.
java.lang.NullPointerException - if the specified collection is null.
See Also:
add(Object)

append

public void append(L2ListElem elem)
Insert element at the end of the list


clear

public void clear()
Make list empty.

Specified by:
clear in interface java.util.Collection

contains

public boolean contains(java.lang.Object o)
Check if object is in collection

Specified by:
contains in interface java.util.Collection
Parameters:
o - object to be searched in the collection
Returns:
true if there is an object in the collection which is equals to the specified object

containsAll

public boolean containsAll(java.util.Collection c)
Returns true if this collection contains all of the elements in the specified collection.

This implementation iterates over the specified collection, checking each element returned by the iterator in turn to see if it's contained in this collection. If all elements are so contained true is returned, otherwise false.

Parameters:
c - collection to be checked for containment in this collection.
Returns:
true if this collection contains all of the elements in the specified collection.
Throws:
java.lang.NullPointerException - if the specified collection is null.
See Also:
contains(Object)

head

public L2ListElem head()
Get list head element

Returns:
list head element or null if list is empty

isEmpty

public boolean isEmpty()
Check if list is empty

Specified by:
isEmpty in interface java.util.Collection
Returns:
true if list is empty

iterator

public java.util.Iterator iterator()
Get list iterator. This iterator supports remove() method put concurrent modifications of thje list during iteration are not possible.

Specified by:
iterator in interface java.util.Collection
Returns:
list iterator

prepend

public void prepend(L2ListElem elem)
Insert element at the beginning of the list


remove

public void remove(L2ListElem elem)
Remove element from the list


remove

public boolean remove(java.lang.Object o)
Remove object from the list

Specified by:
remove in interface java.util.Collection
Parameters:
o - object to be removed from the list
Returns:
always returns true

removeAll

public boolean removeAll(java.util.Collection c)
Removes from this collection all of its elements that are contained in the specified collection (optional operation).

This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's so contained, it's removed from this collection with the iterator's remove method.

Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements in common with the specified collection.

Parameters:
c - elements to be removed from this collection.
Returns:
true if this collection changed as a result of the call.
Throws:
java.lang.UnsupportedOperationException - if the removeAll method is not supported by this collection.
java.lang.NullPointerException - if the specified collection is null.
See Also:
remove(Object), contains(Object)

retainAll

public boolean retainAll(java.util.Collection c)
Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.

This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's not so contained, it's removed from this collection with the iterator's remove method.

Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements not present in the specified collection.

Parameters:
c - elements to be retained in this collection.
Returns:
true if this collection changed as a result of the call.
Throws:
java.lang.UnsupportedOperationException - if the retainAll method is not supported by this Collection.
java.lang.NullPointerException - if the specified collection is null.
See Also:
remove(Object), contains(Object)

select

public java.util.Iterator select(java.lang.Class cls,
                                 java.lang.String predicate)
Select members of the collection using search predicate This iterator doesn't support remove() method. It is not possible to update list during iteration.

Specified by:
select in interface ITable
Parameters:
cls - class of index members
predicate - JSQL condition
Returns:
iterator through members of the collection matching search condition

size

public int size()
Get size of the list

Specified by:
size in interface java.util.Collection
Returns:
number of elements in the list

tail

public L2ListElem tail()
Get list tail element

Returns:
list tail element or null if list is empty

toArray

public java.lang.Object[] toArray()
Get array of the list elements

Specified by:
toArray in interface java.util.Collection
Returns:
array with list elements

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Returns an array containing all of the elements in this list in the correct order; the runtime type of the returned array is that of the specified array. If the list fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this list.

If the list fits in the specified array with room to spare (i.e., the array has more elements than the list), the element in the array immediately following the end of the collection is set to null. This is useful in determining the length of the list only if the caller knows that the list does not contain any null elements.

Parameters:
a - the array into which the elements of the 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:
an array containing the elements of the list.
Throws:
java.lang.ArrayStoreException - if the runtime type of a is not a supertype of the runtime type of every element in this list.