Unit testing: confirm that Analyzer can parse some sample XML
[cfb.git] / prod / net / jaekl / cfb / xml / BugCollection.java
1 package net.jaekl.cfb.xml;
2
3 import java.io.PrintWriter;
4 import java.util.ArrayList;
5
6 import net.jaekl.qd.xml.ParseResult;
7 import net.jaekl.qd.xml.XmlParseException;
8
9 public class BugCollection extends ParseResult {
10
11         static final String TAG = "BugCollection";
12         static final String[] INTERNAL = { };
13         static final Object[][] EXTERNAL = { { BugInstance.TAG, BugInstance.class} };
14
15         ArrayList<BugInstance> m_bugs;
16         
17         public BugCollection() {
18                 super(TAG, INTERNAL, EXTERNAL);
19                 m_bugs = new ArrayList<BugInstance>();
20         }
21         
22         public int size() { return m_bugs.size(); }
23         public BugInstance get(int idx) { return m_bugs.get(idx); }
24         
25         @Override
26         public void endContents(String uri, String localName, String qName,     String chars) 
27                 throws XmlParseException 
28         {
29                 // no-op
30         }
31
32         @Override
33         public void endExternal(String uri, String localName, String qName)
34                 throws XmlParseException 
35         {
36                 if (BugInstance.TAG.equals(localName)) {
37                         ParseResult[] collected = collectParsedChildren(BugInstance.class);
38                         for (ParseResult pr : collected) {
39                                 assert(pr instanceof BugInstance);
40                                 m_bugs.add((BugInstance) pr);
41                         }
42                 }
43         }
44         
45         @Override
46         public void dump(PrintWriter pw, int indent) {
47                 super.dump(pw, indent);
48                 for (BugInstance bug : m_bugs) {
49                         bug.dump(pw, indent + 2);
50                 }
51         }
52
53 }