Top Description Fields Constructors Methods
org.apache.xml.serialize

public Class IndentPrinter

extends Printer
Class Inheritance
Imports
java.io.IOException, .StringWriter, .Writer

Deprecated

This class was deprecated in Xerces 2.9.0. It is recommended that new applications use the DOM Level 3 LSSerializer or JAXP's Transformation API for XML (TrAX) for serializing XML. See the Xerces documentation for more information.

Extends Printer and adds support for indentation and line wrapping.
Author
Assaf Arkin
Version
$Revision: 699892 $ $Date: 2008-09-29 02:38:27 +0530 (Mon, 29 Sep 2008) $

Field Summary

Modifier and TypeField and Description
private StringBuffer
_line

Holds the currently accumulating text line.

private int
_nextIndent

Holds the indentation for the next line to be printed.

private int
_spaces

Counts how many white spaces come between the accumulated line and the current accumulated text.

private StringBuffer
_text

Holds the currently accumulating text that follows _line.

private int
_thisIndent

Holds the indentation for the current line that is now accumulating in memory and will be sent for printing shortly.

Inherited from org.apache.xml.serialize.Printer:
_docWriter_dtdWriter_exception_format_writer

Constructor Summary

AccessConstructor and Description
public
IndentPrinter(Writer writer, OutputFormat format)

Deprecated as a consequence of OutputFormat being deprecated.

Method Summary

Modifier and TypeMethod and Description
public void
breakLine()

Overrides org.apache.xml.serialize.Printer.breakLine.

Called to print a line consisting of the text accumulated so far.
public void
breakLine(boolean preserveSpace)

Overrides org.apache.xml.serialize.Printer.breakLine.

public void
enterDTD()

Overrides org.apache.xml.serialize.Printer.enterDTD.

Called by any of the DTD handlers to enter DTD mode.
public void
flush()

Overrides org.apache.xml.serialize.Printer.flush.

Flush the output stream.
public void
flushLine(boolean preserveSpace)

Overrides org.apache.xml.serialize.Printer.flushLine.

Flushes the line accumulated so far to the writer and get ready to accumulate the next line.
public int
public void
indent()

Overrides org.apache.xml.serialize.Printer.indent.

Increment the indentation for the next line.
public String
leaveDTD()

Overrides org.apache.xml.serialize.Printer.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.
public void
printSpace()

Overrides org.apache.xml.serialize.Printer.printSpace.

Called to print a single space between text parts that may be broken into separate lines.
public void
printText(String
The text to print
text
)

Overrides org.apache.xml.serialize.Printer.printText.

Called to print additional text.
public void
public void
public void
printText(char[] chars, int start, int length)

Overrides org.apache.xml.serialize.Printer.printText.

public void
public void
public void
unindent()

Overrides org.apache.xml.serialize.Printer.unindent.

Decrement the indentation for the next line.
Inherited from org.apache.xml.serialize.Printer:
getException

Field Detail

_lineback to summary
private StringBuffer _line

Holds the currently accumulating text line. This buffer will constantly be reused by deleting its contents instead of reallocating it.

_nextIndentback to summary
private int _nextIndent

Holds the indentation for the next line to be printed. After this line is printed, _nextIndent is assigned to _thisIndent.

_spacesback to summary
private int _spaces

Counts how many white spaces come between the accumulated line and the current accumulated text. Multiple spaces at the end of the a line will not be printed.

_textback to summary
private StringBuffer _text

Holds the currently accumulating text that follows _line. When the end of the part is identified by a call to printSpace or breakLine, this part is added to the accumulated line.

_thisIndentback to summary
private int _thisIndent

Holds the indentation for the current line that is now accumulating in memory and will be sent for printing shortly.

Constructor Detail

IndentPrinterback to summary
public IndentPrinter(Writer writer, OutputFormat format)

Deprecated

as a consequence of OutputFormat being deprecated. See corresponding docs for further information.

Method Detail

breakLineback to summary
public void breakLine()

Overrides org.apache.xml.serialize.Printer.breakLine.

Called to print a line consisting of the text accumulated so far. This is equivalent to calling printSpace but forcing the line to print and starting a new line (printSpace will only start a new line if the current line is long enough).

breakLineback to summary
public void breakLine(boolean preserveSpace)

Overrides org.apache.xml.serialize.Printer.breakLine.

enterDTDback to summary
public void enterDTD()

Overrides org.apache.xml.serialize.Printer.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 and get the accumulated DTD, call leaveDTD.

flushback to summary
public void flush()

Overrides org.apache.xml.serialize.Printer.flush.

Flush the output stream. Must be called when done printing the document, otherwise some text might be buffered.

flushLineback to summary
public void flushLine(boolean preserveSpace)

Overrides org.apache.xml.serialize.Printer.flushLine.

Flushes the line accumulated so far to the writer and get ready to accumulate the next line. This method is called by printText and printSpace when the accumulated line plus accumulated text are two long to fit on a given line. At the end of this method _line is empty and _spaces is zero.

getNextIndentback to summary
public int getNextIndent()

Overrides org.apache.xml.serialize.Printer.getNextIndent.

indentback to summary
public void indent()

Overrides org.apache.xml.serialize.Printer.indent.

Increment the indentation for the next line.

leaveDTDback to summary
public String leaveDTD()

Overrides org.apache.xml.serialize.Printer.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.

printSpaceback to summary
public void printSpace()

Overrides org.apache.xml.serialize.Printer.printSpace.

Called to print a single space between text parts that may be broken into separate lines. Must not be called to print a space when preserving spaces. The text accumulated so far with printText will be added to the accumulated line, and a space separator will be counted. If the line accumulated so far is long enough, it will be printed.

printTextback to summary
public void printText(String text)

Overrides org.apache.xml.serialize.Printer.printText.

Called to print additional text. Each time this method is called it accumulates more text. When a space is printed (printSpace) all the accumulated text becomes one part and is added to the accumulate line. When a line is long enough, it can be broken at its text boundary.

Parameters
text:String

The text to print

printTextback to summary
public void printText(StringBuffer text)

Overrides org.apache.xml.serialize.Printer.printText.

printTextback to summary
public void printText(char ch)

Overrides org.apache.xml.serialize.Printer.printText.

printTextback to summary
public void printText(char[] chars, int start, int length)

Overrides org.apache.xml.serialize.Printer.printText.

setNextIndentback to summary
public void setNextIndent(int indent)

Overrides org.apache.xml.serialize.Printer.setNextIndent.

setThisIndentback to summary
public void setThisIndent(int indent)

Overrides org.apache.xml.serialize.Printer.setThisIndent.

unindentback to summary
public void unindent()

Overrides org.apache.xml.serialize.Printer.unindent.

Decrement the indentation for the next line.