2 * BioJava development code
4 * This code may be freely distributed and modified under the
5 * terms of the GNU Lesser General Public Licence. This should
6 * be distributed with the code. If you do not have a copy,
9 * http://www.gnu.org/copyleft/lesser.html
11 * Copyright for this code is held jointly by the individual
12 * authors. These should be listed in @author doc comments.
14 * For more information on the BioJava project and its aims,
15 * or to join the biojava-l mailing list, visit the home page
18 * http://www.biojava.org/
20 * Created on 19.03.2004
21 * @author Andreas Prlic
24 package org.biojava.dasobert.das;
26 import org.xml.sax.helpers.DefaultHandler;
27 import org.xml.sax.Attributes;
28 import java.util.logging.*;
31 * a class that parses the XML response of a DAS - sequence command.
33 * @author Andreas Prlic
36 public class DAS_Sequence_Handler extends DefaultHandler
39 StringBuffer sequence;
52 public DAS_Sequence_Handler()
56 sequence = new StringBuffer();
64 * set a maximum length of sequence that should be loaded default: -1. if -1
65 * no length restriction is being supplied
67 * @return the maximum length or -1 if no restriction
69 public int getMaxLength()
75 * set a maximum length of sequence that should be loaded default: -1. if -1
76 * no length restriction is being supplied
79 * the maximum length or -1 if unrestricted
81 public void setMaxLength(int maxLength)
83 this.maxLength = maxLength;
86 public void startElement(String uri, String name, String qName,
90 if (qName.equals("SEQUENCE"))
92 version = atts.getValue("version");
93 String lenstr = atts.getValue("stop");
94 length = Integer.parseInt(lenstr);
100 public void characters(char ch[], int start, int length)
104 if (sequence.length() > maxLength)
108 for (int i = start; i < start + length; i++)
111 // all sorts of characters can be found in "seqeunces" ... ignore
116 // System.out.print("\\\\");
119 // System.out.print("\\\"");
122 // System.out.print("\\n");
125 // System.out.print("\\r");
128 // System.out.print("\\t");
133 sequence = sequence.append(ch[i]);
141 public String get_sequence()
146 if (length != sequence.length())
148 Logger logger = Logger.getLogger("org.biojava.spice");
149 logger.warning("Sequence does not match specified length!");
153 return sequence.toString();
156 public String getVersion()