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.crosswire.common.xml
Class PrettySerializingContentHandler

    java.lang.Object
      org.crosswire.common.xml.PrettySerializingContentHandler

All Implemented Interfaces:
  ContentHandler

Direct Known Subclasses:
  HTMLSerializingContentHandler

    public class PrettySerializingContentHandler

extends Object
implements ContentHandler

This class provides for the formatted serialization of a SAX stream to a `Writer`.

Author:
  DM Smith
See Also:
  `The GNU Lesser General Public License for details.`

Field Summary
`private int` | `depth` The depth is incremented on each startElement and decremented on each endElement.
`private FormatType` | `formatting`
`private static char[]` | `indentation` This allows for rapid output of whitespace.
`private boolean` | `lookingForChars` It is possible that characters(...) will be called for adjacent pieces of text.
`private boolean` | `pendingEndTag` One of the difficulties in SAX parsing is that it does not retain state.
`private Writer` | `writer`

Constructor Summary
`PrettySerializingContentHandler()` A formatting serializer that does not add whitespace to the document.
`PrettySerializingContentHandler(FormatType theFormat)` A formatting serializer that adds whitespace to the document according to the specified `FormatType`.
`PrettySerializingContentHandler(FormatType theFormat, Writer theWriter)` A formatting serializer that adds whitespace to the document according to the specified `FormatType`.

Method Summary
`void` | `characters(char[] chars, int start, int length)`
`protected String` | `decorateAttributeName(String attrName)`
`protected String` | `decorateAttributeValue(String attrValue)`
`protected String` | `decorateCharacters(String characters)`
`protected String` | `decorateIndent(int indentLevel)`
`protected String` | `decorateTagName(String tagName)`
`private void` | `emitWhitespace(int indentLevel)`
`void` | `endDocument()`
`void` | `endElement(String uri, String localname, String qname)`
`void` | `endPrefixMapping(String prefix)`
`protected String` | `getEmptyTagEnd()`
`protected String` | `getEndTagStart()`
`protected String` | `getNewline()`
`protected String` | `getPIEnd()`
`protected String` | `getPIStart()`
`protected String` | `getTagEnd()`
`protected String` | `getTagStart()`
`private void` | `handlePending()`
`void` | `ignorableWhitespace(char[] chars, int start, int length)`
`void` | `processingInstruction(String target, String data)`
`void` | `setDocumentLocator(Locator locator)`
`void` | `skippedEntity(String name)`
`void` | `startDocument()`
`void` | `startElement(String uri, String localname, String qname, Attributes attrs)`
`void` | `startPrefixMapping(String prefix, String uri)`
`String` | `toString()`
`protected void` | `write(char obj)`
`protected void` | `write(String obj)`

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

Field Detail

### indentation

    private static char[] indentation

  This allows for rapid output of whitespace.

### depth

    private int depth

  The depth is incremented on each startElement and decremented on each endElement. This is used to output the indentation.

### lookingForChars

    private boolean lookingForChars

  It is possible that characters(...) will be called for adjacent pieces of text. Often this is due to entities in the text. This will allow for these to be joined back together.

### pendingEndTag

    private boolean pendingEndTag

  One of the difficulties in SAX parsing is that it does not retain state. Even for an empty tag, it calls startElement and endElement. This allows for making empty elements to have the empty tag notation: <tag/>.

### formatting

    private FormatType formatting

### writer

    private Writer writer

Constructor Detail

### PrettySerializingContentHandler

    public PrettySerializingContentHandler()

  A formatting serializer that does not add whitespace to the document. This uses a StringWriter and the toString method will return its content.

### PrettySerializingContentHandler

    public PrettySerializingContentHandler(FormatType theFormat)

  A formatting serializer that adds whitespace to the document according to the specified `FormatType`. This uses a StringWriter and the toString method will return its content.

  Parameters:
    `theFormat` - the formatting to use

### PrettySerializingContentHandler

    public PrettySerializingContentHandler(FormatType theFormat,
                                           Writer theWriter)

  A formatting serializer that adds whitespace to the document according to the specified `FormatType`. As the document is serialized it is written to the provided `Writer`.

  Parameters:
    `theFormat` - the formatting to use
    `theWriter` - the writer to use

Method Detail

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### setDocumentLocator

    public void setDocumentLocator(Locator locator)

  Specified by:
    `setDocumentLocator` in interface `ContentHandler`

### startDocument

    public void startDocument()

  Specified by:
    `startDocument` in interface `ContentHandler`

### endDocument

    public void endDocument()

  Specified by:
    `endDocument` in interface `ContentHandler`

### startPrefixMapping

    public void startPrefixMapping(String prefix,
                                   String uri)

  Specified by:
    `startPrefixMapping` in interface `ContentHandler`

### endPrefixMapping

    public void endPrefixMapping(String prefix)

  Specified by:
    `endPrefixMapping` in interface `ContentHandler`

### startElement

    public void startElement(String uri,
                             String localname,
                             String qname,
                             Attributes attrs)

  Specified by:
    `startElement` in interface `ContentHandler`

### endElement

    public void endElement(String uri,
                           String localname,
                           String qname)

  Specified by:
    `endElement` in interface `ContentHandler`

### characters

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

  Specified by:
    `characters` in interface `ContentHandler`

### ignorableWhitespace

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

  Specified by:
    `ignorableWhitespace` in interface `ContentHandler`

### processingInstruction

    public void processingInstruction(String target,
                                      String data)

  Specified by:
    `processingInstruction` in interface `ContentHandler`

### skippedEntity

    public void skippedEntity(String name)

  Specified by:
    `skippedEntity` in interface `ContentHandler`

### getTagStart

    protected String getTagStart()

### getTagEnd

    protected String getTagEnd()

### getEmptyTagEnd

    protected String getEmptyTagEnd()

### getEndTagStart

    protected String getEndTagStart()

### getPIStart

    protected String getPIStart()

### getPIEnd

    protected String getPIEnd()

### getNewline

    protected String getNewline()

### decorateTagName

    protected String decorateTagName(String tagName)

### decorateAttributeName

    protected String decorateAttributeName(String attrName)

### decorateAttributeValue

    protected String decorateAttributeValue(String attrValue)

### decorateCharacters

    protected String decorateCharacters(String characters)

### decorateIndent

    protected String decorateIndent(int indentLevel)

### write

    protected void write(String obj)

### write

    protected void write(char obj)

### handlePending

    private void handlePending()

### emitWhitespace

    private void emitWhitespace(int indentLevel)

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