Package com.arjuna.ats.arjuna.common
Class Uid
- java.lang.Object
-
- com.arjuna.ats.arjuna.common.Uid
-
- All Implemented Interfaces:
Serializable,Cloneable
public class Uid extends Object implements Cloneable, Serializable
Implements a unique identity class. Since 4.9 each instance is immutable.- Since:
- 1.0.
- Version:
- $Id: Uid.java 2342 2006-03-30 13:06:17Z $
- Author:
- Mark Little (mark@arjuna.com)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Uid()Create a new instance.Uid(byte[] byteForm)Uid(long[] addr, int processId, int time, int incr)Uid(Uid copyFrom)Create a copy of the specified identifier.Uid(String uidString)Create Uid from string representation.Uid(String uidString, boolean errsOk)Create Uid from string representation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectclone()Create a copy of this instance.booleanequals(Uid u)booleanequals(Object o)Override Object.equalsStringfileStringForm()byte[]getBytes()Get the byte representation of the Uid.StringgetHexPid()booleangreaterThan(Uid u)inthashCode()Override Object.hashCode.static UidlastResourceUid()Return a last resource Uid (0:0:0:0:1)booleanlessThan(Uid u)static UidmaxUid()Return the maximum Uid (7fffffffffffffff:7fffffffffffffff:7fffffff:7fffffff:7fffffff)static UidminUid()Return the minimum Uid (-8000000000000000:-8000000000000000:-80000000:-80000000:-80000000)booleannotEquals(Uid u)static UidnullUid()Return a null Uid (0:0:0:0:0)voidprint(PrintStream strm)Print a human-readable form of the Uid.StringstringForm()StringtoString()Same as stringForm()booleanvalid()Is the Uid valid?
-
-
-
Field Detail
-
hostAddr
protected volatile long[] hostAddr
-
process
protected volatile int process
-
sec
protected volatile int sec
-
other
protected volatile int other
-
UID_SIZE
public static final int UID_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Uid
public Uid()
Create a new instance.
-
Uid
public Uid(Uid copyFrom)
Create a copy of the specified identifier.
-
Uid
public Uid(byte[] byteForm)
-
Uid
public Uid(String uidString)
Create Uid from string representation. If the string does not represent a valid Uid then the instance will be set to nullUid.
-
Uid
public Uid(String uidString, boolean errsOk)
Create Uid from string representation. boolean arg says whether to give up if an error is detected or to simply replace with nullUid.
-
Uid
public Uid(long[] addr, int processId, int time, int incr)
-
-
Method Detail
-
hashCode
public int hashCode()
Override Object.hashCode. We always return a positive value.
-
print
public void print(PrintStream strm)
Print a human-readable form of the Uid.
-
stringForm
public String stringForm()
-
fileStringForm
public String fileStringForm()
- Returns:
- a string representation of the Uid with all : replaced by _ so that the name may be used as a file name.
-
getBytes
public byte[] getBytes()
Get the byte representation of the Uid. Useful for packing and creating other representations of transaction ids.- Returns:
- the byte array. Cached once created.
-
getHexPid
public String getHexPid()
-
clone
public Object clone() throws CloneNotSupportedException
Create a copy of this instance.- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
equals
public boolean equals(Uid u)
-
notEquals
public boolean notEquals(Uid u)
-
lessThan
public boolean lessThan(Uid u)
-
greaterThan
public boolean greaterThan(Uid u)
-
valid
public final boolean valid()
Is the Uid valid?
-
nullUid
public static final Uid nullUid()
Return a null Uid (0:0:0:0:0)
-
lastResourceUid
public static final Uid lastResourceUid()
Return a last resource Uid (0:0:0:0:1)
-
maxUid
public static final Uid maxUid()
Return the maximum Uid (7fffffffffffffff:7fffffffffffffff:7fffffff:7fffffff:7fffffff)
-
minUid
public static final Uid minUid()
Return the minimum Uid (-8000000000000000:-8000000000000000:-80000000:-80000000:-80000000)
-
-