UID represents an identifier that is unique over time
with respect to the host it is generated on, or one of 216
"well-known" identifiers.
The UID() constructor can be used to generate an
identifier that is unique over time with respect to the host it is
generated on. The UID(short) constructor can be used to
create one of 216 well-known identifiers.
A UID instance contains three primitive values:
unique, an int that uniquely identifies
the VM that this UID was generated in, with respect to its
host and at the time represented by the time value (an
example implementation of the unique value would be a
process identifier),
or zero for a well-known UID
time, a long equal to a time (as returned
by System#currentTimeMillis()) at which the VM that this
UID was generated in was alive,
or zero for a well-known UID
count, a short to distinguish
UIDs generated in the same VM with the same
time value
An independently generated UID instance is unique
over time with respect to the host it is generated on as long as
the host requires more than one millisecond to reboot and its system
clock is never set backward. A globally unique identifier can be
constructed by pairing a UID instance with a unique host
identifier, such as an IP address.
| Modifier and Type | Field and Description |
|---|---|
| private final short | count
16-bit number to distinguish |
| private static int | |
| private static boolean | |
| private static short | |
| private static long | |
| private static final Object | |
| private static final long | serialVersionUID
indicate compatibility with JDK 1.1.x version of class |
| private final long | time
a time (as returned by |
| private final int | unique
number that uniquely identifies the VM that this |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if the given object is equivalent to
this one, and false otherwisethe object to compare this obj)UID toOverrides java. Compares the specified object with this |
| public int | Returns: the hash code value for thisUIDOverrides java. Returns the hash code value for this |
| public static UID | |
| public String | Returns: a string representation of thisUIDOverrides java. Returns a string representation of this |
| public void | write(DataOutput
the out)DataOutput instance to write
this UID toMarshals a binary representation of this |
| count | back to summary |
|---|---|
| private final short count 16-bit number to distinguish | |
| hostUnique | back to summary |
|---|---|
| private static int hostUnique | |
| hostUniqueSet | back to summary |
|---|---|
| private static boolean hostUniqueSet | |
| lastCount | back to summary |
|---|---|
| private static short lastCount | |
| lastTime | back to summary |
|---|---|
| private static long lastTime | |
| lock | back to summary |
|---|---|
| private static final Object lock | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID indicate compatibility with JDK 1.1.x version of class | |
| time | back to summary |
|---|---|
| private final long time a time (as returned by | |
| unique | back to summary |
|---|---|
| private final int unique number that uniquely identifies the VM that this | |
| UID | back to summary |
|---|---|
| public UID() Generates a | |
| UID | back to summary |
|---|---|
| public UID(short num) Creates a "well-known" A
| |
| UID | back to summary |
|---|---|
| private UID(int unique, long time, short count) Constructs a | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Compares the specified object with this
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns the hash code value for this
| |
| read | back to summary |
|---|---|
| public static UID read(DataInput in) throws IOException Constructs and returns a new Specifically, this method first invokes the given stream's
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string representation of this
| |
| write | back to summary |
|---|---|
| public void write(DataOutput out) throws IOException Marshals a binary representation of this Specifically, this method first invokes the given stream's
| |