public class UUID extends Object implements Comparable<UUID>, Externalizable, Cloneable, IDLEntity
All you need to know:
UUID u = new UUID();
Modifier and Type | Field and Description |
---|---|
long |
clockSeqAndNode
The clock sequence and node field of the UUID.
|
long |
time
The time field of the UUID.
|
Constructor and Description |
---|
UUID()
Constructor for UUID.
|
UUID(CharSequence s)
Parses a textual representation of a UUID.
|
UUID(long time,
long clockSeqAndNode)
Constructor for UUID.
|
UUID(UUID u)
Copy constructor for UUID.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Clones this UUID.
|
int |
compareTo(UUID t)
Compares this UUID to another Object.
|
boolean |
equals(Object obj)
Compares two Objects for equality.
|
static UUID |
fromString(String uuid)
Dedicated method which allows UUID object to be created by jaxrs runtime.
|
long |
getClockSeqAndNode()
Returns the clock and node field of the UUID (lower 64 bits).
|
long |
getTime()
Returns the time field of the UUID (upper 64 bits).
|
int |
hashCode()
Returns a hash code of this UUID.
|
static UUID |
nilUUID()
Returns the nil UUID (a UUID whose values are both set to zero).
|
void |
readExternal(ObjectInput in)
Tweaked Serialization routine.
|
Appendable |
toAppendable(Appendable a)
Appends a String representation of this object to the given
Appendable object. |
String |
toString()
Returns this UUID as a String.
|
StringBuffer |
toStringBuffer(StringBuffer in)
Appends a String representation of this to the given
StringBuffer or
creates a new one if none is given. |
void |
writeExternal(ObjectOutput out)
Tweaked Serialization routine.
|
public long time
public long clockSeqAndNode
public UUID()
UUIDGen.newTime()
,
UUIDGen.getClockSeqAndNode()
public UUID(long time, long clockSeqAndNode)
long
values.time
- the upper 64 bitsclockSeqAndNode
- the lower 64 bitspublic UUID(UUID u)
u
- the UUID, may not be null
public UUID(CharSequence s)
No validation is performed. If the CharSequence
is shorter than 36 characters,
ArrayIndexOutOfBoundsException
s will be thrown.
s
- the CharSequence
, may not be null
public int compareTo(UUID t)
ClassCastException
if
the other Object is not an instance of the UUID class. Returns a value
smaller than zero if the other UUID is "larger" than this UUID and a value
larger than zero if the other UUID is "smaller" than this UUID.compareTo
in interface Comparable<UUID>
t
- the other UUID, may not be null
ClassCastException
Comparable.compareTo(java.lang.Object)
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException
readExternal
in interface Externalizable
IOException
public final String toString()
toString
in class Object
null
Object.toString()
,
toAppendable(Appendable)
public StringBuffer toStringBuffer(StringBuffer in)
StringBuffer
or
creates a new one if none is given.in
- the StringBuffer to append to, may be null
null
toAppendable(Appendable)
public Appendable toAppendable(Appendable a)
Appendable
object.
For reasons I'll probably never understand, Sun has decided to have a number of I/O classes implement
Appendable which forced them to destroy an otherwise nice and simple interface with IOException
s.
I decided to ignore any possible IOExceptions in this method.
a
- the Appendable object, may be null
StringBuilder
if a
is null
public int hashCode()
hashCode
in class Object
int
representing the hash codeObject.hashCode()
public Object clone()
public final long getTime()
public final long getClockSeqAndNode()
public boolean equals(Object obj)
equals
in class Object
obj
- the Object to compare this UUID with, may be null
true
if the other Object is equal to this UUID,
false
if notObject.equals(Object)
public static UUID nilUUID()
Starting with version 2.0, this method does return a new UUID instance every time it is called. Earlier versions returned one instance. This has now been changed because this UUID has public, non-final instance fields. Returning a new instance is therefore more safe.
null
Copyright © 2003–2018. All rights reserved.