com.sleepycat.collections

Class StoredContainer

public abstract class StoredContainer extends Object implements Cloneable

A abstract base class for all stored collections and maps. This class provides implementations of methods that are common to the java.util.Collection and the java.util.Map interfaces, namely StoredContainer, StoredContainer and StoredContainer.

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.

Method Summary
booleanareDuplicatesAllowed()
Returns whether duplicate keys are allowed in this container.
booleanareDuplicatesOrdered()
Returns whether duplicate keys are allowed and sorted by element value.
booleanareKeysRenumbered()
Returns whether keys are renumbered when insertions and deletions occur.
voidclear()
Removes all mappings or elements from this map or collection (optional operation).
CursorConfiggetCursorConfig()
Returns the cursor configuration that is used for all operations performed via this container.
booleanisDirtyRead()
booleanisDirtyReadAllowed()
Returns whether read-uncommitted is allowed for this container.
booleanisEmpty()
Returns true if this map or collection contains no mappings or elements.
booleanisOrdered()
Returns whether keys are ordered in this container.
booleanisSecondary()
Returns whether this container is a view on a secondary database rather than directly on a primary database.
booleanisTransactional()
Returns whether the databases underlying this container are transactional.
booleanisWriteAllowed()
Returns true if this is a read-write container or false if this is a read-only container.
abstract intsize()
Returns the number of records in the collection or map.

Method Detail

areDuplicatesAllowed

public final boolean areDuplicatesAllowed()
Returns whether duplicate keys are allowed in this container. Duplicates are optionally allowed for HASH and BTREE databases. This method does not exist in the standard java.util.Map or java.util.Collection interfaces.

Note that the JE product only supports BTREE databases.

Returns: whether duplicates are allowed.

areDuplicatesOrdered

public final boolean areDuplicatesOrdered()
Returns whether duplicate keys are allowed and sorted by element value. Duplicates are optionally sorted for HASH and BTREE databases. This method does not exist in the standard java.util.Map or java.util.Collection interfaces.

Note that the JE product only supports BTREE databases, and duplicates are always sorted.

Returns: whether duplicates are ordered.

areKeysRenumbered

public final boolean areKeysRenumbered()
Returns whether keys are renumbered when insertions and deletions occur. Keys are optionally renumbered for RECNO databases. This method does not exist in the standard java.util.Map or java.util.Collection interfaces.

Note that the JE product does not support RECNO databases, and therefore keys are never renumbered.

Returns: whether keys are renumbered.

clear

public void clear()
Removes all mappings or elements from this map or collection (optional operation). This method conforms to the java.util.Collection#clear and java.util.Map#clear interfaces.

Throws: UnsupportedOperationException if the container is read-only. RuntimeExceptionWrapper if a DatabaseException is thrown.

getCursorConfig

public final CursorConfig getCursorConfig()
Returns the cursor configuration that is used for all operations performed via this container. For example, if CursorConfig.getReadUncommitted returns true, data will be read that is modified but not committed. This method does not exist in the standard java.util.Map or java.util.Collection interfaces.

Returns: the cursor configuration, or null if no configuration has been specified.

isDirtyRead

public final boolean isDirtyRead()

Deprecated: This method has been replaced by StoredContainer. CursorConfig.isReadUncommitted may be called to determine whether dirty-read is enabled.

isDirtyReadAllowed

public final boolean isDirtyReadAllowed()

Deprecated: This method is deprecated with no replacement in this class. In the DB product, DatabaseConfig.getReadUncommitted may be called.

Returns whether read-uncommitted is allowed for this container. For the JE product, read-uncommitted is always allowed; for the DB product, read-uncommitted is allowed if it was configured for the underlying database for this container. Even when read-uncommitted is allowed it must specifically be enabled by calling one of the StoredCollections methods. This method does not exist in the standard java.util.Map or java.util.Collection interfaces.

Returns: whether read-uncommitted is allowed.

isEmpty

public boolean isEmpty()
Returns true if this map or collection contains no mappings or elements. This method conforms to the java.util.Collection#isEmpty and java.util.Map#isEmpty interfaces.

Returns: whether the container is empty.

Throws: RuntimeExceptionWrapper if a DatabaseException is thrown.

isOrdered

public final boolean isOrdered()
Returns whether keys are ordered in this container. Keys are ordered for BTREE, RECNO and QUEUE database. This method does not exist in the standard java.util.Map or java.util.Collection interfaces.

Note that the JE product only support BTREE databases, and therefore keys are always ordered.

Returns: whether keys are ordered.

isSecondary

public final boolean isSecondary()
Returns whether this container is a view on a secondary database rather than directly on a primary database. This method does not exist in the standard java.util.Map or java.util.Collection interfaces.

Returns: whether the view is for a secondary database.

isTransactional

public final boolean isTransactional()
Returns whether the databases underlying this container are transactional. Even in a transactional environment, a database will be transactional only if it was opened within a transaction or if the auto-commit option was specified when it was opened. This method does not exist in the standard java.util.Map or java.util.Collection interfaces.

Returns: whether the database is transactional.

isWriteAllowed

public final boolean isWriteAllowed()
Returns true if this is a read-write container or false if this is a read-only container. This method does not exist in the standard java.util.Map or java.util.Collection interfaces.

Returns: whether write is allowed.

size

public abstract int size()
Returns the number of records in the collection or map. This method conforms to the java.util.Collection#size and java.util.Map#size interfaces.

Note that if other threads are adding or removing records while this method is executing, the size returned may be incorrect. This method does not lock the database.

Also note that, for a large database, this method may be expensive. All non-duplicate records in the database are enumerated by this method, bringing them into memory if they are not already cached.

Throws: RuntimeExceptionWrapper if a DatabaseException is thrown.