JXTA

net.jxta.impl.id.UUID
Class ContentID

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

public class ContentID
extends ContentID

An implementation of the ContentID ID Type. The format of the ID is broken down as follows:

  0 - 15  PeerGroupID
 16 - 31  Unique Content ID
 32       Mode Byte:
              Bit      7: Static content flag
              Bits 6 - 0: Integer representing number the number of bytes
                          used for the variant ID.
 33 - 62  Optional variant ID data.  Bytes not declared as used via the
          integer portion of the mode byte should be zero-filled.
 63       IDType
 

See Also:
Serialized Form

Field Summary
protected static int groupIdOffset
          Location of the group id in the byte array.
protected  IDBytes id
          The id data.
protected static int indexIdLength
          Length of the indexable/unique ID field.
protected static int indexIdOffset
          Location of the indexable/unique ID of the content.
protected static int modeOffset
          Location of the mode byte used to flag static content as well as to indicate the length of the optional variant data.
protected static int variantMaxLength
          Maximum number of bytes that can be used as the unique value.
protected static int variantOffset
          Location of the variant hash value portion of the id within the byte array.
 
Fields inherited from class net.jxta.id.ID
nullID, serialVersionUID, URIEncodingName, URNNamespace
 
Constructor Summary
protected ContentID()
          Internal constructor.
protected ContentID(IDBytes id)
          Intializes contents from provided bytes.
protected ContentID(PeerGroupID groupID)
          Internal constructor.
  ContentID(PeerGroupID groupID, boolean contentIsStatic)
          See IDFactory.Instantiator.newContentID(net.jxta.peergroup.PeerGroupID,boolean).
  ContentID(PeerGroupID groupID, boolean contentIsStatic, byte[] indexSeed)
          See IDFactory.Instantiator.newContentID(net.jxta.peergroup.PeerGroupID,boolean,byte[]).
  ContentID(PeerGroupID groupID, boolean contentIsStatic, byte[] indexSeed, byte[] variant)
          See IDFactory.Instantiator.newContentID(net.jxta.peergroup.PeerGroupID,boolean,byte[],byte[]).
  ContentID(PeerGroupID groupID, boolean contentIsStatic, byte[] indexSeed, InputStream variant)
          See IDFactory.Instantiator.newContentID(net.jxta.peergroup.PeerGroupID,boolean,byte[],InputStream).
  ContentID(PeerGroupID groupID, boolean contentIsStatic, InputStream indexSeed)
          See IDFactory.Instantiator.newContentID(net.jxta.peergroup.PeerGroupID,boolean,InputStream).
  ContentID(PeerGroupID groupID, boolean contentIsStatic, InputStream indexSeed, byte[] variant)
          See IDFactory.Instantiator.newContentID(net.jxta.peergroup.PeerGroupID,boolean,InputStream,byte[]).
  ContentID(PeerGroupID groupID, boolean contentIsStatic, InputStream indexSeed, InputStream variant)
          See IDFactory.Instantiator.newContentID(net.jxta.peergroup.PeerGroupID,boolean,InputStream,InputStream).
protected ContentID(PeerGroupID groupID, UUID indexUUID)
          Internal constructor.
 
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 Content ID belongs.
 Object getUniqueValue()
          Returns an object containing the unique value of the ID.
 Object getVariantValue()
          Returns an object containing the value of the variant portion of this ID.
 int hashCode()
          
 boolean isStatic()
          Returns true if this ContentID is associated with a static Content.
 
Methods inherited from class net.jxta.content.ContentID
create, intern
 
Methods inherited from class net.jxta.id.ID
toString, toURI
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

groupIdOffset

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

See Also:
Constant Field Values

indexIdOffset

protected static final int indexIdOffset
Location of the indexable/unique ID of the content.

See Also:
Constant Field Values

indexIdLength

protected static final int indexIdLength
Length of the indexable/unique ID field.

See Also:
Constant Field Values

modeOffset

protected static final int modeOffset
Location of the mode byte used to flag static content as well as to indicate the length of the optional variant data.

See Also:
Constant Field Values

variantOffset

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

See Also:
Constant Field Values

variantMaxLength

protected static final int variantMaxLength
Maximum number of bytes that can be used as the unique value. This is capped at 127 such that the most significant bit of the mode byte can be used to indicate static content.


id

protected IDBytes id
The id data.

Constructor Detail

ContentID

protected ContentID(IDBytes id)
Intializes contents from provided bytes.

Parameters:
id - the ID data

ContentID

protected ContentID()
Internal constructor.


ContentID

protected ContentID(PeerGroupID groupID)
Internal constructor.


ContentID

protected ContentID(PeerGroupID groupID,
                    UUID indexUUID)
Internal constructor.


ContentID

public ContentID(PeerGroupID groupID,
                 boolean contentIsStatic)
See IDFactory.Instantiator.newContentID(net.jxta.peergroup.PeerGroupID,boolean).


ContentID

public ContentID(PeerGroupID groupID,
                 boolean contentIsStatic,
                 byte[] indexSeed)
See IDFactory.Instantiator.newContentID(net.jxta.peergroup.PeerGroupID,boolean,byte[]).


ContentID

public ContentID(PeerGroupID groupID,
                 boolean contentIsStatic,
                 InputStream indexSeed)
          throws IOException
See IDFactory.Instantiator.newContentID(net.jxta.peergroup.PeerGroupID,boolean,InputStream).

Throws:
IOException

ContentID

public ContentID(PeerGroupID groupID,
                 boolean contentIsStatic,
                 byte[] indexSeed,
                 byte[] variant)
See IDFactory.Instantiator.newContentID(net.jxta.peergroup.PeerGroupID,boolean,byte[],byte[]).


ContentID

public ContentID(PeerGroupID groupID,
                 boolean contentIsStatic,
                 InputStream indexSeed,
                 byte[] variant)
          throws IOException
See IDFactory.Instantiator.newContentID(net.jxta.peergroup.PeerGroupID,boolean,InputStream,byte[]).

Throws:
IOException

ContentID

public ContentID(PeerGroupID groupID,
                 boolean contentIsStatic,
                 byte[] indexSeed,
                 InputStream variant)
          throws IOException
See IDFactory.Instantiator.newContentID(net.jxta.peergroup.PeerGroupID,boolean,byte[],InputStream).

Throws:
IOException

ContentID

public ContentID(PeerGroupID groupID,
                 boolean contentIsStatic,
                 InputStream indexSeed,
                 InputStream variant)
          throws IOException
See IDFactory.Instantiator.newContentID(net.jxta.peergroup.PeerGroupID,boolean,InputStream,InputStream).

Throws:
IOException
Method Detail

getVariantValue

public Object getVariantValue()
Returns an object containing the value of the variant portion of this 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.

Specified by:
getVariantValue in class ContentID
Returns:
Object which can provide canonical representations of the variant value

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 Content ID belongs.

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

isStatic

public boolean isStatic()
Returns true if this ContentID is associated with a static Content.

Specified by:
isStatic in class ContentID
Returns:
true if the contentId is for a Content instance with static content, otherwise false.

JXSE