Team:Freiburg software/Code/BioBrick DAS DNA Handler.java
From 2009.igem.org
(New page: <nowiki> /* Copyright: synbiowave License: GPL Authors: Jörg Wassolesk Version: 0.1 DESCRIPTION: This class provides the functions for ha...) |
|||
Line 1: | Line 1: | ||
<nowiki> | <nowiki> | ||
- | /* | + | /* |
Copyright: synbiowave | Copyright: synbiowave | ||
Line 12: | Line 12: | ||
DESCRIPTION: | DESCRIPTION: | ||
This class provides the functions for handling DAS DNA requests. | This class provides the functions for handling DAS DNA requests. | ||
- | */ | + | */ |
package org.synbiowave.biobrick; | package org.synbiowave.biobrick; | ||
Line 20: | Line 20: | ||
import org.xml.sax.Attributes; | import org.xml.sax.Attributes; | ||
- | // TODO: Auto-generated Javadoc | + | // TODO: Auto-generated Javadoc |
- | /** | + | /** |
* a class to parse the XML response of a DAS-DNA request. | * a class to parse the XML response of a DAS-DNA request. | ||
* | * | ||
* @author Jörg | * @author Jörg | ||
*/ | */ | ||
- | public class BioBrick_DAS_DNA_Handler extends DefaultHandler { | + | public class BioBrick_DAS_DNA_Handler extends DefaultHandler { |
/** The sequence. */ | /** The sequence. */ | ||
Line 110: | Line 110: | ||
return sequence; | return sequence; | ||
- | } | + | } |
- | + | } | |
- | + | ||
- | + | ||
- | + | ||
</nowiki> | </nowiki> |
Revision as of 00:04, 22 October 2009
/* Copyright: synbiowave License: GPL Authors: Jörg Wassolesk Version: 0.1 DESCRIPTION: This class provides the functions for handling DAS DNA requests. */ package org.synbiowave.biobrick; import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.Attributes; // TODO: Auto-generated Javadoc /** * a class to parse the XML response of a DAS-DNA request. * * @author Jörg */ public class BioBrick_DAS_DNA_Handler extends DefaultHandler { /** The sequence. */ String sequence ; /** The length. */ int length ; /** The dna_flag. */ boolean dna_flag; /** * Instantiates a new bio brick_ da s_ dn a_ handler. */ public BioBrick_DAS_DNA_Handler() { super(); // TODO Auto-generated constructor stub sequence = "" ; length = 0; dna_flag = false ; } /* (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("DNA")){ //System.out.println("new element >" + name + "< >" + qName+"<"); // was : length String lenstr = atts.getValue("length"); length = Integer.parseInt(lenstr); dna_flag = true ; } } /* (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int) */ public void characters (char ch[], int start, int length){ //System.out.print("Characters: \""); if (dna_flag) for (int i = start; i < start + length; i++) { switch (ch[i]) { case '\\': //System.out.print("\\\\"); break; case '"': //System.out.print("\\\""); break; case '\n': //System.out.print("\\n"); break; case '\r': //System.out.print("\\r"); break; case '\t': //System.out.print("\\t"); break; case ' ': break; default: sequence = sequence + ch[i]; //System.out.print(ch[i]); break; } } //System.out.print("\"\n"); } /** * Gets the _sequence. * * @return the _sequence */ public String get_sequence() { if ( length != sequence.length()) { System.err.println("Sequence does not match specified length!"); } return sequence; } }