APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.org.apache.xml.internal.serializer

pack-priv final Class SerializerTraceWriter

extends Writer
implements WriterChain
Class Inheritance
All Implemented Interfaces
com.sun.org.apache.xml.internal.serializer.WriterChain
Imports
java.io.IOException, .OutputStream, .Writer

This class wraps the real writer, it only purpose is to send CHARACTERTOSTREAM events to the trace listener. Each method immediately sends the call to the wrapped writer unchanged, but in addition it collects characters to be issued to a trace listener. In this way the trace listener knows what characters have been written to the output Writer. There may still be differences in what the trace events say is going to the output writer and what is really going there. These differences will be due to the fact that this class is UTF-8 encoding before emiting the trace event and the underlying writer may not be UTF-8 encoding. There may also be encoding differences. So the main pupose of this class is to provide a resonable facsimile of the true output.

Field Summary

Modifier and TypeField and Description
private byte[]
buf

Internal buffer to collect the characters to go to the trace listener.

private int
buf_length

The size of the internal buffer, just to keep too many events from being sent to the tracer

private int
count

How many bytes have been collected and still need to go to trace listener.

private final SerializerTrace
m_tracer

The tracer to send events to

private final Writer
m_writer

The real writer to immediately write to.

Inherited from java.io.Writer:
lock

Constructor Summary

AccessConstructor and Description
public
SerializerTraceWriter(Writer
the Writer to write to (possibly null)
out
,
SerializerTrace
the tracer to inform that characters are being written
tracer
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements abstract java.io.Writer.close.

Implements com.sun.org.apache.xml.internal.serializer.WriterChain.close, java.io.Closeable.close.

Flush the internal buffer and close the Writer

public void
flush()

Implements abstract java.io.Writer.flush.

Implements com.sun.org.apache.xml.internal.serializer.WriterChain.flush, java.io.Flushable.flush.

Flush the internal buffer and flush the Writer

private void
flushBuffer()

Flush out the collected characters by sending them to the trace listener.

public OutputStream
getOutputStream()

Implements com.sun.org.apache.xml.internal.serializer.WriterChain.getOutputStream.

Get the OutputStream that is the at the end of the chain of writers.

public Writer
getWriter()

Implements com.sun.org.apache.xml.internal.serializer.WriterChain.getWriter.

Get the writer that this one directly wraps.

private void
setBufferSize(int size)

Creates or replaces the internal buffer, and makes sure it has a few extra bytes slight overflow of the last UTF8 encoded character.

public void
write(final int
int specifying a character to be written.
c
)

Overrides java.io.Writer.write.

Implements com.sun.org.apache.xml.internal.serializer.WriterChain.write.

Write a single character.

public void
write(final char[]
Array of characters
chars
,
final int
Offset from which to start writing characters
start
,
final int
Number of characters to write
length
)

Implements abstract java.io.Writer.write.

Implements com.sun.org.apache.xml.internal.serializer.WriterChain.write.

Write a portion of an array of characters.

public void
write(final String
String to be written
s
)

Overrides java.io.Writer.write.

Implements com.sun.org.apache.xml.internal.serializer.WriterChain.write.

Write a string.

Inherited from java.io.Writer:
appendappendappendnullWriterwritewrite

Field Detail

bufback to summary
private byte[] buf

Internal buffer to collect the characters to go to the trace listener.

buf_lengthback to summary
private int buf_length

The size of the internal buffer, just to keep too many events from being sent to the tracer

countback to summary
private int count

How many bytes have been collected and still need to go to trace listener.

m_tracerback to summary
private final SerializerTrace m_tracer

The tracer to send events to

m_writerback to summary
private final Writer m_writer

The real writer to immediately write to. This reference may be null, in which case nothing is written out, but only the trace events are fired for output.

Constructor Detail

SerializerTraceWriterback to summary
public SerializerTraceWriter(Writer out, SerializerTrace tracer)

Constructor. If the writer passed in is null, then this SerializerTraceWriter will only signal trace events of what would have been written to that writer. If the writer passed in is not null then the trace events will mirror what is going to that writer. In this way tools, such as a debugger, can gather information on what is being written out.

Parameters
out:Writer

the Writer to write to (possibly null)

tracer:SerializerTrace

the tracer to inform that characters are being written

Method Detail

closeback to summary
public void close() throws IOException

Implements abstract java.io.Writer.close.

Implements com.sun.org.apache.xml.internal.serializer.WriterChain.close, java.io.Closeable.close.

Flush the internal buffer and close the Writer

Exceptions
IOException:

Doc from java.io.Writer.close.

If an I/O error occurs

See Also
java.io.Writer#close()
flushback to summary
public void flush() throws IOException

Implements abstract java.io.Writer.flush.

Implements com.sun.org.apache.xml.internal.serializer.WriterChain.flush, java.io.Flushable.flush.

Flush the internal buffer and flush the Writer

Exceptions
IOException:

Doc from java.io.Writer.flush.

If an I/O error occurs

See Also
java.io.Writer#flush()
flushBufferback to summary
private void flushBuffer() throws IOException

Flush out the collected characters by sending them to the trace listener. These characters are never written to the real writer (m_writer) because that has already happened with every method call. This method simple informs the listener of what has already happened.

getOutputStreamback to summary
public OutputStream getOutputStream()

Implements com.sun.org.apache.xml.internal.serializer.WriterChain.getOutputStream.

Get the OutputStream that is the at the end of the chain of writers.

getWriterback to summary
public Writer getWriter()

Implements com.sun.org.apache.xml.internal.serializer.WriterChain.getWriter.

Get the writer that this one directly wraps.

setBufferSizeback to summary
private void setBufferSize(int size)

Creates or replaces the internal buffer, and makes sure it has a few extra bytes slight overflow of the last UTF8 encoded character.

writeback to summary
public void write(final int c) throws IOException

Overrides java.io.Writer.write.

Implements com.sun.org.apache.xml.internal.serializer.WriterChain.write.

Write a single character. The character to be written is contained in the 16 low-order bits of the given integer value; the 16 high-order bits are ignored.

Subclasses that intend to support efficient single-character output should override this method.

Parameters
c:int

int specifying a character to be written.

Exceptions
IOException:
If an I/O error occurs
writeback to summary
public void write(final char[] chars, final int start, final int length) throws IOException

Implements abstract java.io.Writer.write.

Implements com.sun.org.apache.xml.internal.serializer.WriterChain.write.

Write a portion of an array of characters.

Parameters
chars:char[]

Array of characters

start:int

Offset from which to start writing characters

length:int

Number of characters to write

Exceptions
IOException:
If an I/O error occurs
writeback to summary
public void write(final String s) throws IOException

Overrides java.io.Writer.write.

Implements com.sun.org.apache.xml.internal.serializer.WriterChain.write.

Write a string.

Parameters
s:String

String to be written

Exceptions
IOException:
If an I/O error occurs