Add code to load bug categories and patterns from the FindBugs messages.xml file.
[cfb.git] / prod / net / jaekl / cfb / xml / messages / BugPattern.java
diff --git a/prod/net/jaekl/cfb/xml/messages/BugPattern.java b/prod/net/jaekl/cfb/xml/messages/BugPattern.java
new file mode 100644 (file)
index 0000000..82ada92
--- /dev/null
@@ -0,0 +1,60 @@
+package net.jaekl.cfb.xml.messages;
+
+import net.jaekl.qd.xml.MissingAttributeException;
+import net.jaekl.qd.xml.ParseResult;
+import net.jaekl.qd.xml.XmlParseException;
+
+import org.xml.sax.Attributes;
+
+public class BugPattern extends ParseResult {
+       static final String TYPE = "type";
+       static final String SHORT = "ShortDescription";
+       static final String LONG = "LongDescription";
+       static final String DETAILS = "Details";
+
+       static final String TAG = "BugPattern";
+       static final String[] INTERNAL = { SHORT, LONG, DETAILS };
+       static final Object[][] EXTERNAL = {  };
+       
+       String m_type;
+       String m_short;
+       String m_long;
+       String m_details;
+       
+       public BugPattern(String tagName, String[] internalMemberTags, Object[][] externalParserTags) 
+       {
+               super(tagName, internalMemberTags, externalParserTags);
+               m_type = m_short = m_long = m_details = "";
+       }
+       
+       public String getType() { return m_type; }
+       public String getShort() { return m_short; }
+       public String getLong() { return m_long; }
+       public String getDetails() { return m_details; }
+
+       @Override
+       public void endContents(String uri, String localName, String qName, String chars) throws XmlParseException 
+       {
+               if (SHORT.equals(localName)) {
+                       m_short = chars;
+               }
+               else if (LONG.equals(localName)) {
+                       m_long = 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_type = this.getRequiredAttr(TAG, attr, TYPE);
+       }
+}