1 package net.jaekl.cfb.xml;
3 import java.io.PrintWriter;
4 import java.util.ArrayList;
6 import org.xml.sax.Attributes;
8 import net.jaekl.qd.xml.MissingAttributeException;
9 import net.jaekl.qd.xml.ParseResult;
10 import net.jaekl.qd.xml.XmlParseException;
12 public class BugMethod extends ParseResult {
14 static final String TAG = "Method";
15 static final String[] INTERNAL = { };
16 static final Object[][] EXTERNAL = { { SourceLine.TAG, SourceLine.class} };
18 static final String CLASS_NAME = "classname";
19 static final String METHOD_NAME = "name";
20 static final String SIGNATURE = "signature";
21 static final String IS_STATIC = "isStatic";
22 static final String ROLE = "role";
24 static final String TRUE = "true"; // yes value for isStatic
30 String m_role; // optional
31 ArrayList<SourceLine> m_sourceLines;
34 super(TAG, INTERNAL, EXTERNAL);
35 m_className = m_methodName = m_signature = m_role = null;
37 m_sourceLines = new ArrayList<SourceLine>();
40 public String getClassName() { return m_className; }
41 public String getMethodName() { return m_methodName; }
42 public SourceLine[] getSourceLines() { return m_sourceLines.toArray(new SourceLine[m_sourceLines.size()]); }
45 public void handleMainAttributes(Attributes attr) throws MissingAttributeException
47 m_className = getRequiredAttr(TAG, attr, CLASS_NAME);
48 m_methodName = getRequiredAttr(TAG, attr, METHOD_NAME);
49 m_signature = getRequiredAttr(TAG, attr, SIGNATURE);
50 m_isStatic = getRequiredAttr(TAG, attr, IS_STATIC).equals(TRUE);
51 m_role = getOptionalAttr(attr, ROLE, null);
55 public void endContents(String uri, String localName, String qName, String chars)
56 throws XmlParseException
62 public void endExternal(String uri, String localName, String qName)
63 throws XmlParseException
65 if (SourceLine.TAG.equals(localName)) {
66 ParseResult[] collected = collectParsedChildren(SourceLine.class);
67 for (ParseResult pr : collected) {
68 assert(pr instanceof SourceLine);
69 m_sourceLines.add((SourceLine)pr);
75 public void dump(PrintWriter pw, int indent)
77 super.dump(pw, indent);
78 String tab = String.format("%" + (indent + 2) + "s", "");
81 + (m_isStatic ? "static" : "")
87 pw.println(tab + ROLE + "=" + m_role);
89 if (null != m_sourceLines) {
90 for (SourceLine sl : m_sourceLines) {
91 sl.dump(pw, indent + 2);