Package com.sun.xml.txw2.output
Class IndentingXMLFilter
- java.lang.Object
-
- org.xml.sax.helpers.XMLFilterImpl
-
- com.sun.xml.txw2.output.IndentingXMLFilter
-
- All Implemented Interfaces:
org.xml.sax.ContentHandler,org.xml.sax.DTDHandler,org.xml.sax.EntityResolver,org.xml.sax.ErrorHandler,org.xml.sax.ext.LexicalHandler,org.xml.sax.XMLFilter,org.xml.sax.XMLReader
public class IndentingXMLFilter extends org.xml.sax.helpers.XMLFilterImpl implements org.xml.sax.ext.LexicalHandlerXMLFilterImplthat does indentation to SAX events.- Author:
- Kohsuke Kawaguchi
-
-
Constructor Summary
Constructors Constructor Description IndentingXMLFilter()IndentingXMLFilter(org.xml.sax.ContentHandler handler)IndentingXMLFilter(org.xml.sax.ContentHandler handler, org.xml.sax.ext.LexicalHandler lexical)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidcharacters(char[] ch, int start, int length)Write a sequence of characters.voidcomment(char[] ch, int start, int length)voidendCDATA()voidendDTD()voidendElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)Write an end tag.voidendEntity(java.lang.String name)intgetIndentStep()Deprecated.Only return the length of the indent string.org.xml.sax.ext.LexicalHandlergetLexicalHandler()voidsetIndentStep(int indentStep)Deprecated.Should use the version that takes string.voidsetIndentStep(java.lang.String s)voidsetLexicalHandler(org.xml.sax.ext.LexicalHandler lexical)voidstartCDATA()voidstartDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)voidstartElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)Write a start tag.voidstartEntity(java.lang.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
-
-
-
-
Method Detail
-
getLexicalHandler
public org.xml.sax.ext.LexicalHandler getLexicalHandler()
-
setLexicalHandler
public void setLexicalHandler(org.xml.sax.ext.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(java.lang.String s)
-
startElement
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts) throws org.xml.sax.SAXExceptionWrite 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:
startElementin interfaceorg.xml.sax.ContentHandler- Overrides:
startElementin classorg.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:
org.xml.sax.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(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXExceptionWrite 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:
endElementin interfaceorg.xml.sax.ContentHandler- Overrides:
endElementin classorg.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:
org.xml.sax.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 org.xml.sax.SAXExceptionWrite a sequence of characters.- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler- Overrides:
charactersin classorg.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:
org.xml.sax.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 org.xml.sax.SAXException- Specified by:
commentin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
startDTD
public void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId) throws org.xml.sax.SAXException- Specified by:
startDTDin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
endDTD
public void endDTD() throws org.xml.sax.SAXException- Specified by:
endDTDin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
startEntity
public void startEntity(java.lang.String name) throws org.xml.sax.SAXException- Specified by:
startEntityin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
endEntity
public void endEntity(java.lang.String name) throws org.xml.sax.SAXException- Specified by:
endEntityin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
startCDATA
public void startCDATA() throws org.xml.sax.SAXException- Specified by:
startCDATAin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
endCDATA
public void endCDATA() throws org.xml.sax.SAXException- Specified by:
endCDATAin interfaceorg.xml.sax.ext.LexicalHandler- Throws:
org.xml.sax.SAXException
-
-