org.opends.server.replication.common
Class ChangeNumber

java.lang.Object
  extended by org.opends.server.replication.common.ChangeNumber
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<ChangeNumber>

public class ChangeNumber
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable<ChangeNumber>

Class used to represent Change Numbers.

See Also:
Serialized Form

Constructor Summary
ChangeNumber(long time, int seq, short id)
          Create a new ChangeNumber.
ChangeNumber(java.lang.String str)
          Create a new ChangeNumber from a String.
 
Method Summary
static int compare(ChangeNumber CN1, ChangeNumber CN2)
          Compares 2 ChangeNumber.
 int compareTo(ChangeNumber cn)
          Compares this object with the specified object for order.
static int diffSeqNum(ChangeNumber op1, ChangeNumber op2)
          Computes the difference in number of changes between 2 change numbers.
 boolean equals(java.lang.Object obj)
          
 int getSeqnum()
          Getter for the sequence number.
 short getServerId()
          Getter for the server ID.
 long getTime()
          Getter for the time.
 long getTimeSec()
          Get the timestamp associated to this ChangeNumber in seconds.
 int hashCode()
          
 boolean newer(ChangeNumber CN)
          Check if the current Object is strictly newer than ChangeNumber.
 boolean newerOrEquals(ChangeNumber CN)
          Check if the current Object is newer than ChangeNumber.
 java.lang.Boolean older(ChangeNumber CN)
          check if the current Object is strictly older than ChangeNumber given in parameter.
 java.lang.Boolean olderOrEqual(ChangeNumber CN)
          check if the current Object is older than ChangeNumber given in parameter.
 java.lang.String toString()
          Convert the ChangeNumber to a printable String.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChangeNumber

public ChangeNumber(java.lang.String str)
Create a new ChangeNumber from a String.

Parameters:
str - the string from which to create a ChangeNumber

ChangeNumber

public ChangeNumber(long time,
                    int seq,
                    short id)
Create a new ChangeNumber.

Parameters:
time - time for the ChangeNumber
seq - sequence number
id - identity of server
Method Detail

getTime

public long getTime()
Getter for the time.

Returns:
the time

getTimeSec

public long getTimeSec()
Get the timestamp associated to this ChangeNumber in seconds.

Returns:
timestamp associated to this ChangeNumber in seconds

getSeqnum

public int getSeqnum()
Getter for the sequence number.

Returns:
the sequence number

getServerId

public short getServerId()
Getter for the server ID.

Returns:
the server ID

equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Convert the ChangeNumber to a printable String.

Overrides:
toString in class java.lang.Object
Returns:
the string

compare

public static int compare(ChangeNumber CN1,
                          ChangeNumber CN2)
Compares 2 ChangeNumber.

Parameters:
CN1 - the first ChangeNumber to compare
CN2 - the second ChangeNumber to compare
Returns:
value 0 if changeNumber matches, negative if first changeNumber is smaller, positive otherwise

diffSeqNum

public static int diffSeqNum(ChangeNumber op1,
                             ChangeNumber op2)
Computes the difference in number of changes between 2 change numbers.

Parameters:
op1 - the first ChangeNumber
op2 - the second ChangeNumber
Returns:
the difference

older

public java.lang.Boolean older(ChangeNumber CN)
check if the current Object is strictly older than ChangeNumber given in parameter.

Parameters:
CN - the Changenumber to compare with
Returns:
true if strictly older, false if younger or same

olderOrEqual

public java.lang.Boolean olderOrEqual(ChangeNumber CN)
check if the current Object is older than ChangeNumber given in parameter.

Parameters:
CN - the Changenumber to compare with
Returns:
true if older or equal, false if younger

newerOrEquals

public boolean newerOrEquals(ChangeNumber CN)
Check if the current Object is newer than ChangeNumber.

Parameters:
CN - the Changenumber to compare with
Returns:
true if newer

newer

public boolean newer(ChangeNumber CN)
Check if the current Object is strictly newer than ChangeNumber.

Parameters:
CN - the Changenumber to compare with
Returns:
true if strictly newer

compareTo

public int compareTo(ChangeNumber cn)
Compares this object with the specified object for order.

Specified by:
compareTo in interface java.lang.Comparable<ChangeNumber>
Parameters:
cn - the ChangeNumber to compare with.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.