TXW2 Runtime 20110809-redhat-2

com.sun.xml.txw2.output
Class IndentingXMLFilter

java.lang.Object
  extended by org.xml.sax.helpers.XMLFilterImpl
      extended by com.sun.xml.txw2.output.IndentingXMLFilter
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler, LexicalHandler, XMLFilter, XMLReader

public class IndentingXMLFilter
extends org.xml.sax.helpers.XMLFilterImpl
implements LexicalHandler

XMLFilterImpl that does indentation to SAX events.

Author:
Kohsuke Kawaguchi

Constructor Summary
IndentingXMLFilter()
           
IndentingXMLFilter(ContentHandler handler)
           
IndentingXMLFilter(ContentHandler handler, LexicalHandler lexical)
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          Write a sequence of characters.
 void comment(char[] ch, int start, int length)
           
 void endCDATA()
           
 void endDTD()
           
 void endElement(String uri, String localName, String qName)
          Write an end tag.
 void endEntity(String name)
           
 int getIndentStep()
          Deprecated. Only return the length of the indent string.
 LexicalHandler getLexicalHandler()
           
 void setIndentStep(int indentStep)
          Deprecated. Should use the version that takes string.
 void setIndentStep(String s)
           
 void setLexicalHandler(LexicalHandler lexical)
           
 void startCDATA()
           
 void startDTD(String name, String publicId, String systemId)
           
 void startElement(String uri, String localName, String qName, Attributes atts)
          Write a start tag.
 void startEntity(String name)
           
 
Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
endDocument, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, notationDecl, parse, parse, processingInstruction, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, setProperty, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndentingXMLFilter

public IndentingXMLFilter()

IndentingXMLFilter

public IndentingXMLFilter(ContentHandler handler)

IndentingXMLFilter

public IndentingXMLFilter(ContentHandler handler,
                          LexicalHandler lexical)
Method Detail

getLexicalHandler

public LexicalHandler getLexicalHandler()

setLexicalHandler

public void setLexicalHandler(LexicalHandler lexical)

getIndentStep

public int getIndentStep()
Deprecated. Only return the length of the indent string.

Return the current indent step.

Return the current indent step: each start tag will be indented by this number of spaces times the number of ancestors that the element has.

Returns:
The number of spaces in each indentation step, or 0 or less for no indentation.
See Also:
setIndentStep(int)

setIndentStep

public void setIndentStep(int indentStep)
Deprecated. Should use the version that takes string.

Set the current indent step.

Parameters:
indentStep - The new indent step (0 or less for no indentation).
See Also:
getIndentStep()

setIndentStep

public void setIndentStep(String s)

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Write a start tag.

Each tag will begin on a new line, and will be indented by the current indent step times the number of ancestors that the element has.

The newline and indentation will be passed on down the filter chain through regular characters events.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.XMLFilterImpl
Parameters:
uri - The element's Namespace URI.
localName - The element's local name.
qName - The element's qualified (prefixed) name.
atts - The element's attribute list.
Throws:
SAXException - If there is an error writing the start tag, or if a filter further down the chain raises an exception.
See Also:
XMLWriter.startElement(String, String, String,Attributes)

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
Write an end tag.

If the element has contained other elements, the tag will appear indented on a new line; otherwise, it will appear immediately following whatever came before.

The newline and indentation will be passed on down the filter chain through regular characters events.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.XMLFilterImpl
Parameters:
uri - The element's Namespace URI.
localName - The element's local name.
qName - The element's qualified (prefixed) name.
Throws:
SAXException - If there is an error writing the end tag, or if a filter further down the chain raises an exception.
See Also:
XMLWriter.endElement(String, String, String)

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Write a sequence of characters.

Specified by:
characters in interface ContentHandler
Overrides:
characters in class org.xml.sax.helpers.XMLFilterImpl
Parameters:
ch - The characters to write.
start - The starting position in the array.
length - The number of characters to use.
Throws:
SAXException - If there is an error writing the characters, or if a filter further down the chain raises an exception.
See Also:
XMLWriter.characters(char[], int, int)

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws SAXException
Specified by:
comment in interface LexicalHandler
Throws:
SAXException

startDTD

public void startDTD(String name,
                     String publicId,
                     String systemId)
              throws SAXException
Specified by:
startDTD in interface LexicalHandler
Throws:
SAXException

endDTD

public void endDTD()
            throws SAXException
Specified by:
endDTD in interface LexicalHandler
Throws:
SAXException

startEntity

public void startEntity(String name)
                 throws SAXException
Specified by:
startEntity in interface LexicalHandler
Throws:
SAXException

endEntity

public void endEntity(String name)
               throws SAXException
Specified by:
endEntity in interface LexicalHandler
Throws:
SAXException

startCDATA

public void startCDATA()
                throws SAXException
Specified by:
startCDATA in interface LexicalHandler
Throws:
SAXException

endCDATA

public void endCDATA()
              throws SAXException
Specified by:
endCDATA in interface LexicalHandler
Throws:
SAXException

TXW2 Runtime 20110809-redhat-2

Copyright © 2012 Oracle. All Rights Reserved.