java.rmi.server
Class UID

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.rmi.server.UID
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable

public final class UID
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements Serializable sample code for java.io.Serializable definition code for java.io.Serializable

A 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() sample code for java.rmi.server.UID.UID() definition code for java.rmi.server.UID.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) sample code for java.rmi.server.UID.UID(short) definition code for java.rmi.server.UID.UID(short) constructor can be used to create one of 216 well-known identifiers.

A UID instance contains three primitive values:

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.

Since:
JDK1.1
See Also:
Serialized Form

Constructor Summary
UID sample code for java.rmi.server.UID.UID() definition code for java.rmi.server.UID.UID() ()
          Generates a UID that is unique over time with respect to the host that it was generated on.
UID sample code for java.rmi.server.UID.UID(short) definition code for java.rmi.server.UID.UID(short) (short num)
          Creates a "well-known" UID.
 
Method Summary
 boolean equals sample code for java.rmi.server.UID.equals(java.lang.Object) definition code for java.rmi.server.UID.equals(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  obj)
          Compares the specified object with this UID for equality.
 int hashCode sample code for java.rmi.server.UID.hashCode() definition code for java.rmi.server.UID.hashCode() ()
          Returns the hash code value for this UID.
static UID sample code for java.rmi.server.UID definition code for java.rmi.server.UID read sample code for java.rmi.server.UID.read(java.io.DataInput) definition code for java.rmi.server.UID.read(java.io.DataInput) (DataInput sample code for java.io.DataInput definition code for java.io.DataInput  in)
          Constructs and returns a new UID instance by unmarshalling a binary representation from an DataInput instance.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for java.rmi.server.UID.toString() definition code for java.rmi.server.UID.toString() ()
          Returns a string representation of this UID.
 void write sample code for java.rmi.server.UID.write(java.io.DataOutput) definition code for java.rmi.server.UID.write(java.io.DataOutput) (DataOutput sample code for java.io.DataOutput definition code for java.io.DataOutput  out)
          Marshals a binary representation of this UID to a DataOutput instance.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

UID sample code for java.rmi.server.UID() definition code for java.rmi.server.UID()

public UID()
Generates a UID that is unique over time with respect to the host that it was generated on.


UID sample code for java.rmi.server.UID(short) definition code for java.rmi.server.UID(short)

public UID(short num)
Creates a "well-known" UID. There are 216 possible such well-known ids.

A UID created via this constructor will not clash with any UIDs generated via the no-arg constructor.

Parameters:
num - number for well-known UID
Method Detail

hashCode sample code for java.rmi.server.UID.hashCode() definition code for java.rmi.server.UID.hashCode()

public int hashCode()
Returns the hash code value for this UID.

Overrides:
hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
the hash code value for this UID
See Also:
Object.equals(java.lang.Object) sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

equals sample code for java.rmi.server.UID.equals(java.lang.Object) definition code for java.rmi.server.UID.equals(java.lang.Object)

public boolean equals(Object sample code for java.lang.Object definition code for java.lang.Object  obj)
Compares the specified object with this UID for equality. This method returns true if and only if the specified object is a UID instance with the same unique, time, and count values as this one.

Overrides:
equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) in class Object sample code for java.lang.Object definition code for java.lang.Object
Parameters:
obj - the object to compare this UID to
Returns:
true if the given object is equivalent to this one, and false otherwise
See Also:
Object.hashCode() sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable

toString sample code for java.rmi.server.UID.toString() definition code for java.rmi.server.UID.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()
Returns a string representation of this UID.

Overrides:
toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
a string representation of this UID

write sample code for java.rmi.server.UID.write(java.io.DataOutput) definition code for java.rmi.server.UID.write(java.io.DataOutput)

public void write(DataOutput sample code for java.io.DataOutput definition code for java.io.DataOutput  out)
           throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Marshals a binary representation of this UID to a DataOutput instance.

Specifically, this method first invokes the given stream's DataOutput.writeInt(int) sample code for java.io.DataOutput.writeInt(int) definition code for java.io.DataOutput.writeInt(int) method with this UID's unique value, then it invokes the stream's DataOutput.writeLong(long) sample code for java.io.DataOutput.writeLong(long) definition code for java.io.DataOutput.writeLong(long) method with this UID's time value, and then it invokes the stream's DataOutput.writeShort(int) sample code for java.io.DataOutput.writeShort(int) definition code for java.io.DataOutput.writeShort(int) method with this UID's count value.

Parameters:
out - the DataOutput instance to write this UID to
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - if an I/O error occurs while performing this operation

read sample code for java.rmi.server.UID.read(java.io.DataInput) definition code for java.rmi.server.UID.read(java.io.DataInput)

public static UID sample code for java.rmi.server.UID definition code for java.rmi.server.UID  read(DataInput sample code for java.io.DataInput definition code for java.io.DataInput  in)
                throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Constructs and returns a new UID instance by unmarshalling a binary representation from an DataInput instance.

Specifically, this method first invokes the given stream's DataInput.readInt() sample code for java.io.DataInput.readInt() definition code for java.io.DataInput.readInt() method to read a unique value, then it invoke's the stream's DataInput.readLong() sample code for java.io.DataInput.readLong() definition code for java.io.DataInput.readLong() method to read a time value, then it invoke's the stream's DataInput.readShort() sample code for java.io.DataInput.readShort() definition code for java.io.DataInput.readShort() method to read a count value, and then it creates and returns a new UID instance that contains the unique, time, and count values that were read from the stream.

Parameters:
in - the DataInput instance to read UID from
Returns:
unmarshalled UID instance
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - if an I/O error occurs while performing this operation