2cd91c80f70e5a81c5f5df4e8b00f97b55cd954b
[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         int m_startLine;
11         int m_endLine;
12         
13         public Location(SourceLine sourceLine)
14         {
15                 init(sourceLine);
16         }
17         
18         public Location(BugMethod method) 
19         {
20                 init(method.getSourceLines());
21                 m_className = method.getClassName();
22                 m_methodName = method.getMethodName();
23         }
24         
25         public Location(BugClass bugClass)
26         {
27                 init(bugClass.getSourceLines());
28                 m_className = bugClass.getClassName();
29         }
30         
31         public String getClassName() { return m_className; }
32         public String getMethodName() { return m_methodName; }
33         public int getStart() { return m_startLine; }
34         public int getEnd() { return m_endLine; }
35         
36         private void init(SourceLine[] sourceLines) 
37         {
38                 if (sourceLines.length > 0) {
39                         assert(null != sourceLines[0]);
40                         init(sourceLines[0]);
41                 }               
42         }
43
44         private void init(SourceLine sourceLine)
45         {
46                 m_className = sourceLine.getClassName();
47                 m_methodName = null;
48                 m_startLine = sourceLine.getStart();
49                 m_endLine = sourceLine.getEnd();
50         }
51 }