Add unit tests. Make DbStore handle cases where the bug type or category
[cfb.git] / prod / net / jaekl / cfb / xml / messages / BugCategory.java
1 package net.jaekl.cfb.xml.messages;
2
3 import org.xml.sax.Attributes;
4
5 import net.jaekl.qd.xml.MissingAttributeException;
6 import net.jaekl.qd.xml.ParseResult;
7 import net.jaekl.qd.xml.XmlParseException;
8
9 public class BugCategory extends ParseResult {
10         static final String CATEGORY = "category";      // attribute name
11         static final String DESCRIPTION = "Description";
12         static final String ABBREVIATION = "Abbreviation";
13         static final String DETAILS = "Details";
14
15         static final String TAG = "BugCategory";
16         static final String[] INTERNAL = { DESCRIPTION, ABBREVIATION, DETAILS };
17         static final Object[][] EXTERNAL = { };
18         
19         public static final BugCategory UNKNOWN = new BugCategory(-2);
20
21         String m_category;
22         String m_descr;
23         String m_abbrev;
24         String m_details;
25         long m_id;
26         
27         public BugCategory() 
28         {
29                 super(TAG, INTERNAL, EXTERNAL);
30                 m_id = (-1);
31                 m_category = m_descr = m_abbrev = m_details = "";
32         }
33         
34         BugCategory(long id)
35         {
36                 this();
37                 m_id = (-2); 
38         }
39         
40         public String getCategory() { return m_category; }
41         public String getDescr() { return m_descr; }
42         public String getAbbrev() { return m_abbrev; }
43         public String getDetails() { return m_details; }
44
45         public void setId(long id) { m_id = id; }
46         public long getId() { return m_id; }
47
48         @Override
49         public void endContents(String uri, String localName, String qName, String chars) throws XmlParseException 
50         {
51                 if (DESCRIPTION.equals(localName)) {
52                         m_descr = chars;
53                 }
54                 else if (ABBREVIATION.equals(localName)) {
55                         m_abbrev = chars;
56                 }
57                 else if (DETAILS.equals(localName)) {
58                         m_details = chars;
59                 }
60         }
61
62         @Override
63         public void endExternal(String uri, String localName, String qName)
64                 throws XmlParseException 
65         {
66                 // nothing to do
67         }
68         
69         // Called once for this tag itself
70         @Override 
71         public void handleMainAttributes(Attributes attr) throws MissingAttributeException {
72                 m_category = this.getRequiredAttr(TAG, attr, CATEGORY);
73         }
74         
75 }