Class ArrayBufferInput

  • All Implemented Interfaces:
    MessageBufferInput, java.io.Closeable, java.lang.AutoCloseable

    public class ArrayBufferInput
    extends java.lang.Object
    implements MessageBufferInput
    MessageBufferInput adapter for byte arrays
    • Constructor Detail

      • ArrayBufferInput

        public ArrayBufferInput​(MessageBuffer buf)
      • ArrayBufferInput

        public ArrayBufferInput​(byte[] arr)
      • ArrayBufferInput

        public ArrayBufferInput​(byte[] arr,
                                int offset,
                                int length)
    • Method Detail

      • reset

        public MessageBuffer reset​(MessageBuffer buf)
        Reset buffer. This method returns the old buffer.
        Parameters:
        buf - new buffer. This can be null to make this input empty.
        Returns:
        the old buffer.
      • reset

        public void reset​(byte[] arr)
      • reset

        public void reset​(byte[] arr,
                          int offset,
                          int len)
      • next

        public MessageBuffer next()
        Description copied from interface: MessageBufferInput
        Returns a next buffer to read.

        This method should return a MessageBuffer instance that has data filled in. When this method is called twice, the previously returned buffer is no longer used. Thus implementation of this method can safely discard it. This is useful when it uses a memory pool.

        Specified by:
        next in interface MessageBufferInput
        Returns:
        the next MessageBuffer, or return null if no more buffer is available.
      • close

        public void close()
        Description copied from interface: MessageBufferInput
        Closes the input.

        When this method is called, the buffer previously returned from MessageBufferInput.next() method is no longer used. Thus implementation of this method can safely discard it.

        If the input is already closed then invoking this method has no effect.

        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface MessageBufferInput