Class ConcatBytes

  • All Implemented Interfaces:
    Bytes

    public final class ConcatBytes
    extends AbstractBytes
    Implementation of Bytes backed by a list of Bytes instances.
    • Method Detail

      • size

        public int size()
        Description copied from interface: Bytes
        Returns number of bytes in this Bytes.
        Returns:
        number of bytes in this Bytes
      • byteAt

        public byte byteAt​(int index)
        Description copied from interface: Bytes
        Returns byte at the specified index.
        Parameters:
        index - (zero-based) index
        Returns:
        byte at the specified index
      • toByteArray

        public byte[] toByteArray()
        Description copied from interface: Bytes
        Converts this Bytes to array of bytes. This operation always copying and allocation of a new byte array.
        Returns:
        new array containing data of this Bytes.
      • toReadOnlyByteBuffer

        public java.nio.ByteBuffer toReadOnlyByteBuffer()
        Description copied from interface: Bytes
        Converts this Bytes to read-only. ByteBuffer. This operation will involve allocation and copying unless the implementation is backed by ByteBuffer.
        Returns:
        read-only ByteBuffer containing data of this Bytes
      • toString

        public java.lang.String toString​(java.nio.charset.Charset charset)
        Description copied from interface: Bytes
        Converts this Bytes to String in the specified charset. This operation has the same characteristics in terms of allocation and copying as Bytes.toByteArray()
        Parameters:
        charset - charset to be used when decoding the bytes
        Returns:
        String decoded from the bytes
      • newInputStream

        public java.io.InputStream newInputStream()
        Description copied from interface: Bytes
        Returns new InputStream that reads data contained in this Bytes.
        Returns:
        new InputStream that reads data contained in this Bytes
      • view

        public Bytes view​(int beginIndex,
                          int endIndex)
        Description copied from interface: Bytes
        Returns Bytes that is a view into this one. The view begins at the specified beginIndex and extends to the byte at index endIndex - 1. Thus the length of the view is endIndex-beginIndex.
        Parameters:
        beginIndex - the beginning index, inclusive
        endIndex - the ending index, exclusive
        Returns:
        the specified view
      • wrap

        public static ConcatBytes wrap​(java.util.List<Bytes> bytesN)
        Wraps existing instances of Bytes and concatenates them.
        Returns:
        new ConcatBytes wrapping the specified Bytes instances