98ea93b422446de826716cbcce8f0da8511a3518
[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         public void add(BugInstance bug) { m_bugs.add(bug); }
26         
27         @Override
28         public void endContents(String uri, String localName, String qName,     String chars) 
29                 throws XmlParseException 
30         {
31                 // no-op
32         }
33
34         @Override
35         public void endExternal(String uri, String localName, String qName)
36                 throws XmlParseException 
37         {
38                 if (BugInstance.TAG.equals(localName)) {
39                         ParseResult[] collected = collectParsedChildren(BugInstance.class);
40                         for (ParseResult pr : collected) {
41                                 assert(pr instanceof BugInstance);
42                                 m_bugs.add((BugInstance) pr);
43                         }
44                 }
45         }
46         
47         @Override
48         public void dump(PrintWriter pw, int indent) {
49                 super.dump(pw, indent);
50                 for (BugInstance bug : m_bugs) {
51                         bug.dump(pw, indent + 2);
52                 }
53         }
54
55 }