Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jasig.portal.serialize
Class IndentPrinter

    java.lang.Object
      org.jasig.portal.serialize.Printer
          org.jasig.portal.serialize.IndentPrinter

    public class IndentPrinter

extends Printer

Extends `Printer` and adds support for indentation and line wrapping.

Version:
  $Revision: 1.4 $ $Date: 2004/09/10 17:17:28 $
Author:
  Assaf Arkin

Field Summary
`private java.lang.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 java.lang.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.

Fields inherited from class org.jasig.portal.serialize.Printer
`_docWriter, _dtdWriter, _exception, _format, _writer`

Constructor Summary
`IndentPrinter(java.io.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.
`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.
`void` | `printSpace()` Called to print a single space between text parts that may be broken into separate lines.
`void` | `printText(char ch)`
`void` | `printText(char[] chars, int start, int length)`
`void` | `printText(java.lang.String text)` Called to print additional text.
`void` | `printText(java.lang.StringBuffer text)`
`void` | `setNextIndent(int indent)`
`void` | `setThisIndent(int indent)`
`void` | `unindent()` Decrement the indentation for the next line.

Methods inherited from class org.jasig.portal.serialize.Printer
`getException`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### _line

    private java.lang.StringBuffer _line

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

### _text

    private java.lang.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.

### _spaces

    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.

### _thisIndent

    private int _thisIndent

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

### _nextIndent

    private int _nextIndent

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

Constructor Detail

### IndentPrinter

    IndentPrinter(java.io.Writer writer,
                  OutputFormat format)

Method Detail

### 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 and get the accumulated DTD, call `leaveDTD()`.

  Overrides:
    `enterDTD` in class `Printer`

### 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.

  Overrides:
    `leaveDTD` in class `Printer`

### printText

    public void printText(java.lang.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 class `Printer`
  Parameters:
    `text` - The text to print

### printText

    public void printText(java.lang.StringBuffer text)

  Overrides:
    `printText` in class `Printer`

### printText

    public void printText(char ch)

  Overrides:
    `printText` in class `Printer`

### printText

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

  Overrides:
    `printText` in class `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(String)` 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 class `Printer`

### 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 class `Printer`

### breakLine

    public void breakLine(boolean preserveSpace)

  Overrides:
    `breakLine` in class `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(String)` 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 class `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 class `Printer`

### indent

    public void indent()

  Increment the indentation for the next line.

  Overrides:
    `indent` in class `Printer`

### unindent

    public void unindent()

  Decrement the indentation for the next line.

  Overrides:
    `unindent` in class `Printer`

### getNextIndent

    public int getNextIndent()

  Overrides:
    `getNextIndent` in class `Printer`

### setNextIndent

    public void setNextIndent(int indent)

  Overrides:
    `setNextIndent` in class `Printer`

### setThisIndent

    public void setThisIndent(int indent)

  Overrides:
    `setThisIndent` in class `Printer`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD