Add local variable information to DB store.
[cfb.git] / prod / net / jaekl / cfb / store / Location.java
1 package net.jaekl.cfb.store;
2
3 import net.jaekl.cfb.xml.BugClass;
4 import net.jaekl.cfb.xml.BugMethod;
5 import net.jaekl.cfb.xml.SourceLine;
6
7 public class Location {
8         String m_className;
9         String m_methodName;
10         String m_methodRole;
11         int m_startLine;
12         int m_endLine;
13         
14         public Location(SourceLine sourceLine)
15         {
16                 init(sourceLine);
17         }
18         
19         public Location(BugMethod method) 
20         {
21                 init(method.getSourceLines());
22                 m_className = method.getClassName();
23                 m_methodName = method.getMethodName();
24                 m_methodRole = method.getRole();
25         }
26         
27         public Location(BugMethod method, SourceLine sourceLine)
28         {
29                 init(sourceLine);
30                 m_className = method.getClassName();
31                 m_methodName = method.getMethodName();
32                 m_methodRole = method.getRole();
33         }
34         
35         public Location(BugClass bugClass)
36         {
37                 init(bugClass.getSourceLines());
38                 m_className = bugClass.getClassName();
39         }
40         
41         public String getClassName() { return m_className; }
42         public String getMethodName() { return m_methodName; }
43         public String getMethodRole() { return m_methodRole; }
44         public int getStart() { return m_startLine; }
45         public int getEnd() { return m_endLine; }
46         
47         private void init(SourceLine[] sourceLines) 
48         {
49                 if (sourceLines.length > 0) {
50                         assert(null != sourceLines[0]);
51                         init(sourceLines[0]);
52                 }               
53         }
54
55         private void init(SourceLine sourceLine)
56         {
57                 m_className = sourceLine.getClassName();
58                 m_methodName = null;
59                 m_methodRole = null;
60                 m_startLine = sourceLine.getStart();
61                 m_endLine = sourceLine.getEnd();
62         }
63 }