1 8 9 package com.sleepycat.collections; 10 11 import java.util.Set ; 12 13 import com.sleepycat.bind.EntryBinding; 14 import com.sleepycat.je.Database; 15 import com.sleepycat.je.DatabaseEntry; 16 import com.sleepycat.je.DatabaseException; 17 import com.sleepycat.je.OperationStatus; 18 19 29 public class StoredKeySet extends StoredCollection implements Set { 30 31 48 public StoredKeySet(Database database, EntryBinding keyBinding, 49 boolean writeAllowed) { 50 51 super(new DataView(database, keyBinding, null, null, 52 writeAllowed, null)); 53 } 54 55 StoredKeySet(DataView keySetView) { 56 57 super(keySetView); 58 } 59 60 73 public boolean add(Object key) { 74 75 DataCursor cursor = null; 76 boolean doAutoCommit = beginAutoCommit(); 77 try { 78 cursor = new DataCursor(view, true); 79 OperationStatus status = cursor.putNoOverwrite(key, null, false); 80 closeCursor(cursor); 81 commitAutoCommit(doAutoCommit); 82 return (status == OperationStatus.SUCCESS); 83 } catch (Exception e) { 84 closeCursor(cursor); 85 throw handleException(e, doAutoCommit); 86 } 87 } 88 89 101 public boolean remove(Object key) { 102 103 return removeKey(key, null); 104 } 105 106 113 public boolean contains(Object key) { 114 115 return containsKey(key); 116 } 117 118 boolean hasValues() { 119 120 return false; 121 } 122 123 Object makeIteratorData(BaseIterator iterator, 124 DatabaseEntry keyEntry, 125 DatabaseEntry priKeyEntry, 126 DatabaseEntry valueEntry) { 127 128 return view.makeKey(keyEntry, priKeyEntry); 129 } 130 131 boolean iterateDuplicates() { 132 133 return false; 134 } 135 } 136 | Popular Tags |