Improve XML parsing to handle attributes as well.
[cfb.git] / prod / net / jaekl / cfb / xml / BugMethod.java
index 2e001b23abe93116f71c47782bc1f21b428308e6..80afa93392a69b632cd3c9023982a5fc18d9c850 100644 (file)
@@ -1,9 +1,11 @@
 package net.jaekl.cfb.xml;
 
+import java.io.PrintWriter;
 import java.util.ArrayList;
 
 import org.xml.sax.Attributes;
 
+import net.jaekl.qd.xml.MissingAttributeException;
 import net.jaekl.qd.xml.ParseResult;
 import net.jaekl.qd.xml.XmlParseException;
 
@@ -34,16 +36,22 @@ public class BugMethod extends ParseResult {
                m_isStatic = false;
                m_sourceLines = new ArrayList<SourceLine>();
        }
-
+       
        @Override
-       public void endContents(String uri, String localName, String qName, String chars, Attributes attr) 
-               throws XmlParseException 
+       public void handleMainAttributes(Attributes attr) throws MissingAttributeException 
        {
                m_className = getRequiredAttr(TAG, attr, CLASS_NAME);
                m_methodName = getRequiredAttr(TAG, attr, METHOD_NAME);
                m_signature = getRequiredAttr(TAG, attr, SIGNATURE);
                m_isStatic = getRequiredAttr(TAG, attr, IS_STATIC).equals(TRUE);
-               m_role = getOptionalAttr(attr, ROLE, null);
+               m_role = getOptionalAttr(attr, ROLE, null);             
+       }
+
+       @Override
+       public void endContents(String uri, String localName, String qName, String chars) 
+               throws XmlParseException 
+       {
+               // no-op
        }
 
        @Override
@@ -58,5 +66,27 @@ public class BugMethod extends ParseResult {
                        }
                }
        }
+       
+       @Override
+       public void dump(PrintWriter pw, int indent) 
+       {
+               super.dump(pw, indent);
+               String tab = String.format("%" + (indent + 2) + "s", "");
+               
+               pw.println(tab 
+                               + (m_isStatic ? "static" : "")
+                               + m_className 
+                               + "."
+                               + m_methodName 
+                               + m_signature);
+               if (null != m_role) {
+                       pw.println(tab + ROLE + "=" + m_role);
+               }
+               if (null != m_sourceLines) {
+                       for (SourceLine sl : m_sourceLines) {
+                               sl.dump(pw, indent + 2);
+                       }
+               }
+       }
 
 }