- Type Parameters:
A
- the appendable
- All Known Subinterfaces:
Escaper
public interface Appender<A extends Appendable>
A singleton like decorator for appendables that has additional methods for dealing with
native types.
- Author:
- agentgt
- See Also:
- API Note
- Unlike an Appendable this class is expected to be reused so avoid state and implementations should be thread safe.
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
Write a long by usingString.valueOf(long)
.void
Appends a character to an appendable.default void
Write a long by usingString.valueOf(long)
.default void
Write a int by usingString.valueOf(int)
.default void
Write a long by usingString.valueOf(long)
.default void
Write a short by usingString.valueOf(int)
void
append
(A a, CharSequence s) Analogous toAppendable.append(CharSequence)
.void
append
(A a, CharSequence csq, int start, int end) Analogous toAppendable.append(CharSequence, int, int)
.static Appender<Appendable>
Default appender simply passes the contents unchanged to the Appendable.static Appender<StringBuilder>
An appender that will directly call StringBuilder methods for native types.default Appendable
toAppendable
(A appendable) Decorates an appendable with this appender such that the returned appendable will call the this appender which will then write to the inputted appendable.
-
Method Details
-
append
Analogous toAppendable.append(CharSequence)
.- Parameters:
a
- appendable to write to. Always non null.s
- unlike appendable always non null.- Throws:
IOException
- if an error happens while writting to the appendable
-
append
Analogous toAppendable.append(CharSequence, int, int)
.- Parameters:
a
- appendable to write to. Never null.csq
- Unlike appendable never null.start
- start inclusiveend
- end exclusive- Throws:
IOException
- if an error happens while writting to the appendable
-
append
Appends a character to an appendable.- Parameters:
a
- appendable to write to. Never null.c
- character- Throws:
IOException
- if an error happens while writting to the appendable
-
append
Write a short by usingString.valueOf(int)
- Parameters:
a
- appendable to write to. Never null.s
- short- Throws:
IOException
- if an error happens while writting to the appendable
-
append
Write a int by usingString.valueOf(int)
.Implementations should override if they want different behavior or able to support appendables that can write the native type.
- Parameters:
a
- appendable to write to. Never null.i
- int- Throws:
IOException
- if an error happens while writting to the appendable
-
append
Write a long by usingString.valueOf(long)
.Implementations should override if they want different behavior or able to support appendables that can write the native type.
- Parameters:
a
- appendable to write to. Never null.l
- long- Throws:
IOException
- if an error happens while writting to the appendable
-
append
Write a long by usingString.valueOf(long)
.Implementations should override if they want different behavior or able to support appendables that can write the native type.
- Parameters:
a
- appendable to write to. Never null.d
- double- Throws:
IOException
- if an error happens while writting to the appendable
-
append
Write a long by usingString.valueOf(long)
.Implementations should override if they want different behavior or able to support appendables that can write the native type.
- Parameters:
a
- appendable to write to. Never null.b
- boolean- Throws:
IOException
- if an error happens while writting to the appendable
-
toAppendable
Decorates an appendable with this appender such that the returned appendable will call the this appender which will then write to the inputted appendable.- Parameters:
appendable
- never null.- Returns:
- Appendable never null.
-
defaultAppender
Default appender simply passes the contents unchanged to the Appendable.- Returns:
- a passthrough appender
-
stringAppender
An appender that will directly call StringBuilder methods for native types.This is a low level utility appenrer for where performance matters.
- Returns:
- an appender specifically for
StringBuilder
-