CONTENTS | PREV | NEXT Java Remote Method Invocation


9.4 The UID Class

The class UID is an abstraction for creating identifiers that are unique with respect to the host on which it is generated. A UID is contained in an ObjID as an address space identifier. A UID consists of a number that is unique on the host (an int), a time (a long), and a count (a short).

package java.rmi.server;

public final class UID implements java.io.Serializable {

    public UID();

    public UID(short num); 

    public int hashCode();

    public boolean equals(Object obj);

    public String toString();

    public void write(DataOutput out) throws java.io.IOException;

    public static UID read(DataInput in) throws java.io.IOException;
}


The first form of the constructor creates a pure identifier that is unique with respect to the host on which it is generated. This UID is unique under the following conditions: a) the machine takes more than one second to reboot, and b) the machine's clock is never set backward. In order to construct a UID that is globally unique, simply pair a UID with an InetAddress.

The second form of the constructor creates a well-known UID. There are 216 -1 such possible well-known IDs. An ID generated via this constructor will not clash with any ID generated via the default UID constructor which generates a genuinely unique identifier with respect to this host.

The methods hashCode, equals, and toString are defined for UIDs. Two UIDs are considered equal if they have the same contents.

The method write writes the UID to the output stream.

The method read constructs a UID whose contents is read from the specified input stream.



CONTENTS | PREV | NEXT
Copyright © 1997-1998 Sun Microsystems, Inc. All Rights Reserved.