Interface BufferView.Reader

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int available()
      Gets a value indicating the number of bytes available to read.
      byte readByte()
      Reads one byte and advances the reader position by 1.
      int readBytes​(java.nio.ByteBuffer byteBuffer)
      Reads a number of bytes into the given ByteBuffer using the most efficient method for the implementation of this BufferView.
      ArrayView readFully​(int bufferSize)
      Copies all the remaining bytes from this BufferView.Reader into a new ArrayView.
      int readInt()
      Reads 4 bytes (and advances the reader position by 4) and composes a 32-bit Integer (Big-Endian).
      long readLong()
      Reads 8 bytes (and advances the reader position by 4) and composes a 64-bit Long (Big-Endian).
      BufferView readSlice​(int length)
      Returns a BufferView that is a representation of the next bytes starting at the given position.
    • Method Detail

      • available

        int available()
        Gets a value indicating the number of bytes available to read.
        Returns:
        The number of bytes available to read.
      • readBytes

        int readBytes​(java.nio.ByteBuffer byteBuffer)
        Reads a number of bytes into the given ByteBuffer using the most efficient method for the implementation of this BufferView.
        Parameters:
        byteBuffer - The target ByteBuffer.
        Returns:
        The number of bytes copied. This should be
        Math.min(available(), byteBuffer.remaining())
        . If this returns 0, then either the given ByteBuffer has Buffer.remaining() equal to 0, or there are no more bytes to be read (available() is 0).
      • readSlice

        BufferView readSlice​(int length)
        Returns a BufferView that is a representation of the next bytes starting at the given position. The reader position will be advanced by the requested number of bytes.
        Parameters:
        length - The number of bytes to slice out.
        Returns:
        A BufferView that represents the given bytes. This BufferView represents a view into the underlying BufferView and is not a copy of the given range.
        Throws:
        BufferView.Reader.OutOfBoundsException - If available() is less than length.
      • readFully

        ArrayView readFully​(int bufferSize)
        Copies all the remaining bytes from this BufferView.Reader into a new ArrayView. The reader position will be set to the end of the BufferView.
        Parameters:
        bufferSize - The maximum number of bytes to copy at each iteration. Set to Integer.MAX_VALUE to attempt to copy the whole buffer at once.
        Returns:
        A new ByteArraySegment with the remaining contents of BufferView.Reader.