Class NettyDataBuffer

  • All Implemented Interfaces:
    DataBuffer

    public final class NettyDataBuffer
    extends java.lang.Object
    implements DataBuffer
    A DataBuffer with the underlying data being a ByteBuf.
    • Constructor Summary

      Constructors 
      Constructor Description
      NettyDataBuffer​(io.netty.buffer.ByteBuf bytebuf)
      Constructor for creating a NettyDataBuffer, by passing a Netty ByteBuf.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getLength()
      Returns the length of the data.
      java.lang.Object getNettyOutput()
      Returns an object for writing to a netty channel.
      java.nio.ByteBuffer getReadOnlyByteBuffer()
      Returns a ByteBuffer for read-only access to the data.
      int readableBytes()  
      void readBytes​(byte[] dst, int dstIndex, int length)
      Transfers this buffer's data to the specified destination starting at the current readerIndex and increases the readerIndex by the number of the transferred bytes (= length).
      void readBytes​(java.io.OutputStream outputStream, int length)
      Transfers this buffer's data to the given stream.
      void readBytes​(java.nio.ByteBuffer outputBuf)
      Transfers this buffer's data to the given ByteBuffer.
      void release()
      Release the Netty ByteBuf.
      • Methods inherited from class java.lang.Object

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

      • NettyDataBuffer

        public NettyDataBuffer​(io.netty.buffer.ByteBuf bytebuf)
        Constructor for creating a NettyDataBuffer, by passing a Netty ByteBuf.
        Parameters:
        bytebuf - The ByteBuf having the data
    • Method Detail

      • getNettyOutput

        public java.lang.Object getNettyOutput()
        Description copied from interface: DataBuffer
        Returns an object for writing to a netty channel.
        Specified by:
        getNettyOutput in interface DataBuffer
        Returns:
        the netty buffer
      • getLength

        public long getLength()
        Description copied from interface: DataBuffer
        Returns the length of the data.
        Specified by:
        getLength in interface DataBuffer
        Returns:
        the length of the data in bytes
      • getReadOnlyByteBuffer

        public java.nio.ByteBuffer getReadOnlyByteBuffer()
        Description copied from interface: DataBuffer
        Returns a ByteBuffer for read-only access to the data.
        Specified by:
        getReadOnlyByteBuffer in interface DataBuffer
        Returns:
        a read-only ByteBuffer representing the data
      • readBytes

        public void readBytes​(byte[] dst,
                              int dstIndex,
                              int length)
        Description copied from interface: DataBuffer
        Transfers this buffer's data to the specified destination starting at the current readerIndex and increases the readerIndex by the number of the transferred bytes (= length).
        Specified by:
        readBytes in interface DataBuffer
        Parameters:
        dst - the destination
        dstIndex - the first index of the destination
        length - the number of bytes to transfer
      • readBytes

        public void readBytes​(java.io.OutputStream outputStream,
                              int length)
                       throws java.io.IOException
        Description copied from interface: DataBuffer
        Transfers this buffer's data to the given stream.
        Specified by:
        readBytes in interface DataBuffer
        Parameters:
        outputStream - the stream to transfer data to
        length - length of the data to be transferred
        Throws:
        java.io.IOException
      • readBytes

        public void readBytes​(java.nio.ByteBuffer outputBuf)
        Description copied from interface: DataBuffer
        Transfers this buffer's data to the given ByteBuffer.
        Specified by:
        readBytes in interface DataBuffer
        Parameters:
        outputBuf - the buffer to transfer data to
      • readableBytes

        public int readableBytes()
        Specified by:
        readableBytes in interface DataBuffer
        Returns:
        the number of readable bytes remaining
      • release

        public void release()
        Release the Netty ByteBuf.
        Specified by:
        release in interface DataBuffer