Class IntegerLEB128

java.lang.Object
com.pnfsoftware.jeb.util.encoding.IntegerLEB128

public class IntegerLEB128 extends Object
Read and write LEB128-encoded integers. A 4-byte integer is encoded on 1 to 5 bytes.

For decoding only on byte arrays, use the highest-level utility methods in LEB128.

  • Constructor Details

    • IntegerLEB128

      public IntegerLEB128()
  • Method Details

    • writeULEB128

      public static void writeULEB128(OutputStream out, int v) throws IOException
      Write an unsigned LEB128-encoded 32-bit integer.
      Parameters:
      out - output stream
      v - value to encode
      Throws:
      IOException - if the output stream cannot be written
    • readULEB128

      public static int readULEB128(InputStream input) throws IOException
      Read an unsigned LEB128-encoded 32-bit integer.
      Parameters:
      input - input stream positioned at the encoded value
      Returns:
      decoded value
      Throws:
      IOException - if the value is malformed or cannot be fully read
    • decodeULEB128

      public static IntegerLEB128.DecodedInt decodeULEB128(InputStream input) throws IOException
      Read an unsigned LEB128-encoded 32-bit integer and its encoded size.
      Parameters:
      input - input stream positioned at the encoded value
      Returns:
      decoded value and encoded byte length
      Throws:
      IOException - if the value is malformed or cannot be fully read
    • writeSLEB128

      public static void writeSLEB128(OutputStream out, int v) throws IOException
      Write a signed LEB128-encoded 32-bit integer.
      Parameters:
      out - output stream
      v - value to encode
      Throws:
      IOException - if the output stream cannot be written