Interface Output

All Superinterfaces:
ByteOutput
All Known Subinterfaces:
AnnotatedOutput
All Known Implementing Classes:
ByteArrayAnnotatedOutput

public interface Output extends ByteOutput
Interface for a sink for binary output. This is similar to java.util.DataOutput, but no IOExceptions are declared, and multibyte output is defined to be little-endian.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    alignTo(int alignment)
    Adds extra bytes if necessary (with value 0) to force alignment of the output cursor as given.
    void
    assertCursor(int expectedCursor)
    Asserts that the cursor is the given value.
    int
    Gets the current cursor position.
    void
    write(byte[] bytes)
    Writes a byte[] to this instance.
    void
    write(byte[] bytes, int offset, int length)
    Writes a portion of a byte[] to this instance.
    void
    Writes a ByteArray to this instance.
    void
    writeByte(int value)
    Writes a byte to this instance.
    void
    writeInt(int value)
    Writes an int to this instance.
    void
    writeLong(long value)
    Writes a long to this instance.
    void
    writeShort(int value)
    Writes a short to this instance.
    int
    writeSleb128(int value)
    Writes a DWARFv3-style unsigned LEB128 integer.
    int
    writeUleb128(int value)
    Writes a DWARFv3-style unsigned LEB128 integer.
    void
    writeZeroes(int count)
    Writes the given number of 0 bytes.
  • Method Details

    • getCursor

      int getCursor()
      Gets the current cursor position. This is the same as the number of bytes written to this instance.
      Returns:
      >= 0; the cursor position
    • assertCursor

      void assertCursor(int expectedCursor)
      Asserts that the cursor is the given value.
      Parameters:
      expectedCursor - the expected cursor value
      Throws:
      RuntimeException - thrown if getCursor() != expectedCursor
    • writeByte

      void writeByte(int value)
      Writes a byte to this instance.
      Specified by:
      writeByte in interface ByteOutput
      Parameters:
      value - the value to write; all but the low 8 bits are ignored
    • writeShort

      void writeShort(int value)
      Writes a short to this instance.
      Parameters:
      value - the value to write; all but the low 16 bits are ignored
    • writeInt

      void writeInt(int value)
      Writes an int to this instance.
      Parameters:
      value - the value to write
    • writeLong

      void writeLong(long value)
      Writes a long to this instance.
      Parameters:
      value - the value to write
    • writeUleb128

      int writeUleb128(int value)
      Writes a DWARFv3-style unsigned LEB128 integer. For details, see the "Dalvik Executable Format" document or DWARF v3 section 7.6.
      Parameters:
      value - value to write, treated as an unsigned value
      Returns:
      1..5; the number of bytes actually written
    • writeSleb128

      int writeSleb128(int value)
      Writes a DWARFv3-style unsigned LEB128 integer. For details, see the "Dalvik Executable Format" document or DWARF v3 section 7.6.
      Parameters:
      value - value to write
      Returns:
      1..5; the number of bytes actually written
    • write

      void write(ByteArray bytes)
      Writes a ByteArray to this instance.
      Parameters:
      bytes - non-null; the array to write
    • write

      void write(byte[] bytes, int offset, int length)
      Writes a portion of a byte[] to this instance.
      Parameters:
      bytes - non-null; the array to write
      offset - >= 0; offset into bytes for the first byte to write
      length - >= 0; number of bytes to write
    • write

      void write(byte[] bytes)
      Writes a byte[] to this instance. This is just a convenient shorthand for write(bytes, 0, bytes.length).
      Parameters:
      bytes - non-null; the array to write
    • writeZeroes

      void writeZeroes(int count)
      Writes the given number of 0 bytes.
      Parameters:
      count - >= 0; the number of zeroes to write
    • alignTo

      void alignTo(int alignment)
      Adds extra bytes if necessary (with value 0) to force alignment of the output cursor as given.
      Parameters:
      alignment - > 0; the alignment; must be a power of two