01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: SubIndexCursor.java,v 1.5.2.2 2008/01/07 15:14:18 cwl Exp $
07: */
08:
09: package com.sleepycat.persist;
10:
11: import com.sleepycat.je.DatabaseException;
12: import com.sleepycat.je.LockMode;
13: import 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: */
23: class SubIndexCursor<V> extends BasicCursor<V> {
24:
25: SubIndexCursor(RangeCursor cursor, ValueAdapter<V> adapter) {
26: super (cursor, adapter);
27: }
28:
29: public EntityCursor<V> dup() throws DatabaseException {
30:
31: return new SubIndexCursor<V>(cursor.dup(true), adapter);
32: }
33:
34: public V nextDup(LockMode lockMode) throws DatabaseException {
35:
36: checkInitialized();
37: return null;
38: }
39:
40: public V nextNoDup(LockMode lockMode) throws DatabaseException {
41:
42: return returnValue(cursor.getNext(key, pkey, data, lockMode));
43: }
44:
45: public V prevDup(LockMode lockMode) throws DatabaseException {
46:
47: checkInitialized();
48: return null;
49: }
50:
51: public V prevNoDup(LockMode lockMode) throws DatabaseException {
52:
53: return returnValue(cursor.getPrev(key, pkey, data, lockMode));
54: }
55: }
|