Project JXTA

net.jxta.impl.id.UUID
Class IDBytes

java.lang.Object
  extended by net.jxta.impl.id.UUID.IDBytes
All Implemented Interfaces:
Serializable

public final class IDBytes
extends Object
implements Serializable

Maintains the internal representation of a 'uuid' JXTA ID.

See Also:
IDFactory, IDFormat, JXTA Protocols Specification : UUID ID Format, Serialized Form

Field Summary
 byte[] bytes
          The bytes.
protected  int cachedHash
          The cached hash value for this object
protected  boolean hashIsCached
          if true then we have calculated the hash value for this object.
 
Constructor Summary
IDBytes()
          Constructs a new byte representation.
 
Method Summary
 long bytesIntoLong(int offset)
          Return the long value of a portion of the byte array.
 boolean equals(Object target)
          Compares two IDs for equality.
 Object getUniqueValue()
          Return an object containing the unique value of the ID.
 int hashCode()
          Public member calculates a hash code for this ID.
 void longIntoBytes(int offset, long value)
          Insert a long value into the byte array.
 String toString()
          Returns a string representation of the ID bytes.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

bytes

public byte[] bytes
The bytes.


hashIsCached

protected transient volatile boolean hashIsCached
if true then we have calculated the hash value for this object.


cachedHash

protected transient int cachedHash
The cached hash value for this object

Constructor Detail

IDBytes

public IDBytes()
Constructs a new byte representation. This constructor initializes only the flag fields of the ID.

Method Detail

equals

public boolean equals(Object target)
Compares two IDs for equality.

Overrides:
equals in class Object
Parameters:
target - the ID to be compared against.
Returns:
boolean true if IDs are equal, false otherwise.

hashCode

public int hashCode()
Public member calculates a hash code for this ID. Used by Hashmaps.

Overrides:
hashCode in class Object
Returns:
int Containing the hashcode of this ID.

toString

public String toString()
Returns a string representation of the ID bytes. The bytes are encoded in hex ASCII format with two characters per byte. The pad bytes between the primary id portion and the flags field are ommitted.

Overrides:
toString in class Object
Returns:
String containting the URI

getUniqueValue

public Object getUniqueValue()
Return an object containing the unique value of the ID. This object must provide implementations of toString() and hashCode() that are canonical and conisistent from run-to-run given the same input values. Beyond this nothing should be assumed about the nature of this object. For some implementations the object returned may be the same as provided.

Returns:
Object which can provide canonical representations of the ID.

longIntoBytes

public void longIntoBytes(int offset,
                          long value)
Insert a long value into the byte array. The long is stored in big-endian order into the byte array begining at the specified index.

Parameters:
offset - location within the byte array to insert.
value - value to be inserted.

bytesIntoLong

public long bytesIntoLong(int offset)
Return the long value of a portion of the byte array. The long is retrieved in big-endian order from the byte array at the specified offset.

Parameters:
offset - location within the byte array to extract.
Returns:
long value extracted from the byte array.

JXTA J2SE