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 int
(package private) final boolean
(package private) final WriterConfig
(package private) final OutputStream
(package private) byte[]
(package private) final int
(package private) int
(package private) int
When outputting chars from BMP, surrogate pairs need to be coalesced.(package private) static final int
(package private) static final int
(package private) static final int
(package private) static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate final void
_close
(boolean forceClosing) private final int
_convertSurrogate
(int secondPart) Method called to calculate UTF codepoint, from a surrogate pair.void
close()
void
void
flush()
private void
throwIllegal
(int code) void
write
(char[] cbuf) void
write
(char[] cbuf, int off, int len) void
write
(int c) void
void
-
Field Details
-
DEFAULT_BUF_LEN
private static final int DEFAULT_BUF_LEN- See Also:
-
SURR1_FIRST
static final int SURR1_FIRST- See Also:
-
SURR1_LAST
static final int SURR1_LAST- See Also:
-
SURR2_FIRST
static final int SURR2_FIRST- See Also:
-
SURR2_LAST
static final int SURR2_LAST- See Also:
-
mConfig
-
mAutoCloseOutput
final boolean mAutoCloseOutput -
mOut
-
mOutBuffer
byte[] mOutBuffer -
mOutBufferLast
final int mOutBufferLast -
mOutPtr
int mOutPtr -
mSurrogate
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:
closeCompletely
in interfaceCompletelyCloseable
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in classWriter
- Throws:
IOException
-
write
- Overrides:
write
in classWriter
- Throws:
IOException
-
write
- Specified by:
write
in classWriter
- Throws:
IOException
-
write
- Overrides:
write
in classWriter
- Throws:
IOException
-
write
- Overrides:
write
in classWriter
- Throws:
IOException
-
write
- Overrides:
write
in classWriter
- Throws:
IOException
-
_close
- Throws:
IOException
-
_convertSurrogate
Method called to calculate UTF codepoint, from a surrogate pair.- Throws:
IOException
-
throwIllegal
- Throws:
IOException
-