001/**
002 *  BioJava development code This code may be freely distributed and modified
003 *  under the terms of the GNU Lesser General Public Licence. This should be
004 *  distributed with the code. If you do not have a copy, see:
005 *  http://www.gnu.org/copyleft/lesser.html Copyright for this code is held
006 *  jointly by the individual authors. These should be listed in
007 *
008 *@author    doc comments. For more information on the BioJava project and its
009 *      aims, or to join the biojava-l mailing list, visit the home page at:
010 *      http://www.biojava.org/
011 */
012
013package org.biojava.bio.seq.io.game12;
014
015import org.biojava.bio.seq.io.game.ElementRecognizer;
016import org.biojava.utils.stax.StAXContentHandler;
017import org.biojava.utils.stax.StringElementHandlerBase;
018import org.xml.sax.Attributes;
019
020/**
021 *  Handles the GAME <annotation> element
022 *
023 * @author     David Huen
024 * @since      1.2
025 */
026public class GAMEGeneHandler
027         extends StAXFeatureHandler {
028    // <annotation> is a container for all features of a "gene".
029    // the only important property of this container is its id
030    // which I need to capture and supply nested classes.
031
032
033    // set up factory method
034    /**
035     *  Description of the Field
036     */
037    public final static StAXHandlerFactory GAME_GENE_HANDLER_FACTORY
038             =
039        new StAXHandlerFactory() {
040            public StAXContentHandler getHandler(StAXFeatureHandler staxenv) {
041                return new GAMEGeneHandler(staxenv);
042            }
043        };
044
045    /**
046     *  Constructor for the GAMEGeneHandler object
047     *
048     *@param  staxenv   Description of the Parameter
049     *@param  parentID  Description of the Parameter
050     */
051    GAMEGeneHandler(StAXFeatureHandler staxenv) {
052        // setup environment
053        super(staxenv);
054
055        // setup handlers
056        // <name>
057        super.addHandler(new ElementRecognizer.ByLocalName("name"),
058            new StAXHandlerFactory() {
059                public StAXContentHandler getHandler(StAXFeatureHandler staxenv) {
060                    return new NameHandler();
061                }
062            }
063                );
064        // <synonym>
065//        super.addHandler(new ElementRecognizer.ByLocalName("synonym"),
066//            new StAXHandlerFactory() {
067//                public StAXContentHandler getHandler(StAXFeatureHandler staxenv, long parentID) {
068//                    return new SynonymHandler();
069//                }
070//            }
071//                );
072        // <dbxref>
073        super.addHandler(new ElementRecognizer.ByLocalName("dbxref"),
074                GAMEDbxrefHandler.GAME_DBXREF_HANDLER_FACTORY);
075    }
076
077
078    /**
079     *  Description of the Class
080     *
081     *@author     david
082     */
083    private class NameHandler extends StringElementHandlerBase {
084        /**
085         *  Sets the stringValue attribute of the NameHandler object
086         *
087         *@param  s  The new stringValue value
088         */
089        protected void setStringValue(String s) {
090        }
091    }
092
093//    private class SynonymHandler extends StringElementHandlerBase {
094//        /**
095//         *  Sets the stringValue attribute of the SynonymHandler object
096//         *
097//         *@param  s  The new stringValue value
098//         */
099//        protected void setStringValue(String s) {
100//            synonym = s.trim();
101//        }
102//    }
103
104    public void startElementHandler(
105            String nsURI,
106            String localName,
107            String qName,
108            Attributes attrs) {
109    }
110
111    public void endElementHandler(
112            String nsURI,
113            String localName,
114            String qName,
115            StAXContentHandler contentHandler) {
116    }
117
118}
119