Class LEB128


  • public final class LEB128
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      LEB128()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static long decode​(byte[] bytes, boolean isSigned)
      Decodes a LEB128 number using a byte array and stores it in a long.
      static long decode​(byte[] bytes, int offset, boolean isSigned)
      Decodes a LEB128 number using an offset into a byte array and stores it in a long.
      static long decode​(BinaryReader reader, boolean isSigned)
      Decodes a LEB128 number using a binary reader and stores it in a long.
      static int decode32s​(BinaryReader reader)
      Decode a LEB128 signed number and return it as a java 32 bit int.
      static int decode32u​(BinaryReader reader)
      Decode a LEB128 unsigned number and return it as a java 32 bit int.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LEB128

        public LEB128()
    • Method Detail

      • decode32s

        public static int decode32s​(BinaryReader reader)
                             throws java.io.IOException
        Decode a LEB128 signed number and return it as a java 32 bit int.

        If the value of the number can not fit in the int type, an IOException will be thrown.

        Parameters:
        reader -
        Returns:
        Throws:
        java.io.IOException
      • decode32u

        public static int decode32u​(BinaryReader reader)
                             throws java.io.IOException
        Decode a LEB128 unsigned number and return it as a java 32 bit int.

        If the value of the number can not fit in the positive range of the int type, an IOException will be thrown.

        Parameters:
        reader -
        Returns:
        Throws:
        java.io.IOException
      • decode

        public static long decode​(BinaryReader reader,
                                  boolean isSigned)
                           throws java.io.IOException
        Decodes a LEB128 number using a binary reader and stores it in a long.

        Large unsigned integers that use 64 bits will be returned in java's native 'long' type, which is signed. It is up to the caller to treat the value as unsigned.

        Large integers that use more than 64 bits will cause an IOException to be thrown.

        Parameters:
        reader - the binary reader
        isSigned - true if the value is signed
        Throws:
        java.io.IOException - if an I/O error occurs
      • decode

        public static long decode​(byte[] bytes,
                                  boolean isSigned)
                           throws java.io.IOException
        Decodes a LEB128 number using a byte array and stores it in a long. This function cannot read numbers larger than Long.MAX_VALUE.
        Parameters:
        bytes - the bytes representing the LEB128 number
        isSigned - true if the value is signed
        Throws:
        java.io.IOException
      • decode

        public static long decode​(byte[] bytes,
                                  int offset,
                                  boolean isSigned)
                           throws java.io.IOException
        Decodes a LEB128 number using an offset into a byte array and stores it in a long. This function cannot read numbers larger than Long.MAX_VALUE.
        Parameters:
        bytes - the bytes representing the LEB128 number
        offset - offset into the byte array
        isSigned - true if the value is signed
        Throws:
        java.io.IOException