Class ArrayOfByteArraysOutput

  • All Implemented Interfaces:
    RockerOutput<AbstractRockerOutput>

    public class ArrayOfByteArraysOutput
    extends AbstractRockerOutput<ArrayOfByteArraysOutput>
    Output stores a list of references to byte arrays. Extremely optimized for taking static byte arrays (e.g. plain text) and just saving a pointer to it rather than copying it. Optimized for writing bytes vs. Strings. Strings are converted to bytes using the specified charset on each write and then that byte array is internally stored as part of the underlying list. Thus, the output will consist of reused byte arrays as well as new ones when Strings are written to this output.
    • Constructor Detail

      • ArrayOfByteArraysOutput

        public ArrayOfByteArraysOutput​(ContentType contentType,
                                       java.lang.String charsetName)
      • ArrayOfByteArraysOutput

        public ArrayOfByteArraysOutput​(ContentType contentType,
                                       java.nio.charset.Charset charset)
    • Method Detail

      • getArrays

        public java.util.List<byte[]> getArrays()
      • w

        public ArrayOfByteArraysOutput w​(java.lang.String string)
                                  throws java.io.IOException
        Description copied from interface: RockerOutput
        Writes a String to the output. Implementations are responsible for handling the conversion to the correct charset. Note that underlying implementations may be optimized to handle Strings vs. Bytes.
        Parameters:
        string - The string to write
        Returns:
        This output (so builder pattern can be used)
        Throws:
        java.io.IOException - Thrown on exception.
      • toByteArray

        public byte[] toByteArray()
        Expensive operation of allocating a byte array to hold the entire contents of this output and then copying each underlying byte array into this new byte array. Lots of memory copying...
        Returns:
        A new byte array
      • asReadableByteChannel

        public java.nio.channels.ReadableByteChannel asReadableByteChannel()
      • asInputStream

        public java.io.InputStream asInputStream()