public class DataUnformatFilter extends XMLFilterBase
This filter removes leading and trailing whitespace from field-oriented XML without mixed content. Note that this class will likely not yield appropriate results for document-oriented XML like XHTML pages, which mix character data and elements together.
DataFormatFilterEMPTY_ATTS, LEXICAL_HANDLER_NAMES| 构造器和说明 |
|---|
DataUnformatFilter()
Create a new filter.
|
DataUnformatFilter(XMLReader xmlreader)
Create a new filter.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
characters(char[] ch,
int start,
int length)
Filter a character data event.
|
protected void |
clearWhitespace()
Discards saved whitespace.
|
protected void |
emitWhitespace()
Passes saved whitespace down the filter chain.
|
void |
endElement(String uri,
String localName,
String qName)
Filter an end element event.
|
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Filter an ignorable whitespace event.
|
void |
processingInstruction(String target,
String data)
Filter a processing instruction event.
|
void |
reset()
Reset the filter so that it can be reused.
|
protected void |
saveWhitespace(char[] ch,
int start,
int length)
Saves trailing whitespace.
|
void |
startDocument()
Filter a start document event.
|
void |
startElement(String uri,
String localName,
String qName,
Attributes atts)
Filter a start element event.
|
characters, comment, dataElement, dataElement, dataElement, dataElement, emptyElement, emptyElement, emptyElement, emptyElement, endCDATA, endDTD, endElement, endElement, endEntity, getLexicalHandler, getProperty, parse, setLexicalHandler, setProperty, startCDATA, startDTD, startElement, startElement, startElement, startEntityendDocument, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, notationDecl, parse, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, skippedEntity, startPrefixMapping, unparsedEntityDecl, warningpublic DataUnformatFilter()
public DataUnformatFilter(XMLReader xmlreader)
Use the XMLReader provided as the source of events.
xmlreader - The parent in the filter chain.public void reset()
This method is especially useful if the filter failed with an exception the last time through.
public void startDocument()
throws SAXException
Reset state and pass the event on for further processing.
startDocument 在接口中 ContentHandlerstartDocument 在类中 org.xml.sax.helpers.XMLFilterImplSAXException - If a filter further down the chain raises an exception.ContentHandler.startDocument()public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException
startElement 在接口中 ContentHandlerstartElement 在类中 org.xml.sax.helpers.XMLFilterImpluri - 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 a filter further down the chain raises an exception.ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)public void endElement(String uri, String localName, String qName) throws SAXException
endElement 在接口中 ContentHandlerendElement 在类中 org.xml.sax.helpers.XMLFilterImpluri - The element's Namespace URI.localName - The element's local name.qName - The element's qualified (prefixed) name.SAXException - If a filter further down the chain raises an exception.ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)public void characters(char[] ch,
int start,
int length)
throws SAXException
characters 在接口中 ContentHandlercharacters 在类中 org.xml.sax.helpers.XMLFilterImplch - The characters to write.start - The starting position in the array.length - The number of characters to use.SAXException - If a filter further down the chain raises an exception.ContentHandler.characters(char[], int, int)public void ignorableWhitespace(char[] ch,
int start,
int length)
throws SAXException
ignorableWhitespace 在接口中 ContentHandlerignorableWhitespace 在类中 org.xml.sax.helpers.XMLFilterImplch - The array of characters to write.start - The starting position in the array.length - The number of characters to write.SAXException - If a filter further down the chain raises an exception.ContentHandler.ignorableWhitespace(char[], int, int)public void processingInstruction(String target, String data) throws SAXException
processingInstruction 在接口中 ContentHandlerprocessingInstruction 在类中 org.xml.sax.helpers.XMLFilterImpltarget - The PI target.data - The PI data.SAXException - If a filter further down the chain raises an exception.ContentHandler.processingInstruction(java.lang.String, java.lang.String)protected void saveWhitespace(char[] ch,
int start,
int length)
protected void emitWhitespace()
throws SAXException
SAXExceptionprotected void clearWhitespace()
Copyright © 2018. All rights reserved.