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

/*   Copyright: synbiowave License: GPL Authors: Jörg Wassolesk Version: 0.1 DESCRIPTION: This class provides the methods needed for the handling of DAS entry_point requests.

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> segments; /** The ids. */	TreeSet ids; /** The current entry point. */	Map currentEntryPoint; /**	 * Instantiates a new bio brick_ da s_ entry_ points_ handler. */	public BioBrick_DAS_Entry_Points_Handler{ segments=new ArrayList>; ids=new TreeSet; currentEntryPoint=new HashMap;} /* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#startDocument */	public void startDocument{ segments=new ArrayList>; ids=new TreeSet;}

/* (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 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> getSegemnts{return segments;} /**	 * Gets the i ds. * 	 * @return the i ds	 */ public TreeSet getIDs{return ids;} }