This reverse encoding algorithm requires a fully materialized IonDatagram
DOM to qualify for use. It uses a single buffer, myBuffer, to hold
the entire binary-encoded data, with an integer, myOffset, to index
the current position to write the bytes.
The algorithm begins by traversing from the last top-level value to the first top-level value. During this traversal, it recursively goes into the nested values of the top-level value being traversed in a similar last-to-first (right-to-left) order.
| Modifier and Type | Field and Description |
|---|---|
| private static final BigInteger | |
| private byte[] | myBuffer
Holds the entire binary encoded data. |
| private IonSystem | |
| private int | myOffset
Index onto the position where the bytes are last written to the buffer. |
| private SymbolTable | mySymbolTable
The symbol table attached to the IonValue (and its nested values) that the encoder is currently traversing on. |
| private static final byte[] | |
| private static final int | |
| private static final byte[] | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv int | Returns: the number of bytes of the byte arrayReturns the size of the Ion binary-encoded byte array. |
| private void | checkLocalSymbolTablePlacement(IonValue
the next top-level IonValue to be encoded nextTopLevelValue)Determine if the local symbol table attached to the previous top-level
value (TLV), |
| private int | |
| private int | Returns: the updated offsetthe original offset offset)Grows the current buffer and returns the updated offset. |
| pack-priv void | serialize(IonDatagram dg)
Serialize the IonDatagram into Ion binary-encoding, to the internal byte array buffer of the encoder. |
| pack-priv void | |
| pack-priv byte[] | Returns: the newly allocated byte arrayCopies the current contents of the Ion binary-encoded byte array into a new byte array. |
| pack-priv int | Returns: the number of bytes copied intodstthe byte array into which bytes are to be written dst)Copies the current contents of the Ion binary-encoded byte array into a a given byte array. |
| pack-priv int | Returns: the number of bytes copied intodstthe byte sub-array into which bytes are to be written dst, int the offset within the sub-array of the first byte to be
written; must be non-negative and no larger
than offset)dst.lengthCopies the current contents of the Ion binary-encoded byte array into a a given byte sub-array. |
| private void | |
| private void | |
| pack-priv int | Returns: the number of bytes written intooutCopies the current contents of the Ion binary-encoded byte array to a specified stream. |
| private void | |
| private void | writeImport(SymbolTable
the shared symbol table, not local, not system symTab)Write a single import declaration (which refers to a shared SymbolTable). |
| private void | writeImportsField(SymbolTable
the local symbol table, not shared, not system symTab)Write import declarations (which refer to shared symbol tables) if any exists. |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | writeIonValue(IonValue value)
Writes the IonValue and its nested values recursively, including annotations. |
| private void | |
| private void | writeLocalSymbolTable(SymbolTable
the local symbol table, not shared, not system symTab)Write contents of a local symbol table as a struct. |
| private void | writePrefix(int
the value's type, a four-bit high-nibble mask type, int the number of bytes (octets) in the body, excluding the prefix
itself length)Writes the prefix (type and length) preceding the body of an encoded value. |
| private void | writeSymbolsField(SymbolTable
the local symbol table, not shared, not system symTab)Write declared local symbol names if any exists. |
| private void | |
| private void | |
| private void |
| MAX_LONG_VALUE | back to summary |
|---|---|
| private static final BigInteger MAX_LONG_VALUE | |
| myBuffer | back to summary |
|---|---|
| private byte[] myBuffer Holds the entire binary encoded data. When IonDatagram is fully encoded into binary data, this byte array will hold that data. | |
| myIonSystem | back to summary |
|---|---|
| private IonSystem myIonSystem | |
| myOffset | back to summary |
|---|---|
| private int myOffset Index onto the position where the bytes are last written to the buffer. That means that if you want to write 1 more byte to the buffer, you have to decrease the index by 1 (myOffset - 1). | |
| mySymbolTable | back to summary |
|---|---|
| private SymbolTable mySymbolTable The symbol table attached to the IonValue (and its nested values) that the encoder is currently traversing on. | |
| negativeZeroBitArray | back to summary |
|---|---|
| private static final byte[] negativeZeroBitArray | |
| NULL_LENGTH_MASK | back to summary |
|---|---|
| private static final int NULL_LENGTH_MASK | |
| positiveZeroBitArray | back to summary |
|---|---|
| private static final byte[] positiveZeroBitArray | |
| TYPE_ANNOTATIONS | back to summary |
|---|---|
| private static final int TYPE_ANNOTATIONS | |
| TYPE_BLOB | back to summary |
|---|---|
| private static final int TYPE_BLOB | |
| TYPE_BOOL | back to summary |
|---|---|
| private static final int TYPE_BOOL | |
| TYPE_CLOB | back to summary |
|---|---|
| private static final int TYPE_CLOB | |
| TYPE_DECIMAL | back to summary |
|---|---|
| private static final int TYPE_DECIMAL | |
| TYPE_FLOAT | back to summary |
|---|---|
| private static final int TYPE_FLOAT | |
| TYPE_LIST | back to summary |
|---|---|
| private static final int TYPE_LIST | |
| TYPE_NEG_INT | back to summary |
|---|---|
| private static final int TYPE_NEG_INT | |
| TYPE_NULL | back to summary |
|---|---|
| private static final int TYPE_NULL | |
| TYPE_POS_INT | back to summary |
|---|---|
| private static final int TYPE_POS_INT | |
| TYPE_SEXP | back to summary |
|---|---|
| private static final int TYPE_SEXP | |
| TYPE_STRING | back to summary |
|---|---|
| private static final int TYPE_STRING | |
| TYPE_STRUCT | back to summary |
|---|---|
| private static final int TYPE_STRUCT | |
| TYPE_SYMBOL | back to summary |
|---|---|
| private static final int TYPE_SYMBOL | |
| TYPE_TIMESTAMP | back to summary |
|---|---|
| private static final int TYPE_TIMESTAMP | |
| ReverseBinaryEncoder | back to summary |
|---|---|
| pack-priv ReverseBinaryEncoder(int initialSize) | |
| byteSize | back to summary |
|---|---|
| pack-priv int byteSize() Returns the size of the Ion binary-encoded byte array.
This makes an unchecked assumption that {
| |
| checkLocalSymbolTablePlacement | back to summary |
|---|---|
| private void checkLocalSymbolTablePlacement(IonValue nextTopLevelValue) Determine if the local symbol table attached to the previous top-level
value (TLV), Connotations of "Previous TLV" and "Next TLV" in this method are different from those defined outside of this method. This is done on purpose within this method to facilitate a clear understanding of what is going on within this method.
The following 4 cases define the scenarios where a LST/IVM is written to the buffer:Next symtab is a local table:
Next symtab is a system table:
IonDatagram#systemIterator() doesn't
retain information about interspersed IVMs within the IonDatagram.
As such, we cannot obtain the location of interspersed IVMs, if any.
| |
| findSid | back to summary |
|---|---|
| private int findSid(SymbolToken symToken) | |
| growBuffer | back to summary |
|---|---|
| private int growBuffer(int offset) Grows the current buffer and returns the updated offset.
| |
| serialize | back to summary |
|---|---|
| pack-priv void serialize(IonDatagram dg) throws IonException Serialize the IonDatagram into Ion binary-encoding, to the internal byte array buffer of the encoder. If the IonDatagram has been modified after this method call, you must call this method again to correctly reflect the modifications. | |
| serialize | back to summary |
|---|---|
| pack-priv void serialize(SymbolTable symTab) throws IonException | |
| toNewByteArray | back to summary |
|---|---|
| pack-priv byte[] toNewByteArray() Copies the current contents of the Ion binary-encoded byte array into a new byte array. The allocates an array of the size needed to exactly hold the output and copies the entire byte array to it.
This makes an unchecked assumption that {
| |
| toNewByteArray | back to summary |
|---|---|
| pack-priv int toNewByteArray(byte[] dst) Copies the current contents of the Ion binary-encoded byte array into a a given byte array. The given array must be large enough to contain all the bytes of the Ion binary-encoded byte array.
This makes an unchecked assumption that {
TODO To be deprecated along with
| |
| toNewByteArray | back to summary |
|---|---|
| pack-priv int toNewByteArray(byte[] dst, int offset) Copies the current contents of the Ion binary-encoded byte array into a a given byte sub-array. The given sub-array must be large enough to contain all the bytes of the Ion binary-encoded byte array.
This makes an unchecked assumption that {
TODO To be deprecated along with
| |
| writeAnnotations | back to summary |
|---|---|
| private void writeAnnotations(IonValue value, int endOfValueOffset) | |
| writeByte | back to summary |
|---|---|
| private void writeByte(int b) | |
| writeBytes | back to summary |
|---|---|
| pack-priv int writeBytes(OutputStream out) throws IOException Copies the current contents of the Ion binary-encoded byte array to a specified stream.
This makes an unchecked assumption that {
| |
| writeBytes | back to summary |
|---|---|
| private void writeBytes(byte[] bytes) | |
| writeImport | back to summary |
|---|---|
| private void writeImport(SymbolTable symTab) Write a single import declaration (which refers to a shared SymbolTable).
| |
| writeImportsField | back to summary |
|---|---|
| private void writeImportsField(SymbolTable symTab) Write import declarations (which refer to shared symbol tables) if any exists.
| |
| writeIonBlobContent | back to summary |
|---|---|
| private void writeIonBlobContent(IonBlob val) | |
| writeIonBoolContent | back to summary |
|---|---|
| private void writeIonBoolContent(IonBool val) | |
| writeIonClobContent | back to summary |
|---|---|
| private void writeIonClobContent(IonClob val) | |
| writeIonDatagramContent | back to summary |
|---|---|
| private void writeIonDatagramContent(IonDatagram dg) | |
| writeIonDecimalContent | back to summary |
|---|---|
| private void writeIonDecimalContent(BigDecimal bd) | |
| writeIonDecimalContent | back to summary |
|---|---|
| private void writeIonDecimalContent(IonDecimal val) | |
| writeIonFloatContent | back to summary |
|---|---|
| private void writeIonFloatContent(IonFloat val) | |
| writeIonIntContent | back to summary |
|---|---|
| private void writeIonIntContent(IonInt val) | |
| writeIonListContent | back to summary |
|---|---|
| private void writeIonListContent(IonList val) | |
| writeIonNullContent | back to summary |
|---|---|
| private void writeIonNullContent() | |
| writeIonSequenceContent | back to summary |
|---|---|
| private void writeIonSequenceContent(IonSequence seq) | |
| writeIonSexpContent | back to summary |
|---|---|
| private void writeIonSexpContent(IonSexp val) | |
| writeIonStringContent | back to summary |
|---|---|
| private void writeIonStringContent(IonString val) | |
| writeIonStringContent | back to summary |
|---|---|
| private void writeIonStringContent(String str) | |
| writeIonStructContent | back to summary |
|---|---|
| private void writeIonStructContent(IonStruct val) | |
| writeIonSymbolContent | back to summary |
|---|---|
| private void writeIonSymbolContent(IonSymbol val) | |
| writeIonTimestampContent | back to summary |
|---|---|
| private void writeIonTimestampContent(IonTimestamp val) | |
| writeIonValue | back to summary |
|---|---|
| private void writeIonValue(IonValue value) throws IonException Writes the IonValue and its nested values recursively, including annotations. | |
| writeLobContent | back to summary |
|---|---|
| private void writeLobContent(byte[] lob) | |
| writeLocalSymbolTable | back to summary |
|---|---|
| private void writeLocalSymbolTable(SymbolTable symTab) Write contents of a local symbol table as a struct. The contents are the IST:: annotation, declared symbols, and import declarations (that refer to shared symtabs) if they exist.
| |
| writePrefix | back to summary |
|---|---|
| private void writePrefix(int type, int length) Writes the prefix (type and length) preceding the body of an encoded value. This method is only called after a value's body is written to the buffer.
| |
| writeSymbolsField | back to summary |
|---|---|
| private void writeSymbolsField(SymbolTable symTab) Write declared local symbol names if any exists.
| |
| writeUInt | back to summary |
|---|---|
| private void writeUInt(long v) | |
| writeVarInt | back to summary |
|---|---|
| private void writeVarInt(int v) Write a VarInt field. VarInts are sequence of bytes. The high-order bit of the last octet is one, indicating the end of the sequence. All other high-order bits must be zero. The second-highest order bit (0x40) is a sign flag in the first octet of the representation, but part of the extension bits for all other octets. Writes at least one byte, even for zero values. int parameter is enough as the scalar and container writers do not have APIs that return long or BigInteger representations. | |
| writeVarUInt | back to summary |
|---|---|
| private void writeVarUInt(int v) Write a VarUInt field. VarUInts are sequence of bytes. The high-order bit of the last octet is one, indicating the end of the sequence. All other high-order bits must be zero. Writes at least one byte, even for zero values. int parameter is enough as the scalar and container writers do not have APIs that return long or BigInteger representations. | |