1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.qedeq.kernel.se.common;
17
18 import org.qedeq.base.io.SourcePosition;
19 import org.qedeq.base.trace.Trace;
20 import org.qedeq.base.utility.EqualsUtility;
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 public class ModuleContext {
36
37
38 private static final Class CLASS = ModuleContext.class;
39
40
41 private ModuleAddress moduleLocation;
42
43
44 private String locationWithinModule;
45
46
47 private final SourcePosition startDelta;
48
49
50 private final SourcePosition endDelta;
51
52
53
54
55
56
57
58
59
60
61
62
63
64 public ModuleContext(final ModuleAddress moduleLocation, final String locationWithinModule,
65 final SourcePosition startDelta, final SourcePosition endDelta) {
66 if (moduleLocation == null) {
67 throw new NullPointerException("module adress should not be null");
68 }
69 if (locationWithinModule == null) {
70 throw new NullPointerException("location within module should not be null");
71 }
72 this.moduleLocation = moduleLocation;
73 this.locationWithinModule = locationWithinModule;
74 this.startDelta = startDelta;
75 this.endDelta = endDelta;
76 }
77
78
79
80
81
82
83
84
85 public ModuleContext(final ModuleAddress moduleLocation, final String locationWithinModule) {
86 this(moduleLocation, locationWithinModule, null, null);
87 }
88
89
90
91
92
93
94 public ModuleContext(final ModuleAddress moduleLocation) {
95 this(moduleLocation, "");
96 }
97
98
99
100
101
102
103 public ModuleContext(final ModuleContext original) {
104 this(original.getModuleLocation(), original.getLocationWithinModule(),
105 original.getStartDelta(), original.getEndDelta());
106 }
107
108
109
110
111
112
113
114 public ModuleContext(final ModuleContext main, final String moduleLocation) {
115 this(main.getModuleLocation(), moduleLocation);
116 }
117
118
119
120
121
122
123 public final ModuleAddress getModuleLocation() {
124 return moduleLocation;
125 }
126
127
128
129
130
131
132 public final String getLocationWithinModule() {
133 return locationWithinModule;
134 }
135
136
137
138
139
140
141 public final void setLocationWithinModule(final String locationWithinModule) {
142 final String method = "setLocationWithinModule(String)";
143 this.locationWithinModule = locationWithinModule;
144 Trace.param(CLASS, this, method, "locationWithinModule", locationWithinModule);
145 }
146
147
148
149
150
151
152
153
154 public final SourcePosition getStartDelta() {
155 return startDelta;
156 }
157
158
159
160
161
162
163
164
165 public final SourcePosition getEndDelta() {
166 return endDelta;
167 }
168
169 public final int hashCode() {
170 return getModuleLocation().hashCode() ^ getLocationWithinModule().hashCode()
171 ^ (startDelta != null ? startDelta.hashCode() : 7)
172 ^ (endDelta != null ? endDelta.hashCode() : 11);
173 }
174
175 public final boolean equals(final Object obj) {
176 if (!(obj instanceof ModuleContext)) {
177 return false;
178 }
179 final ModuleContext other = (ModuleContext) obj;
180 return getModuleLocation().equals(other.getModuleLocation())
181 && getLocationWithinModule().equals(other.getLocationWithinModule())
182 && EqualsUtility.equals(startDelta, other.startDelta)
183 && EqualsUtility.equals(endDelta, other.endDelta);
184 }
185
186 public final String toString() {
187 return getModuleLocation() + ":" + getLocationWithinModule()
188 + ":" + startDelta + ":" + endDelta;
189 }
190
191 }