Interface LEB128Writer


  • public interface LEB128Writer
    • Method Detail

      • reset

        void reset()
        Reset the writer. Discard any collected data and set position to 0.
      • writeChar

        LEB128Writer writeChar​(char data)
        Write Character data in LEB128 encoding
        Parameters:
        data - the data
        Returns:
        the writer instance for chaining
      • writeChar

        long writeChar​(long offset,
                       char data)
        Write Character data in LEB128 encoding at the given offset
        Parameters:
        offset - the offset from which to start writing the data
        data - the data
        Returns:
        the writer position after the data has been written
      • writeShort

        LEB128Writer writeShort​(short data)
        Write Short data in LEB128 encoding
        Parameters:
        data - the data
        Returns:
        the writer instance for chaining
      • writeShort

        long writeShort​(long offset,
                        short data)
        Write Short data in LEB128 encoding at the given offset
        Parameters:
        offset - the offset from which to start writing the data
        data - the data
        Returns:
        the writer position after the data has been written
      • writeInt

        LEB128Writer writeInt​(int data)
        Write Integer data in LEB128 encoding
        Parameters:
        data - the data
        Returns:
        the writer instance for chaining
      • writeInt

        long writeInt​(long offset,
                      int data)
        Write Integer data in LEB128 encoding at the given offset
        Parameters:
        offset - the offset from which to start writing the data
        data - the data
        Returns:
        the writer position after the data has been written
      • writeLong

        LEB128Writer writeLong​(long data)
        Write Long data in LEB128 encoding
        Parameters:
        data - the data
        Returns:
        the writer instance for chaining
      • writeLong

        long writeLong​(long offset,
                       long data)
        Write Long data in LEB128 encoding at the given offset
        Parameters:
        offset - the offset from which to start writing the data
        data - the data
        Returns:
        the writer position after the data has been written
      • writeFloat

        LEB128Writer writeFloat​(float data)
        Write Float data in default Java encoding
        Parameters:
        data - the data
        Returns:
        the writer instance for chaining
      • writeFloat

        long writeFloat​(long offset,
                        float data)
        Write Float data in default Java encoding at the given offset
        Parameters:
        offset - the offset from which to start writing the data
        data - the data
        Returns:
        the writer position after the data has been written
      • writeDouble

        LEB128Writer writeDouble​(double data)
        Write Double data in default Java encoding
        Parameters:
        data - the data
        Returns:
        the writer instance for chaining
      • writeDouble

        long writeDouble​(long offset,
                         double data)
        Write Double data in default Java encoding at the given offset
        Parameters:
        offset - the offset from which to start writing the data
        data - the data
        Returns:
        the writer position after the data has been written
      • writeBoolean

        LEB128Writer writeBoolean​(boolean data)
        Write Boolean data in default Java encoding
        Parameters:
        data - the data
        Returns:
        the writer instance for chaining
      • writeBoolean

        long writeBoolean​(long offset,
                          boolean data)
        Write Boolean data in default Java encoding at the given offset
        Parameters:
        offset - the offset from which to start writing the data
        data - the data
        Returns:
        the writer position after the data has been written
      • writeByte

        LEB128Writer writeByte​(byte data)
        Write Byte data
        Parameters:
        data - the data
        Returns:
        the writer instance for chaining
      • writeByte

        long writeByte​(long offset,
                       byte data)
        Write Byte data at the given offset
        Parameters:
        offset - the offset from which to start writing the data
        data - the data
        Returns:
        the writer position after the data has been written
      • writeBytes

        LEB128Writer writeBytes​(byte... data)
        Write an array of Byte elements
        Parameters:
        data - the data
        Returns:
        the writer instance for chaining
      • writeBytes

        long writeBytes​(long offset,
                        byte... data)
        Write an array of Byte elements at the given offset
        Parameters:
        offset - the offset from which to start writing the data
        data - the data
        Returns:
        the writer position after the data has been written
      • writeUTF

        LEB128Writer writeUTF​(String data)
        Write String as a sequence of bytes representing UTF8 encoded string. The sequence starts with LEB128 encoded int for the length of the sequence followed by the sequence bytes.
        Parameters:
        data - the data
        Returns:
        the writer instance for chaining
      • writeUTF

        LEB128Writer writeUTF​(byte[] utf8Data)
        Write String byte array data as a sequence of bytes representing UTF8 encoded string. The sequence starts with LEB128 encoded int for the length of the sequence followed by the sequence bytes.
        Parameters:
        utf8Data - the byte array representation of an UTF8 string
        Returns:
        the writer instance for chaining
      • writeUTF

        long writeUTF​(long offset,
                      String data)
        Write String as a sequence of bytes representing UTF8 encoded string at the given offset. The sequence starts with LEB128 encoded int for the length of the sequence followed by the sequence bytes.
        Parameters:
        offset - the offset from which to start writing the data
        data - the data
        Returns:
        the writer position after the data has been written
      • writeUTF

        long writeUTF​(long offset,
                      byte[] utf8Data)
        Write String byte array data at the given offset. The sequence starts with LEB128 encoded int for the length of the sequence followed by the sequence bytes.
        Parameters:
        offset - the offset from which to start writing the data
        utf8Data - the byte array representation of an UTF8 string
        Returns:
        the writer position after the data has been written
      • writeCompactUTF

        LEB128Writer writeCompactUTF​(byte[] utf8Data)
        Write String byte array data in special encoding. The string will translate to (byte)0 for null value, (byte)1 for empty string and (byte)3 for the sequence of bytes representing UTF8 encoded string. The sequence starts with LEB128 encoded int for the length of the sequence followed by the sequence bytes.
        Parameters:
        utf8Data - the byte array representation of an UTF8 string
        Returns:
        the writer instance for chaining
      • writeCompactUTF

        long writeCompactUTF​(long offset,
                             byte[] utf8Data)
        Write String as a sequence of bytes representing UTF8 encoded string at the given offset. The sequence starts with LEB128 encoded int for the length of the sequence followed by the sequence bytes.
        Parameters:
        offset - the offset from which to start writing the data
        utf8Data - the byte array representation of an UTF8 string
        Returns:
        the writer position after the data has been written
      • writeCompactUTF

        LEB128Writer writeCompactUTF​(String data)
        Write String in special encoding. The string will translate to (byte)0 for null value, (byte)1 for empty string and (byte)3 for the sequence of bytes representing UTF8 encoded string. The sequence starts with LEB128 encoded int for the length of the sequence followed by the sequence bytes.
        Parameters:
        data - the data
        Returns:
        the writer instance for chaining
      • writeCompactUTF

        long writeCompactUTF​(long offset,
                             String data)
        Write String byte array data in special encoding at the given offset. The string will translate to (byte)0 for null value, (byte)1 for empty string and (byte)3 for the sequence of bytes representing UTF8 encoded string. The sequence starts with LEB128 encoded int for the length of the sequence followed by the sequence bytes.
        Parameters:
        offset - the offset from which to start writing the data
        data - the data
        Returns:
        the writer position after the data has been written
      • writeShortRaw

        LEB128Writer writeShortRaw​(short data)
        Write Short data in default Java encoding
        Parameters:
        data - the data
        Returns:
        the writer instance for chaining
      • writeShortRaw

        long writeShortRaw​(long offset,
                           short data)
        Write Short data in default Java encoding at the given offset
        Parameters:
        offset - the offset from which to start writing the data
        data - the data
        Returns:
        the writer position after the data has been written
      • writeIntRaw

        LEB128Writer writeIntRaw​(int data)
        Write Integer data in default Java encoding
        Parameters:
        data - the data
        Returns:
        the writer instance for chaining
      • writeIntRaw

        long writeIntRaw​(long offset,
                         int data)
        Write Integer data in default Java encoding at the given offset
        Parameters:
        offset - the offset from which to start writing the data
        data - the data
        Returns:
        the writer position after the data has been written
      • writeLongRaw

        LEB128Writer writeLongRaw​(long data)
        Write Long data in default Java encoding
        Parameters:
        data - the data
        Returns:
        the writer instance for chaining
      • writeLongRaw

        long writeLongRaw​(long offset,
                          long data)
        Write Long data in default Java encoding at the given offset
        Parameters:
        offset - the offset from which to start writing the data
        data - the data
        Returns:
        the writer position after the data has been written
      • export

        default byte[] export()
        Transfer the written data to a byte array
        Returns:
        byte array containing the written data
      • position

        int position()
        Returns:
        current writer position
      • length

        int length()
        Returns:
        number of bytes written adjusted by the number of bytes necessary to encode the length itself
      • capacity

        int capacity()
        Returns:
        the maximum number of bytes the writer can process