All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.biojava.bio.program.ssbind.SeqSimilarityAdapter Maven / Gradle / Ivy

There is a newer version: 1.9.7
Show newest version
/*
 *                    BioJava development code
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  If you do not have a copy,
 * see:
 *
 *      http://www.gnu.org/copyleft/lesser.html
 *
 * Copyright for this code is held jointly by the individual
 * authors.  These should be listed in @author doc comments.
 *
 * For more information on the BioJava project and its aims,
 * or to join the biojava-l mailing list, visit the home page
 * at:
 *
 *      http://www.biojava.org/
 *
 */

package org.biojava.bio.program.ssbind;

import org.biojava.bio.search.SearchContentHandler;
import org.biojava.utils.stax.SAX2StAXAdaptor;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;

/**
 * A SeqSimilarityAdapter converts SAX events into method
 * calls on a SearchContentHandler implementation. The
 * SAX events should describe elements conforming to the BioJava
 * BlastLikeDataSetCollection DTD. A
 * BlastLikeSearchBuilder is supplied, implementing the
 * SearchContentHandler interface, which will create
 * SeqSimilaritySearchResults from the stream.
 *
 * @author Keith James
 * @since 1.2
 */
public class SeqSimilarityAdapter implements ContentHandler
{
    private SeqSimilarityStAXAdapter staxHandler;
    private ContentHandler contentHandler;
    
    public SeqSimilarityAdapter()
    {
        staxHandler = new SeqSimilarityStAXAdapter();
        contentHandler = new SAX2StAXAdaptor(staxHandler);
    }

    /**
     * getSearchContentHandler gets the handler which
     * will recieve the method calls generated by the adapter.
     *
     * @return a SearchContentHandler.
     */
    public SearchContentHandler getSearchContentHandler()
    {
        return staxHandler.getSearchContentHandler();
    }

    /**
     * setSearchContentHandler sets the handler which
     * will recieve the method calls generated by the adapter.
     *
     * @param scHandler a SearchContentHandler.
     */
    public void setSearchContentHandler(SearchContentHandler scHandler)
    {
        staxHandler.setSearchContentHandler(scHandler);
    }

    public void startDocument() throws SAXException
    {
        contentHandler.startDocument();
    }

    public void endDocument() throws SAXException
    {
        contentHandler.endDocument();
    }

    public void characters(char[] ch, int start, int end) throws SAXException
    {
	contentHandler.characters(ch, start, end);
    }

    public void ignorableWhitespace(char[] ch, int start, int end)
	throws SAXException
    {
	contentHandler.ignorableWhitespace(ch, start, end);
    }

    public void startPrefixMapping(String prefix, String uri)
        throws SAXException
    {
	contentHandler.startPrefixMapping(prefix, uri);
    }

    public void endPrefixMapping(String prefix) throws SAXException
    {
	contentHandler.endPrefixMapping(prefix);
    }

    public void processingInstruction(String target, String data)
        throws SAXException
    {
	contentHandler.processingInstruction(target, data);
    }

    public void setDocumentLocator(Locator locator)
    {
	contentHandler.setDocumentLocator(locator);
    }

    public void skippedEntity(String name) throws SAXException
    {
	contentHandler.skippedEntity(name);
    }

    public void startElement(String     nsURI,
			     String     localName,
			     String     qName,
			     Attributes attrs)
	throws SAXException
    {
        contentHandler.startElement(nsURI, localName, qName, attrs);
    }

    public void endElement(String nsURI, String localName, String qName)
        throws SAXException
    {
        contentHandler.endElement(nsURI, localName, qName);
    }

    /**
     * getProgram returns the program type which
     * generated the results.
     *
     * @return a String indicating the progam
     * name.
     */
    String getProgram()
    {
        return staxHandler.getProgram();
    }

    /**
     * setProgram informs the adapter which program type
     * it is working on.
     *
     * @param program a String indicating the progam
     * name.
     */
    void setProgram(String program)
    {
        staxHandler.setProgram(program);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy