Class Csn
- java.lang.Object
-
- org.apache.directory.api.ldap.model.csn.Csn
-
- All Implemented Interfaces:
Comparable<Csn>
public class Csn extends Object implements Comparable<Csn>
Represents 'Change Sequence Number' in LDUP specification. A CSN is a composition of a timestamp, a replica ID and a operation sequence number. It's described in http://tools.ietf.org/html/draft-ietf-ldup-model-09. The CSN syntax is :<CSN> ::= <timestamp> # <changeCount> # <replicaId> # <modifierNumber> <timestamp> ::= A GMT based time, YYYYmmddHHMMSS.uuuuuuZ <changeCount> ::= [000000-ffffff] <replicaId> ::= [000-fff] <modifierNumber> ::= [000000-ffffff]
It distinguishes a change made on an object on a server, and if two operations take place during the same timeStamp, the operation sequence number makes those operations distinct.- Author:
- Apache Directory Project
-
-
Constructor Summary
Constructors Constructor Description Csn(byte[] value)Creates a new instance of SimpleCSN from the serialized dataCsn(long timestamp, int changeCount, int replicaId, int operationNumber)Creates a new instance.Csn(String value)Creates a new instance of SimpleCSN from a String.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Csn csn)Compares this object with the specified object for order.booleanequals(Object o)Indicates whether some other object is "equal to" this onebyte[]getBytes()Get the CSN as a byte array.intgetChangeCount()intgetOperationNumber()intgetReplicaId()longgetTimestamp()inthashCode()Returns a hash code value for the object.static booleanisValid(String value)Check if the given String is a valid CSN.StringtoString()
-
-
-
Constructor Detail
-
Csn
public Csn(long timestamp, int changeCount, int replicaId, int operationNumber)Creates a new instance. This method should be used only for deserializing a CSN- Parameters:
timestamp- GMT timestamp of modificationchangeCount- The operation incrementreplicaId- Replica ID where modification occurred ([-_A-Za-z0-9]{1,16})operationNumber- Operation number in a modification operation
-
Csn
public Csn(String value)
Creates a new instance of SimpleCSN from a String. The string format must be : <timestamp> # <changeCount> # <replica ID> # <operation number>- Parameters:
value- The String containing the CSN
-
Csn
Csn(byte[] value)
Creates a new instance of SimpleCSN from the serialized data- Parameters:
value- The byte array which contains the serialized CSN
-
-
Method Detail
-
isValid
public static boolean isValid(String value)
Check if the given String is a valid CSN.- Parameters:
value- The String to check- Returns:
trueif the String is a valid CSN
-
getBytes
public byte[] getBytes()
Get the CSN as a byte array. The data are stored as : bytes 1 to 8 : timestamp, big-endian bytes 9 to 12 : change count, big endian bytes 13 to ... : ReplicaId- Returns:
- A copy of the byte array representing theCSN
-
getTimestamp
public long getTimestamp()
- Returns:
- The timestamp
-
getChangeCount
public int getChangeCount()
- Returns:
- The changeCount
-
getReplicaId
public int getReplicaId()
- Returns:
- The replicaId
-
getOperationNumber
public int getOperationNumber()
- Returns:
- The operation number
-
hashCode
public int hashCode()
Returns a hash code value for the object.
-
equals
public boolean equals(Object o)
Indicates whether some other object is "equal to" this one
-
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:
compareToin interfaceComparable<Csn>- Parameters:
csn- 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.
-
-