org.hd.d.pg2k.svrCore.vars
Class InstanceID

java.lang.Object
  extended by org.hd.d.pg2k.svrCore.vars.InstanceID
All Implemented Interfaces:
java.io.ObjectInputValidation, java.io.Serializable, java.lang.Comparable<InstanceID>, MemoryTools.Internable

public final class InstanceID
extends java.lang.Object
implements java.io.Serializable, java.io.ObjectInputValidation, MemoryTools.Internable, java.lang.Comparable<InstanceID>

Immutable globally-unique instance ID for a JVM participating in a set of SystemVariables. This is the key to a globalmap variable, and each participating system should have just one such value, probably generated by a data pipeline endpoint.

Internally, this is a randomly-generated (non-negative) long value.

See Also:
Serialized Form

Field Summary
private  long ID
          Unique (positive) long ID from a cryptographically-good random-number source.
private static long serialVersionUID
          Unique Serialisation class ID generated by http://random.hd.org/.
 
Constructor Summary
private InstanceID()
          Create a new instance with a new/unique ID from a cryptographically-good random-number source.
 
Method Summary
 int compareTo(InstanceID other)
          Comparable ordering is on ID value alone in numeric ID order.
static InstanceID createInstanceID()
          Create a new, unique instance ID; never null.
 boolean equals(java.lang.Object obj)
          Equality is based on the whole ID.
 int hashCode()
          The hash is derived from the ID.
 long longValue()
          Long representation of ID; non-negative.
protected  java.lang.Object readResolve()
          Deserialise: validate and eliminate duplicates coming off the wire.
 java.lang.String toString()
          String representation of ID as a non-negative base-36 number.
 void validateObject()
          Check for legal state.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ID

private final long ID
Unique (positive) long ID from a cryptographically-good random-number source.


serialVersionUID

private static final long serialVersionUID
Unique Serialisation class ID generated by http://random.hd.org/.

See Also:
Constant Field Values
Constructor Detail

InstanceID

private InstanceID()
Create a new instance with a new/unique ID from a cryptographically-good random-number source.

Method Detail

createInstanceID

public static InstanceID createInstanceID()
Create a new, unique instance ID; never null. This is immediately intern()ed so that there will never be more than one copy of each unique InstanceID in memory at any one time (except transiently during deserialisation).


longValue

public long longValue()
Long representation of ID; non-negative.


toString

public java.lang.String toString()
String representation of ID as a non-negative base-36 number.

Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(InstanceID other)
Comparable ordering is on ID value alone in numeric ID order.

Specified by:
compareTo in interface java.lang.Comparable<InstanceID>

equals

public boolean equals(java.lang.Object obj)
Equality is based on the whole ID. But in fact due to instance control we can in fact use == at least as an optimisation!

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
The hash is derived from the ID. This implementation just uses the hash of the name.

Overrides:
hashCode in class java.lang.Object

readResolve

protected java.lang.Object readResolve()
                                throws java.io.ObjectStreamException
Deserialise: validate and eliminate duplicates coming off the wire. Ensures that there is never more than one copy of any given InstanceID value in memory (other than transiently).

Returns:
identical, de-duped, non-null instance
Throws:
java.io.ObjectStreamException

validateObject

public void validateObject()
                    throws java.io.InvalidObjectException
Check for legal state.

Specified by:
validateObject in interface java.io.ObjectInputValidation
Throws:
java.io.InvalidObjectException

DHD Multimedia Gallery V1.57.21

Copyright (c) 1996-2011, Damon Hart-Davis. All rights reserved.