Some progress toward implementing store(Analysis).
[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 import java.util.Collections;
6 import java.util.List;
7
8 import net.jaekl.qd.xml.ParseResult;
9 import net.jaekl.qd.xml.XmlParseException;
10
11 public class BugCollection extends ParseResult {
12
13         static final String TAG = "BugCollection";
14         static final String[] INTERNAL = { };
15         static final Object[][] EXTERNAL = { { BugInstance.TAG, BugInstance.class} };
16
17         ArrayList<BugInstance> m_bugs;
18         
19         public BugCollection() {
20                 super(TAG, INTERNAL, EXTERNAL);
21                 m_bugs = new ArrayList<BugInstance>();
22         }
23         
24         public List<BugInstance> getBugs() { return Collections.unmodifiableList(m_bugs); }
25         
26         @Override
27         public void endContents(String uri, String localName, String qName,     String chars) 
28                 throws XmlParseException 
29         {
30                 // no-op
31         }
32
33         @Override
34         public void endExternal(String uri, String localName, String qName)
35                 throws XmlParseException 
36         {
37                 if (BugInstance.TAG.equals(localName)) {
38                         ParseResult[] collected = collectParsedChildren(BugInstance.class);
39                         for (ParseResult pr : collected) {
40                                 assert(pr instanceof BugInstance);
41                                 m_bugs.add((BugInstance) pr);
42                         }
43                 }
44         }
45         
46         @Override
47         public void dump(PrintWriter pw, int indent) {
48                 super.dump(pw, indent);
49                 for (BugInstance bug : m_bugs) {
50                         bug.dump(pw, indent + 2);
51                 }
52         }
53
54 }