The printer is responsible for sending text to the output stream
or writer. This class performs direct writing for efficiency.
IndentPrinter supports indentation and line wrapping by
extending this class.
Version:
$Revision: 1.3 $ $Date: 2000/08/30 18:59:21 $
Field Summary
protected java.io.Writer
Holds a reference to the document writer while we are
in DTD mode.
protected java.io.StringWriter
The DTD writer.
protected java.io.IOException
Holds the exception thrown by the serializer.
The output format associated with this serializer.
protected java.io.Writer
The writer to which the document is written.
Constructor Summary
Method Summary
void
void
void
Called by any of the DTD handlers to enter DTD mode.
void
Flush the output stream.
void
java.io.IOException
int
void
java.lang.String
Called by the root element to leave DTD mode and if any
DTD parts were printer, will return a string with their
textual content.
The output format associated with this serializer. This will never
be a null reference. If no format was passed to the constructor,
the default one for this document type will be used. The format
object is never changed by the serializer.
_writer
protected java.io.Writer _writer
The writer to which the document is written.
_dtdWriter
protected java.io.StringWriter _dtdWriter
The DTD writer. When we switch to DTD mode, all output is
accumulated in this DTD writer. When we switch out of it,
the output is obtained as a string. Must not be reset to
null until we're done with the document.
_docWriter
protected java.io.Writer _docWriter
Holds a reference to the document writer while we are
in DTD mode.
_exception
protected java.io.IOException _exception
Holds the exception thrown by the serializer. Exceptions do not cause
the serializer to quit, but are held and one is thrown at the end.
Constructor Detail
Printer
public Printer(java.io.Writer writer,
Method Detail
getException
public java.io.IOException getException()
enterDTD
public void enterDTD()
Called by any of the DTD handlers to enter DTD mode.
Once entered, all output will be accumulated in a string
that can be printed as part of the document's DTD.
This method may be called any number of time but will only
have affect the first time it's called. To exist DTD state
leaveDTD
public java.lang.String leaveDTD()
Called by the root element to leave DTD mode and if any
DTD parts were printer, will return a string with their
textual content.
printText
public void printText(java.lang.String text)
printText
public void printText(java.lang.StringBuffer text)
printText
public void printText(char[] chars,
int start,
int length)
printText
public void printText(char ch)
printSpace
public void printSpace()
breakLine
public void breakLine()
breakLine
public void breakLine(boolean preserveSpace)
flushLine
public void flushLine(boolean preserveSpace)
flush
public void flush()
Flush the output stream. Must be called when done printing
the document, otherwise some text might be buffered.