01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: TestKeyAssigner.java,v 1.20.2.2 2008/01/07 15:14:24 cwl Exp $
07: */
08:
09: package com.sleepycat.collections.test;
10:
11: import com.sleepycat.bind.RecordNumberBinding;
12: import com.sleepycat.collections.PrimaryKeyAssigner;
13: import com.sleepycat.je.DatabaseEntry;
14: import com.sleepycat.je.DatabaseException;
15:
16: /**
17: * @author Mark Hayes
18: */
19: class TestKeyAssigner implements PrimaryKeyAssigner {
20:
21: private byte next = 1;
22: private boolean isRecNum;
23:
24: TestKeyAssigner(boolean isRecNum) {
25:
26: this .isRecNum = isRecNum;
27: }
28:
29: public void assignKey(DatabaseEntry keyData)
30: throws DatabaseException {
31:
32: if (isRecNum) {
33: RecordNumberBinding.recordNumberToEntry(next, keyData);
34: } else {
35: keyData.setData(new byte[] { next }, 0, 1);
36: }
37: next += 1;
38: }
39:
40: void reset() {
41:
42: next = 1;
43: }
44: }
|