org.ccnx.ccn.impl.encoding.XMLDecoder Interface Reference

Each XMLCodec consists effectively of an encoder/decoder pair. More...

Inheritance diagram for org.ccnx.ccn.impl.encoding.XMLDecoder:

org.ccnx.ccn.impl.encoding.BinaryXMLDecoder org.ccnx.ccn.impl.encoding.GenericXMLDecoder org.ccnx.ccn.impl.encoding.TextXMLDecoder org.ccnx.ccn.impl.encoding.BinaryXMLDecoder org.ccnx.ccn.impl.encoding.TextXMLDecoder

List of all members.

Public Member Functions

void beginDecoding (InputStream istream) throws ContentDecodingException
 Initiates top-level decoding, handling any necessary initialization.
void endDecoding () throws ContentDecodingException
 Completes top-level decoding, handling any necessary shutdown.
void readStartDocument () throws ContentDecodingException
 Reads the document start marker, if there is one.
void readEndDocument () throws ContentDecodingException
 Reads the document end marker, if there is one.
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.
void readStartElement (String startTag, TreeMap< String, String > attributes) throws ContentDecodingException
 Reads an expected element start tag from the stream, extracting any attributes that are present on the tag.
void readStartElement (long startTag, TreeMap< String, String > attributes) throws ContentDecodingException
 Reads an expected element start tag from the stream, extracting any attributes that are present on the tag.
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 peekStartElementAsString () throws ContentDecodingException
 Pulls the next tag out of the stream and then resets the stream to the point before that tag.
Long peekStartElementAsLong () throws ContentDecodingException
 Pulls the next tag out of the stream and then resets the stream to the point before that tag.
void readEndElement () throws ContentDecodingException
 Reads an end element from the stream, if this codec has end elements.
String readUTF8Element (String startTag, TreeMap< String, String > attributes) throws ContentDecodingException
 Read a UTF-8 encoded string element from the stream.
String readUTF8Element (long startTag, TreeMap< String, String > attributes) throws ContentDecodingException
 Read a UTF-8 encoded string element from the stream.
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.
byte[] readBinaryElement (String startTag, TreeMap< String, String > attributes) throws ContentDecodingException
 Read a binary element from the stream.
byte[] readBinaryElement (long startTag, TreeMap< String, String > attributes) throws ContentDecodingException
 Read a binary element from the stream.
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.
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.
CCNTime readDateTime (String startTag) throws ContentDecodingException
 Read and parse a timestamp from the stream.
CCNTime readDateTime (long startTag) throws ContentDecodingException
 Read and parse a timestamp from the stream.
String readUString () throws ContentDecodingException
 Read UTF-8 string data starting from beginning of element (text element in text XML, type/value for UDATA in binary, etc).
byte[] readBlob () throws ContentDecodingException
 Read BLOB data starting from beginning of element (encoded binary element in text XML, type/value for BLOB in binary, etc).
void pushXMLDictionary (XMLDictionary dictionary)
 Some codecs use a dictionary to make encoding and decoding more efficient.
XMLDictionary popXMLDictionary ()
 Some codecs use a dictionary to make encoding and decoding more efficient.
InputStream getInputStream ()
 Get the decoder's input stream - needed for error recovery.


Detailed Description

Each XMLCodec consists effectively of an encoder/decoder pair.

The decoder implements this interface, the encoder must implement XMLEncoder. These do the work of encoding or decoding content. The ccnb binary encoding supports only a number of simple types, all codecs are limited to these same types for simplicity.


Member Function Documentation

void org.ccnx.ccn.impl.encoding.XMLDecoder.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

Implemented in org.ccnx.ccn.impl.encoding.GenericXMLDecoder.

void org.ccnx.ccn.impl.encoding.XMLDecoder.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

Implemented in org.ccnx.ccn.impl.encoding.GenericXMLDecoder.

void org.ccnx.ccn.impl.encoding.XMLDecoder.readStartDocument (  )  throws ContentDecodingException

Reads the document start marker, if there is one.

Exceptions:
ContentDecodingException if there is an error in decoding

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

