public interface Encoder
Encodes data as it is written to the provided output.
- Author:
- AO Industries, Inc.
-
Method Summary
Modifier and TypeMethodDescriptionappend
(char c, Appendable out) append
(CharSequence csq, int start, int end, Appendable out) append
(CharSequence csq, Appendable out) default boolean
Is this encoder buffered? A buffered encoder may delay validation untilwriteSuffixTo(java.lang.Appendable, boolean)
.void
void
void
void
void
void
writePrefixTo
(Appendable out) This is called before any data is written.void
writeSuffixTo
(Appendable out) Deprecated.default void
writeSuffixTo
(Appendable out, boolean trim) This is called when no more data will be written.
-
Method Details
-
isBuffered
default boolean isBuffered()Is this encoder buffered? A buffered encoder may delay validation untilwriteSuffixTo(java.lang.Appendable, boolean)
. Furthermore, a buffered encoder should not be bypassed before any buffered data has been written viawriteSuffixTo(java.lang.Appendable, boolean)
. An example of encoder bypassing is performing direct output on the writer fromEncoderWriter.getOut()
.- Returns:
false
by default
-
writePrefixTo
This is called before any data is written.- Parameters:
out
- May optionally have already been optimized viaCoercion.optimize(java.lang.Appendable, com.aoapps.lang.io.Encoder)
.- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
append
- Throws:
IOException
-
append
- Throws:
IOException
-
append
- Throws:
IOException
-
writeSuffixTo
Deprecated.Please usewriteSuffixTo(java.lang.Appendable, boolean)
while specifying desired trim.This is called when no more data will be written. This should also flush any internal buffers toout
. It should not, however, call flush onout
itself. This is to not interfere with any output buffering ofout
.The internal buffer is always clear for re-use, even when an exception is thrown.
- Parameters:
out
- May optionally have already been optimized viaCoercion.optimize(java.lang.Appendable, com.aoapps.lang.io.Encoder)
.- Throws:
IOException
-
writeSuffixTo
This is called when no more data will be written. This should also flush any internal buffers toout
. It should not, however, call flush onout
itself. This is to not interfere with any output buffering ofout
.The internal buffer is always clear for re-use, even when an exception is thrown.
- Parameters:
out
- May optionally have already been optimized viaCoercion.optimize(java.lang.Appendable, com.aoapps.lang.io.Encoder)
.trim
- Requests that the buffer be trimmed, if buffered and trim supported.- Throws:
IOException
-
writeSuffixTo(java.lang.Appendable, boolean)
while specifying desired trim.