Class DeserializerBuffer


  • public class DeserializerBuffer
    extends java.lang.Object
    Deserializing methods
    Since:
    0.1.0
    • Constructor Summary

      Constructors 
      Constructor Description
      DeserializerBuffer​(byte[] bytes)
      Initializes buffer with serialized bytes a byte array
      DeserializerBuffer​(java.lang.String hexString)
      Initializes buffer with serialized bytes from hex-encoded String
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.math.BigInteger readBigInteger()
      Larger numeric values (e.g., U128, U256, U512) serialize as one byte of the length of the next number, followed by the two’s complement representation with little-endian byte order.
      java.lang.Boolean readBool()
      Reads a Boolean value
      byte[] readByteArray​(int length)
      Reads a byte[] from buffer
      protected byte[] readBytes​(int length)
      Reads a specified number of bytes
      float readF32()
      Reads a float of 32 bits (4 bytes)
      double readF64()
      Reads a float of 64 bits (8 bytes)
      int readI32()
      Reads a signed int of 32 bits (4 bytes)
      long readI64()
      Reads a signed int of 64 bits (8 bytes)
      java.lang.String readString()
      Reads a String value from buffer
      java.math.BigInteger readU128()
      Reads an unsigned int of 128 bits (16 bytes) max
      java.math.BigInteger readU256()
      Reads U256 from buffer
      long readU32()
      Reads an unsigned int of 32 bits (4 bytes)
      java.math.BigInteger readU512()
      Reads U512 from buffer
      java.math.BigInteger readU64()
      Reads an unsigned int of 64 bits (8 bytes)
      byte readU8()
      Reads a byte from buffer
      • Methods inherited from class java.lang.Object

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

      • DeserializerBuffer

        public DeserializerBuffer​(byte[] bytes)
        Initializes buffer with serialized bytes a byte array
        Parameters:
        bytes - byte array to deserialize and read from
      • DeserializerBuffer

        public DeserializerBuffer​(java.lang.String hexString)
                           throws InvalidByteStringException
        Initializes buffer with serialized bytes from hex-encoded String
        Parameters:
        hexString - hex-encoded String to deserialize and read from
        Throws:
        InvalidByteStringException - if the byte string is invalid or can't be parsed
    • Method Detail

      • readU8

        public byte readU8()
        Reads a byte from buffer
        Returns:
        the byte
      • readByteArray

        public byte[] readByteArray​(int length)
        Reads a byte[] from buffer
        Parameters:
        length - the length of the array
        Returns:
        the byte array as byte[]
      • readF32

        public float readF32()
        Reads a float of 32 bits (4 bytes)
        Returns:
        the number as a float
      • readF64

        public double readF64()
        Reads a float of 64 bits (8 bytes)
        Returns:
        the number as a double
      • readI32

        public int readI32()
        Reads a signed int of 32 bits (4 bytes)
        Returns:
        the number as an int
      • readU32

        public long readU32()
        Reads an unsigned int of 32 bits (4 bytes)
        Returns:
        the number as a long
      • readI64

        public long readI64()
        Reads a signed int of 64 bits (8 bytes)
        Returns:
        the number as a long
      • readU64

        public java.math.BigInteger readU64()
        Reads an unsigned int of 64 bits (8 bytes)
        Returns:
        the number as a BigInteger
      • readU128

        public java.math.BigInteger readU128()
        Reads an unsigned int of 128 bits (16 bytes) max
        Returns:
        the number as a BigInteger
      • readU256

        public java.math.BigInteger readU256()
        Reads U256 from buffer
        Returns:
        the number as a BigInteger
      • readU512

        public java.math.BigInteger readU512()
        Reads U512 from buffer
        Returns:
        the number as a BigInteger
      • readBigInteger

        protected java.math.BigInteger readBigInteger()
        Larger numeric values (e.g., U128, U256, U512) serialize as one byte of the length of the next number, followed by the two’s complement representation with little-endian byte order.
        Returns:
        the number as a BigInteger
      • readString

        public java.lang.String readString()
        Reads a String value from buffer
        Returns:
        the String read
      • readBytes

        protected byte[] readBytes​(int length)
        Reads a specified number of bytes
        Parameters:
        length - the number of bytes to read
        Returns:
        bytes read