public class Csn extends java.lang.Object implements java.lang.Comparable<Csn>
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.::= # # # ::= A GMT based time, YYYYmmddHHMMSS.uuuuuuZ ::= [000000-ffffff] ::= [000-fff] ::= [000000-ffffff]
| Modifier and Type | Field and Description |
|---|---|
private byte[] |
bytes
Stores the byte array representation of the CSN
|
private int |
changeCount
The changeCount to distinguish operations done in the same second
|
private java.lang.String |
csnStr
Stores the String representation of the CSN
|
private static org.slf4j.Logger |
LOG
The logger for this class
|
private int |
operationNumber
The operation number in a modification operation
|
private static java.lang.String[] |
PADDING_3
Padding used to format number with a fixed size
|
private static java.lang.String[] |
PADDING_6
Padding used to format number with a fixed size
|
private int |
replicaId
The server identification
|
private static java.text.SimpleDateFormat |
SDF
The Timestamp syntax.
|
private long |
timestamp
The timeStamp of this operation
|
private static java.util.TimeZone |
UTC_TIME_ZONE |
| Constructor and Description |
|---|
Csn(byte[] value)
Creates a new instance of SimpleCSN from the serialized data
|
Csn(long timestamp,
int changeCount,
int replicaId,
int operationNumber)
Creates a new instance.
|
Csn(java.lang.String value)
Creates a new instance of SimpleCSN from a String.
|
| Modifier and Type | Method and Description |
|---|---|
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
|
byte[] |
getBytes()
Get the CSN as a byte array.
|
int |
getChangeCount() |
int |
getOperationNumber() |
int |
getReplicaId() |
private int |
getReplicaIdCompareResult(Csn csn) |
long |
getTimestamp() |
int |
hashCode()
Returns a hash code value for the object.
|
static boolean |
isValid(java.lang.String value)
Check if the given String is a valid CSN.
|
java.lang.String |
toString() |
private static final org.slf4j.Logger LOG
private final long timestamp
private final int replicaId
private final int operationNumber
private final int changeCount
private java.lang.String csnStr
private byte[] bytes
private static final java.text.SimpleDateFormat SDF
private static final java.util.TimeZone UTC_TIME_ZONE
private static final java.lang.String[] PADDING_6
private static final java.lang.String[] PADDING_3
public Csn(long timestamp,
int changeCount,
int replicaId,
int operationNumber)
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 operationpublic Csn(java.lang.String value)
throws InvalidCSNException
value - The String containing the CSNInvalidCSNException - if the value doesn't contain a valid CSNCsn(byte[] value)
value - The byte array which contains the serialized CSNpublic static boolean isValid(java.lang.String value)
value - The String to checktrue if the String is a valid CSNpublic byte[] getBytes()
public long getTimestamp()
public int getChangeCount()
public int getReplicaId()
public int getOperationNumber()
public java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - the reference object with which to compare.true if this object is the same as the obj argument;
false otherwise.public int compareTo(Csn csn)
compareTo in interface java.lang.Comparable<Csn>csn - the Object to be compared.private int getReplicaIdCompareResult(Csn csn)