• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src/router/db-4.8.30/java/src/com/sleepycat/persist/
1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2002-2009 Oracle.  All rights reserved.
5 *
6 * $Id$
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    @Override
30    public EntityCursor<V> dup()
31        throws DatabaseException {
32
33        return new SubIndexCursor<V>(cursor.dup(true), adapter);
34    }
35
36    @Override
37    public V nextDup(LockMode lockMode) {
38        checkInitialized();
39        return null;
40    }
41
42    @Override
43    public V nextNoDup(LockMode lockMode)
44        throws DatabaseException {
45
46        return returnValue(cursor.getNext(key, pkey, data, lockMode));
47    }
48
49    @Override
50    public V prevDup(LockMode lockMode) {
51        checkInitialized();
52        return null;
53    }
54
55    @Override
56    public V prevNoDup(LockMode lockMode)
57        throws DatabaseException {
58
59        return returnValue(cursor.getPrev(key, pkey, data, lockMode));
60    }
61}
62