/*
 *  ----------------------------------------------------------------------------
 *  This file was automatically generated by SWIG (http://www.swig.org).
 *  Version: 1.3.19
 *
 *  Do not make changes to this file unless you know what you are doing--modify
 *  the SWIG interface file instead.
 *  -----------------------------------------------------------------------------
 */
package com.sleepycat.db;

/**
 *  The DbLsn object is a <b>log sequence number</b> which specifies a
 *  unique location in a log file. A DbLsn consists of two unsigned
 *  32-bit integers -- one specifies the log file number, and the
 *  other specifies an offset in the log file.</p>
 */
public class DbLsn {
    private long swigCPtr;
    protected boolean swigCMemOwn;


    protected DbLsn(long cPtr, boolean cMemoryOwn) {
        swigCMemOwn = cMemoryOwn;
        swigCPtr = cPtr;
    }


    protected DbLsn() {
        this(0, false);
    }


    protected void finalize() {
        try {
            delete();
        } catch (Exception e) {
            System.err.println("Exception during finalization: " + e);
            e.printStackTrace(System.err);
        }
    }


    void delete() {
        if (swigCPtr != 0 && swigCMemOwn) {
            db_javaJNI.delete_DbLsn(swigCPtr);
            swigCMemOwn = false;
        }
        swigCPtr = 0;
    }


    protected static long getCPtr(DbLsn obj) {
        return (obj == null) ? 0 : obj.swigCPtr;
    }


    /**
     *  The DbLsn constructor constructs a DbLsn with the specified
     *  file and offset.</p>
     *
     * @param  file          the log file number.
     * @param  offset        the log file offset.
     * @throws  DbException  Signals that an exception of some sort
     *      has occurred.
     */
    public DbLsn(int file, int offset) throws DbException {
        this(db_javaJNI.new_DbLsn(file, offset), true);
    }


    /**
     * @deprecated    As of Berkeley DB 4.2, replaced by {@link
     *      #getFile()}
     */
    public int get_file() throws DbException {
        return getFile();
    }


    /**
     *  The DbLsn.getFile method returns the DbLsn object's file
     *  number.</p>
     *
     * @throws  DbException  Signals that an exception of some sort
     *      has occurred.
     * @return               The DbLsn.getFile method returns the
     *      DbLsn object's file number.</p>
     */
    public int getFile() throws DbException {
        return db_javaJNI.DbLsn_get_file(swigCPtr);
    }


    /**
     * @deprecated    As of Berkeley DB 4.2, replaced by {@link
     *      #getOffset()}
     */
    public int get_offset() throws DbException {
        return getOffset();
    }


    /**
     *  The DbLsn.getOffset method returns the DbLsn object's file
     *  number.</p>
     *
     * @throws  DbException  Signals that an exception of some sort
     *      has occurred.
     * @return               The DbLsn.getOffset method returns the
     *      DbLsn object's file number.</p>
     */
    public int getOffset() throws DbException {
        return db_javaJNI.DbLsn_get_offset(swigCPtr);
    }

}
