Class ProtonByteBufferAllocator

    • Constructor Detail

      • ProtonByteBufferAllocator

        public ProtonByteBufferAllocator()
    • Method Detail

      • allocate

        public ProtonByteBuffer allocate()
        Description copied from interface: ProtonBufferAllocator
        Create a new ProtonBuffer instance with default initial capacity. The buffer implementation should support growing the buffer on an as needed basis to allow writes without the user needing to code extra capacity and buffer reallocation checks. It is not recommended that these buffers be backed by a pooled resource as there is no defined release point within the buffer API and if used by an AMQP engine they could be lost as buffers are copied or aggregated together.
        Specified by:
        allocate in interface ProtonBufferAllocator
        Returns:
        a new ProtonBuffer instance with default initial capacity.
      • allocate

        public ProtonByteBuffer allocate​(int initialCapacity)
        Description copied from interface: ProtonBufferAllocator
        Create a new ProtonBuffer instance with the given initial capacity and the maximum capacity should be that of the underlying buffer implementations limit. It is not recommended that these buffers be backed by a pooled resource as there is no defined release point within the buffer API and if used by an AMQP engine they could be lost as buffers are copied or aggregated together.
        Specified by:
        allocate in interface ProtonBufferAllocator
        Parameters:
        initialCapacity - The initial capacity to use when creating the new ProtonBuffer.
        Returns:
        a new ProtonBuffer instance with the given initial capacity.
      • allocate

        public ProtonByteBuffer allocate​(int initialCapacity,
                                         int maximumCapacity)
        Description copied from interface: ProtonBufferAllocator
        Create a new ProtonBuffer instance with the given initial capacity and the maximum capacity should that of the value specified by the caller. It is not recommended that these buffers be backed by a pooled resource as there is no defined release point within the buffer API and if used by an AMQP engine they could be lost as buffers are copied or aggregated together.
        Specified by:
        allocate in interface ProtonBufferAllocator
        Parameters:
        initialCapacity - The initial capacity to use when creating the new ProtonBuffer.
        maximumCapacity - The largest amount of bytes the new ProtonBuffer is allowed to grow to.
        Returns:
        a new ProtonBuffer instance with the given initial capacity.
      • outputBuffer

        public ProtonBuffer outputBuffer​(int initialCapacity)
        Description copied from interface: ProtonBufferAllocator
        Create a new output ProtonBuffer instance with the given initial capacity and the maximum capacity should be that of the underlying buffer implementations limit. The buffer implementation should support growing the buffer on an as needed basis to allow writes without the user needing to code extra capacity and buffer reallocation checks.

        The returned buffer will be used for frame output from the Proton engine and can be a pooled buffer which the IO handler will then need to release once the buffer has been written.

        Specified by:
        outputBuffer in interface ProtonBufferAllocator
        Parameters:
        initialCapacity - The initial capacity to use when creating the new ProtonBuffer.
        Returns:
        a new ProtonBuffer instance with the given initial capacity.
      • outputBuffer

        public ProtonBuffer outputBuffer​(int initialCapacity,
                                         int maximumCapacity)
        Description copied from interface: ProtonBufferAllocator
        Create a new output ProtonBuffer instance with the given initial capacity and the maximum capacity should that of the value specified by the caller.

        The returned buffer will be used for frame output from the Proton engine and can be a pooled buffer which the IO handler will then need to release once the buffer has been written.

        Specified by:
        outputBuffer in interface ProtonBufferAllocator
        Parameters:
        initialCapacity - The initial capacity to use when creating the new ProtonBuffer.
        maximumCapacity - The largest amount of bytes the new ProtonBuffer is allowed to grow to.
        Returns:
        a new ProtonBuffer instance with the given initial capacity.
      • wrap

        public ProtonBuffer wrap​(byte[] array)
        Description copied from interface: ProtonBufferAllocator
        Create a new ProtonBuffer that wraps the given byte array.

        The capacity and maximum capacity for the resulting ProtonBuffer should equal to the length of the wrapped array and the returned array offset is zero.

        Specified by:
        wrap in interface ProtonBufferAllocator
        Parameters:
        array - the byte array to wrap.
        Returns:
        a new ProtonBuffer that wraps the given array.
      • wrap

        public ProtonBuffer wrap​(byte[] array,
                                 int offset,
                                 int length)
        Description copied from interface: ProtonBufferAllocator
        Create a new ProtonBuffer that wraps the given byte array using the provided offset and length values to confine the view of that array. The maximum capacity of the buffer should be that of the length of the wrapped array.

        The capacity and maximum capacity for the resulting ProtonBuffer should equal to the length parameter provided and the returned buffer offset will be zero.

        Specified by:
        wrap in interface ProtonBufferAllocator
        Parameters:
        array - the byte array to wrap.
        offset - the offset into the array where the view begins.
        length - the number of bytes in the array to expose
        Returns:
        a new ProtonBuffer that wraps the given array.
      • wrap

        public ProtonBuffer wrap​(ByteBuffer buffer)
        Description copied from interface: ProtonBufferAllocator
        Create a new ProtonBuffer that wraps the given ByteBuffer. The maximum capacity of the returned buffer should be same as the remaining bytes within the wrapped ByteBuffer.

        The capacity and maximum capacity of the returned ProtonBuffer will be the same as that of the underlying ByteBuffer. The ProtonBuffer will return true from the ProtonBuffer.hasArray() method only when the wrapped ByteBuffer reports that it is backed by an array.

        Specified by:
        wrap in interface ProtonBufferAllocator
        Parameters:
        buffer - the ByteBuffer to wrap.
        Returns:
        a new ProtonBuffer that wraps the given ByteBuffer.