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...
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] |
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.
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.
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.
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). |
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.
buf | input stream to read from |
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. |
buf | input stream to read from | |
codec | the codec to use; must be recognized by XMLCodecFactory |
ContentDecodingException | if there is an error decoding the content |
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.
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.
Implements org.ccnx.ccn.impl.encoding.GenericXMLEncodable.
int org.ccnx.ccn.io.content.Header.segmentRemainder | ( | ) |
Length of last block.
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.
Implements org.ccnx.ccn.impl.encoding.GenericXMLEncodable.