org.apache.xml.serialize

Class IndentPrinter


public class IndentPrinter
extends Printer

Extends Printer and adds support for indentation and line wrapping.
Version:
$Revision: 1.9 $ $Date: 2004/02/24 23:34:03 $
Author:
Assaf Arkin

Field Summary

Fields inherited from class org.apache.xml.serialize.Printer

_docWriter, _dtdWriter, _exception, _format, _writer

Constructor Summary

IndentPrinter(Writer writer, OutputFormat format)

Method Summary

void
breakLine()
Called to print a line consisting of the text accumulated so far.
void
breakLine(boolean preserveSpace)
void
enterDTD()
Called by any of the DTD handlers to enter DTD mode.
void
flush()
Flush the output stream.
void
flushLine(boolean preserveSpace)
Flushes the line accumulated so far to the writer and get ready to accumulate the next line.
int
getNextIndent()
void
indent()
Increment the indentation for the next line.
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.
void
printSpace()
Called to print a single space between text parts that may be broken into separate lines.
void
printText(String text)
Called to print additional text.
void
printText(StringBuffer text)
void
printText(char ch)
void
printText(char[] chars, int start, int length)
void
setNextIndent(int indent)
void
setThisIndent(int indent)
void
unindent()
Decrement the indentation for the next line.

Methods inherited from class org.apache.xml.serialize.Printer

breakLine, breakLine, enterDTD, flush, flushLine, getException, getNextIndent, indent, leaveDTD, printSpace, printText, printText, printText, printText, setNextIndent, setThisIndent, unindent

Constructor Details

IndentPrinter

public IndentPrinter(Writer writer,
                     OutputFormat format)

Method Details

breakLine

public void 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).
Overrides:
breakLine in interface Printer

breakLine

public void breakLine(boolean preserveSpace)
Overrides:
breakLine in interface Printer

enterDTD

public void enterDTD()
Overrides:
enterDTD in interface Printer

flush

public void flush()
Flush the output stream. Must be called when done printing the document, otherwise some text might be buffered.
Overrides:
flush in interface Printer

flushLine

public void flushLine(boolean preserveSpace)
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.
Overrides:
flushLine in interface Printer

getNextIndent

public int getNextIndent()
Overrides:
getNextIndent in interface Printer

indent

public void indent()
Increment the indentation for the next line.
Overrides:
indent in interface Printer

leaveDTD

public 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.
Overrides:
leaveDTD in interface Printer

printSpace

public void 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.
Overrides:
printSpace in interface Printer

printText

public void printText(String text)
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.
Overrides:
printText in interface Printer
Parameters:
text - The text to print

printText

public void printText(StringBuffer text)
Overrides:
printText in interface Printer

printText

public void printText(char ch)
Overrides:
printText in interface Printer

printText

public void printText(char[] chars,
                      int start,
                      int length)
Overrides:
printText in interface Printer

setNextIndent

public void setNextIndent(int indent)
Overrides:
setNextIndent in interface Printer

setThisIndent

public void setThisIndent(int indent)
Overrides:
setThisIndent in interface Printer

unindent

public void unindent()
Decrement the indentation for the next line.
Overrides:
unindent in interface Printer

Copyright B) 1999-2005 Apache XML Project. All Rights Reserved.