public class IndentingXMLFilter extends XMLFilterImpl implements LexicalHandler
XMLFilterImpl
that does indentation to SAX events.Constructor and Description |
---|
IndentingXMLFilter() |
IndentingXMLFilter(ContentHandler handler) |
IndentingXMLFilter(ContentHandler handler,
LexicalHandler lexical) |
Modifier and Type | Method and Description |
---|---|
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) |
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
public IndentingXMLFilter()
public IndentingXMLFilter(ContentHandler handler)
public IndentingXMLFilter(ContentHandler handler, LexicalHandler lexical)
public LexicalHandler getLexicalHandler()
public void setLexicalHandler(LexicalHandler lexical)
@Deprecated public int getIndentStep()
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.
setIndentStep(int)
@Deprecated public void setIndentStep(int indentStep)
indentStep
- The new indent step (0 or less for no
indentation).getIndentStep()
public void setIndentStep(String s)
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException
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.
startElement
in interface ContentHandler
startElement
in class XMLFilterImpl
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.SAXException
- If there is an error
writing the start tag, or if a filter further
down the chain raises an exception.XMLWriter.startElement(String, String, String,Attributes)
public void endElement(String uri, String localName, String qName) throws SAXException
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.
endElement
in interface ContentHandler
endElement
in class XMLFilterImpl
uri
- The element's Namespace URI.localName
- The element's local name.qName
- The element's qualified (prefixed) name.SAXException
- If there is an error
writing the end tag, or if a filter further
down the chain raises an exception.XMLWriter.endElement(String, String, String)
public void characters(char[] ch, int start, int length) throws SAXException
characters
in interface ContentHandler
characters
in class XMLFilterImpl
ch
- The characters to write.start
- The starting position in the array.length
- The number of characters to use.SAXException
- If there is an error
writing the characters, or if a filter further
down the chain raises an exception.XMLWriter.characters(char[], int, int)
public void comment(char[] ch, int start, int length) throws SAXException
comment
in interface LexicalHandler
SAXException
public void startDTD(String name, String publicId, String systemId) throws SAXException
startDTD
in interface LexicalHandler
SAXException
public void endDTD() throws SAXException
endDTD
in interface LexicalHandler
SAXException
public void startEntity(String name) throws SAXException
startEntity
in interface LexicalHandler
SAXException
public void endEntity(String name) throws SAXException
endEntity
in interface LexicalHandler
SAXException
public void startCDATA() throws SAXException
startCDATA
in interface LexicalHandler
SAXException
public void endCDATA() throws SAXException
endCDATA
in interface LexicalHandler
SAXException
Copyright © 2021 JBoss by Red Hat. All rights reserved.