KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > persist > SubIndexCursor


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: SubIndexCursor.java,v 1.5 2006/10/30 21:14:30 bostic Exp $
7  */

8
9 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()
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
Popular Tags