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