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 Printer

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

Direct Known Subclasses:
  IndentPrinter

    public class Printer

extends java.lang.Object

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.2 $ $Date: 2003/04/04 00:46:44 $
Author:
  Assaf Arkin

Field Summary
`private char[]` | `_buffer` Output buffer.
`protected java.io.Writer` | `_docWriter` Holds a reference to the document writer while we are in DTD mode.
`protected java.io.StringWriter` | `_dtdWriter` The DTD writer.
`protected java.io.IOException` | `_exception` Holds the exception thrown by the serializer.
`protected OutputFormat` | `_format` The output format associated with this serializer.
`private int` | `_pos` Position within the output buffer.
`protected java.io.Writer` | `_writer` The writer to which the document is written.
`private static int` | `BufferSize` The size of the output buffer.

Constructor Summary
`Printer(java.io.Writer writer, OutputFormat format)`

Method Summary
`void` | `breakLine()`
`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)`
`java.io.IOException` | `getException()`
`int` | `getNextIndent()`
`void` | `indent()`
`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()`
`void` | `printText(char ch)`
`void` | `printText(char[] chars, int start, int length)`
`void` | `printText(java.lang.String text)`
`void` | `printText(java.lang.StringBuffer text)`
`void` | `setNextIndent(int indent)`
`void` | `setThisIndent(int indent)`
`void` | `unindent()`

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

Field Detail

### _format

    protected final OutputFormat _format

  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.

### BufferSize

    private static final int BufferSize

  The size of the output buffer.

  See Also:
    Constant Field Values

### _buffer

    private final char[] _buffer

  Output buffer.

### _pos

    private int _pos

  Position within the output buffer.

Constructor Detail

### Printer

    public Printer(java.io.Writer writer,
                   OutputFormat format)

Method Detail

### getException

    public java.io.IOException getException()

### enterDTD

    public void enterDTD()
                  throws java.io.IOException

  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()`.

  Throws:
    `java.io.IOException`

### leaveDTD

    public java.lang.String leaveDTD()
                              throws java.io.IOException

  Called by the root element to leave DTD mode and if any DTD parts were printer, will return a string with their textual content.

  Throws:
    `java.io.IOException`

### printText

    public void printText(java.lang.String text)
                   throws java.io.IOException

  Throws:
    `java.io.IOException`

### printText

    public void printText(java.lang.StringBuffer text)
                   throws java.io.IOException

  Throws:
    `java.io.IOException`

### printText

    public void printText(char[] chars,
                          int start,
                          int length)
                   throws java.io.IOException

  Throws:
    `java.io.IOException`

### printText

    public void printText(char ch)
                   throws java.io.IOException

  Throws:
    `java.io.IOException`

### printSpace

    public void printSpace()
                    throws java.io.IOException

  Throws:
    `java.io.IOException`

### breakLine

    public void breakLine()
                   throws java.io.IOException

  Throws:
    `java.io.IOException`

### breakLine

    public void breakLine(boolean preserveSpace)
                   throws java.io.IOException

  Throws:
    `java.io.IOException`

### flushLine

    public void flushLine(boolean preserveSpace)
                   throws java.io.IOException

  Throws:
    `java.io.IOException`

### flush

    public void flush()
               throws java.io.IOException

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

  Throws:
    `java.io.IOException`

### indent

    public void indent()

### unindent

    public void unindent()

### getNextIndent

    public int getNextIndent()

### setNextIndent

    public void setNextIndent(int indent)

### setThisIndent

    public void setThisIndent(int indent)

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