JXTA

net.jxta.impl.id.UUID
Class CodatID

java.lang.Object
  extended by net.jxta.id.ID
      extended by net.jxta.codat.CodatID
          extended by net.jxta.impl.id.UUID.CodatID
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
CodatID

public class CodatID
extends CodatID

An implementation of the CodatID ID Type.

See Also:
Serialized Form

Field Summary
protected static int codatHashOffset
          Location of the hash value portion of the id within the byte array.
protected static int groupIdOffset
          Location of the group id in the byte array.
protected static int hashSize
          size of a SHA1 hash.
protected  IDBytes id
          The id data
protected static int idOffset
          Location of the randomly chosen portion of the id within the byte array.
protected static int padOffset
          Location of the beginning of pad (unused space) within the byte array.
protected static int padSize
          Size of the pad.
 
Fields inherited from class net.jxta.id.ID
nullID, URIEncodingName, URNNamespace
 
Constructor Summary
protected CodatID()
          Internal constructor
protected CodatID(IDBytes id)
          Initializes contents from provided bytes.
  CodatID(PeerGroupID groupID)
          See IDFactory.Instantiator.newCodatID(net.jxta.peergroup.PeerGroupID).
  CodatID(PeerGroupID groupID, byte[] seed)
          See IDFactory.Instantiator.newCodatID(net.jxta.peergroup.PeerGroupID,byte[]).
  CodatID(PeerGroupID groupID, byte[] seed, InputStream in)
          See IDFactory.Instantiator.newCodatID(net.jxta.peergroup.PeerGroupID,InputStream).
  CodatID(PeerGroupID groupID, InputStream in)
          See IDFactory.Instantiator.newCodatID(net.jxta.peergroup.PeerGroupID,InputStream).
protected CodatID(UUID groupUUID, UUID idUUID)
           
 
Method Summary
 boolean equals(Object target)
          
 String getIDFormat()
          Returns a string identifier which indicates which ID format is used by this ID instance.
 ID getPeerGroupID()
          Returns PeerGroupID of the Peer Group to which this Codat ID belongs.
 Object getUniqueValue()
          Returns an object containing the unique value of the ID.
 int hashCode()
          
 boolean isStatic()
          Returns true if this CodatID is associated with a static Codat.
protected  void setHash(InputStream in)
          Calculates the SHA-1 hash of a stream.
 
Methods inherited from class net.jxta.codat.CodatID
create, intern
 
Methods inherited from class net.jxta.id.ID
getURL, toString, toURI
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

hashSize

protected static final int hashSize
size of a SHA1 hash. I would use MessageDigest.getDigestLength, but possible exceptions make it difficult to do.

See Also:
Constant Field Values

groupIdOffset

protected static final int groupIdOffset
Location of the group id in the byte array.

See Also:
Constant Field Values

idOffset

protected static final int idOffset
Location of the randomly chosen portion of the id within the byte array.

See Also:
Constant Field Values

codatHashOffset

protected static final int codatHashOffset
Location of the hash value portion of the id within the byte array.

See Also:
Constant Field Values

padOffset

protected static final int padOffset
Location of the beginning of pad (unused space) within the byte array.

See Also:
Constant Field Values

padSize

protected static final int padSize
Size of the pad.

See Also:
Constant Field Values

id

protected IDBytes id
The id data

Constructor Detail

CodatID

protected CodatID()
Internal constructor


CodatID

protected CodatID(IDBytes id)
Initializes contents from provided bytes.

Parameters:
id - the ID data

CodatID

protected CodatID(UUID groupUUID,
                  UUID idUUID)

CodatID

public CodatID(PeerGroupID groupID)
See IDFactory.Instantiator.newCodatID(net.jxta.peergroup.PeerGroupID).


CodatID

public CodatID(PeerGroupID groupID,
               byte[] seed)
See IDFactory.Instantiator.newCodatID(net.jxta.peergroup.PeerGroupID,byte[]).


CodatID

public CodatID(PeerGroupID groupID,
               InputStream in)
        throws IOException
See IDFactory.Instantiator.newCodatID(net.jxta.peergroup.PeerGroupID,InputStream).

Throws:
IOException

CodatID

public CodatID(PeerGroupID groupID,
               byte[] seed,
               InputStream in)
        throws IOException
See IDFactory.Instantiator.newCodatID(net.jxta.peergroup.PeerGroupID,InputStream).

Throws:
IOException
Method Detail

equals

public boolean equals(Object target)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

getIDFormat

public String getIDFormat()
Returns a string identifier which indicates which ID format is used by this ID instance.

Specified by:
getIDFormat in class ID
Returns:
a string identifier which indicates which ID format is used by this ID instance.

getUniqueValue

public Object getUniqueValue()
Returns an object containing the unique value of the ID. This object must provide implementations of toString(), equals() and hashCode() that are canonical and consistent 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 this.

Specified by:
getUniqueValue in class ID
Returns:
Object which can provide canonical representations of the ID.

getPeerGroupID

public ID getPeerGroupID()
Returns PeerGroupID of the Peer Group to which this Codat ID belongs.

Specified by:
getPeerGroupID in class CodatID
Returns:
PeerGroupID of the Peer Group which this ID is part of.

isStatic

public boolean isStatic()
Returns true if this CodatID is associated with a static Codat.

Specified by:
isStatic in class CodatID
Returns:
true if the codatId is for a Codat with static content otherwise false.

setHash

protected void setHash(InputStream in)
                throws IOException
Calculates the SHA-1 hash of a stream.

Parameters:
in - The InputStream.
Throws:
IOException

JXSE