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

StoredSortedValueSet.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: StoredSortedValueSet.java,v 12.2 2005/10/05 20:40:10 mark Exp $
00008  */
00009 
00010 package com.sleepycat.collections;
00011 
00012 import java.util.Comparator;
00013 import java.util.SortedSet;
00014 
00015 import com.sleepycat.bind.EntityBinding;
00016 import com.sleepycat.db.Database;
00017 
00047 public class StoredSortedValueSet extends StoredValueSet implements SortedSet {
00048 
00049     /*
00050      * No valueBinding ctor is possible since key cannot be derived.
00051      */
00052 
00070     public StoredSortedValueSet(Database database,
00071                                 EntityBinding valueEntityBinding,
00072                                 boolean writeAllowed) {
00073 
00074         super(new DataView(database, null, null, valueEntityBinding,
00075                            writeAllowed, null));
00076         checkKeyDerivation();
00077     }
00078 
00079     StoredSortedValueSet(DataView valueSetView) {
00080 
00081         super(valueSetView);
00082         checkKeyDerivation();
00083     }
00084 
00085     private void checkKeyDerivation() {
00086 
00087         if (!view.canDeriveKeyFromValue()) {
00088             throw new IllegalArgumentException("Cannot derive key from value");
00089         }
00090     }
00091 
00101     public Comparator comparator() {
00102 
00103         return null;
00104     }
00105 
00115     public Object first() {
00116 
00117         return getFirstOrLast(true);
00118     }
00119 
00129     public Object last() {
00130 
00131         return getFirstOrLast(false);
00132     }
00133 
00149     public SortedSet headSet(Object toValue) {
00150 
00151         return subSet(null, false, toValue, false);
00152     }
00153 
00171     public SortedSet headSet(Object toValue, boolean toInclusive) {
00172 
00173         return subSet(null, false, toValue, toInclusive);
00174     }
00175 
00191     public SortedSet tailSet(Object fromValue) {
00192 
00193         return subSet(fromValue, true, null, false);
00194     }
00195 
00213     public SortedSet tailSet(Object fromValue, boolean fromInclusive) {
00214 
00215         return subSet(fromValue, fromInclusive, null, false);
00216     }
00217 
00235     public SortedSet subSet(Object fromValue, Object toValue) {
00236 
00237         return subSet(fromValue, true, toValue, false);
00238     }
00239 
00262     public SortedSet subSet(Object fromValue, boolean fromInclusive,
00263                             Object toValue, boolean toInclusive) {
00264 
00265         try {
00266             return new StoredSortedValueSet(
00267                view.subView(fromValue, fromInclusive, toValue, toInclusive,
00268                             null));
00269         } catch (Exception e) {
00270             throw StoredContainer.convertException(e);
00271         }
00272     }
00273 }

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