Class NettyDERBuffer

  • All Implemented Interfaces:
    DERBuffer

    final class NettyDERBuffer
    extends Object
    implements DERBuffer
    DERBuffer that uses a ByteBuf. Since ByteBuf does not have the concept of limit the writer index is used to track the limit.
    • Field Detail

      • buffer

        private final io.netty.buffer.ByteBuf buffer
        Underlying byte buffer.
    • Constructor Detail

      • NettyDERBuffer

        NettyDERBuffer​(io.netty.buffer.ByteBuf buf)
        Creates a new netty DER buffer.
        Parameters:
        buf - existing byte buf
      • NettyDERBuffer

        NettyDERBuffer​(io.netty.buffer.ByteBuf buf,
                       int pos,
                       int lim)
        Creates a new netty DER buffer and sets the initial position and limit.
        Parameters:
        buf - existing byte buf
        pos - initial buffer position
        lim - initial buffer limit
    • Method Detail

      • position

        public int position()
        Description copied from interface: DERBuffer
        Returns this buffer's position.
        Specified by:
        position in interface DERBuffer
        Returns:
        position of this buffer
      • position

        public DERBuffer position​(int newPosition)
        Description copied from interface: DERBuffer
        Sets this buffer's position.
        Specified by:
        position in interface DERBuffer
        Parameters:
        newPosition - The new position value; must be non-negative and no larger than the current limit
        Returns:
        This buffer
      • limit

        public int limit()
        Description copied from interface: DERBuffer
        Returns this buffer's limit.
        Specified by:
        limit in interface DERBuffer
        Returns:
        limit of this buffer
      • capacity

        public int capacity()
        Description copied from interface: DERBuffer
        Returns this buffer's capacity.
        Specified by:
        capacity in interface DERBuffer
        Returns:
        capacity of this buffer
      • limit

        public DERBuffer limit​(int newLimit)
        Description copied from interface: DERBuffer
        Sets this buffer's limit.
        Specified by:
        limit in interface DERBuffer
        Parameters:
        newLimit - The new limit value; must be non-negative and no larger than this buffer's capacity
        Returns:
        This buffer
      • clear

        public DERBuffer clear()
        Description copied from interface: DERBuffer
        Sets the position to zero and the limit to the capacity.

        This method does not actually erase the data in the buffer.

        Specified by:
        clear in interface DERBuffer
        Returns:
        This buffer
      • get

        public byte get()
        Description copied from interface: DERBuffer
        Relative get method. Reads the byte at this buffer's current position and then increments the position.
        Specified by:
        get in interface DERBuffer
        Returns:
        byte at the buffer's current position
      • get

        public DERBuffer get​(byte[] dst)
        Description copied from interface: DERBuffer
        Relative bulk get method.
        Specified by:
        get in interface DERBuffer
        Parameters:
        dst - destination array
        Returns:
        This buffer
      • slice

        public DERBuffer slice()
        Description copied from interface: DERBuffer
        Creates a new DER buffer whose content is a shared sub-sequence of this buffer's content.

        The content of the new buffer will start at this buffer's current position. Changes to this buffer's content will be visible in the new buffer, and vice versa; the two buffers' position and limit will be independent.

        The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer.

        Specified by:
        slice in interface DERBuffer
        Returns:
        The new byte buffer