com.jdon.util.jdom
类 XMLFilterBase

java.lang.Object
  继承者 org.xml.sax.helpers.XMLFilterImpl
      继承者 com.jdon.util.jdom.XMLFilterBase
所有已实现的接口:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler, LexicalHandler, XMLFilter, XMLReader
直接已知子类:
DataFormatFilter, DataUnformatFilter

public class XMLFilterBase
extends XMLFilterImpl
implements LexicalHandler

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)
           
 
从类 org.xml.sax.helpers.XMLFilterImpl 继承的方法
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, warning
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

EMPTY_ATTS

protected static final Attributes EMPTY_ATTS

LEXICAL_HANDLER_NAMES

protected static final String[] LEXICAL_HANDLER_NAMES
构造方法详细信息

XMLFilterBase

public XMLFilterBase()
Construct an XML filter with no parent.

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)

XMLFilterBase

public XMLFilterBase(XMLReader parent)
Create an XML filter with the specified parent.

Use the XMLReader provided as the source of events.

参数:
xmlreader - The parent in the filter chain.
方法详细信息

startElement

public void startElement(String uri,
                         String localName)
                  throws SAXException
Start a new element without a qname or attributes.

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)

startElement

public void startElement(String localName,
                         Attributes atts)
                  throws SAXException
Start a new element without a Namespace URI or qname.

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)

startElement

public void startElement(String localName)
                  throws SAXException
Start a new element without a Namespace URI, qname, or attributes.

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)

endElement

public void endElement(String uri,
                       String localName)
                throws SAXException
End an element without a qname.

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)

endElement

public void endElement(String localName)
                throws SAXException
End an element without a Namespace URI or qname.

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)

emptyElement

public void emptyElement(String uri,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Add an empty element. Both a 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)

emptyElement

public void emptyElement(String uri,
                         String localName)
                  throws SAXException
Add an empty element without a qname or attributes.

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)

emptyElement

public void emptyElement(String localName,
                         Attributes atts)
                  throws SAXException
Add an empty element without a Namespace URI or qname.

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)

emptyElement

public void emptyElement(String localName)
                  throws SAXException
Add an empty element without a Namespace URI, qname or attributes.

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)

dataElement

public void dataElement(String uri,
                        String localName,
                        String qName,
                        Attributes atts,
                        String content)
                 throws SAXException
Add an element with character data content.

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)

dataElement

public void dataElement(String uri,
                        String localName,
                        String content)
                 throws SAXException
Add an element with character data content but no qname or attributes.

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)

dataElement

public void dataElement(String localName,
                        Attributes atts,
                        String content)
                 throws SAXException
Add an element with character data content but no Namespace URI or qname.

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)

dataElement

public void dataElement(String localName,
                        String content)
                 throws SAXException
Add an element with character data content but no attributes or Namespace URI.

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)

characters

public void characters(String data)
                throws SAXException
Add a string of character data, with XML escaping.

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

setProperty

public void setProperty(String name,
                        Object value)
                 throws SAXNotRecognizedException,
                        SAXNotSupportedException
Set the value of a property.

This will always fail if the parent is null.

指定者:
接口 XMLReader 中的 setProperty
覆盖:
XMLFilterImpl 中的 setProperty
参数:
name - 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)

getProperty

public Object getProperty(String name)
                   throws SAXNotRecognizedException,
                          SAXNotSupportedException
Look up the value of a property.

指定者:
接口 XMLReader 中的 getProperty
覆盖:
XMLFilterImpl 中的 getProperty
参数:
name - The property name.
返回:
The current value of the property.
抛出:
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)

parse

public void parse(InputSource input)
           throws SAXException,
                  IOException
Parse a document.

指定者:
接口 XMLReader 中的 parse
覆盖:
XMLFilterImpl 中的 parse
参数:
input - 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)

setLexicalHandler

public void setLexicalHandler(LexicalHandler handler)
Set the lexical handler.

参数:
handler - The new lexical handler.
抛出:
NullPointerException - If the handler is null.

getLexicalHandler

public LexicalHandler getLexicalHandler()
Get the current lexical handler.

返回:
The current lexical handler, or null if none was set.

startDTD

public void startDTD(String name,
                     String publicId,
                     String systemId)
              throws SAXException
Filter a start DTD event.

指定者:
接口 LexicalHandler 中的 startDTD
参数:
name - 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)

endDTD

public void endDTD()
            throws SAXException
Filter a end DTD event.

指定者:
接口 LexicalHandler 中的 endDTD
抛出:
SAXException - If a filter further down the chain raises an exception.
另请参见:
LexicalHandler.endDTD()

startEntity

public void startEntity(String name)
                 throws SAXException
指定者:
接口 LexicalHandler 中的 startEntity
抛出:
SAXException

endEntity

public void endEntity(String name)
               throws SAXException
指定者:
接口 LexicalHandler 中的 endEntity
抛出:
SAXException

startCDATA

public void startCDATA()
                throws SAXException
指定者:
接口 LexicalHandler 中的 startCDATA
抛出:
SAXException

endCDATA

public void endCDATA()
              throws SAXException
指定者:
接口 LexicalHandler 中的 endCDATA
抛出:
SAXException

comment

public void comment(char[] ch,
                    int start,
                    int length)
             throws SAXException
指定者:
接口 LexicalHandler 中的 comment
抛出:
SAXException


Copyright © 2013. All Rights Reserved.