A highly optimized decoder for wire packets. More...
Public Member Functions | |
final XMLEncodable | getPacket () throws ContentDecodingException |
final void | beginDecoding (InputStream istream) throws ContentDecodingException |
Reset the Decoder's state and start parsing the input stream. | |
String | toString () |
final boolean | peekStartElement (long startTag) throws ContentDecodingException |
Peeks ahead in the stream to see if an expected element is next. | |
final Long | peekStartElementAsLong () throws ContentDecodingException |
Return the value of the current XML_DTAG. | |
final byte[] | readBinary (byte type) throws ContentDecodingException |
As with the BinaryXMLDecoder, this will consume the next END element, which actually closes the preceeding start element, not the Blob's END (blobs don't have an end element). | |
final byte[] | readBinaryElement (long startTag) throws ContentDecodingException |
Advances the parser by 3 elements (start tag, blob, end tag). | |
final byte[] | readBinaryElement (long startTag, TreeMap< String, String > attributes) throws ContentDecodingException |
Advances the parser by 3 elements (start tag, blob, end tag). | |
final 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). | |
CCNTime | readDateTime (long startTag) throws ContentDecodingException |
Read the current tag, ensure its XML_DTAG and matches . | |
void | readEndDocument () throws ContentDecodingException |
Reads the document end marker, if there is one. | |
void | readEndElement () throws ContentDecodingException |
Ensures the current DOM object is XML_CLOSE and advances parser. | |
void | readStartDocument () throws ContentDecodingException |
Reads the document start marker, if there is one. | |
void | readStartElement (long startTag) throws ContentDecodingException |
Read the current DOM element and ensure it matches startTag, otherwise throw ContentDecodingException. | |
void | readStartElement (long startTag, TreeMap< String, String > attributes) throws ContentDecodingException |
Read the current DOM element and ensure it matches startTag, otherwise throw ContentDecodingException. | |
String | readUString () throws ContentDecodingException |
Reads a blob of bytes as UTF-8 data. | |
void | setResyncable (boolean value) |
void | setLimit (int limit) |
String | peekStartElementAsString () throws ContentDecodingException |
Dont use strings! will always throw exception to find any such uses when decoding the wire format. | |
CCNTime | readDateTime (String startTag) throws ContentDecodingException |
Dont use STRINGS when parsing a WIRE PACKET. | |
void | readStartElement (String startTag, TreeMap< String, String > attributes) throws ContentDecodingException |
Dont use strings! will always throw exception to find any such uses when decoding the wire format. | |
Public Attributes | |
final int | RESYNC_LIMIT = 512 |
Protected Attributes | |
int | _resyncLimit = RESYNC_LIMIT |
boolean | _resyncable = false |
A highly optimized decoder for wire packets.
Can be used as an normal XMLDecoder.
It also exposes the segment buffer through getBytes() and the segment DOM via getElement().
TODO:
Notes about resync:
final void org.ccnx.ccn.impl.encoding.BinaryXMLDecoder.beginDecoding | ( | InputStream | istream | ) | throws ContentDecodingException |
Reset the Decoder's state and start parsing the input stream.
Handle resyncing.
istream |
Reimplemented from org.ccnx.ccn.impl.encoding.GenericXMLDecoder.
final boolean org.ccnx.ccn.impl.encoding.BinaryXMLDecoder.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
startTag | next tag we expect to occur |
ContentDecodingException | if an error is encountered |
Reimplemented from org.ccnx.ccn.impl.encoding.GenericXMLDecoder.
final Long org.ccnx.ccn.impl.encoding.BinaryXMLDecoder.peekStartElementAsLong | ( | ) | throws ContentDecodingException |
Return the value of the current XML_DTAG.
This is expected to return NULL if the tag is a CLOSE Does not advance the parser.
ContentDecodingException | if not XML_DTAG or past end of DOM |
Implements org.ccnx.ccn.impl.encoding.XMLDecoder.
final byte [] org.ccnx.ccn.impl.encoding.BinaryXMLDecoder.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).
ContentDecodingException |
Implements org.ccnx.ccn.impl.encoding.XMLDecoder.
CCNTime org.ccnx.ccn.impl.encoding.BinaryXMLDecoder.readDateTime | ( | long | startTag | ) | throws ContentDecodingException |
Read the current tag, ensure its XML_DTAG and matches .
Read a binary blob Read the END tag So, this advances the parser by 3 elements.
Implements org.ccnx.ccn.impl.encoding.XMLDecoder.
void org.ccnx.ccn.impl.encoding.BinaryXMLDecoder.readEndDocument | ( | ) | throws ContentDecodingException |
Reads the document end marker, if there is one.
ContentDecodingException | if there is an error in decoding |
Implements org.ccnx.ccn.impl.encoding.XMLDecoder.
void org.ccnx.ccn.impl.encoding.BinaryXMLDecoder.readStartDocument | ( | ) | throws ContentDecodingException |
Reads the document start marker, if there is one.
ContentDecodingException | if there is an error in decoding |
Implements org.ccnx.ccn.impl.encoding.XMLDecoder.
void org.ccnx.ccn.impl.encoding.BinaryXMLDecoder.readStartElement | ( | long | startTag, | |
TreeMap< String, String > | attributes | |||
) | throws ContentDecodingException |
Read the current DOM element and ensure it matches startTag, otherwise throw ContentDecodingException.
Advances parser.
There are no attributes in the Wire format, so never do anything with .
Implements org.ccnx.ccn.impl.encoding.XMLDecoder.
void org.ccnx.ccn.impl.encoding.BinaryXMLDecoder.readStartElement | ( | long | startTag | ) | throws ContentDecodingException |
Read the current DOM element and ensure it matches startTag, otherwise throw ContentDecodingException.
Advances parser.
Reimplemented from org.ccnx.ccn.impl.encoding.GenericXMLDecoder.
String org.ccnx.ccn.impl.encoding.BinaryXMLDecoder.readUString | ( | ) | throws ContentDecodingException |
Reads a blob of bytes as UTF-8 data.
current element must be XML_UDATA. Consumes the next END element too. Advances parser by 2
Implements org.ccnx.ccn.impl.encoding.XMLDecoder.