Interface Appender

All Known Subinterfaces:
Escaper

public sealed interface Appender permits Escaper
A singleton like decorator for appendables that has additional methods for dealing with native types used to output variables that have been formatted. This interface is mostly an internal detail for performance and generally direct implementations are unnecessary.

When a template outputs an escaped variable the callstack is as follows:

 formatter --> escaper --> appendable
 
When a template outputs an unescaped variable the callstack is as follows:
 formatter --> appender --> appendable
 
When a template outputs anything else (e.g. HTML markup) it writes directly to the appendable.
Author:
agentgt
See Also:
API Note
Important: The interface while public is currently sealed. If you would like to see it unsealed to allow control of intercepting unescaped variable output please file an issue. Unlike an Appendable this class is expected to be reused so state should be avoided and implementations should be thread safe.
  • Method Details

    • append

      <A extends Output<E>, E extends Exception> void append(A a, CharSequence s) throws E
      Type Parameters:
      A - output type
      E - exception type
      Parameters:
      a - appendable to write to. Always non null.
      s - unlike appendable always non null.
      Throws:
      E - if an error happens while writting to the appendable
      API Note
      Implementations are required to implement this method.
    • append

      <A extends Output<E>, E extends Exception> void append(A a, CharSequence csq, int start, int end) throws E
      Type Parameters:
      A - output type
      E - exception type
      Parameters:
      a - appendable to write to. Never null.
      csq - Unlike appendable never null.
      start - start inclusive
      end - end exclusive
      Throws:
      E - if an error happens while writting to the appendable
      API Note
      Implementations are required to implement this method.
    • append

      <A extends Output<E>, E extends Exception> void append(A a, char c) throws E
      Appends a character to the output.
      Type Parameters:
      A - output type
      E - exception type
      Parameters:
      a - appendable to write to. Never null.
      c - character
      Throws:
      E - if an error happens while writting to the appendable
      API Note
      Implementations are required to implement this method.
    • append

      <A extends Output<E>, E extends Exception> void append(A a, short s) throws E
      Appends a short to the output.
      Type Parameters:
      A - output type
      E - exception type
      Parameters:
      a - appendable to write to. Never null.
      s - short
      Throws:
      E - if an error happens while writting to the appendable
    • append

      <A extends Output<E>, E extends Exception> void append(A a, int i) throws E
      Appends an int to the output.

      Implementations should override if they want different behavior or able to support appendables that can write the native type.

      Type Parameters:
      A - output type
      E - exception type
      Parameters:
      a - appendable to write to. Never null.
      i - int
      Throws:
      E - if an error happens while writting to the appendable
    • append

      <A extends Output<E>, E extends Exception> void append(A a, long l) throws E
      Appends a long to the output.

      Implementations should override if they want different behavior or able to support appendables that can write the native type.

      Type Parameters:
      A - output type
      E - exception type
      Parameters:
      a - appendable to write to. Never null.
      l - long
      Throws:
      E - if an error happens while writting to the appendable
    • append

      <A extends Output<E>, E extends Exception> void append(A a, double d) throws E
      Appends a double to the output.

      Implementations should override if they want different behavior or able to support appendables that can write the native type.

      Type Parameters:
      A - output type
      E - exception type
      Parameters:
      a - appendable to write to. Never null.
      d - double
      Throws:
      E - if an error happens while writting to the appendable
    • append

      <A extends Output<E>, E extends Exception> void append(A a, boolean b) throws E
      Appends a boolean to the output.

      Implementations should override if they want different behavior or able to support appendables that can write the native type.

      Type Parameters:
      A - output type
      E - exception type
      Parameters:
      a - appendable to write to. Never null.
      b - boolean
      Throws:
      E - if an error happens while writting to the appendable
    • defaultAppender

      Default appender simply passes the contents unchanged to the Appendable.
      Returns:
      a passthrough appender