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.bio.seq.io.agave;
022import org.xml.sax.Attributes;
023import org.xml.sax.SAXException;
024
025/**
026 *
027 * @author Hanning Ni    Doubletwist Inc
028 */
029public class AGAVEResultGroupHandler
030               extends StAXFeatureHandler
031
032{
033  public static final StAXHandlerFactory AGAVE_RESULT_GROUP_HANDLER_FACTORY
034    = new StAXHandlerFactory() {
035    public StAXContentHandler getHandler(StAXFeatureHandler staxenv) {
036      return new AGAVEResultGroupHandler(staxenv);
037    }
038  };
039
040
041  AGAVEResultGroupHandler(StAXFeatureHandler staxenv) {
042    // setup up environment stuff
043    super( staxenv );
044    featureListener = staxenv.featureListener;
045    setHandlerCharacteristics("result_group", true);
046    super.addHandler(new ElementRecognizer.ByLocalName("comp_result"),
047      AGAVECompResultHandler.AGAVE_COMP_RESULT_HANDLER_FACTORY);
048
049 }
050  /*
051  protected Feature.Template createTemplate() {
052    // create Gene Template for this
053    Feature.Template st = new Feature.Template();
054
055    // assume feature set to describe a transcript
056    st.type = "result_group";
057    // set up annotation bundle
058    st.annotation = new SmallAnnotation();
059    st.location = new  Location.EmptyLocation();
060    if( staxenv != null )
061        staxenv. subFeatures .add( this ) ;
062
063    return st;
064  }*/
065
066  public void startElementHandler(
067                String nsURI,
068                String localName,
069                String qName,
070                Attributes attrs)
071                throws SAXException
072  {
073      try{
074        featureListener.startFeature( featureTemplate );
075        boolean forFeature = true ;
076        setProperty( "group_order",  attrs.getValue("group_order"), forFeature ) ;
077      }catch(Exception e){
078         throw new SAXException( e.getMessage() ) ;
079      }
080  }
081
082
083}
084