net.sf.saxon.event

Class UTF8Writer

public final class UTF8Writer extends Writer

Specialized buffering UTF-8 writer. 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).

Author: Tatu Saloranta

Field Summary
static intSURR1_FIRST
static intSURR1_LAST
static intSURR2_FIRST
static intSURR2_LAST
protected OutputStream_out
protected byte[]_outBuffer
protected int_outBufferLast
protected int_outPtr
int_surrogate
When outputting chars from BMP, surrogate pairs need to be coalesced.
Constructor Summary
UTF8Writer(OutputStream out)
UTF8Writer(OutputStream out, int bufferLength)
Method Summary
voidclose()
voidflush()
voidwrite(char[] cbuf)
voidwrite(char[] cbuf, int off, int len)
voidwrite(int c)
voidwrite(String str)
voidwrite(String str, int off, int len)

Field Detail

SURR1_FIRST

static final int SURR1_FIRST

SURR1_LAST

static final int SURR1_LAST

SURR2_FIRST

static final int SURR2_FIRST

SURR2_LAST

static final int SURR2_LAST

_out

protected OutputStream _out

_outBuffer

protected byte[] _outBuffer

_outBufferLast

protected final int _outBufferLast

_outPtr

protected int _outPtr

_surrogate

int _surrogate
When 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 Detail

UTF8Writer

public UTF8Writer(OutputStream out)

UTF8Writer

public UTF8Writer(OutputStream out, int bufferLength)

Method Detail

close

public void close()

flush

public void flush()

write

public void write(char[] cbuf)

write

public void write(char[] cbuf, int off, int len)

write

public void write(int c)

write

public void write(String str)

write

public void write(String str, int off, int len)