Add ability to load previously found bugs back out of the database.
[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         Long m_id;
9         String m_className;
10         String m_methodName;
11         String m_methodRole;
12         int m_startLine;
13         int m_endLine;
14         
15         public Location(SourceLine sourceLine)
16         {
17                 init(sourceLine);
18         }
19         
20         public Location(BugMethod method) 
21         {
22                 init(method.getSourceLines());
23                 m_className = method.getClassName();
24                 m_methodName = method.getMethodName();
25                 m_methodRole = method.getRole();
26         }
27         
28         public Location(BugMethod method, SourceLine sourceLine)
29         {
30                 init(sourceLine);
31                 m_className = method.getClassName();
32                 m_methodName = method.getMethodName();
33                 m_methodRole = method.getRole();
34         }
35         
36         public Location(BugClass bugClass)
37         {
38                 init(bugClass.getSourceLines());
39                 m_className = bugClass.getClassName();
40         }
41         
42         public Location(Long id, String className, String methodName, String methodRole, long startLine, long endLine)
43         {
44                 
45         }
46         
47         public String getClassName() { return m_className; }
48         public String getMethodName() { return m_methodName; }
49         public String getMethodRole() { return m_methodRole; }
50         public int getStart() { return m_startLine; }
51         public int getEnd() { return m_endLine; }
52         
53         private void init(SourceLine[] sourceLines) 
54         {
55                 if (sourceLines.length > 0) {
56                         assert(null != sourceLines[0]);
57                         init(sourceLines[0]);
58                 }               
59         }
60         
61         private void init(SourceLine sourceLine) 
62         {
63                 init(sourceLine.getClassName(), sourceLine.getStart(), sourceLine.getEnd());
64         }
65
66         private void init(String className, int startLine, int endLine)
67         {
68                 m_id = null;
69                 m_className = className;
70                 m_methodName = null;
71                 m_methodRole = null;
72                 m_startLine = startLine;
73                 m_endLine = endLine;
74         }
75 }