Berkeley DB
version 4.2.52

com.sleepycat.bdb.collection
Class StoredList

java.lang.Object
  |
  +--com.sleepycat.bdb.collection.StoredContainer
        |
        +--com.sleepycat.bdb.collection.StoredCollection
              |
              +--com.sleepycat.bdb.collection.StoredList
All Implemented Interfaces:
Cloneable, Collection, List

public class StoredList
extends StoredCollection
implements List

A List view of a DataStore or DataIndex.

For all stored lists the keys of the underlying DataStore or DataIndex must have record number format, and therefore the store or index must be a RECNO, RECNO-RENUMBER, QUEUE, or BTREE-RECNUM database. Only RECNO-RENUMBER allows true list behavior where record numbers are renumbered following the position of an element that is added or removed. For the other access methods (RECNO, QUEUE, and BTREE-RECNUM), stored Lists are most useful as read-only collections where record numbers are not required to be sequential.

In addition to the standard List methods, this class provides the following methods for stored lists only. Note that the use of these methods is not compatible with the standard Java collections interface.


Constructor Summary
StoredList(DataIndex index, DataBinding valueBinding, boolean writeAllowed)
          Creates a list view of a DataIndex.
StoredList(DataIndex index, EntityBinding valueEntityBinding, boolean writeAllowed)
          Creates a list entity view of a DataIndex.
StoredList(DataStore store, DataBinding valueBinding, boolean writeAllowed)
          Creates a list view of a DataStore.
StoredList(DataStore store, EntityBinding valueEntityBinding, boolean writeAllowed)
          Creates a list entity view of a DataStore.
 
Method Summary
 void add(int index, Object value)
          Inserts the specified element at the specified position in this list (optional operation).
 boolean add(Object value)
          Appends the specified element to the end of this list (optional operation).
 boolean addAll(int index, Collection coll)
          Inserts all of the elements in the specified collection into this list at the specified position (optional operation).
 int append(Object value)
          Appends a given value returning the newly assigned index.
 boolean contains(Object value)
          Returns true if this list contains the specified element.
 boolean equals(Object other)
          Compares the specified object with this list for equality.
 Object get(int index)
          Returns the element at the specified position in this list.
 int indexOf(Object value)
          Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.
 int lastIndexOf(Object value)
          Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element.
 ListIterator listIterator()
          Returns a list iterator of the elements in this list (in proper sequence).
 ListIterator listIterator(int index)
          Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list.
 Object remove(int index)
          Removes the element at the specified position in this list (optional operation).
 boolean remove(Object value)
          Removes the first occurrence in this list of the specified element (optional operation).
 Object set(int index, Object value)
          Replaces the element at the specified position in this list with the specified element (optional operation).
 List subList(int fromIndex, int toIndex)
          Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
 
Methods inherited from class com.sleepycat.bdb.collection.StoredCollection
addAll, containsAll, iterator, iterator, join, join, removeAll, retainAll, toArray, toArray, toList, toString
 
Methods inherited from class com.sleepycat.bdb.collection.StoredContainer
areDuplicatesAllowed, areDuplicatesOrdered, areKeysRenumbered, clear, isAutoCommit, isDirtyReadAllowed, isDirtyReadEnabled, isEmpty, isIndexed, isOrdered, isTransactional, isWriteAllowed, size
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, clear, containsAll, hashCode, isEmpty, iterator, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

StoredList

public StoredList(DataStore store,
                  DataBinding valueBinding,
                  boolean writeAllowed)
Creates a list view of a DataStore.

Parameters:
store - is the DataStore underlying the new collection.
valueBinding - is the binding used to translate between value buffers and value objects.
writeAllowed - is true to create a read-write collection or false to create a read-only collection.
Throws:
IllegalArgumentException - if formats are not consistently defined or a parameter is invalid.
RuntimeExceptionWrapper - if a DbException is thrown.

StoredList

public StoredList(DataStore store,
                  EntityBinding valueEntityBinding,
                  boolean writeAllowed)
Creates a list entity view of a DataStore.

Parameters:
store - is the DataStore underlying the new collection.
valueEntityBinding - is the binding used to translate between key/value buffers and entity value objects.
writeAllowed - is true to create a read-write collection or false to create a read-only collection.
Throws:
IllegalArgumentException - if formats are not consistently defined or a parameter is invalid.
RuntimeExceptionWrapper - if a DbException is thrown.

StoredList

public StoredList(DataIndex index,
                  DataBinding valueBinding,
                  boolean writeAllowed)
Creates a list view of a DataIndex.

Parameters:
index - is the DataIndex underlying the new collection.
valueBinding - is the binding used to translate between value buffers and value objects.
writeAllowed - is true to create a read-write collection or false to create a read-only collection.
Throws:
IllegalArgumentException - if formats are not consistently defined or a parameter is invalid.
RuntimeExceptionWrapper - if a DbException is thrown.

StoredList

public StoredList(DataIndex index,
                  EntityBinding valueEntityBinding,
                  boolean writeAllowed)
Creates a list entity view of a DataIndex.

Parameters:
index - is the DataIndex underlying the new collection.
valueEntityBinding - is the binding used to translate between key/value buffers and entity value objects.
writeAllowed - is true to create a read-write collection or false to create a read-only collection.
Throws:
IllegalArgumentException - if formats are not consistently defined or a parameter is invalid.
RuntimeExceptionWrapper - if a DbException is thrown.
Method Detail

add

public void add(int index,
                Object value)