void org.ccnx.ccn.impl.encoding.XMLDecoder.readEndDocument (  )  throws ContentDecodingException

Reads the document end marker, if there is one.

Exceptions:
ContentDecodingException if there is an error in decoding

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

void org.ccnx.ccn.impl.encoding.XMLDecoder.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

Implemented in org.ccnx.ccn.impl.encoding.GenericXMLDecoder.

void org.ccnx.ccn.impl.encoding.XMLDecoder.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

Implemented in org.ccnx.ccn.impl.encoding.GenericXMLDecoder.

void org.ccnx.ccn.impl.encoding.XMLDecoder.readStartElement ( String  startTag,
TreeMap< String, String >  attributes 
) throws ContentDecodingException

Reads an expected element start tag from the stream, extracting any attributes that are present on the tag.

Parameters:
startTag next tag we expect to occur
attributes map into which we store (attribute, value) pairs
Exceptions:
ContentDecodingException if that tag does not occur, or another error is encountered

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

void org.ccnx.ccn.impl.encoding.XMLDecoder.readStartElement ( long  startTag,
TreeMap< String, String >  attributes 
) throws ContentDecodingException

Reads an expected element start tag from the stream, extracting any attributes that are present on the tag.

Parameters:
startTag next tag we expect to occur
attributes map into which we store (attribute, value) pairs
Exceptions:
ContentDecodingException if that tag does not occur, or another error is encountered

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

boolean org.ccnx.ccn.impl.encoding.XMLDecoder.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

Implemented in org.ccnx.ccn.impl.encoding.GenericXMLDecoder.

boolean org.ccnx.ccn.impl.encoding.XMLDecoder.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

Implemented in org.ccnx.ccn.impl.encoding.GenericXMLDecoder.

String org.ccnx.ccn.impl.encoding.XMLDecoder.peekStartElementAsString (  )  throws ContentDecodingException

Pulls the next tag out of the stream and then resets the stream to the point before that tag.

Requires the underlying stream to return true from InputStream.markSupported().

Returns:
the next tag found
Exceptions:
ContentDecodingException if there is an error reading the stream or decoding the tag

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

Long org.ccnx.ccn.impl.encoding.XMLDecoder.peekStartElementAsLong (  )  throws ContentDecodingException

Pulls the next tag out of the stream and then resets the stream to the point before that tag.

Requires the underlying stream to return true from InputStream.markSupported().

Returns:
the next tag found, or null if not a start element
Exceptions:
ContentDecodingException if there is an error reading the stream or decoding the tag

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

void org.ccnx.ccn.impl.encoding.XMLDecoder.readEndElement (  )  throws ContentDecodingException

Reads an end element from the stream, if this codec has end elements.

Exceptions:
ContentDecodingException if the next element in the stream is not an end element, or there is another error reading

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

String org.ccnx.ccn.impl.encoding.XMLDecoder.readUTF8Element ( String  startTag,
TreeMap< String, String >  attributes 
) throws ContentDecodingException

Read a UTF-8 encoded string element from the stream.

Parameters:
startTag expected start tag
attributes will be used to hold attributes on this tag, if there are any
Returns:
the decoded String
Exceptions:
ContentDecodingException if startTag is not the next tag in the stream, or there is an error decoding the element

Implemented in org.ccnx.ccn.impl.encoding.GenericXMLDecoder.

String org.ccnx.ccn.impl.encoding.XMLDecoder.readUTF8Element ( long  startTag,
TreeMap< String, String >  attributes 
) throws ContentDecodingException

Read a UTF-8 encoded string element from the stream.

Parameters:
startTag expected start tag
attributes will be used to hold attributes on this tag, if there are any
Returns:
the decoded String
Exceptions:
ContentDecodingException if startTag is not the next tag in the stream, or there is an error decoding the element

Implemented in org.ccnx.ccn.impl.encoding.GenericXMLDecoder.

String org.ccnx.ccn.impl.encoding.XMLDecoder.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

Implemented in org.ccnx.ccn.impl.encoding.GenericXMLDecoder.

