Improve XML parsing to handle attributes as well.
[cfb.git] / prod / net / jaekl / cfb / xml / BugCollection.java
index b59bdc8263b630bb38b4056d5a007dbba67d2f72..8fb78e411ab973b770e30a618d26e82f52ad97ad 100644 (file)
@@ -1,6 +1,7 @@
 package net.jaekl.cfb.xml;
 
-import org.xml.sax.Attributes;
+import java.io.PrintWriter;
+import java.util.ArrayList;
 
 import net.jaekl.qd.xml.ParseResult;
 import net.jaekl.qd.xml.XmlParseException;
@@ -11,22 +12,39 @@ public class BugCollection extends ParseResult {
        static final String[] INTERNAL = { };
        static final Object[][] EXTERNAL = { { BugInstance.TAG, BugInstance.class} };
 
+       ArrayList<BugInstance> m_bugs;
+       
        public BugCollection() {
                super(TAG, INTERNAL, EXTERNAL);
+               m_bugs = new ArrayList<BugInstance>();
        }
        
        @Override
-       public void endContents(String uri, String localName, String qName,
-                       String chars, Attributes attr) throws XmlParseException {
-               // TODO Auto-generated method stub
-
+       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 {
-               // TODO Auto-generated method stub
-
+               throws XmlParseException 
+       {
+               if (BugInstance.TAG.equals(localName)) {
+                       ParseResult[] collected = collectParsedChildren(BugInstance.class);
+                       for (ParseResult pr : collected) {
+                               assert(pr instanceof BugInstance);
+                               m_bugs.add((BugInstance) pr);
+                       }
+               }
+       }
+       
+       @Override
+       public void dump(PrintWriter pw, int indent) {
+               super.dump(pw, indent);
+               for (BugInstance bug : m_bugs) {
+                       bug.dump(pw, indent + 2);
+               }
        }
 
 }