Work toward improving solidity. Add a few more unit tests, and some toString()
[cfb.git] / prod / net / jaekl / cfb / xml / SourceLine.java
index 627667a161ac4e3902c6170412e5f32badf2c6b8..e5e82f6aa3e8e88f47042bdf9795dfee1049e668 100644 (file)
@@ -1,5 +1,8 @@
 package net.jaekl.cfb.xml;
 
+import java.io.PrintWriter;
+
+import net.jaekl.qd.xml.MissingAttributeException;
 import net.jaekl.qd.xml.ParseResult;
 import net.jaekl.qd.xml.XmlParseException;
 
@@ -25,25 +28,43 @@ public class SourceLine extends ParseResult {
                m_start = m_end = (-1);
        }       
        
+       public String getClassName() { return m_className; }
+       public int getStart() { return m_start; }
+       public int getEnd() { return m_end; }
+       
        @Override
-       public void endContents(String uri, String localName, String qName,     String chars, Attributes attr) 
-               throws XmlParseException 
-       {
+       public void handleMainAttributes(Attributes attr) throws MissingAttributeException {
                String scratch;
                
-               m_className = getRequiredAttr(localName, attr, ATTR_CLASS_NAME);
+               m_className = getRequiredAttr(TAG, attr, ATTR_CLASS_NAME);
                
-               scratch = getRequiredAttr(localName, attr, ATTR_START);
+               scratch = getOptionalAttr(attr, ATTR_START, "-1");
                m_start = Integer.parseInt(scratch);
                
-               scratch = getRequiredAttr(localName, attr, ATTR_END);
+               scratch = getOptionalAttr(attr, ATTR_END, "-1");
                m_end = Integer.parseInt(scratch);
        }
        
+       @Override
+       public void endContents(String uri, String localName, String qName,     String chars) 
+               throws XmlParseException 
+       {
+               // no-op
+       }
+       
        @Override
        public void endExternal(String uri, String localName, String qName)
                throws XmlParseException 
        {
                // no-op
        }
+       
+       @Override
+       public void dump(PrintWriter pw, int indent) 
+       {
+               super.dump(pw, indent);
+               String tab = String.format("%" + (indent + 2) + "s", "");
+               
+               pw.println(tab + m_className + " (" + m_start + " .. " + m_end + ")");
+       }
 }