String org.ccnx.ccn.impl.encoding.XMLDecoder.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

Implemented in org.ccnx.ccn.impl.encoding.GenericXMLDecoder.

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

Read a binary element from the stream.

Parameters:
startTag expected start tag
attributes will be used to hold attributes on this tag, if there are any
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

Implemented in org.ccnx.ccn.impl.encoding.GenericXMLDecoder.

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

Read a binary element from the stream.

Parameters:
startTag expected start tag
attributes will be used to hold attributes on this tag, if there are any
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

Implemented in org.ccnx.ccn.impl.encoding.GenericXMLDecoder.

byte [] org.ccnx.ccn.impl.encoding.XMLDecoder.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

Implemented in org.ccnx.ccn.impl.encoding.GenericXMLDecoder.

byte [] org.ccnx.ccn.impl.encoding.XMLDecoder.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

Implemented in org.ccnx.ccn.impl.encoding.GenericXMLDecoder.

long org.ccnx.ccn.impl.encoding.XMLDecoder.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

Implemented in org.ccnx.ccn.impl.encoding.GenericXMLDecoder.

long org.ccnx.ccn.impl.encoding.XMLDecoder.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

Implemented in org.ccnx.ccn.impl.encoding.GenericXMLDecoder.

int org.ccnx.ccn.impl.encoding.XMLDecoder.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

Implemented in org.ccnx.ccn.impl.encoding.GenericXMLDecoder.

int org.ccnx.ccn.impl.encoding.XMLDecoder.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

Implemented in org.ccnx.ccn.impl.encoding.GenericXMLDecoder.

CCNTime org.ccnx.ccn.impl.encoding.XMLDecoder.readDateTime ( String  startTag  )  throws ContentDecodingException

Read and parse a timestamp from the stream.

Parameters:
startTag expected start tag
Returns:
the decoded timestamp, using a quantized CCNTime
Exceptions:
ContentDecodingException if startTag is not the next tag in the stream, or there is an error decoding the element or parsing the integer

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

CCNTime org.ccnx.ccn.impl.encoding.XMLDecoder.readDateTime ( long  startTag  )  throws ContentDecodingException

Read and parse a timestamp from the stream.

Parameters:
startTag expected start tag
Returns:
the decoded timestamp, using a quantized CCNTime
Exceptions:
ContentDecodingException if startTag is not the next tag in the stream, or there is an error decoding the element or parsing the integer

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

String org.ccnx.ccn.impl.encoding.XMLDecoder.readUString (  )  throws ContentDecodingException

Read UTF-8 string data starting from beginning of element (text element in text XML, type/value for UDATA in binary, etc).

Consumes the end element (text has to, so we copy).

Returns:
the string
Exceptions:
ContentDecodingException 

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

byte [] org.ccnx.ccn.impl.encoding.XMLDecoder.readBlob (  )  throws ContentDecodingException

Read BLOB data starting from beginning of element (encoded binary element in text XML, type/value for BLOB in binary, etc).

Consumes the end element (text has to, so we copy).

Returns:
the BLOB data
Exceptions:
ContentDecodingException 

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

void org.ccnx.ccn.impl.encoding.XMLDecoder.pushXMLDictionary ( XMLDictionary  dictionary  ) 

Some codecs use a dictionary to make encoding and decoding more efficient.

Those codecs typically load their default dictionary automatically. This call allows a user to manipulate the dictionary stack, adding their own dictionaries to the set used to decode.

Parameters:
dictionary a dictionary to add to the set used for decoding

XMLDictionary org.ccnx.ccn.impl.encoding.XMLDecoder.popXMLDictionary (  ) 

Some codecs use a dictionary to make encoding and decoding more efficient.

Those codecs typically load their default dictionary automatically. This call allows a user to manipulate the dictionary stack, removing the most recently added dictionary from the set used to decode.

Returns:
returns the removed dictionary


The documentation for this interface was generated from the following file:

Generated on Thu Feb 16 00:44:53 2012 for Content-Centric Networking in Java by  doxygen 1.5.6