Project JXTA

net.jxta.codat
Class CodatID

java.lang.Object
  |
  +--net.jxta.id.ID
        |
        +--net.jxta.codat.CodatID

public class CodatID
extends ID
implements java.lang.Cloneable

This class represents a CodatID. Codats are JXTA objects that can hold both data or code.

Codats are containers objects that are used to hold any kinds of objects or data. A codat can represent a file, a class file, the saved state of an application, a loadable C library. Codats are handled transparently by the JXTA platform, and are used as placeholders for any type of data. Codats hold Document that represent the data that they hold.

A CodatID is formed by the conjuction of a PeerGroup unique ID and the Codat Document hash value.The Id is the unique Id for this Codat within the JXTA world. Some codats may not hold a document. In that case a codatId is constructed without the document hash value.

Since:
JXTA 1.0
See Also:
Codat, Document, StructuredDocument

Field Summary
static CodatID nullCodatID
          The null CodatID.
 
Fields inherited from class net.jxta.id.ID
bytes, flagCodatID, flagID, flagPeerGroupID, flagPeerID, flagPipeID, flagsEncodingOffset, flagsIdTypeOffset, flagsOffset, flagsSize, IdByteArraySize, nullID, URIEncodingName, UUIDEncoded
 
Constructor Summary
CodatID()
          Constructor used in the creation of a CodatID when no concrete Document is associated.
CodatID(PeerGroupID groupID)
          Creates a CodatID for a Codat without document.
CodatID(PeerGroupID groupID, Document document)
          Constructor to create a new CodatID.
CodatID(PeerGroupID groupID, java.io.InputStream in)
          Constructor.
 
Method Summary
 java.lang.Object clone()
          Clones this CodatID
 boolean equals(java.lang.Object id)
          Returns true if the two CodatIDs are same
 PeerGroupID getPeerGroupID()
          Returns the PeerGroupID of the PeerGroup associated with this Codat
 boolean isStatic()
          Returns true if the CodatID is associated with a static Codat.
 
Methods inherited from class net.jxta.id.ID
bytesIntoLong, getURL, hashCode, isSamePeerGroup, longIntoBytes, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

nullCodatID

public static final CodatID nullCodatID
The null CodatID. Useful for comparisons and cases where the CodatId is ignored.
Constructor Detail

CodatID

public CodatID()
Constructor used in the creation of a CodatID when no concrete Document is associated. Dymamic codats.
Since:
JXTA 1.0

CodatID

public CodatID(PeerGroupID groupID)
Creates a CodatID for a Codat without document. A PeerGroupID is provided but no Document is provided. CodatID contains no hash value for the Codat data.
Parameters:
groupID - the group to which this content will belong.
Since:
JXTA 1.0

CodatID

public CodatID(PeerGroupID groupID,
               Document document)
        throws java.io.IOException,
               java.security.NoSuchAlgorithmException
Constructor to create a new CodatID. CodatID contains the hash value for the associated Codat document and the PeerGroup Id where this codat is published.
Parameters:
groupID - PeerGroup to which this content will belong.
document - Document which will be associcated with this CodatID
Throws:
java.security.NoSuchAlgorithmException - Did not find correct encoding algorithm
java.io.IOException - I/O Error reading document
Since:
JXTA 1.0

CodatID

public CodatID(PeerGroupID groupID,
               java.io.InputStream in)
        throws java.io.IOException,
               java.security.NoSuchAlgorithmException
Constructor. Creates a static Codat. ID contains hash value for Codat data.
Parameters:
groupID - the group to which this dynamic content will belong.
in - the InputStream from which the content hash is calculated. The stream is read until EOF and then closed.
Throws:
java.security.NoSuchAlgorithmException - Did not find correct encoding algorithm
java.io.IOException - I/O Error reading document
Since:
JXTA 1.0
Method Detail

isStatic

public boolean isStatic()
Returns true if the CodatID is associated with a static Codat.
Returns:
boolean chcek if the codatId is for a codat without document (Static codat)
Since:
JXTA 1.0

getPeerGroupID

public PeerGroupID getPeerGroupID()
Returns the PeerGroupID of the PeerGroup associated with this Codat
Overrides:
getPeerGroupID in class ID
Returns:
PeerGroupID return peer group Id associated with this codat id
Since:
JXTA 1.0

equals

public boolean equals(java.lang.Object id)
Returns true if the two CodatIDs are same
Overrides:
equals in class ID
Parameters:
id - CodatID to be checked with
Returns:
boolean
Since:
JXTA 1.0

clone

public java.lang.Object clone()
Clones this CodatID
Overrides:
clone in class ID
Returns:
Object clone object
Since:
JXTA 1.0

Project JXTA