com.sleepycat.collections
public class StoredMap extends StoredContainer implements Map
In addition to the standard Map methods, this class provides the following methods for stored maps only. Note that the use of these methods is not compatible with the standard Java collections interface.
Constructor Summary | |
---|---|
StoredMap(Database database, EntryBinding keyBinding, EntryBinding valueBinding, boolean writeAllowed)
Creates a map view of a Database.
| |
StoredMap(Database database, EntryBinding keyBinding, EntryBinding valueBinding, PrimaryKeyAssigner keyAssigner)
Creates a map view of a Database with a PrimaryKeyAssigner. | |
StoredMap(Database database, EntryBinding keyBinding, EntityBinding valueEntityBinding, boolean writeAllowed)
Creates a map entity view of a Database.
| |
StoredMap(Database database, EntryBinding keyBinding, EntityBinding valueEntityBinding, PrimaryKeyAssigner keyAssigner)
Creates a map entity view of a Database with a PrimaryKeyAssigner. |
Method Summary | |
---|---|
Object | append(Object value)
Appends a given value returning the newly assigned key. |
boolean | containsKey(Object key)
Returns true if this map contains the specified key. |
boolean | containsValue(Object value)
Returns true if this map contains the specified value. |
Collection | duplicates(Object key)
Returns a new collection containing the values mapped to the given key
in this map. |
Map | duplicatesMap(Object secondaryKey, EntryBinding primaryKeyBinding)
Returns a new map from primary key to value for the subset of records
having a given secondary key (duplicates). |
Set | entrySet()
Returns a set view of the mappings contained in this map. |
boolean | equals(Object other)
Compares the specified object with this map for equality. |
Object | get(Object key)
Returns the value to which this map maps the specified key. |
int | hashCode() |
Set | keySet()
Returns a set view of the keys contained in this map. |
Object | put(Object key, Object value)
Associates the specified value with the specified key in this map
(optional operation). |
void | putAll(Map map)
Copies all of the mappings from the specified map to this map (optional
operation). |
Object | remove(Object key)
Removes the mapping for this key from this map if present (optional
operation). |
int | size() |
String | toString()
Converts the map to a string representation for debugging. |
Collection | values()
Returns a collection view of the values contained in this map. |
Parameters: database is the Database underlying the new collection. keyBinding is the binding used to translate between key buffers and key objects. 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 DatabaseException is thrown.
Parameters: database is the Database underlying the new collection. keyBinding is the binding used to translate between key buffers and key objects. valueBinding is the binding used to translate between value buffers and value objects. keyAssigner is used by the StoredMap method to assign primary keys.
Throws: IllegalArgumentException if formats are not consistently defined or a parameter is invalid. RuntimeExceptionWrapper if a DatabaseException is thrown.
Parameters: database is the Database underlying the new collection. keyBinding is the binding used to translate between key buffers and key objects. 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 DatabaseException is thrown.
Parameters: database is the Database underlying the new collection. keyBinding is the binding used to translate between key buffers and key objects. valueEntityBinding is the binding used to translate between key/value buffers and entity value objects. keyAssigner is used by the StoredMap method to assign primary keys.
Throws: IllegalArgumentException if formats are not consistently defined or a parameter is invalid. RuntimeExceptionWrapper if a DatabaseException is thrown.
Note that for the JE product, QUEUE and RECNO databases are not supported, and therefore a PrimaryKeyAssigner must be associated with the map in order to call this method.
Parameters: value the value to be appended.
Returns: the assigned key.
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 DatabaseException is thrown.
Throws: RuntimeExceptionWrapper if a DatabaseException is thrown.
Throws: RuntimeExceptionWrapper if a DatabaseException is thrown.
If no mapping for the given key is present, an empty collection is returned. If duplicates are not allowed, at most a single value will be in the collection returned. If duplicates are allowed, the returned collection's add() method may be used to add values for the given key.
Parameters: key is the key for which values are to be returned.
Throws: RuntimeExceptionWrapper if a DatabaseException is thrown.
If no mapping for the given key is present, an empty collection is returned. If duplicates are not allowed, at most a single value will be in the collection returned. If duplicates are allowed, the returned collection's add() method may be used to add values for the given key.
Parameters: secondaryKey is the secondary key for which duplicates values will be represented by the returned map. primaryKeyBinding is the binding used for keys in the returned map.
Throws: RuntimeExceptionWrapper if a DatabaseException is thrown.
Note that the return value is a StoredCollection and must be treated as such; for example, its iterators must be explicitly closed.
Returns: a StoredEntrySet or a StoredSortedEntrySet for this map.
Throws: RuntimeExceptionWrapper if a DatabaseException is thrown.
Throws: RuntimeExceptionWrapper if a DatabaseException is thrown.
Throws: RuntimeExceptionWrapper if a DatabaseException is thrown.
Note that the return value is a StoredCollection and must be treated as such; for example, its iterators must be explicitly closed.
Returns: a StoredKeySet or a StoredSortedKeySet for this map.
Throws: RuntimeExceptionWrapper if a DatabaseException is thrown.
The key parameter may be null if an entity binding is used and the key will be derived from the value (entity) parameter. If an entity binding is used and the key parameter is non-null, then the key parameter must be equal to the key derived from the value parameter.
Returns: the previous value associated with specified key, or null if there was no mapping for the key or if duplicates are allowed.
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 DatabaseException is thrown.
Throws: UnsupportedOperationException if the collection is read-only, or if the collection is indexed. RuntimeExceptionWrapper if a DatabaseException is thrown.
Throws: UnsupportedOperationException if the collection is read-only. RuntimeExceptionWrapper if a DatabaseException is thrown.
Returns: the string representation.
Throws: RuntimeExceptionWrapper if a DatabaseException is thrown.
Note that the return value is a StoredCollection and must be treated as such; for example, its iterators must be explicitly closed.
Returns: a StoredValueSet or a StoredSortedValueSet for this map.
Throws: RuntimeExceptionWrapper if a DatabaseException is thrown.