java.lang.Cloneable
, java.lang.Iterable<E>
, java.util.Collection<E>
StoredEntrySet
, StoredKeySet
, StoredList
, StoredValueSet
public abstract class StoredCollection<E> extends StoredContainer implements java.util.Collection<E>
StoredContainer
, provide implementations of most methods
in the Collection
interface. Other methods, such as add(java.lang.Object, java.lang.Object)
and Collection.remove(java.lang.Object)
, are provided by concrete classes that extend this
class.
In addition, this class provides the following methods for stored collections only. Note that the use of these methods is not compatible with the standard Java collections interface.
Modifier and Type | Field | Description |
---|---|---|
static int |
DEFAULT_ITERATOR_BLOCK_SIZE |
The default number of records read at one time by iterators.
|
Modifier and Type | Method | Description |
---|---|---|
boolean |
addAll(java.util.Collection<? extends E> coll) |
Adds all of the elements in the specified collection to this collection
(optional operation).
|
boolean |
containsAll(java.util.Collection<?> coll) |
Returns true if this collection contains all of the elements in the
specified collection.
|
boolean |
equals(java.lang.Object other) |
Compares the specified object with this collection for equality.
|
int |
getIteratorBlockSize() |
Returns the number of records read at one time by iterators returned by
the
iterator() method. |
int |
hashCode() |
|
java.util.Iterator<E> |
iterator() |
Returns an iterator over the elements in this collection.
|
StoredIterator<E> |
iterator(boolean writeAllowed) |
Deprecated.
Please use
storedIterator() or storedIterator(boolean) instead. |
StoredIterator<E> |
join(StoredContainer[] indices,
java.lang.Object[] indexKeys,
JoinConfig joinConfig) |
Returns an iterator representing an equality join of the indices and
index key values specified.
|
boolean |
removeAll(java.util.Collection<?> coll) |
Removes all this collection's elements that are also contained in the
specified collection (optional operation).
|
boolean |
retainAll(java.util.Collection<?> coll) |
Retains only the elements in this collection that are contained in the
specified collection (optional operation).
|
void |
setIteratorBlockSize(int blockSize) |
Changes the number of records read at one time by iterators returned by
the
iterator() method. |
int |
size() |
Returns a non-transactional count of the records in the collection or
map.
|
StoredIterator<E> |
storedIterator() |
Returns an iterator over the elements in this collection.
|
StoredIterator<E> |
storedIterator(boolean writeAllowed) |
Returns a read or read-write iterator over the elements in this
collection.
|
java.lang.Object[] |
toArray() |
Returns an array of all the elements in this collection.
|
<T> T[] |
toArray(T[] a) |
Returns an array of all the elements in this collection whose runtime
type is that of the specified array.
|
java.util.List<E> |
toList() |
Returns a copy of this collection as an ArrayList.
|
java.lang.String |
toString() |
Converts the collection to a string representation for debugging.
|
areDuplicatesAllowed, areDuplicatesOrdered, areKeyRangesAllowed, areKeysRenumbered, clear, getCursorConfig, isEmpty, isOrdered, isSecondary, isTransactional, isWriteAllowed
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
public static final int DEFAULT_ITERATOR_BLOCK_SIZE
setIteratorBlockSize(int)
,
Constant Field Valuespublic int getIteratorBlockSize()
iterator()
method. By default this value is DEFAULT_ITERATOR_BLOCK_SIZE
.public void setIteratorBlockSize(int blockSize)
iterator()
method. By default this value is DEFAULT_ITERATOR_BLOCK_SIZE
.blockSize
- the number of records.java.lang.IllegalArgumentException
- if the blockSize is less than two.public java.util.Iterator<E> iterator()
Collection.iterator()
interface.
The iterator returned by this method does not keep a database cursor
open and therefore it does not need to be closed. It reads blocks of
records as needed, opening and closing a cursor to read each block of
records. The number of records per block is 10 by default and can be
changed with setIteratorBlockSize(int)
.
Because this iterator does not keep a cursor open, if it is used
without transactions, the iterator does not have cursor
stability characteristics. In other words, the record at the
current iterator position can be changed or deleted by another thread.
To prevent this from happening, call this method within a transaction or
use the storedIterator()
method instead.
iterator
in interface java.util.Collection<E>
iterator
in interface java.lang.Iterable<E>
Iterator
for this collection.StoredContainer.isWriteAllowed()
public StoredIterator<E> storedIterator()
Collection
interface.
If Iterator.set
or Iterator.remove
will be called
and the underlying Database is transactional, then a transaction must be
active when calling this method and must remain active while using the
iterator.
Warning: The iterator returned must be explicitly
closed using StoredIterator.close()
or StoredIterator.close(java.util.Iterator)
to release the underlying
database cursor resources.
StoredIterator
for this collection.StoredContainer.isWriteAllowed()
public StoredIterator<E> storedIterator(boolean writeAllowed)
Collection
interface.
If Iterator.set
or Iterator.remove
will be called
and the underlying Database is transactional, then a transaction must be
active when calling this method and must remain active while using the
iterator.
Warning: The iterator returned must be explicitly
closed using StoredIterator.close()
or StoredIterator.close(java.util.Iterator)
to release the underlying
database cursor resources.
writeAllowed
- is true to open a read-write iterator or false to
open a read-only iterator. If the collection is read-only the iterator
will always be read-only.StoredIterator
for this collection.java.lang.IllegalStateException
- if writeAllowed is true but the collection
is read-only.RuntimeExceptionWrapper
- if a checked exception is thrown,
including a DatabaseException
on BDB (C Edition).StoredContainer.isWriteAllowed()
@Deprecated public StoredIterator<E> iterator(boolean writeAllowed)
storedIterator()
or storedIterator(boolean)
instead. Because the iterator returned must
be closed, the method name iterator
is confusing since standard
Java iterators do not need to be closed.writeAllowed
- is true to open a read-write iterator or false to
open a read-only iterator. If the collection is read-only the iterator
will always be read-only.StoredIterator
for this collection.public java.lang.Object[] toArray()
Collection.toArray()
interface.toArray
in interface java.util.Collection<E>
RuntimeExceptionWrapper
- if a checked exception is thrown,
including a DatabaseException
on BDB (C Edition).public <T> T[] toArray(T[] a)
Collection.toArray(Object[])
interface.toArray
in interface java.util.Collection<E>
RuntimeExceptionWrapper
- if a checked exception is thrown,
including a DatabaseException
on BDB (C Edition).public boolean containsAll(java.util.Collection<?> coll)
Collection.containsAll(java.util.Collection<?>)
interface.containsAll
in interface java.util.Collection<E>
RuntimeExceptionWrapper
- if a checked exception is thrown,
including a DatabaseException
on BDB (C Edition).public boolean addAll(java.util.Collection<? extends E> coll)
Collection.add(Object)
method of the concrete
collection class, which may or may not be supported.
This method conforms to the Collection.addAll(java.util.Collection<? extends E>)
interface.addAll
in interface java.util.Collection<E>
java.lang.UnsupportedOperationException
- if the collection is read-only, or
if the collection is indexed, or if the add method is not supported by
the concrete collection.RuntimeExceptionWrapper
- if a checked exception is thrown,
including a DatabaseException
on BDB (C Edition).public boolean removeAll(java.util.Collection<?> coll)
Collection.removeAll(java.util.Collection<?>)
interface.removeAll
in interface java.util.Collection<E>
java.lang.UnsupportedOperationException
- if the collection is read-only.RuntimeExceptionWrapper
- if a checked exception is thrown,
including a DatabaseException
on BDB (C Edition).public boolean retainAll(java.util.Collection<?> coll)
Collection.removeAll(java.util.Collection<?>)
interface.retainAll
in interface java.util.Collection<E>
java.lang.UnsupportedOperationException
- if the collection is read-only.RuntimeExceptionWrapper
- if a checked exception is thrown,
including a DatabaseException
on BDB (C Edition).public boolean equals(java.lang.Object other)
Collection.equals(java.lang.Object)
interface.equals
in interface java.util.Collection<E>
equals
in class java.lang.Object
RuntimeExceptionWrapper
- if a checked exception is thrown,
including a DatabaseException
on BDB (C Edition).public int hashCode()
hashCode
in interface java.util.Collection<E>
hashCode
in class java.lang.Object
public java.util.List<E> toList()
toArray()
but returns a collection instead of an array.ArrayList
containing a copy of all elements in this
collection.RuntimeExceptionWrapper
- if a checked exception is thrown,
including a DatabaseException
on BDB (C Edition).public java.lang.String toString()
toString
in class java.lang.Object
RuntimeExceptionWrapper
- if a checked exception is thrown,
including a DatabaseException
on BDB (C Edition).public int size()
StoredContainer
Collection.size()
and
Map.size()
interfaces.size
in interface java.util.Collection<E>
size
in class StoredContainer
public StoredIterator<E> join(StoredContainer[] indices, java.lang.Object[] indexKeys, JoinConfig joinConfig)
Collection
interface.
Warning: The iterator returned must be explicitly
closed using StoredIterator.close()
or StoredIterator.close(java.util.Iterator)
to release the underlying
database cursor resources.
The returned iterator supports only the two methods: hasNext() and next(). All other methods will throw UnsupportedOperationException.
indices
- is an array of indices with elements corresponding to
those in the indexKeys array.indexKeys
- is an array of index key values identifying the
elements to be selected.joinConfig
- is the join configuration, or null to use the
default configuration.java.lang.IllegalArgumentException
- if this collection is indexed or if a
given index does not have the same store as this collection.RuntimeExceptionWrapper
- if a checked exception is thrown,
including a DatabaseException
on BDB (C Edition).Copyright (c) 1996, 2020 Oracle and/or its affiliates. All rights reserved.