cf16e237ddd47ad4a916996737ff492760bbd9f0
[cfb.git] / prod / net / jaekl / cfb / xml / messages / MessageCollection.java
1 package net.jaekl.cfb.xml.messages;
2
3 import java.util.HashMap;
4
5 import net.jaekl.qd.xml.ParseResult;
6 import net.jaekl.qd.xml.XmlParseException;
7
8 public class MessageCollection extends ParseResult {
9         static final String TAG = "MessageCollection";
10         static final String[] INTERNAL = {  };
11         static final Object[][] EXTERNAL = { { BugCategory.TAG, BugCategory.class },
12                                                  { BugPattern.TAG,  BugPattern.class }   };
13
14         HashMap<String, BugCategory> m_categories;
15         HashMap<String, BugPattern> m_patterns;
16         
17         public MessageCollection() 
18         {
19                 super(TAG, INTERNAL, EXTERNAL);
20                 m_categories = new HashMap<String, BugCategory>();
21                 m_patterns   = new HashMap<String, BugPattern>();
22         }
23
24         @Override
25         public void endContents(String uri, String localName, String qName, String chars) 
26                 throws XmlParseException 
27         {
28                 // Nothing to do
29         }
30
31         @Override
32         public void endExternal(String uri, String localName, String qName) throws XmlParseException 
33         {
34                 ParseResult[] prs;
35                 
36                 prs = collectParsedChildren(BugCategory.class);
37                 if (null != prs && prs.length > 0) {
38                         for (ParseResult pr : prs) {
39                                 assert(pr instanceof BugCategory);
40                                 BugCategory bc = (BugCategory)pr;
41                                 m_categories.put(bc.getCategory(), bc);
42                         }
43                 }
44                 
45                 prs = collectParsedChildren(BugPattern.class);
46                 if (null != prs && prs.length > 0) {
47                         for (ParseResult pr : prs) {
48                                 assert(pr instanceof BugPattern);
49                                 BugPattern bp = (BugPattern) pr;
50                                 m_patterns.put(bp.getType(), bp);
51                         }
52                 }
53         }
54
55 }