org.ccnx.ccn.io.content.Header Class Reference

A Header is a set of metadata describing a particular CCN stream; basically it provides summary file-level information about that set of content. More...

List of all members.

Classes

class  HeaderObject
 A CCNNetworkObject wrapper around Header, used for easily saving and retrieving versioned Headers to CCN. More...

Public Types

enum  SegmentationType { SIMPLE_BLOCK }

Public Member Functions

 Header (long start, long count, int blockSize, long length, byte[] contentDigest, byte[] rootDigest)
 Basic constructor for content sequence headers.
 Header (long length, byte[] contentDigest, byte[] rootDigest, int blockSize)
 Basic constructor for content sequences.
 Header ()
 For decoders.
long start ()
long count ()
int blockSize ()
long length ()
byte[] rootDigest ()
byte[] contentDigest ()
SegmentationType type ()
void type (SegmentationType type)
String typeName ()
void decode (XMLDecoder decoder) throws ContentDecodingException
 Decode this object as the top-level item in a new XML document, reading it from a network buffer.
void encode (XMLEncoder encoder) throws ContentEncodingException
 Encode this object during an ongoing encoding pass; this is what subclasses generally need to know how to implement.
long getElementLabel ()
 Allow the encoder/decoder to retrieve the top-level element name programmatically.
boolean validate ()
 Make sure all of the necessary fields are filled in prior to attempting to encode.
int hashCode ()
boolean equals (Object obj)
int[] positionToSegmentLocation (long position)
long segmentLocationToPosition (long block, int offset)
int segmentCount ()
int segmentRemainder ()
 Length of last block.

Static Public Member Functions

static String typeToName (SegmentationType type)
static SegmentationType nameToType (String name)

Protected Attributes

long _start
 Specific to simple block fragmentation.
long _count
long _blockSize
long _length
SegmentationType _type
 Generic.
byte[] _contentDigest
byte[] _rootDigest

Static Protected Attributes

static final HashMap
< SegmentationType, String > 
SegmentationTypeNames = new HashMap<SegmentationType, String>()
static final HashMap< String,
SegmentationType > 
SegmentationNameTypes = new HashMap<String, SegmentationType>()

Static Package Functions

 [static initializer]

Detailed Description

A Header is a set of metadata describing a particular CCN stream; basically it provides summary file-level information about that set of content.

It is usually stored and read by CCNFileOutputStream and CCNFileInputStream and their subclasses, rather than being created directly by clients.

A number of the segmentation-related definitions currently found in Header will eventually move to the SegmentationProfile.


Constructor & Destructor Documentation

org.ccnx.ccn.io.content.Header.Header ( long  start,
long  count,
int  blockSize,
long  length,
byte[]  contentDigest,
byte[]  rootDigest 
)

Basic constructor for content sequence headers.

Parameters:
start The starting byte offset for this file.
count The number of blocks.
blockSize The size of blocks (in bytes).
length The total length of the stream.
contentDigest For convenience, the digest of the unsegmented content.
rootDigest The root digest of the bulk signature tree for the content (Merkle Hash Tree). This turns out to be less useful than you'd think as there are typically multiple MHT's per file, and is likely to be removed.
org.ccnx.ccn.io.content.Header.Header ( long  length,
byte[]  contentDigest,
byte[]  rootDigest,
int  blockSize 
)

Basic constructor for content sequences.

Parameters:
length The total length of the stream.
contentDigest For convenience, the digest of the unsegmented content.
rootDigest The root digest of the bulk signature tree for the content (Merkle Hash Tree). This turns out to be less useful than you'd think as there are typically multiple MHT's per file, and is likely to be removed.
blockSize The size of blocks (in bytes).

Member Function Documentation

void org.ccnx.ccn.io.content.Header.decode ( XMLDecoder  decoder  )  throws ContentDecodingException [virtual]

Decode this object as the top-level item in a new XML document, reading it from a network buffer.

Reads document start and end. Assumes default encoding.

Parameters:
buf input stream to read from
Exceptions:
ContentDecodingException if there is an error decoding the content Decode this object as the top-level item in a new XML document, reading it from a network buffer. Reads document start and end.
Parameters:
buf input stream to read from
codec the codec to use; must be recognized by XMLCodecFactory
Exceptions:
ContentDecodingException if there is an error decoding the content
See also:
XMLCodecFactory Decode this object during an ongoing decoding pass; this is what subclasses generally need to know how to implement. Reads just the object itself, higher-level processes have handled start and end document if need be. Allows object to be read using the same code whether it is a top-level element written alone, or nested inside another element.
Parameters:
decoder the decoder being used; encapsulates state including the codec being used as well as the input source and current offset

Implements org.ccnx.ccn.impl.encoding.GenericXMLEncodable.

void org.ccnx.ccn.io.content.Header.encode ( XMLEncoder  encoder  )  throws ContentEncodingException [virtual]

Encode this object during an ongoing encoding pass; this is what subclasses generally need to know how to implement.

Writes just the object itself, higher-level processes have handled start and end document if need be. Allows object to be written using the same code whether it is a top-level element written alone, or nested inside another element.

Parameters:
encoder the encoder being used; encapsulates state including the codec being used as well as the output destination and current offset

Implements org.ccnx.ccn.impl.encoding.GenericXMLEncodable.

long org.ccnx.ccn.io.content.Header.getElementLabel (  )  [virtual]

Allow the encoder/decoder to retrieve the top-level element name programmatically.

This allows subclasses to rename elements without changing their encoder/decoders.

Returns:
the element label to use, as a key in a loaded encoding dictionary

Implements org.ccnx.ccn.impl.encoding.GenericXMLEncodable.

int org.ccnx.ccn.io.content.Header.segmentRemainder (  ) 

Length of last block.

Returns:
boolean org.ccnx.ccn.io.content.Header.validate (  )  [virtual]

Make sure all of the necessary fields are filled in prior to attempting to encode.

All implementations of encode(XMLEncoder) should call this for their classes prior to encoding.

Returns:
true if object is valid and can be encoded, false if there is a problem; for example mandatory fields are uninitialized

Implements org.ccnx.ccn.impl.encoding.GenericXMLEncodable.


The documentation for this class was generated from the following file:
Generated on Fri May 13 16:27:45 2011 for Content-Centric Networking in Java by  doxygen 1.6.3