001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 */
021package org.biojava.utils.stax;
022
023import org.xml.sax.Attributes;
024import org.xml.sax.Locator;
025import org.xml.sax.SAXException;
026
027/**
028 * Interface for StAX content handlers.  This interface is
029 * very similar in spirit and design to the SAX content handler.
030 * Differences are:
031 *
032 * <ol>
033 * <li>start/endDocument methods are replaced by start/endTree.  This
034 *     recognises the fact that a StAX content handler may only see
035 *     a sub-tree of an XML document, rather than the whole document.</li>
036 * <li>the startElement method takes a <code>DelegationManager</code>,
037 *     allowing delegation of sub-trees to other content handlers.</li>
038 * </ol>
039 *
040 * @author Thomas Down
041 */
042
043public interface StAXContentHandler {
044    public void startTree()
045        throws SAXException;
046
047    public void endTree()
048        throws SAXException;
049
050    public void characters(char[] ch,
051                           int start,
052                           int length)
053        throws SAXException;
054
055    public void ignorableWhitespace(char[] ch,
056                                    int start,
057                                    int length)
058        throws SAXException;
059
060    public void startPrefixMapping(String prefix, String uri)
061        throws SAXException;
062
063    public void endPrefixMapping(String prefix)
064        throws SAXException;
065
066    public void processingInstruction(String target, String data)
067        throws SAXException;
068
069    public void setDocumentLocator(Locator locator);
070
071    public void skippedEntity(String name)
072        throws SAXException;
073
074    public void startElement(String nsURI,
075                             String localName,
076                             String qName,
077                             Attributes attrs,
078                             DelegationManager dm)
079        throws SAXException;
080
081    public void endElement(String nsURI,
082                           String localName,
083                           String qName,
084                           StAXContentHandler delegate)
085        throws SAXException;
086}