• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/db-4.8.30/java/src/com/sleepycat/db/
1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2001-2009 Oracle.  All rights reserved.
5 *
6 * $Id$
7 */
8
9package com.sleepycat.db;
10
11import com.sleepycat.db.internal.DbEnv;
12
13/**
14The LogSequenceNumber object is a <em>log sequence number</em> which
15specifies a unique location in a log file.  A LogSequenceNumber consists
16of two unsigned 32-bit integers -- one specifies the log file number,
17and the other specifies the offset in the log file.
18*/
19public class LogSequenceNumber {
20    private int file;
21    private int offset;
22
23    /**
24    Construct a LogSequenceNumber with the specified file and offset.
25    <p>
26    @param file
27    The log file number.
28    <p>
29    @param offset
30    The log file offset.
31    */
32    public LogSequenceNumber(final int file, final int offset) {
33        this.file = file;
34        this.offset = offset;
35    }
36
37    /**
38    Construct an uninitialized LogSequenceNumber.
39    */
40    public LogSequenceNumber() {
41        this(0, 0);
42    }
43
44    /**
45    Return the file number component of the LogSequenceNumber.
46    <p>
47    @return
48    The file number component of the LogSequenceNumber.
49    */
50    public int getFile() {
51        return file;
52    }
53
54    /**
55    Return the file offset component of the LogSequenceNumber.
56    <p>
57    @return
58    The file offset component of the LogSequenceNumber.
59    */
60    public int getOffset() {
61        return offset;
62    }
63
64    /**
65    Compare two LogSequenceNumber objects.
66    <p>
67    This method returns 0 if the two LogSequenceNumber objects are
68    equal, 1 if lsn0 is greater than lsn1, and -1 if lsn0 is less than
69    lsn1.
70    <p>
71    @param lsn1
72    The first LogSequenceNumber object to be compared.
73    <p>
74    @param lsn2
75    The second LogSequenceNumber object to be compared.
76    <p>
77    @return
78    0 if the two LogSequenceNumber objects are equal, 1 if lsn1 is
79    greater than lsn2, and -1 if lsn1 is less than lsn2.
80    */
81    public static int compare(LogSequenceNumber lsn1, LogSequenceNumber lsn2) {
82        return DbEnv.log_compare(lsn1, lsn2);
83    }
84}
85