Class StoredList<E>
- All Implemented Interfaces:
Cloneable,Iterable<E>,Collection<E>,List<E>,SequencedCollection<E>
Database.
For all stored lists the keys of the underlying Database 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.
-
Field Summary
Fields inherited from class com.sleepycat.collections.StoredCollection
DEFAULT_ITERATOR_BLOCK_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionStoredList(Database database, EntityBinding<E> valueEntityBinding, boolean writeAllowed) Creates a list entity view of aDatabase.StoredList(Database database, EntityBinding<E> valueEntityBinding, PrimaryKeyAssigner keyAssigner) Creates a list entity view of aDatabasewith aPrimaryKeyAssigner.StoredList(Database database, EntryBinding<E> valueBinding, boolean writeAllowed) Creates a list view of aDatabase.StoredList(Database database, EntryBinding<E> valueBinding, PrimaryKeyAssigner keyAssigner) Creates a list view of aDatabasewith aPrimaryKeyAssigner. -
Method Summary
Modifier and TypeMethodDescriptionvoidInserts the specified element at the specified position in this list (optional operation).booleanAppends the specified element to the end of this list (optional operation).booleanaddAll(int index, Collection<? extends E> coll) Inserts all of the elements in the specified collection into this list at the specified position (optional operation).intAppends a given value returning the newly assigned index.booleanReturns true if this list contains the specified element.booleanCompares the specified object with this list for equality.get(int index) Returns the element at the specified position in this list.inthashCode()intReturns the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.intlastIndexOf(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.Returns a list iterator of the elements in this list (in proper sequence).listIterator(int index) Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list.remove(int index) Removes the element at the specified position in this list (optional operation).booleanRemoves the first occurrence in this list of the specified element (optional operation).Replaces the element at the specified position in this list with the specified element (optional operation).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.collections.StoredCollection
addAll, containsAll, getIteratorBlockSize, iterator, iterator, join, removeAll, retainAll, setIteratorBlockSize, size, storedIterator, storedIterator, toArray, toArray, toList, toStringMethods inherited from class com.sleepycat.collections.StoredContainer
areDuplicatesAllowed, areDuplicatesOrdered, areKeyRangesAllowed, areKeysRenumbered, clear, getCursorConfig, isEmpty, isOrdered, isSecondary, isTransactional, isWriteAllowedMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addAll, addFirst, addLast, clear, containsAll, getFirst, getLast, isEmpty, iterator, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, size, sort, spliterator, toArray, toArray
-
Constructor Details
-
StoredList
Creates a list view of aDatabase.- Parameters:
database- is the Database 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 checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
StoredList
Creates a list entity view of aDatabase.- Parameters:
database- is the Database 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 checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
StoredList
Creates a list view of aDatabasewith aPrimaryKeyAssigner. Writing is allowed for the created list.- Parameters:
database- is the Database underlying the new collection.valueBinding- is the binding used to translate between value buffers and value objects.keyAssigner- is used by theadd(int, E)andappend(E)methods to assign primary keys.- Throws:
IllegalArgumentException- if formats are not consistently defined or a parameter is invalid.RuntimeExceptionWrapper- if a checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
StoredList
public StoredList(Database database, EntityBinding<E> valueEntityBinding, PrimaryKeyAssigner keyAssigner) Creates a list entity view of aDatabasewith aPrimaryKeyAssigner. Writing is allowed for the created list.- Parameters:
database- is the Database underlying the new collection.valueEntityBinding- is the binding used to translate between key/value buffers and entity value objects.keyAssigner- is used by theadd(int, E)andappend(E)methods to assign primary keys.- Throws:
IllegalArgumentException- if formats are not consistently defined or a parameter is invalid.RuntimeExceptionWrapper- if a checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
-
Method Details
-
add
Inserts the specified element at the specified position in this list (optional operation). This method conforms to theList.add(int, Object)interface.- Specified by:
addin interfaceList<E>- 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 checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
add
Appends the specified element to the end of this list (optional operation). This method conforms to theList.add(Object)interface.- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceList<E>- 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 checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
append
Appends a given value returning the newly assigned index. If aPrimaryKeyAssigneris 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 standardListinterface.- 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 noPrimaryKeyAssignerand is not a QUEUE or RECNO database.RuntimeExceptionWrapper- if a checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
addAll
Inserts all of the elements in the specified collection into this list at the specified position (optional operation). This method conforms to theList.addAll(int, Collection)interface.- Specified by:
addAllin interfaceList<E>- 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 checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
contains
Returns true if this list contains the specified element. This method conforms to theList.contains(java.lang.Object)interface.- Specified by:
containsin interfaceCollection<E>- Specified by:
containsin interfaceList<E>- Throws:
RuntimeExceptionWrapper- if a checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
get
Returns the element at the specified position in this list. This method conforms to theList.get(int)interface.- Specified by:
getin interfaceList<E>- Throws:
RuntimeExceptionWrapper- if a checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
indexOf
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 theList.indexOf(java.lang.Object)interface.- Specified by:
indexOfin interfaceList<E>- Throws:
RuntimeExceptionWrapper- if a checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
lastIndexOf
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 theList.lastIndexOf(java.lang.Object)interface.- Specified by:
lastIndexOfin interfaceList<E>- Throws:
RuntimeExceptionWrapper- if a checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
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 theList.listIterator()interface.For information on cursor stability and iterator block size, see
StoredCollection.iterator().- Specified by:
listIteratorin interfaceList<E>- Returns:
- a
ListIteratorfor this collection. - Throws:
RuntimeExceptionWrapper- if a checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).- See Also:
-
listIterator
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 theList.listIterator(int)interface.For information on cursor stability and iterator block size, see
StoredCollection.iterator().- Specified by:
listIteratorin interfaceList<E>- Returns:
- a
ListIteratorfor this collection. - Throws:
RuntimeExceptionWrapper- if a checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).- See Also:
-
remove
Removes the element at the specified position in this list (optional operation). This method conforms to theList.remove(int)interface.- Specified by:
removein interfaceList<E>- Throws:
UnsupportedOperationException- if the collection is a sublist, or if the collection is read-only.RuntimeExceptionWrapper- if a checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
remove
Removes the first occurrence in this list of the specified element (optional operation). This method conforms to theList.remove(Object)interface.- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceList<E>- Throws:
UnsupportedOperationException- if the collection is a sublist, or if the collection is read-only.RuntimeExceptionWrapper- if a checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
set
Replaces the element at the specified position in this list with the specified element (optional operation). This method conforms to theList.set(int, E)interface.- Specified by:
setin interfaceList<E>- 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 checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
subList
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 theList.subList(int, int)interface.- Specified by:
subListin interfaceList<E>- Throws:
RuntimeExceptionWrapper- if a checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
equals
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 theList.equals(java.lang.Object)interface.- Specified by:
equalsin interfaceCollection<E>- Specified by:
equalsin interfaceList<E>- Overrides:
equalsin classStoredCollection<E>- Throws:
RuntimeExceptionWrapper- if a checked exception is thrown, including aDatabaseExceptionon BDB (C Edition).
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<E>- Specified by:
hashCodein interfaceList<E>- Overrides:
hashCodein classStoredCollection<E>
-