- All Known Subinterfaces:
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 --> appendableWhen a template outputs an unescaped variable the callstack is as follows:
formatter --> appender --> appendableWhen 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 Summary
Modifier and TypeMethodDescriptionappend
(A a, boolean b) Appends a boolean to the output.append
(A a, char c) Appends a character to the output.append
(A a, double d) Appends a double to the output.append
(A a, int i) Appends an int to the output.append
(A a, long l) Appends a long to the output.append
(A a, short s) Appends a short to the output.append
(A a, CharSequence s) Analogous toAppendable.append(CharSequence)
.append
(A a, CharSequence csq, int start, int end) Analogous toAppendable.append(CharSequence, int, int)
.static Appender
Default appender simply passes the contents unchanged to the Appendable.
-
Method Details
-
append
Analogous toAppendable.append(CharSequence)
.- Type Parameters:
A
- output typeE
- 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 Analogous toAppendable.append(CharSequence, int, int)
.- Type Parameters:
A
- output typeE
- exception type- Parameters:
a
- appendable to write to. Never null.csq
- Unlike appendable never null.start
- start inclusiveend
- end exclusive- Throws:
E
- if an error happens while writting to the appendable- API Note
- Implementations are required to implement this method.
-
append
Appends a character to the output.- Type Parameters:
A
- output typeE
- 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
Appends a short to the output.- Type Parameters:
A
- output typeE
- exception type- Parameters:
a
- appendable to write to. Never null.s
- short- Throws:
E
- if an error happens while writting to the appendable
-
append
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 typeE
- exception type- Parameters:
a
- appendable to write to. Never null.i
- int- Throws:
E
- if an error happens while writting to the appendable
-
append
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 typeE
- exception type- Parameters:
a
- appendable to write to. Never null.l
- long- Throws:
E
- if an error happens while writting to the appendable
-
append
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 typeE
- exception type- Parameters:
a
- appendable to write to. Never null.d
- double- Throws:
E
- if an error happens while writting to the appendable
-
append
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 typeE
- 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
-