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 java.util.ListIterator; 023 024import org.xml.sax.Attributes; 025import org.xml.sax.SAXException; 026 027/** 028 * xref_property 029 * 030 * @author Hanning Ni Doubletwist Inc 031 */ 032public class AGAVEXrefPropPropHandler extends StAXPropertyHandler{ 033 034 035 public static final StAXHandlerFactory AGAVE_XREF_PROP_PROP_HANDLER_FACTORY 036 = new StAXHandlerFactory() { 037 public StAXContentHandler getHandler(StAXFeatureHandler staxenv) { 038 return new AGAVEXrefPropPropHandler(staxenv); 039 } 040 }; 041 042 private String prop_type; 043 private String data_type ; 044 private String value ; 045 AGAVEXrefPropPropHandler(StAXFeatureHandler staxenv) { 046 // execute superclass method to setup environment 047 super(staxenv); 048 setHandlerCharacteristics("xref_property", true); 049 } 050 051 public void startElementHandler( 052 String nsURI, 053 String localName, 054 String qName, 055 Attributes attrs) 056 throws SAXException 057 { 058 prop_type = attrs.getValue( "prop_type" ) ; 059 data_type = attrs.getValue( "data_type" ) ; 060 } 061 public void characters(char[] ch, int start, int length) 062 throws SAXException 063 { 064 value = new String(ch) ; 065 } 066 public void endElementHandler( 067 String nsURI, 068 String localName, 069 String qName, 070 StAXContentHandler handler) 071 throws SAXException 072 { 073 int currLevel = staxenv.getLevel(); 074 if (currLevel >=1) { 075 ListIterator li = staxenv.getHandlerStackIterator(currLevel); 076 while( li.hasPrevious() ) 077 { 078 Object ob = li.previous() ; 079 if( ob instanceof AGAVEDbIdPropCallbackItf ) 080 { 081 ( (AGAVEDbIdPropCallbackItf) ob ).addProperty( 082 new AGAVEProperty(AGAVEProperty.XREF_PROPERTY, prop_type, data_type, value)) ; 083 return ; 084 } 085 } 086 } 087 088 } 089 090 091}