org.ccnx.ccn.impl.encoding.GenericXMLDecoder Class Reference

This class contains methods for content encoding/decoding common to all or many codecs. More...

List of all members.

Public Member Functions

 GenericXMLDecoder (BinaryXMLDictionary dictionary)
void beginDecoding (InputStream istream) throws ContentDecodingException
 Initiates top-level decoding, handling any necessary initialization.
void initializeDecoding () throws ContentDecodingException
 Default implementation does nothing.
void endDecoding () throws ContentDecodingException
 Completes top-level decoding, handling any necessary shutdown.
void readStartElement (String startTag) throws ContentDecodingException
 Reads an expected element start tag from the stream.
void readStartElement (long startTag) throws ContentDecodingException
 Reads an expected element start tag from the stream.
boolean peekStartElement (String startTag) throws ContentDecodingException
 Peeks ahead in the stream to see if an expected element is next.
boolean peekStartElement (long startTag) throws ContentDecodingException
 Peeks ahead in the stream to see if an expected element is next.
String readUTF8Element (String startTag) throws ContentDecodingException
 Read a UTF-8 encoded string element which has no attributes from the stream.
String readUTF8Element (long startTag) throws ContentDecodingException
 Read a UTF-8 encoded string element which has no attributes from the stream.
String readUTF8Element (String startTag, TreeMap< String, String > attributes) throws ContentDecodingException
 Force low-level readers to all consume the end element, to get behavior matching the text decoder (lowest common denominator); allows us to collapse this level of behavior here.
String readUTF8Element (long startTag, TreeMap< String, String > attributes) throws ContentDecodingException
 Force low-level readers to all consume the end element, to get behavior matching the text decoder (lowest common denominator); allows us to collapse this level of behavior here.
byte[] readBinaryElement (String startTag) throws ContentDecodingException
 Read a binary element with no attributes from the stream.
byte[] readBinaryElement (long startTag) throws ContentDecodingException
 Read a binary element with no attributes from the stream.
byte[] readBinaryElement (String startTag, TreeMap< String, String > attributes) throws ContentDecodingException
 Expect a start tag (label), optional attributes, a BLOB, and an end element.
byte[] readBinaryElement (long startTag, TreeMap< String, String > attributes) throws ContentDecodingException
 Force low-level readers to all consume the end element, to get behavior matching the text decoder (lowest common denominator); allows us to collapse this level of behavior here.
long readLongElement (String startTag) throws ContentDecodingException
 Read and parse a number from the stream.
long readLongElement (long startTag) throws ContentDecodingException
 Read and parse an integer from the stream.
int readIntegerElement (String startTag) throws ContentDecodingException
 Read and parse a number from the stream.
int readIntegerElement (long startTag) throws ContentDecodingException
 Read and parse an integer from the stream.

Protected Attributes

InputStream _istream = null

Detailed Description

This class contains methods for content encoding/decoding common to all or many codecs.


Member Function Documentation

void org.ccnx.ccn.impl.encoding.GenericXMLDecoder.beginDecoding ( InputStream  istream  )  throws ContentDecodingException

Initiates top-level decoding, handling any necessary initialization.

Calls readStartDocment() to read the document start.

Parameters:
istream stream to decode from
Exceptions:
ContentDecodingException if there is an error in decoding

Implements org.ccnx.ccn.impl.encoding.XMLDecoder.

void org.ccnx.ccn.impl.encoding.GenericXMLDecoder.endDecoding (  )  throws ContentDecodingException

Completes top-level decoding, handling any necessary shutdown.

Calls readEndDocment() to read the document end.

Exceptions:
ContentDecodingException if there is an error in decoding

Implements org.ccnx.ccn.impl.encoding.XMLDecoder.

void org.ccnx.ccn.impl.encoding.GenericXMLDecoder.initializeDecoding (  )  throws ContentDecodingException

Default implementation does nothing.

Subclass-specific parser setup.

Reimplemented in org.ccnx.ccn.impl.encoding.BinaryXMLDecoder, and org.ccnx.ccn.impl.encoding.TextXMLDecoder.

boolean org.ccnx.ccn.impl.encoding.GenericXMLDecoder.peekStartElement ( long  startTag  )  throws ContentDecodingException

Peeks ahead in the stream to see if an expected element is next.

Requires the underlying stream to return true from InputStream.markSupported(). Resets the stream to the point at which it was called afterwards

Parameters:
startTag next tag we expect to occur
Returns:
true if that is the next tag, false otherwise
Exceptions:
ContentDecodingException if an error is encountered

Implements org.ccnx.ccn.impl.encoding.XMLDecoder.

boolean org.ccnx.ccn.impl.encoding.GenericXMLDecoder.peekStartElement ( String  startTag  )  throws ContentDecodingException

Peeks ahead in the stream to see if an expected element is next.

Requires the underlying stream to return true from InputStream.markSupported(). Resets the stream to the point at which it was called afterwards

Parameters:
startTag next tag we expect to occur
Returns:
true if that is the next tag, false otherwise
Exceptions:
ContentDecodingException if an error is encountered

