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

public Class IndentPrinter

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

Deprecated

As of JDK 9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation is replaced by that of Xalan. Main class com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl is replaced by com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl.

Extends Printer and adds support for indentation and line wrapping.
Author
Assaf Arkin

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 com.sun.org.apache.xml.internal.serialize.Printer:
_docWriter_dtdWriter_exception_format_writer

Constructor Summary

AccessConstructor and Description
public
IndentPrinter(Writer writer, OutputFormat format)
References Deprecated OutputFormat is deprecated or references (maybe indirectly) at least one deprecated element.

Method Summary

Modifier and TypeMethod and Description
public void
breakLine()

Overrides com.sun.org.apache.xml.internal.serialize.Printer.breakLine.

Called to print a line consisting of the text accumulated so far.

public void
public void
enterDTD()

Overrides com.sun.org.apache.xml.internal.serialize.Printer.enterDTD.

Called by any of the DTD handlers to enter DTD mode.

public void
public void
flushLine(boolean preserveSpace)

Overrides com.sun.org.apache.xml.internal.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 com.sun.org.apache.xml.internal.serialize.Printer.indent.

Increment the indentation for the next line.

public String
leaveDTD()

Overrides com.sun.org.apache.xml.internal.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 com.sun.org.apache.xml.internal.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 com.sun.org.apache.xml.internal.serialize.Printer.printText.

Called to print additional text.

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

Overrides com.sun.org.apache.xml.internal.serialize.Printer.printText.

public void
public void
public void
unindent()

Overrides com.sun.org.apache.xml.internal.serialize.Printer.unindent.

Decrement the indentation for the next line.

Inherited from com.sun.org.apache.xml.internal.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)

References Deprecated

OutputFormat is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Method Detail

breakLineback to summary
public void breakLine()

Overrides com.sun.org.apache.xml.internal.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 com.sun.org.apache.xml.internal.serialize.Printer.breakLine.

enterDTDback to summary
public void enterDTD()

Overrides com.sun.org.apache.xml.internal.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 com.sun.org.apache.xml.internal.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 com.sun.org.apache.xml.internal.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 com.sun.org.apache.xml.internal.serialize.Printer.getNextIndent.

indentback to summary
public void indent()

Overrides com.sun.org.apache.xml.internal.serialize.Printer.indent.

Increment the indentation for the next line.

leaveDTDback to summary
public String leaveDTD()

Overrides com.sun.org.apache.xml.internal.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 com.sun.org.apache.xml.internal.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 com.sun.org.apache.xml.internal.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 com.sun.org.apache.xml.internal.serialize.Printer.printText.

printTextback to summary
public void printText(char ch)

Overrides com.sun.org.apache.xml.internal.serialize.Printer.printText.

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

Overrides com.sun.org.apache.xml.internal.serialize.Printer.printText.

setNextIndentback to summary
public void setNextIndent(int indent)

Overrides com.sun.org.apache.xml.internal.serialize.Printer.setNextIndent.

setThisIndentback to summary
public void setThisIndent(int indent)

Overrides com.sun.org.apache.xml.internal.serialize.Printer.setThisIndent.

unindentback to summary
public void unindent()

Overrides com.sun.org.apache.xml.internal.serialize.Printer.unindent.

Decrement the indentation for the next line.