Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

TestKeyAssigner.java

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2002-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: TestKeyAssigner.java,v 12.1 2005/01/31 19:27:35 mark Exp $
00008  */
00009 
00010 package com.sleepycat.collections.test;
00011 
00012 import com.sleepycat.bind.RecordNumberBinding;
00013 import com.sleepycat.collections.PrimaryKeyAssigner;
00014 import com.sleepycat.db.DatabaseEntry;
00015 import com.sleepycat.db.DatabaseException;
00016 
00020 class TestKeyAssigner implements PrimaryKeyAssigner {
00021 
00022     private byte next = 1;
00023     private boolean isRecNum;
00024 
00025     TestKeyAssigner(boolean isRecNum) {
00026 
00027         this.isRecNum = isRecNum;
00028     }
00029 
00030     public void assignKey(DatabaseEntry keyData)
00031         throws DatabaseException {
00032 
00033         if (isRecNum) {
00034             RecordNumberBinding.recordNumberToEntry(next, keyData);
00035         } else {
00036             keyData.setData(new byte[] { next }, 0, 1);
00037         }
00038         next += 1;
00039     }
00040 
00041     void reset() {
00042 
00043         next = 1;
00044     }
00045 }

Generated on Sun Dec 25 12:14:56 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2