Inserts the specified element at the specified position in this list (optional operation). This method conforms to the List.add(int, Object) interface.

Specified by:
add in interface List
Throws:
UnsupportedOperationException - if the collection is a sublist, or if the collection is indexed, or if the collection is read-only, or if the RECNO-RENUMBER access method was not used.
RuntimeExceptionWrapper - if a DbException is thrown.

add

public boolean add(Object value)
Appends the specified element to the end of this list (optional operation). This method conforms to the List.add(Object) interface.

Specified by:
add in interface List
Throws:
UnsupportedOperationException - if the collection is a sublist, or if the collection is indexed, or if the collection is read-only, or if the RECNO-RENUMBER access method was not used.
RuntimeExceptionWrapper - if a DbException is thrown.

append

public int append(Object value)
Appends a given value returning the newly assigned index. If a PrimaryKeyAssigner is associated with Store for this list, it will be used to assigned the returned index. Otherwise the Store must be a QUEUE or RECNO database and the next available record number is assigned as the index. This method does not exist in the standard List interface.

Parameters:
value - the value to be appended.
Returns:
the assigned index.
Throws:
UnsupportedOperationException - if the collection is indexed, or if the collection is read-only, or if the Store has no PrimaryKeyAssigner and is not a QUEUE or RECNO database.
RuntimeExceptionWrapper - if a DbException is thrown.

addAll

public boolean addAll(int index,
                      Collection coll)
Inserts all of the elements in the specified collection into this list at the specified position (optional operation). This method conforms to the List.addAll(int, Collection) interface.

Specified by:
addAll in interface List
Throws:
UnsupportedOperationException - if the collection is a sublist, or if the collection is indexed, or if the collection is read-only, or if the RECNO-RENUMBER access method was not used.
RuntimeExceptionWrapper - if a DbException is thrown.

contains

public boolean contains(Object value)
Returns true if this list contains the specified element. This method conforms to the List.contains(java.lang.Object) interface.

Specified by:
contains in interface List
Throws:
RuntimeExceptionWrapper - if a DbException is thrown.

get

public Object get(int index)
Returns the element at the specified position in this list. This method conforms to the List.get(int) interface.

Specified by:
get in interface List
Throws:
RuntimeExceptionWrapper - if a DbException is thrown.

indexOf

public int indexOf(Object value)
Returns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element. This method conforms to the List.indexOf(java.lang.Object) interface.

Specified by:
indexOf in interface List
Throws:
RuntimeExceptionWrapper - if a DbException is thrown.

lastIndexOf

public int lastIndexOf(Object value)
Returns the index in this list of the last occurrence of the specified element, or -1 if this list does not contain this element. This method conforms to the List.lastIndexOf(java.lang.Object) interface.

Specified by:
lastIndexOf in interface List
Throws:
RuntimeExceptionWrapper - if a DbException is thrown.

listIterator

public ListIterator listIterator()
Returns a list iterator of the elements in this list (in proper sequence). The iterator will be read-only if the collection is read-only. This method conforms to the List.listIterator() interface.

Specified by:
listIterator in interface List
Returns:
a StoredIterator for this collection.
Throws:
RuntimeExceptionWrapper - if a DbException is thrown.
See Also:
StoredContainer.isWriteAllowed()

listIterator

public ListIterator listIterator(int index)
Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list. The iterator will be read-only if the collection is read-only. This method conforms to the List.listIterator(int) interface.

Specified by:
listIterator in interface List
Returns:
a StoredIterator for this collection.
Throws:
RuntimeExceptionWrapper - if a DbException is thrown.
See Also:
StoredContainer.isWriteAllowed()

remove

public Object remove(int index)
Removes the element at the specified position in this list (optional operation). This method conforms to the List.remove(int) interface.

Specified by:
remove in interface List
Throws:
UnsupportedOperationException - if the collection is a sublist, or if the collection is read-only.
RuntimeExceptionWrapper - if a DbException is thrown.

remove

public boolean remove(Object value)
Removes the first occurrence in this list of the specified element (optional operation). This method conforms to the List.remove(Object) interface.

Specified by:
remove in interface List
Throws:
UnsupportedOperationException - if the collection is a sublist, or if the collection is read-only.
RuntimeExceptionWrapper - if a DbException is thrown.

set

public Object set(int index,
                  Object value)
Replaces the element at the specified position in this list with the specified element (optional operation). This method conforms to the List.set(int, java.lang.Object) interface.

Specified by:
set in interface List
Throws:
UnsupportedOperationException - if the collection is indexed, or if the collection is read-only.
IllegalArgumentException - if an entity value binding is used and the primary key of the value given is different than the existing stored primary key.
RuntimeExceptionWrapper - if a DbException is thrown.

subList

public List subList(int fromIndex,
                    int toIndex)
Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. Note that add() and remove() may not be called for the returned sublist. This method conforms to the List.subList(int, int) interface.

Specified by:
subList in interface List
Throws:
RuntimeExceptionWrapper - if a DbException is thrown.

equals

public boolean equals(Object other)
Compares the specified object with this list for equality. A value comparison is performed by this method and the stored values are compared rather than calling the equals() method of each element. This method conforms to the List.equals(java.lang.Object) interface.

Specified by:
equals in interface List
Overrides:
equals in class StoredCollection
Throws:
RuntimeExceptionWrapper - if a DbException is thrown.

Berkeley DB
version 4.2.52

Copyright (c) 1996-2003 Sleepycat Software, Inc. - All rights reserved.