|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectorg.xml.sax.helpers.XMLFilterImpl
com.jdon.util.jdom.XMLFilterBase
public class XMLFilterBase
Adds convenience methods and lexical event filtering to base SAX2 Filter implementation. Code and comments adapted from XMLWriter-0.2, written by David Megginson and released into the public domain, without warranty.
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)
|
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
protected 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.
XMLReader.setFeature(java.lang.String, boolean),
XMLReader.setProperty(java.lang.String, java.lang.Object)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#characters
public void setProperty(String name,
Object value)
throws SAXNotRecognizedException,
SAXNotSupportedException
This will always fail if the parent is null.
XMLReader 中的 setPropertyXMLFilterImpl 中的 setPropertyname - 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
XMLReader 中的 getPropertyXMLFilterImpl 中的 getPropertyname - 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
XMLReader 中的 parseXMLFilterImpl 中的 parseinput - 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
LexicalHandler 中的 startDTDname - 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
LexicalHandler 中的 endDTDSAXException - If a filter
further down the chain raises an exception.LexicalHandler.endDTD()
public void startEntity(String name)
throws SAXException
LexicalHandler 中的 startEntitySAXException
public void endEntity(String name)
throws SAXException
LexicalHandler 中的 endEntitySAXException
public void startCDATA()
throws SAXException
LexicalHandler 中的 startCDATASAXException
public void endCDATA()
throws SAXException
LexicalHandler 中的 endCDATASAXException
public void comment(char[] ch,
int start,
int length)
throws SAXException
LexicalHandler 中的 commentSAXException
|
||||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||