/[alph]/alph/org/nongnu/alph/xml/SpanReader.java
ViewVC logotype

Diff of /alph/org/nongnu/alph/xml/SpanReader.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by tjl, Wed Mar 26 09:39:48 2003 UTC revision 1.2 by tjl, Wed Mar 26 10:17:54 2003 UTC
# Line 3  Line 3 
3  package org.nongnu.alph.xml;  package org.nongnu.alph.xml;
4  import org.nongnu.alph.*;  import org.nongnu.alph.*;
5    
6    import java.util.ArrayList;
7    import java.util.List;
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   */   */
12    
13  public class SpanReader extends org.xml.sax.helpers.DefaultHandler  {  public class SpanReader extends org.xml.sax.helpers.DefaultHandler  {
14        public static boolean dbg = true;
15        private static void pa(String s) { System.out.println(s); }
16    
17      public interface ScrollBlockFactory {      public interface ScrollBlockFactory {
18          ScrollBlock getScrollBlock(String id);          ScrollBlock getScrollBlock(String id);
# Line 21  public class SpanReader extends org.xml. Line 26  public class SpanReader extends org.xml.
26    
27      public  void startElement(String uri, String localName, String qName,      public  void startElement(String uri, String localName, String qName,
28                              org.xml.sax.Attributes attributes)  {                              org.xml.sax.Attributes attributes)  {
29          if(localName.equals("ts")) {          if(dbg) pa("Se: '"+uri+"' '"+localName+"' '"+qName+"'");
30              String b = attributes.getValue("s");          if(qName.equals("ts")) {
31                String b = attributes.getValue("b");
32              int s = Integer.parseInt(attributes.getValue("s"));              int s = Integer.parseInt(attributes.getValue("s"));
33              int e = Integer.parseInt(attributes.getValue("e"));              int e = Integer.parseInt(attributes.getValue("e"));
34              spans.add((TextScrollBlock)(scrollBlockFactory.getScrollBlock(b))              spans.add(((TextScrollBlock)(scrollBlockFactory.getScrollBlock(b)))
35                  . getSpan(s, e));                  . getSpan(s, e));
36          } else {          } else {
37              throw new Error("Unknown element "+localName);              throw new Error("Unknown element '"+localName+"'");
38          }          }
39      }      }
40      public  void endElement(String uri, String localName, String qName) {      public  void endElement(String uri, String localName, String qName) {

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26