org.apache.directory.mitosis.common
Class DefaultCSN

java.lang.Object
  extended by org.apache.directory.mitosis.common.DefaultCSN
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<CSN>, CSN

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

A default implementation of CSN.

Author:
Apache Directory Project
See Also:
Serialized Form

Constructor Summary
DefaultCSN(byte[] value)
          Creates a new instance of SimpleCSN from the serialized data
DefaultCSN(long timestamp, java.lang.String replicaId, int operationSequence)
          Creates a new instance.
DefaultCSN(java.lang.String value)
          Creates a new instance of SimpleCSN from a String.
 
Method Summary
 int compareTo(CSN csn)
          Compares this object with the specified object for order.
 boolean equals(java.lang.Object o)
          Indicates whether some other object is "equal to" this one
 int getOperationSequence()
          Returns sequence number of modification.
 java.lang.String getReplicaId()
          Returns replica ID.
 long getTimestamp()
          Returns GMT timestamp of modification.
 int hashCode()
          Returns a hash code value for the object.
 byte[] toBytes()
          Get the CSN as a byte array.
 java.lang.String toOctetString()
          Return the CSN as a formated string.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultCSN

public DefaultCSN(long timestamp,
                  java.lang.String replicaId,
                  int operationSequence)
Creates a new instance.

Parameters:
timestamp - GMT timestamp of modification
replicaId - Replica ID where modification occurred ([-_A-Za-z0-9]{1,16})
operationSequence - Operation sequence

DefaultCSN

public DefaultCSN(java.lang.String value)
           throws InvalidCSNException
Creates a new instance of SimpleCSN from a String. The string format must be : <timestamp> : <replica ID> : <operation sequence>

Parameters:
value - The String containing the CSN
Throws:
InvalidCSNException

DefaultCSN

public DefaultCSN(byte[] value)
Creates a new instance of SimpleCSN from the serialized data

Parameters:
value - The byte array which contains the serialized CSN
Method Detail

toOctetString

public java.lang.String toOctetString()
Return the CSN as a formated string. The used format is : <timestamp> ':' <replicaId> ':' <operation sequence>

Specified by:
toOctetString in interface CSN
Returns:
The CSN as a String

toBytes

public byte[] toBytes()
Get the CSN as a byte array. The data are stored as : bytes 1 to 8 : timestamp, big-endian bytes 9 to 12 : operation sequence, big-endian bytes 13 to ... : ReplicaId

Specified by:
toBytes in interface CSN
Returns:
A byte array representing theCSN

getTimestamp

public long getTimestamp()
Description copied from interface: CSN
Returns GMT timestamp of modification.

Specified by:
getTimestamp in interface CSN
Returns:
The timestamp

getReplicaId

public java.lang.String getReplicaId()
Description copied from interface: CSN
Returns replica ID.

Specified by:
getReplicaId in interface CSN
Returns:
The replicaId

getOperationSequence

public int getOperationSequence()
Description copied from interface: CSN
Returns sequence number of modification.

Specified by:
getOperationSequence in interface CSN
Returns:
The operation sequence

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
The CSN as a String

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.

equals

public boolean equals(java.lang.Object o)
Indicates whether some other object is "equal to" this one

Overrides:
equals in class java.lang.Object
Parameters:
o - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.

compareTo

public int compareTo(CSN csn)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Specified by:
compareTo in interface java.lang.Comparable<CSN>
Parameters:
o - the Object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.


Copyright © 2003-2009 Apache Software Foundation. All Rights Reserved.