Package com.ctc.wstx.io
Class UTF8Writer
java.lang.Object
java.io.Writer
com.ctc.wstx.io.UTF8Writer
- All Implemented Interfaces:
CompletelyCloseable,Closeable,Flushable,Appendable,AutoCloseable
Specialized buffering UTF-8 writer used by
XmlWriter.
The main reason for custom version is to allow for efficient
buffer recycling; the second benefit is that encoder has less
overhead for short content encoding (compared to JDK default
codecs).-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate final booleanprivate final WriterConfigprivate final OutputStreamprivate byte[]private final intprivate intprivate intWhen outputting chars from BMP, surrogate pairs need to be coalesced.private static final intprivate static final intprivate static final intprivate static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void_close(boolean forceClosing) private final int_convertSurrogate(int secondPart) Method called to calculate UTF codepoint, from a surrogate pair.voidclose()voidvoidflush()private voidthrowIllegal(int code) voidwrite(char[] cbuf) voidwrite(char[] cbuf, int off, int len) voidwrite(int c) voidvoidMethods inherited from class java.io.Writer
append, append, append, nullWriter
-
Field Details
-
DEFAULT_BUF_LEN
private static final int DEFAULT_BUF_LEN- See Also:
-
SURR1_FIRST
private static final int SURR1_FIRST- See Also:
-
SURR1_LAST
private static final int SURR1_LAST- See Also:
-
SURR2_FIRST
private static final int SURR2_FIRST- See Also:
-
SURR2_LAST
private static final int SURR2_LAST- See Also:
-
mConfig
-
mAutoCloseOutput
private final boolean mAutoCloseOutput -
mOut
-
mOutBuffer
private byte[] mOutBuffer -
mOutBufferLast
private final int mOutBufferLast -
mOutPtr
private int mOutPtr -
mSurrogate
private int mSurrogateWhen outputting chars from BMP, surrogate pairs need to be coalesced. To do this, both pairs must be known first; and since it is possible pairs may be split, we need temporary storage for the first half
-
-
Constructor Details
-
UTF8Writer
-
-
Method Details
-
closeCompletely
- Specified by:
closeCompletelyin interfaceCompletelyCloseable- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classWriter- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Specified by:
flushin classWriter- Throws:
IOException
-
write
- Overrides:
writein classWriter- Throws:
IOException
-
write
- Specified by:
writein classWriter- Throws:
IOException
-
write
- Overrides:
writein classWriter- Throws:
IOException
-
write
- Overrides:
writein classWriter- Throws:
IOException
-
write
- Overrides:
writein classWriter- Throws:
IOException
-
_close
- Throws:
IOException
-
_convertSurrogate
Method called to calculate UTF codepoint, from a surrogate pair.- Throws:
IOException
-
throwIllegal
- Throws:
IOException
-