Team:Freiburg software/Code/BioBrick DAS Entry Points Handler.java

From 2009.igem.org

Revision as of 00:05, 22 October 2009 by JonasOnlyJonas (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

/* Copyright: synbiowave License: GPL Authors: Jörg Wassolesk Version: 0.1 DESCRIPTION: This class provides the functions for recieving url-connections. Our central SynBioWave-Robot extends this class in instead of AbstractSbwRobot. All others don't. This class enhances the servlet capabilities of the Google Wave Robot Servlet to serve also file up - and download. */ package org.synbiowave.biobrick ; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeSet; import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.Attributes; // TODO: Auto-generated Javadoc /** * a class to parse the reponse of the BioBrick DAS - entry_points request. */ public class BioBrick_DAS_Entry_Points_Handler extends DefaultHandler { /** The segments. */ List<Map<String,String>> segments; /** The ids. */ TreeSet<String> ids; /** The current entry point. */ Map<String,String> currentEntryPoint; /** * Instantiates a new bio brick_ da s_ entry_ points_ handler. */ public BioBrick_DAS_Entry_Points_Handler(){ segments=new ArrayList<Map<String,String>>(); ids=new TreeSet<String>(); currentEntryPoint=new HashMap<String,String>();} /* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#startDocument() */ public void startDocument(){ segments=new ArrayList<Map<String,String>>(); ids=new TreeSet<String>();} /* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) */ public void startElement(String uri,String name,String qName,Attributes atts){ if(qName.equals("SEGMENT")){ currentEntryPoint=new HashMap<String,String>(); String id=atts.getValue("id"); if(!(id==null)){ currentEntryPoint.put("id",id); ids.add(id);} String size=atts.getValue("size"); if(!(size==null)){currentEntryPoint.put("size",size);} String start=atts.getValue("start"); if(!(start==null)){currentEntryPoint.put("start",start);} String stop=atts.getValue("stop"); if(!(stop==null)){currentEntryPoint.put("stop",stop);} String orientation=atts.getValue("orientation"); if(!(orientation==null)){currentEntryPoint.put("orientation",orientation);} String subparts=atts.getValue("subparts"); if(!(subparts==null)){currentEntryPoint.put("subparts",subparts);}}} /* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String) */ public void endElement(String uri,String name,String qName){ if(qName.equals("SEGMENT")){segments.add(currentEntryPoint);}} /** * Gets the segemnts. * * @return the segemnts */ public List<Map<String,String>> getSegemnts(){return segments;} /** * Gets the i ds. * * @return the i ds */ public TreeSet<String> getIDs(){return ids;} }