Berkeley DB Java Edition
version 1.5.1

com.sleepycat.collections
Class StoredValueSet

java.lang.Object
  |
  +--com.sleepycat.collections.StoredContainer
        |
        +--com.sleepycat.collections.StoredCollection
              |
              +--com.sleepycat.collections.StoredValueSet
All Implemented Interfaces:
Cloneable, Collection, Set
Direct Known Subclasses:
StoredSortedValueSet

public class StoredValueSet
extends StoredCollection
implements Set

The Set returned by Map.values() and Map.duplicates(), and which can also be constructed directly if a Map is not needed. Although this collection is a set it may contain duplicate values. Only if an entity value binding is used are all elements guaranteed to be unique.

Note that this class does not conform to the standard Java collections interface in the following ways:

Author:
Mark Hayes

Constructor Summary
StoredValueSet(Database database, EntityBinding valueEntityBinding, boolean writeAllowed)
          Creates a value set entity view of a Database.
StoredValueSet(Database database, EntryBinding valueBinding, boolean writeAllowed)
          Creates a value set view of a Database.
 
Method Summary
 boolean add(Object entity)
          Adds the specified entity to this set if it is not already present (optional operation).
 boolean contains(Object value)
          Returns true if this set contains the specified element.
 boolean remove(Object value)
          Removes the specified value from this set if it is present (optional operation).
 int size()
          Always throws UnsupportedOperationException.
 
Methods inherited from class com.sleepycat.collections.StoredCollection
addAll, containsAll, equals, iterator, iterator, join, removeAll, retainAll, toArray, toArray, toList, toString
 
Methods inherited from class com.sleepycat.collections.StoredContainer
areDuplicatesAllowed, areDuplicatesOrdered, areKeysRenumbered, clear, isDirtyRead, isDirtyReadAllowed, isEmpty, isOrdered, isSecondary, isTransactional, isWriteAllowed
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, clear, containsAll, equals, hashCode, isEmpty, iterator, removeAll, retainAll, toArray, toArray
 

Constructor Detail

StoredValueSet

public StoredValueSet(Database database,
                      EntryBinding valueBinding,
                      boolean writeAllowed)
Creates a value set view of a Database.

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 DatabaseException is thrown.

StoredValueSet

public StoredValueSet(Database database,
                      EntityBinding valueEntityBinding,
                      boolean writeAllowed)
Creates a value set entity view of a Database.

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 DatabaseException is thrown.
Method Detail

add

public boolean add(Object entity)
Adds the specified entity to this set if it is not already present (optional operation). This method conforms to the Set.add(java.lang.Object) interface.

Specified by:
add in interface Set
Parameters:
entity - is the entity to be added.
Returns:
true if the entity was added, that is the key-value pair represented by the entity was not previously present in the collection.
Throws:
UnsupportedOperationException - if the collection is read-only, if the collection is indexed, or if an entity binding is not used.
RuntimeExceptionWrapper - if a DatabaseException is thrown.

contains

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

Specified by:
contains in interface Set
Parameters:
value - the value to check.
Returns:
whether the set contains the given value.

remove

public boolean remove(Object value)
Removes the specified value from this set if it is present (optional operation). If an entity binding is used, the key-value pair represented by the given entity is removed. If an entity binding is used, the first occurrence of a key-value pair with the given value is removed. This method conforms to the Set.remove(java.lang.Object) interface.

Specified by:
remove in interface Set
Throws:
UnsupportedOperationException - if the collection is read-only.
RuntimeExceptionWrapper - if a DatabaseException is thrown.

size

public int size()
Description copied from class: StoredContainer
Always throws UnsupportedOperationException. The size of a database cannot be obtained reliably or inexpensively. This method therefore violates the Collection.size() and Map.size() interfaces.

Specified by:
size in interface Set
Overrides:
size in class StoredContainer
Returns:
always throws an exception.

Berkeley DB Java Edition
version 1.5.1

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