1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 2002,2008 Oracle. All rights reserved. 5 * 6 * $Id: SubIndexCursor.java,v 1.1 2008/02/07 17:12:26 mark Exp $ 7 */ 8 9package com.sleepycat.persist; 10 11import com.sleepycat.db.DatabaseException; 12import com.sleepycat.db.LockMode; 13import com.sleepycat.util.keyrange.RangeCursor; 14 15/** 16 * The cursor for a SubIndex treats Dup and NoDup operations specially because 17 * the SubIndex never has duplicates -- the keys are primary keys. So a 18 * next/prevDup operation always returns null, and a next/prevNoDup operation 19 * actually does next/prev. 20 * 21 * @author Mark Hayes 22 */ 23class SubIndexCursor<V> extends BasicCursor<V> { 24 25 SubIndexCursor(RangeCursor cursor, ValueAdapter<V> adapter) { 26 super(cursor, adapter, false/*updateAllowed*/); 27 } 28 29 public EntityCursor<V> dup() 30 throws DatabaseException { 31 32 return new SubIndexCursor<V>(cursor.dup(true), adapter); 33 } 34 35 public V nextDup(LockMode lockMode) 36 throws DatabaseException { 37 38 checkInitialized(); 39 return null; 40 } 41 42 public V nextNoDup(LockMode lockMode) 43 throws DatabaseException { 44 45 return returnValue(cursor.getNext(key, pkey, data, lockMode)); 46 } 47 48 public V prevDup(LockMode lockMode) 49 throws DatabaseException { 50 51 checkInitialized(); 52 return null; 53 } 54 55 public V prevNoDup(LockMode lockMode) 56 throws DatabaseException { 57 58 return returnValue(cursor.getPrev(key, pkey, data, lockMode)); 59 } 60} 61