Implements org.ccnx.ccn.impl.encoding.XMLDecoder.

byte [] org.ccnx.ccn.impl.encoding.GenericXMLDecoder.readBinaryElement ( String  startTag,
TreeMap< String, String >  attributes 
) throws ContentDecodingException

Expect a start tag (label), optional attributes, a BLOB, and an end element.

Force low-level readers to all consume the end element, to get behavior matching the text decoder (lowest common denominator); allows us to collapse this level of behavior here.

Implements org.ccnx.ccn.impl.encoding.XMLDecoder.

byte [] org.ccnx.ccn.impl.encoding.GenericXMLDecoder.readBinaryElement ( long  startTag  )  throws ContentDecodingException

Read a binary element with no attributes from the stream.

Parameters:
startTag expected start tag
Returns:
the decoded byte array
Exceptions:
ContentDecodingException if startTag is not the next tag in the stream, or there is an error decoding the element

Implements org.ccnx.ccn.impl.encoding.XMLDecoder.

byte [] org.ccnx.ccn.impl.encoding.GenericXMLDecoder.readBinaryElement ( String  startTag  )  throws ContentDecodingException

Read a binary element with no attributes from the stream.

Parameters:
startTag expected start tag
Returns:
the decoded byte array
Exceptions:
ContentDecodingException if startTag is not the next tag in the stream, or there is an error decoding the element

Implements org.ccnx.ccn.impl.encoding.XMLDecoder.

int org.ccnx.ccn.impl.encoding.GenericXMLDecoder.readIntegerElement ( long  startTag  )  throws ContentDecodingException

Read and parse an integer from the stream.

Parameters:
startTag expected start tag
Returns:
the decoded value, or null if content was empty
Exceptions:
ContentDecodingException if startTag is not the next tag in the stream, or there is an error decoding the element or parsing the integer

Implements org.ccnx.ccn.impl.encoding.XMLDecoder.

int org.ccnx.ccn.impl.encoding.GenericXMLDecoder.readIntegerElement ( String  startTag  )  throws ContentDecodingException

Read and parse a number from the stream.

Parameters:
startTag expected start tag
Returns:
the decoded value, or null if content was empty
Exceptions:
ContentDecodingException if startTag is not the next tag in the stream, or there is an error decoding the element or parsing the integer

Implements org.ccnx.ccn.impl.encoding.XMLDecoder.

long org.ccnx.ccn.impl.encoding.GenericXMLDecoder.readLongElement ( long  startTag  )  throws ContentDecodingException

Read and parse an integer from the stream.

Parameters:
startTag expected start tag
Returns:
the decoded value, or null if content was empty
Exceptions:
ContentDecodingException if startTag is not the next tag in the stream, or there is an error decoding the element or parsing the integer

Implements org.ccnx.ccn.impl.encoding.XMLDecoder.

long org.ccnx.ccn.impl.encoding.GenericXMLDecoder.readLongElement ( String  startTag  )  throws ContentDecodingException

Read and parse a number from the stream.

Parameters:
startTag expected start tag
Returns:
the decoded value, or null if content was empty
Exceptions:
ContentDecodingException if startTag is not the next tag in the stream, or there is an error decoding the element or parsing the integer

Implements org.ccnx.ccn.impl.encoding.XMLDecoder.

void org.ccnx.ccn.impl.encoding.GenericXMLDecoder.readStartElement ( long  startTag  )  throws ContentDecodingException

Reads an expected element start tag from the stream.

Parameters:
startTag next tag we expect to occur
Exceptions:
ContentDecodingException if that tag does not occur, or another error is encountered

Implements org.ccnx.ccn.impl.encoding.XMLDecoder.

void org.ccnx.ccn.impl.encoding.GenericXMLDecoder.readStartElement ( String  startTag  )  throws ContentDecodingException

Reads an expected element start tag from the stream.

Parameters:
startTag next tag we expect to occur
Exceptions:
ContentDecodingException if that tag does not occur, or another error is encountered

Implements org.ccnx.ccn.impl.encoding.XMLDecoder.

String org.ccnx.ccn.impl.encoding.GenericXMLDecoder.readUTF8Element ( long  startTag  )  throws ContentDecodingException

Read a UTF-8 encoded string element which has no attributes from the stream.

Parameters:
startTag expected start tag
Returns:
the decoded String
Exceptions:
ContentDecodingException if startTag is not the next tag in the stream, or there is an error decoding the element

Implements org.ccnx.ccn.impl.encoding.XMLDecoder.

String org.ccnx.ccn.impl.encoding.GenericXMLDecoder.readUTF8Element ( String  startTag  )  throws ContentDecodingException

Read a UTF-8 encoded string element which has no attributes from the stream.

Parameters:
startTag expected start tag
Returns:
the decoded String
Exceptions:
ContentDecodingException if startTag is not the next tag in the stream, or there is an error decoding the element

Implements org.ccnx.ccn.impl.encoding.XMLDecoder.


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