Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

StoredKeySet.java

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2000-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: StoredKeySet.java,v 12.1 2005/01/31 19:27:32 mark Exp $
00008  */
00009 
00010 package com.sleepycat.collections;
00011 
00012 import java.util.Set;
00013 
00014 import com.sleepycat.bind.EntryBinding;
00015 import com.sleepycat.db.Database;
00016 import com.sleepycat.db.DatabaseException;
00017 import com.sleepycat.db.OperationStatus;
00018 
00040 public class StoredKeySet extends StoredCollection implements Set {
00041 
00059     public StoredKeySet(Database database, EntryBinding keyBinding,
00060                         boolean writeAllowed) {
00061 
00062         super(new DataView(database, keyBinding, null, null,
00063                            writeAllowed, null));
00064     }
00065 
00066     StoredKeySet(DataView keySetView) {
00067 
00068         super(keySetView);
00069     }
00070 
00084     public boolean add(Object key) {
00085 
00086         DataCursor cursor = null;
00087         boolean doAutoCommit = beginAutoCommit();
00088         try {
00089             cursor = new DataCursor(view, true);
00090             OperationStatus status = cursor.putNoOverwrite(key, null, false);
00091             closeCursor(cursor);
00092             commitAutoCommit(doAutoCommit);
00093             return (status == OperationStatus.SUCCESS);
00094         } catch (Exception e) {
00095             closeCursor(cursor);
00096             throw handleException(e, doAutoCommit);
00097         }
00098     }
00099 
00112     public boolean remove(Object key) {
00113 
00114         return removeKey(key, null);
00115     }
00116 
00124     public boolean contains(Object key) {
00125 
00126         return containsKey(key);
00127     }
00128 
00129     boolean hasValues() {
00130 
00131         return false;
00132     }
00133 
00134     Object makeIteratorData(StoredIterator iterator, DataCursor cursor)
00135         throws DatabaseException {
00136 
00137         return cursor.getCurrentKey();
00138     }
00139 
00140     boolean iterateDuplicates() {
00141 
00142         return false;
00143     }
00144 }

Generated on Sun Dec 25 12:14:31 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2