X-Git-Url: http://jaekl.net/gitweb/?p=cfb.git;a=blobdiff_plain;f=prod%2Fnet%2Fjaekl%2Fcfb%2Fstore%2FLocation.java;h=91aed9f8c32100a1a911bd74725c5ce6d5d72310;hp=208c3db3dd10d8740e532ae9c89af39715499130;hb=749427d1b39953205e05f0d5fee7b05b2a52dd47;hpb=598968590bf67cf87d3243878f7ebb2ff8015065 diff --git a/prod/net/jaekl/cfb/store/Location.java b/prod/net/jaekl/cfb/store/Location.java index 208c3db..91aed9f 100644 --- a/prod/net/jaekl/cfb/store/Location.java +++ b/prod/net/jaekl/cfb/store/Location.java @@ -1,14 +1,21 @@ package net.jaekl.cfb.store; +import java.io.PrintWriter; + +import net.jaekl.cfb.util.Util; import net.jaekl.cfb.xml.BugClass; import net.jaekl.cfb.xml.BugMethod; import net.jaekl.cfb.xml.SourceLine; public class Location { + public static final String METHOD_CALLED = "METHOD_CALLED"; + + Long m_id; String m_className; String m_methodName; - int m_startLine; - int m_endLine; + String m_methodRole; + Integer m_startLine; + Integer m_endLine; public Location(SourceLine sourceLine) { @@ -20,6 +27,15 @@ public class Location { init(method.getSourceLines()); m_className = method.getClassName(); m_methodName = method.getMethodName(); + m_methodRole = method.getRole(); + } + + public Location(BugMethod method, SourceLine sourceLine) + { + init(sourceLine); + m_className = method.getClassName(); + m_methodName = method.getMethodName(); + m_methodRole = method.getRole(); } public Location(BugClass bugClass) @@ -28,6 +44,84 @@ public class Location { m_className = bugClass.getClassName(); } + public Location(Long id, String className, String methodName, String methodRole, Integer startLine, Integer endLine) + { + m_id = id; + m_className = className; + m_methodName = methodName; + m_methodRole = methodRole; + m_startLine = startLine; + m_endLine = endLine; + } + + public String getClassName() { return m_className; } + public String getMethodName() { return m_methodName; } + public String getMethodRole() { return m_methodRole; } + public int getStart() { return m_startLine; } + public int getEnd() { return m_endLine; } + + public void dump(PrintWriter pw, int indent) + { + String margin = String.format("%" + indent + "s", ""); + String tab = margin + " "; + pw.println(margin + "Location"); + if (null != m_className) { + pw.println(tab + "classname = " + m_className); + } + if (null != m_methodName) { + if (null != m_methodRole) { + pw.println(tab + "method = " + m_methodName + " (" + m_methodRole + ")"); + } + else { + pw.println(tab + "method = " + m_methodName); + } + } + if (null != m_startLine) { + pw.println(tab + "lines = " + m_startLine + " .. " + m_endLine); + } + } + + public boolean fuzzyEquals(Location that) + { + if (null == that) { + return false; + } + + if (! Util.objsAreEqual(this.m_className, that.m_className)) { + return false; + } + + if (! Util.objsAreEqual(this.m_methodName, that.m_methodName)) { + return false; + } + + if (! Util.objsAreEqual(this.m_methodRole, that.m_methodRole)) { + return false; + } + + return true; + } + + @Override + public boolean equals(Object other) + { + if (null == other) { + return false; + } + if (other instanceof Location) { + return fuzzyEquals((Location)other); + } + return false; + } + + @Override + public int hashCode() + { + return Util.objHashCode(m_className) + ^ Util.objHashCode(m_methodName) + ^ Util.objHashCode(m_methodRole); + } + private void init(SourceLine[] sourceLines) { if (sourceLines.length > 0) { @@ -35,12 +129,19 @@ public class Location { init(sourceLines[0]); } } + + private void init(SourceLine sourceLine) + { + init(sourceLine.getClassName(), sourceLine.getStart(), sourceLine.getEnd()); + } - private void init(SourceLine sourceLine) + private void init(String className, int startLine, int endLine) { - m_className = sourceLine.getClassName(); + m_id = null; + m_className = className; m_methodName = null; - m_startLine = sourceLine.getStart(); - m_endLine = sourceLine.getEnd(); + m_methodRole = null; + m_startLine = startLine; + m_endLine = endLine; } }