Save This Page
Home » Xerces-J-src.2.9.1 » sax » [javadoc | source]
sax
public class: XMLFilterBase [javadoc | source]
java.lang.Object
   org.xml.sax.helpers.XMLFilterImpl
      sax.XMLFilterBase

All Implemented Interfaces:
    LexicalHandler, ErrorHandler, EntityResolver, XMLFilter, ContentHandler, DTDHandler

Direct Known Subclasses:
    XMLWriter, DataUnformatFilter, DataFormatFilter

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");
Field Summary
protected static final  Attributes EMPTY_ATTS     
protected static final  String[] LEXICAL_HANDLER_NAMES     
Constructor:
 public XMLFilterBase() 
 public XMLFilterBase(XMLReader parent) 
    Create an XML filter with the specified parent.

    Use the XMLReader provided as the source of events.

    Parameters:
    xmlreader - The parent in the filter chain.
Method from sax.XMLFilterBase Summary:
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,   startEntity
Methods from org.xml.sax.helpers.XMLFilterImpl:
characters,   endDocument,   endElement,   endPrefixMapping,   error,   fatalError,   getContentHandler,   getDTDHandler,   getEntityResolver,   getErrorHandler,   getFeature,   getParent,   getProperty,   ignorableWhitespace,   notationDecl,   parse,   parse,   processingInstruction,   resolveEntity,   setContentHandler,   setDTDHandler,   setDocumentLocator,   setEntityResolver,   setErrorHandler,   setFeature,   setParent,   setProperty,   skippedEntity,   startDocument,   startElement,   startPrefixMapping,   unparsedEntityDecl,   warning
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from sax.XMLFilterBase Detail:
 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 .

 public  void comment(char[] ch,
    int start,
    int length) throws SAXException 
 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.

 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.

 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.

 public  void dataElement(String uri,
    String localName,
    String qName,
    Attributes atts,
    String content) throws SAXException 
 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.

 public  void emptyElement(String uri,
    String localName) throws SAXException 
 public  void emptyElement(String localName,
    Attributes atts) throws SAXException 
 public  void emptyElement(String uri,
    String localName,
    String qName,
    Attributes atts) throws SAXException 
 public  void endCDATA() throws SAXException 
 public  void endDTD() throws SAXException 
    Filter a end DTD event.
 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 #endElement(String, String, String) directly.

 public  void endElement(String uri,
    String localName) throws SAXException 
 public  void endEntity(String name) throws SAXException 
 public LexicalHandler getLexicalHandler() 
    Get the current lexical handler.
 public Object getProperty(String name) throws SAXNotSupportedException, SAXNotRecognizedException 
    Look up the value of a property.
 public  void parse(InputSource input) throws IOException, SAXException 
    Parse a document.
 public  void setLexicalHandler(LexicalHandler handler) 
    Set the lexical handler.
 public  void setProperty(String name,
    Object value) throws SAXNotSupportedException, SAXNotRecognizedException 
    Set the value of a property.

    This will always fail if the parent is null.

 public  void startCDATA() throws SAXException 
 public  void startDTD(String name,
    String publicId,
    String systemId) throws SAXException 
    Filter a start DTD event.
 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 #startElement(String, String, String, Attributes) directly.

 public  void startElement(String uri,
    String localName) throws SAXException 
 public  void startElement(String localName,
    Attributes atts) throws SAXException 
 public  void startEntity(String name) throws SAXException