Add code to load bug categories and patterns from the FindBugs messages.xml file.
[cfb.git] / prod / net / jaekl / cfb / xml / messages / BugCategory.java
diff --git a/prod/net/jaekl/cfb/xml/messages/BugCategory.java b/prod/net/jaekl/cfb/xml/messages/BugCategory.java
new file mode 100644 (file)
index 0000000..6b5b492
--- /dev/null
@@ -0,0 +1,62 @@
+package net.jaekl.cfb.xml.messages;
+
+import org.xml.sax.Attributes;
+
+import net.jaekl.qd.xml.MissingAttributeException;
+import net.jaekl.qd.xml.ParseResult;
+import net.jaekl.qd.xml.XmlParseException;
+
+public class BugCategory extends ParseResult {
+       static final String CATEGORY = "category";      // attribute name
+       static final String DESCRIPTION = "Description";
+       static final String ABBREVIATION = "Abbreviation";
+       static final String DETAILS = "Details";
+
+       static final String TAG = "BugCategory";
+       static final String[] INTERNAL = { DESCRIPTION, ABBREVIATION, DETAILS };
+       static final Object[][] EXTERNAL = { };
+
+       String m_category;
+       String m_descr;
+       String m_abbrev;
+       String m_details;
+       
+       public BugCategory(String tagName, String[] internalMemberTags, Object[][] externalParserTags) 
+       {
+               super(tagName, internalMemberTags, externalParserTags);
+               m_category = m_descr = m_abbrev = m_details = "";
+       }
+       
+       public String getCategory() { return m_category; }
+       public String getDescr() { return m_descr; }
+       public String getAbbrev() { return m_abbrev; }
+       public String getDetails() { return m_details; }
+
+       @Override
+       public void endContents(String uri, String localName, String qName, String chars) throws XmlParseException 
+       {
+               if (DESCRIPTION.equals(localName)) {
+                       m_descr = chars;
+               }
+               else if (ABBREVIATION.equals(localName)) {
+                       m_abbrev = chars;
+               }
+               else if (DETAILS.equals(localName)) {
+                       m_details = chars;
+               }
+       }
+
+       @Override
+       public void endExternal(String uri, String localName, String qName)
+               throws XmlParseException 
+       {
+               // nothing to do
+       }
+       
+       // Called once for this tag itself
+       @Override 
+       public void handleMainAttributes(Attributes attr) throws MissingAttributeException {
+               m_category = this.getRequiredAttr(TAG, attr, CATEGORY);
+       }
+       
+}