Some progress toward implementing store(Analysis).
[cfb.git] / prod / net / jaekl / cfb / store / Location.java
diff --git a/prod/net/jaekl/cfb/store/Location.java b/prod/net/jaekl/cfb/store/Location.java
new file mode 100644 (file)
index 0000000..208c3db
--- /dev/null
@@ -0,0 +1,46 @@
+package net.jaekl.cfb.store;
+
+import net.jaekl.cfb.xml.BugClass;
+import net.jaekl.cfb.xml.BugMethod;
+import net.jaekl.cfb.xml.SourceLine;
+
+public class Location {
+       String m_className;
+       String m_methodName;
+       int m_startLine;
+       int m_endLine;
+       
+       public Location(SourceLine sourceLine)
+       {
+               init(sourceLine);
+       }
+       
+       public Location(BugMethod method) 
+       {
+               init(method.getSourceLines());
+               m_className = method.getClassName();
+               m_methodName = method.getMethodName();
+       }
+       
+       public Location(BugClass bugClass)
+       {
+               init(bugClass.getSourceLines());
+               m_className = bugClass.getClassName();
+       }
+       
+       private void init(SourceLine[] sourceLines) 
+       {
+               if (sourceLines.length > 0) {
+                       assert(null != sourceLines[0]);
+                       init(sourceLines[0]);
+               }               
+       }
+
+       private void init(SourceLine sourceLine)
+       {
+               m_className = sourceLine.getClassName();
+               m_methodName = null;
+               m_startLine = sourceLine.getStart();
+               m_endLine = sourceLine.getEnd();
+       }
+}