Interface Output.EncodedOutput<E extends Exception>

Type Parameters:
E - the exception type
All Superinterfaces:
Output<E>
All Known Subinterfaces:
BufferedEncodedOutput, ByteBufferEncodedOutput, ChunkEncodedOutput<T>, LimitEncodedOutput<T,E>, Output.CloseableEncodedOutput<E>
All Known Implementing Classes:
ByteBufferedOutputStream, ForwardingEncodedOutput, ThresholdEncodedOutput, ThresholdEncodedOutput.OutputStreamThresholdEncodedOutput
Enclosing interface:
Output<E extends Exception>

public static interface Output.EncodedOutput<E extends Exception> extends Output<E>
A specialized Output designed for pre-encoded templates that have already encoded byte arrays to be used directly.

Most template engines traditionally write to an Appendable and as they write to the appendable in a web framework the output is eventually converted to bytes in almost always UTF-8 format. Given that a large majority of templates is static text this encoding can be done apriori which saves some processing time especially if the text contains any non latin1 characters.

Author:
agentgt
  • Method Details

    • write

      void write(byte[] bytes) throws E
      Analogous to OutputStream.write(byte[]). Implementations should not alter the byte array.
      Parameters:
      bytes - already encoded bytes
      Throws:
      E - if an error happens
    • write

      default void write(byte[] bytes, int off, int len) throws E
      Analogous to OutputStream.write(byte[], int, int). Generated templates do not call this method as great care as to be taken to preserve the encoding. It is only provided in the case of future found optimizations and is not currently required.

      The default implementation creates an array copies the data and then calls write(byte[]).

      Parameters:
      bytes - already encoded bytes
      off - offset
      len - length to copy
      Throws:
      E - if an error happens
    • append

      default void append(char c) throws E
      Description copied from interface: Output
      Appends a character to an appendable.
      Specified by:
      append in interface Output<E extends Exception>
      Parameters:
      c - character
      Throws:
      E - if an error happens while writting to the appendable
    • append

      default void append(String s) throws E
      Description copied from interface: Output
      Analogous to Appendable.append(CharSequence) which by default treats the String as a CharSequence.
      Specified by:
      append in interface Output<E extends Exception>
      Parameters:
      s - unlike appendable always non null.
      Throws:
      E - if an error happens while writting to the appendable
    • append

      default void append(CharSequence csq, int start, int end) throws E
      Description copied from interface: Output
      Specified by:
      append in interface Output<E extends Exception>
      Parameters:
      csq - Unlike appendable never null.
      start - start inclusive
      end - end exclusive
      Throws:
      E - if an error happens while writting to the appendable
    • charset

      The charset that the encoded output should be.
      Returns:
      expected charset
    • of

      Adapts an OutputStream as an Output.EncodedOutput. The resulting output can be closed and will close the passed in OutputStream.
      Parameters:
      a - the OutputStream to be wrapped.
      charset - the encoding to use
      Returns:
      outputstream output