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

Sequence.java

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2001-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: Sequence.java,v 12.1 2005/06/16 20:23:03 bostic Exp $
00008  */
00009 
00010 package com.sleepycat.db;
00011 
00012 import com.sleepycat.db.internal.DbConstants;
00013 import com.sleepycat.db.internal.DbSequence;
00014 
00015 public class Sequence {
00016     private DbSequence seq;
00017     private int autoCommitFlag;
00018 
00019     /* package */
00020     Sequence(final DbSequence seq, SequenceConfig config)
00021         throws DatabaseException {
00022 
00023         this.seq = seq;
00024         seq.wrapper = this;
00025         if (seq.get_db().get_transactional())
00026                 this.autoCommitFlag = DbConstants.DB_AUTO_COMMIT |
00027                     (SequenceConfig.checkNull(config).getAutoCommitNoSync() ?
00028                     DbConstants.DB_TXN_NOSYNC : 0);
00029     }
00030 
00031     public void close()
00032         throws DatabaseException {
00033 
00034         seq.close(0);
00035     }
00036 
00037     public long get(Transaction txn, int delta)
00038         throws DatabaseException {
00039 
00040         return seq.get((txn == null) ? null : txn.txn, delta,
00041             (txn == null) ? autoCommitFlag : 0);
00042     }
00043 
00044     public Database getDatabase()
00045         throws DatabaseException {
00046 
00047         return seq.get_db().wrapper;
00048     }
00049 
00050     public DatabaseEntry getKey()
00051         throws DatabaseException {
00052 
00053         DatabaseEntry key = new DatabaseEntry();
00054         seq.get_key(key);
00055         return key;
00056     }
00057 
00058     public SequenceStats getStats(StatsConfig config)
00059         throws DatabaseException {
00060 
00061         return seq.stat(config.getFlags());
00062     }
00063 }

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