X-Git-Url: http://jaekl.net/gitweb/?a=blobdiff_plain;f=prod%2Fnet%2Fjaekl%2Fcfb%2Fxml%2FBugMethod.java;h=f05c510af39ddd412df0744439cb3edcb445b032;hb=a4a577abc3f9b2b1147caafd1cb39fa8c2622cd4;hp=6a63b439e339de56d556616357ada548d80cf6a9;hpb=08a530ef53cc4756f5e632b69c78830872ebd9f4;p=cfb.git diff --git a/prod/net/jaekl/cfb/xml/BugMethod.java b/prod/net/jaekl/cfb/xml/BugMethod.java index 6a63b43..f05c510 100644 --- a/prod/net/jaekl/cfb/xml/BugMethod.java +++ b/prod/net/jaekl/cfb/xml/BugMethod.java @@ -1,32 +1,106 @@ package net.jaekl.cfb.xml; +import java.io.PrintWriter; +import java.util.ArrayList; + 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 BugMethod extends ParseResult { - static final String ROOT_TAG = "Method"; + static final String TAG = "Method"; static final String[] INTERNAL = { }; - static final Object[][] EXTERNAL = { { SourceLine.ROOT_TAG, SourceLine.class} }; + static final Object[][] EXTERNAL = { { SourceLine.TAG, SourceLine.class} }; + static final String CLASS_NAME = "classname"; + static final String METHOD_NAME = "name"; + static final String SIGNATURE = "signature"; + static final String IS_STATIC = "isStatic"; + static final String ROLE = "role"; + + static final String TRUE = "true"; // yes value for isStatic + + String m_className; + String m_methodName; + String m_signature; + boolean m_isStatic; + String m_role; // optional + ArrayList m_sourceLines; + public BugMethod() { - super(ROOT_TAG, INTERNAL, EXTERNAL); + super(TAG, INTERNAL, EXTERNAL); + m_className = m_methodName = m_signature = m_role = null; + m_isStatic = false; + m_sourceLines = new ArrayList(); } - + + public BugMethod(Long id, String methodName, String methodRole) { + super(TAG, INTERNAL, EXTERNAL); + m_className = null; + m_methodName = methodName; + m_role = methodRole; + m_isStatic = false; + m_sourceLines = new ArrayList(); + } + + public String getClassName() { return m_className; } + public String getMethodName() { return m_methodName; } + public String getRole() { return m_role; } + public SourceLine[] getSourceLines() { return m_sourceLines.toArray(new SourceLine[m_sourceLines.size()]); } + @Override - public void endContents(String uri, String localName, String qName, - String chars, Attributes attr) throws XmlParseException { - // TODO Auto-generated method stub + public void handleMainAttributes(Attributes attr) throws MissingAttributeException + { + m_className = getRequiredAttr(TAG, attr, CLASS_NAME); + m_methodName = getRequiredAttr(TAG, attr, METHOD_NAME); + m_signature = getRequiredAttr(TAG, attr, SIGNATURE); + m_isStatic = getRequiredAttr(TAG, attr, IS_STATIC).equals(TRUE); + m_role = getOptionalAttr(attr, ROLE, null); + } + @Override + public void endContents(String uri, String localName, String qName, String chars) + throws XmlParseException + { + // no-op } @Override public void endExternal(String uri, String localName, String qName) - throws XmlParseException { - // TODO Auto-generated method stub - + throws XmlParseException + { + if (SourceLine.TAG.equals(localName)) { + ParseResult[] collected = collectParsedChildren(SourceLine.class); + for (ParseResult pr : collected) { + assert(pr instanceof SourceLine); + m_sourceLines.add((SourceLine)pr); + } + } + } + + @Override + public void dump(PrintWriter pw, int indent) + { + super.dump(pw, indent); + String tab = String.format("%" + (indent + 2) + "s", ""); + + pw.println(tab + + (m_isStatic ? "static" : "") + + m_className + + "." + + m_methodName + + m_signature); + if (null != m_role) { + pw.println(tab + ROLE + "=" + m_role); + } + if (null != m_sourceLines) { + for (SourceLine sl : m_sourceLines) { + sl.dump(pw, indent + 2); + } + } } }