8 |
|
|
9 |
/** A simple span serializer / deserializer. |
/** A simple span serializer / deserializer. |
10 |
* Just takes a sequence of spans and adds them to a list. |
* Just takes a sequence of spans and adds them to a list. |
11 |
|
* To clear the list between readings, call clear(). |
12 |
*/ |
*/ |
13 |
|
|
14 |
public class SpanReader extends org.xml.sax.helpers.DefaultHandler { |
public class SpanReader extends org.xml.sax.helpers.DefaultHandler { |
23 |
|
|
24 |
private ArrayList spans = new ArrayList(); |
private ArrayList spans = new ArrayList(); |
25 |
|
|
26 |
|
/** Empty this SpanReader for another read operation. |
27 |
|
*/ |
28 |
|
public void clear() { spans.clear(); } |
29 |
|
|
30 |
public List getSpans() { return spans; } |
public List getSpans() { return spans; } |
31 |
|
|
32 |
public void startElement(String uri, String localName, String qName, |
public void startElement(String uri, String localName, String qName, |
33 |
org.xml.sax.Attributes attributes) { |
org.xml.sax.Attributes attributes) { |
34 |
if(dbg) pa("Se: '"+uri+"' '"+localName+"' '"+qName+"'"); |
if(dbg) pa("Se: '"+uri+"' '"+localName+"' '"+qName+"'"); |
35 |
|
// Wrapper element |
36 |
|
if(qName.equals("alph")) return; |
37 |
if(qName.equals("ts")) { |
if(qName.equals("ts")) { |
38 |
String b = attributes.getValue("b"); |
String b = attributes.getValue("b"); |
39 |
int s = Integer.parseInt(attributes.getValue("s")); |
int s = Integer.parseInt(attributes.getValue("s")); |