public class XMLFilterBase extends org.xml.sax.helpers.XMLFilterImpl implements LexicalHandler
The convenience methods are provided so that clients do not have to create empty attribute lists or provide empty strings as parameters; for example, the method invocation
w.startElement("foo");
is equivalent to the regular SAX2 ContentHandler method
w.startElement("", "foo", "", new AttributesImpl());
Except that it is more efficient because it does not allocate a new empty attribute list each time.
In fact, there is an even simpler convenience method, dataElement, designed for writing elements that contain only character data.
w.dataElement("greeting", "Hello, world!");
is equivalent to
w.startElement("greeting");
w.characters("Hello, world!");
w.endElement("greeting");
XMLFilterImpl| 限定符和类型 | 字段和说明 |
|---|---|
protected static Attributes |
EMPTY_ATTS |
protected static String[] |
LEXICAL_HANDLER_NAMES |
| 构造器和说明 |
|---|
XMLFilterBase()
Construct an XML filter with no parent.
|
XMLFilterBase(XMLReader parent)
Create an XML filter with the specified parent.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
characters(String data)
Add a string of character data, with XML escaping.
|
void |
comment(char[] ch,
int start,
int length) |
void |
dataElement(String localName,
Attributes atts,
String content)
Add an element with character data content but no Namespace URI or qname.
|
void |
dataElement(String localName,
String content)
Add an element with character data content but no attributes
or Namespace URI.
|
void |
dataElement(String uri,
String localName,
String content)
Add an element with character data content but no qname or attributes.
|
void |
dataElement(String uri,
String localName,
String qName,
Attributes atts,
String content)
Add an element with character data content.
|
void |
emptyElement(String localName)
Add an empty element without a Namespace URI, qname or attributes.
|
void |
emptyElement(String localName,
Attributes atts)
Add an empty element without a Namespace URI or qname.
|
void |
emptyElement(String uri,
String localName)
Add an empty element without a qname or attributes.
|
void |
emptyElement(String uri,
String localName,
String qName,
Attributes atts)
Add an empty element.
|
void |
endCDATA() |
void |
endDTD()
Filter a end DTD event.
|
void |
endElement(String localName)
End an element without a Namespace URI or qname.
|
void |
endElement(String uri,
String localName)
End an element without a qname.
|
void |
endEntity(String name) |
LexicalHandler |
getLexicalHandler()
Get the current lexical handler.
|
Object |
getProperty(String name)
Look up the value of a property.
|
void |
parse(InputSource input)
Parse a document.
|
void |
setLexicalHandler(LexicalHandler handler)
Set the lexical handler.
|
void |
setProperty(String name,
Object value)
Set the value of a property.
|
void |
startCDATA() |
void |
startDTD(String name,
String publicId,
String systemId)
Filter a start DTD event.
|
void |
startElement(String localName)
Start a new element without a Namespace URI, qname, or attributes.
|
void |
startElement(String localName,
Attributes atts)
Start a new element without a Namespace URI or qname.
|
void |
startElement(String uri,
String localName)
Start a new element without a qname or attributes.
|
void |
startEntity(String name) |
characters, endDocument, endElement, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, ignorableWhitespace, notationDecl, parse, processingInstruction, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warningprotected static final Attributes EMPTY_ATTS
protected static final String[] LEXICAL_HANDLER_NAMES
public XMLFilterBase()
This filter will have no parent: you must assign a parent before you start a parse or do any configuration with setFeature or setProperty.
public XMLFilterBase(XMLReader parent)
Use the XMLReader provided as the source of events.
xmlreader - The parent in the filter chain.public void startElement(String uri, String localName) throws SAXException
This method will provide a default empty attribute
list and an empty string for the qualified name. It invokes
XMLFilterImpl.startElement(String, String, String, Attributes)
directly.
uri - The element's Namespace URI.localName - The element's local name.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 startElement(String localName, Attributes atts) throws SAXException
This method will provide an empty string for the
Namespace URI, and empty string for the qualified name.
It invokes
XMLFilterImpl.startElement(String, String, String, Attributes)
directly.
localName - The element's local 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 startElement(String localName) throws SAXException
This method will provide an empty string for the
Namespace URI, and empty string for the qualified name,
and a default empty attribute list. It invokes
XMLFilterImpl.startElement(String, String, String, Attributes)
directly.
localName - The element's local name.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) throws SAXException
This method will supply an empty string for the qName.
It invokes XMLFilterImpl.endElement(String, String, String)
directly.
uri - The element's Namespace URI.localName - The element's local 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 endElement(String localName) throws SAXException
This method will supply an empty string for the qName
and an empty string for the Namespace URI.
It invokes XMLFilterImpl.endElement(String, String, String)
directly.
localName - The element's local 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 emptyElement(String uri, String localName, String qName, Attributes atts) throws SAXException
startElement and an
endElement event will be passed on down
the filter chain.uri - The element's Namespace URI, or the empty string
if the element has no Namespace or if Namespace
processing is not being performed.localName - The element's local name (without prefix). This
parameter must be provided.qName - The element's qualified name (with prefix), or
the empty string if none is available. This parameter
is strictly advisory: the writer may or may not use
the prefix attached.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),
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)public void emptyElement(String uri, String localName) throws SAXException
This method will supply an empty string for the qname
and an empty attribute list. It invokes
emptyElement(String, String, String, Attributes)
directly.
uri - The element's Namespace URI.localName - The element's local name.SAXException - If a filter
further down the chain raises an exception.emptyElement(String, String, String, Attributes)public void emptyElement(String localName, Attributes atts) throws SAXException
This method will provide an empty string for the
Namespace URI, and empty string for the qualified name.
It invokes
emptyElement(String, String, String, Attributes)
directly.
localName - The element's local 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 emptyElement(String localName) throws SAXException
This method will supply an empty string for the qname,
and empty string for the Namespace URI, and an empty
attribute list. It invokes
emptyElement(String, String, String, Attributes)
directly.
localName - The element's local name.SAXException - If a filter
further down the chain raises an exception.emptyElement(String, String, String, Attributes)public void dataElement(String uri, String localName, String qName, Attributes atts, String content) throws SAXException
This is a convenience method to add a complete element with character data content, including the start tag and end tag.
This method invokes
org.xml.sax.ContentHandler#startElement,
followed by
characters(String), followed by
org.xml.sax.ContentHandler#endElement.
uri - The element's Namespace URI.localName - The element's local name.qName - The element's default qualified name.atts - The element's attributes.content - The character data content.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),
characters(String),
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)public void dataElement(String uri, String localName, String content) throws SAXException
This is a convenience method to add a complete element
with character data content, including the start tag
and end tag. This method provides an empty string
for the qname and an empty attribute list. It invokes
dataElement(String, String, String, Attributes, String)}
directly.
uri - The element's Namespace URI.localName - The element's local name.content - The character data content.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),
characters(String),
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)public void dataElement(String localName, Attributes atts, String content) throws SAXException
This is a convenience method to add a complete element
with character data content, including the start tag
and end tag. The method provides an empty string for the
Namespace URI, and empty string for the qualified name. It invokes
dataElement(String, String, String, Attributes, String)}
directly.
localName - The element's local name.atts - The element's attributes.content - The character data content.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),
characters(String),
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)public void dataElement(String localName, String content) throws SAXException
This is a convenience method to add a complete element
with character data content, including the start tag
and end tag. The method provides an empty string for the
Namespace URI, and empty string for the qualified name,
and an empty attribute list. It invokes
dataElement(String, String, String, Attributes, String)}
directly.
localName - The element's local name.content - The character data content.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),
characters(String),
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)public void characters(String data) throws SAXException
This is a convenience method that takes an XML
String, converts it to a character array, then invokes
org.xml.sax.ContentHandler#characters.
data - The character data.SAXException - If a filter
further down the chain raises an exception.org.xml.sax.ContentHandler#characterspublic void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException
This will always fail if the parent is null.
setProperty 在接口中 XMLReadersetProperty 在类中 org.xml.sax.helpers.XMLFilterImplname - The property name.state - The requested property value.SAXNotRecognizedException - When the
XMLReader does not recognize the property name.SAXNotSupportedException - When the
XMLReader recognizes the property name but
cannot set the requested value.XMLReader.setProperty(java.lang.String, java.lang.Object)public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException
getProperty 在接口中 XMLReadergetProperty 在类中 org.xml.sax.helpers.XMLFilterImplname - The property name.SAXNotRecognizedException - When the
XMLReader does not recognize the feature name.SAXNotSupportedException - When the
XMLReader recognizes the property name but
cannot determine its value at this time.XMLReader.setFeature(java.lang.String, boolean)public void parse(InputSource input) throws SAXException, IOException
parse 在接口中 XMLReaderparse 在类中 org.xml.sax.helpers.XMLFilterImplinput - The input source for the document entity.SAXException - Any SAX exception, possibly
wrapping another exception.IOException - An IO exception from the parser,
possibly from a byte stream or character stream
supplied by the application.XMLReader.parse(org.xml.sax.InputSource)public void setLexicalHandler(LexicalHandler handler)
handler - The new lexical handler.NullPointerException - If the handler
is null.public LexicalHandler getLexicalHandler()
public void startDTD(String name, String publicId, String systemId) throws SAXException
startDTD 在接口中 LexicalHandlername - The document type name.publicId - The declared public identifier for the
external DTD subset, or null if none was declared.systemId - The declared system identifier for the
external DTD subset, or null if none was declared.SAXException - If a filter
further down the chain raises an exception.LexicalHandler.startDTD(java.lang.String, java.lang.String, java.lang.String)public void endDTD()
throws SAXException
endDTD 在接口中 LexicalHandlerSAXException - If a filter
further down the chain raises an exception.LexicalHandler.endDTD()public void startEntity(String name) throws SAXException
startEntity 在接口中 LexicalHandlerSAXExceptionpublic void endEntity(String name) throws SAXException
endEntity 在接口中 LexicalHandlerSAXExceptionpublic void startCDATA()
throws SAXException
startCDATA 在接口中 LexicalHandlerSAXExceptionpublic void endCDATA()
throws SAXException
endCDATA 在接口中 LexicalHandlerSAXExceptionpublic void comment(char[] ch,
int start,
int length)
throws SAXException
comment 在接口中 LexicalHandlerSAXExceptionCopyright © 2018. All rights reserved.