01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09: //
10:
11: package de.uka.ilkd.key.java;
12:
13: /**
14: * represents a group of three Positions: relativePosition,
15: * startPosition, endPosition
16: */
17: public class PositionInfo {
18:
19: Position relPos;
20: Position startPos;
21: Position endPos;
22:
23: String fileName = null;
24: protected String parentClass;
25:
26: public final static PositionInfo UNDEFINED = new PositionInfo();
27:
28: private PositionInfo() {
29: this .relPos = Position.UNDEFINED;
30: this .startPos = Position.UNDEFINED;
31: this .endPos = Position.UNDEFINED;
32: }
33:
34: public PositionInfo(Position relPos, Position startPos,
35: Position endPos) {
36: this .relPos = relPos;
37: this .startPos = startPos;
38: this .endPos = endPos;
39: }
40:
41: public PositionInfo(Position relPos, Position startPos,
42: Position endPos, String fileName) {
43: this .relPos = relPos;
44: this .startPos = startPos;
45: this .endPos = endPos;
46: this .fileName = fileName;
47: }
48:
49: public Position getRelativePosition() {
50: return relPos;
51: }
52:
53: public Position getStartPosition() {
54: return startPos;
55: }
56:
57: public Position getEndPosition() {
58: return endPos;
59: }
60:
61: public String getFileName() {
62: return fileName;
63: }
64:
65: /** this violates immutability, but the method is only called
66: * right after the object is created...
67: */
68: protected void setParentClass(String s) {
69: parentClass = s;
70: }
71:
72: /** get the class the statement originates from */
73: public String getParentClass() {
74: return parentClass;
75: }
76:
77: public String toString() {
78: if (this == PositionInfo.UNDEFINED)
79: return "UNDEFINED";
80: else
81: return (fileName + " rel. Pos: " + relPos + " start Pos: "
82: + startPos + " end Pos: " + endPos);
83: }
84:
85: }
|