Some progress toward implementing store(Analysis).
[cfb.git] / prod / net / jaekl / cfb / xml / SourceLine.java
1 package net.jaekl.cfb.xml;
2
3 import java.io.PrintWriter;
4
5 import net.jaekl.qd.xml.MissingAttributeException;
6 import net.jaekl.qd.xml.ParseResult;
7 import net.jaekl.qd.xml.XmlParseException;
8
9 import org.xml.sax.Attributes;
10
11 public class SourceLine extends ParseResult {
12
13         static final String TAG = "SourceLine";
14         static final String[] INTERNAL = { };
15         static final Object[][] EXTERNAL = { };
16         
17         static final String ATTR_CLASS_NAME = "classname";
18         static final String ATTR_START = "start";
19         static final String ATTR_END = "end";
20         
21         String m_className;
22         int m_start;
23         int m_end;
24
25         public SourceLine() {
26                 super(TAG, INTERNAL, EXTERNAL);
27                 m_className = null;
28                 m_start = m_end = (-1);
29         }       
30         
31         public String getClassName() { return m_className; }
32         public int getStart() { return m_start; }
33         public int getEnd() { return m_end; }
34         
35         @Override
36         public void handleMainAttributes(Attributes attr) throws MissingAttributeException {
37                 String scratch;
38                 
39                 m_className = getRequiredAttr(TAG, attr, ATTR_CLASS_NAME);
40                 
41                 scratch = getOptionalAttr(attr, ATTR_START, "-1");
42                 m_start = Integer.parseInt(scratch);
43                 
44                 scratch = getOptionalAttr(attr, ATTR_END, "-1");
45                 m_end = Integer.parseInt(scratch);
46         }
47         
48         @Override
49         public void endContents(String uri, String localName, String qName,     String chars) 
50                 throws XmlParseException 
51         {
52                 // no-op
53         }
54         
55         @Override
56         public void endExternal(String uri, String localName, String qName)
57                 throws XmlParseException 
58         {
59                 // no-op
60         }
61         
62         @Override
63         public void dump(PrintWriter pw, int indent) 
64         {
65                 super.dump(pw, indent);
66                 String tab = String.format("%" + (indent + 2) + "s", "");
67                 
68                 pw.println(tab + m_className + " (" + m_start + " .. " + m_end + ")");
69         }
70 }