Class ReadableBuffers.ByteArrayWrapper

    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) byte[] bytes  
      (package private) int end  
      (package private) int mark  
      (package private) int offset  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] array()
      Gets the backing array for this buffer.
      int arrayOffset()
      Gets the offset in the backing array of the current read position.
      boolean hasArray()
      Indicates whether or not this buffer exposes a backing array.
      void mark()
      Marks the current position in this buffer.
      boolean markSupported()
      Indicates whether or not ReadableBuffer.mark() operation is supported for this buffer.
      int readableBytes()
      Gets the current number of readable bytes remaining in this buffer.
      void readBytes​(byte[] dest, int destIndex, int length)
      Reads length bytes from this buffer and writes them to the destination array.
      ReadableBuffers.ByteArrayWrapper readBytes​(int length)
      Reads length bytes from this buffer and returns a new Buffer containing them.
      void readBytes​(java.io.OutputStream dest, int length)
      Reads length bytes from this buffer and writes them to the destination stream.
      void readBytes​(java.nio.ByteBuffer dest)
      Reads from this buffer until the destination's position reaches its limit, and increases the read position by the number of the transferred bytes.
      int readUnsignedByte()
      Reads the next unsigned byte from this buffer and increments the read position by 1.
      void reset()
      Repositions this buffer to the position at the time ReadableBuffer.mark() was last called on this buffer.
      void skipBytes​(int length)
      Increments the read position by the given length.
      • Methods inherited from class java.lang.Object

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

      • offset

        int offset
      • end

        final int end
      • bytes

        final byte[] bytes
      • mark

        int mark
    • Constructor Detail

      • ByteArrayWrapper

        ByteArrayWrapper​(byte[] bytes)
      • ByteArrayWrapper

        ByteArrayWrapper​(byte[] bytes,
                         int offset,
                         int length)
    • Method Detail

      • readableBytes

        public int readableBytes()
        Description copied from interface: ReadableBuffer
        Gets the current number of readable bytes remaining in this buffer.
      • skipBytes

        public void skipBytes​(int length)
        Description copied from interface: ReadableBuffer
        Increments the read position by the given length.
      • readUnsignedByte

        public int readUnsignedByte()
        Description copied from interface: ReadableBuffer
        Reads the next unsigned byte from this buffer and increments the read position by 1.
      • readBytes

        public void readBytes​(byte[] dest,
                              int destIndex,
                              int length)
        Description copied from interface: ReadableBuffer
        Reads length bytes from this buffer and writes them to the destination array. Increments the read position by length.
        Parameters:
        dest - the destination array to receive the bytes.
        destIndex - the starting offset in the destination array.
        length - the number of bytes to be copied.
      • readBytes

        public void readBytes​(java.nio.ByteBuffer dest)
        Description copied from interface: ReadableBuffer
        Reads from this buffer until the destination's position reaches its limit, and increases the read position by the number of the transferred bytes.
        Parameters:
        dest - the destination buffer to receive the bytes.
      • readBytes

        public void readBytes​(java.io.OutputStream dest,
                              int length)
                       throws java.io.IOException
        Description copied from interface: ReadableBuffer
        Reads length bytes from this buffer and writes them to the destination stream. Increments the read position by length. If the required bytes are not readable, throws IndexOutOfBoundsException.
        Parameters:
        dest - the destination stream to receive the bytes.
        length - the number of bytes to be copied.
        Throws:
        java.io.IOException - thrown if any error was encountered while writing to the stream.
      • readBytes

        public ReadableBuffers.ByteArrayWrapper readBytes​(int length)
        Description copied from interface: ReadableBuffer
        Reads length bytes from this buffer and returns a new Buffer containing them. Some implementations may return a Buffer sharing the backing memory with this buffer to prevent copying. However, that means that the returned buffer may keep the (possibly much larger) backing memory in use even after this buffer is closed.
        Parameters:
        length - the number of bytes to contain in returned Buffer.