1 8 9 package com.sleepycat.collections; 10 11 import java.util.Comparator ; 12 import java.util.SortedSet ; 13 14 import com.sleepycat.bind.EntityBinding; 15 import com.sleepycat.je.Database; 16 17 35 public class StoredSortedValueSet extends StoredValueSet implements SortedSet { 36 37 40 41 58 public StoredSortedValueSet(Database database, 59 EntityBinding valueEntityBinding, 60 boolean writeAllowed) { 61 62 super(new DataView(database, null, null, valueEntityBinding, 63 writeAllowed, null)); 64 checkKeyDerivation(); 65 } 66 67 StoredSortedValueSet(DataView valueSetView) { 68 69 super(valueSetView); 70 checkKeyDerivation(); 71 } 72 73 private void checkKeyDerivation() { 74 75 if (!view.canDeriveKeyFromValue()) { 76 throw new IllegalArgumentException ("Cannot derive key from value"); 77 } 78 } 79 80 89 public Comparator comparator() { 90 91 return null; 92 } 93 94 103 public Object first() { 104 105 return getFirstOrLast(true); 106 } 107 108 117 public Object last() { 118 119 return getFirstOrLast(false); 120 } 121 122 137 public SortedSet headSet(Object toValue) { 138 139 return subSet(null, false, toValue, false); 140 } 141 142 159 public SortedSet headSet(Object toValue, boolean toInclusive) { 160 161 return subSet(null, false, toValue, toInclusive); 162 } 163 164 179 public SortedSet tailSet(Object fromValue) { 180 181 return subSet(fromValue, true, null, false); 182 } 183 184 201 public SortedSet tailSet(Object fromValue, boolean fromInclusive) { 202 203 return subSet(fromValue, fromInclusive, null, false); 204 } 205 206 223 public SortedSet subSet(Object fromValue, Object toValue) { 224 225 return subSet(fromValue, true, toValue, false); 226 } 227 228 250 public SortedSet subSet(Object fromValue, boolean fromInclusive, 251 Object toValue, boolean toInclusive) { 252 253 try { 254 return new StoredSortedValueSet( 255 view.subView(fromValue, fromInclusive, toValue, toInclusive, 256 null)); 257 } catch (Exception e) { 258 throw StoredContainer.convertException(e); 259 } 260 } 261 } 262 | Popular Tags |