1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
package com.stevesoft.pat; |
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
|
|
| 37.7% |
Uncovered Elements: 86 (138) |
Complexity: 72 |
Complexity Density: 1.09 |
|
17 |
|
public class RegRes implements Cloneable |
18 |
|
{ |
19 |
|
protected int[] marks = null; |
20 |
|
|
21 |
|
protected boolean didMatch_ = false; |
22 |
|
|
23 |
|
protected StringLike src = null; |
24 |
|
|
25 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
26 |
0 |
public String getString()... |
27 |
|
{ |
28 |
0 |
return src.toString(); |
29 |
|
} |
30 |
|
|
31 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
32 |
3 |
public StringLike getStringLike()... |
33 |
|
{ |
34 |
3 |
return src; |
35 |
|
} |
36 |
|
|
37 |
|
protected int charsMatched_ = 0, matchFrom_ = 0, numSubs_ = 0; |
38 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
39 |
0 |
public String toString()... |
40 |
|
{ |
41 |
0 |
StringBuffer sb = new StringBuffer(); |
42 |
0 |
sb.append("match=" + matchedFrom() + ":" + charsMatched()); |
43 |
0 |
if (!didMatch()) |
44 |
|
{ |
45 |
0 |
return sb.toString(); |
46 |
|
} |
47 |
0 |
for (int i = 0; i < numSubs(); i++) |
48 |
|
{ |
49 |
0 |
int n = i + 1; |
50 |
0 |
sb.append(" sub(" + n + ")=" + matchedFrom(n) + ":" + charsMatched(n)); |
51 |
|
} |
52 |
0 |
return sb.toString(); |
53 |
|
} |
54 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
55 |
3468 |
public RegRes()... |
56 |
|
{ |
57 |
|
} |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
59 |
161 |
public RegRes(RegRes r)... |
60 |
|
{ |
61 |
161 |
copyOutOf(r); |
62 |
|
} |
63 |
|
|
|
|
| 53.3% |
Uncovered Elements: 7 (15) |
Complexity: 4 |
Complexity Density: 0.36 |
|
64 |
161 |
public void copyOutOf(RegRes r)... |
65 |
|
{ |
66 |
161 |
if (r.marks == null) |
67 |
|
{ |
68 |
161 |
marks = null; |
69 |
|
} |
70 |
|
else |
71 |
|
{ |
72 |
0 |
try |
73 |
|
{ |
74 |
|
|
75 |
0 |
marks = new int[r.marks.length]; |
76 |
0 |
for (int i = 0; i < marks.length; i++) |
77 |
|
{ |
78 |
0 |
marks[i] = r.marks[i]; |
79 |
|
} |
80 |
|
|
81 |
|
} catch (Throwable t) |
82 |
|
{ |
83 |
|
} |
84 |
|
} |
85 |
161 |
didMatch_ = r.didMatch_; |
86 |
161 |
src = r.src; |
87 |
161 |
charsMatched_ = r.charsMatched_; |
88 |
161 |
matchFrom_ = r.matchFrom_; |
89 |
161 |
numSubs_ = r.numSubs_; |
90 |
|
} |
91 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
92 |
0 |
public Object clone()... |
93 |
|
{ |
94 |
0 |
return new RegRes(this); |
95 |
|
} |
96 |
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 13 |
Complexity Density: 1.08 |
|
97 |
0 |
public boolean equals(RegRes r)... |
98 |
|
{ |
99 |
0 |
if (charsMatched_ != r.charsMatched_ || matchFrom_ != r.matchFrom_ |
100 |
|
|| didMatch_ != r.didMatch_ || numSubs_ != r.numSubs_ |
101 |
|
|| !src.unwrap().equals(r.src.unwrap())) |
102 |
|
{ |
103 |
0 |
return false; |
104 |
|
} |
105 |
0 |
if (marks == null && r.marks != null) |
106 |
|
{ |
107 |
0 |
return false; |
108 |
|
} |
109 |
0 |
if (marks != null && r.marks == null) |
110 |
|
{ |
111 |
0 |
return false; |
112 |
|
} |
113 |
0 |
for (int i = 1; i <= numSubs_; i++) |
114 |
|
{ |
115 |
0 |
if (matchedFrom(i) != r.matchedFrom(i)) |
116 |
|
{ |
117 |
0 |
return false; |
118 |
|
} |
119 |
0 |
else if (charsMatched(i) != r.charsMatched(i)) |
120 |
|
{ |
121 |
0 |
return false; |
122 |
|
} |
123 |
|
} |
124 |
0 |
return true; |
125 |
|
} |
126 |
|
|
127 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 4 |
Complexity Density: 2 |
|
128 |
22 |
public String stringMatched()... |
129 |
|
{ |
130 |
22 |
int mf = matchedFrom(), cm = charsMatched(); |
131 |
22 |
return !didMatch_ || mf < 0 || cm < 0 ? null : src.substring(mf, mf |
132 |
|
+ cm); |
133 |
|
} |
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
139 |
39385 |
public int matchedFrom(int i)... |
140 |
|
{ |
141 |
39385 |
if (marks == null || i > numSubs_) |
142 |
|
{ |
143 |
0 |
return -1; |
144 |
|
} |
145 |
|
|
146 |
|
|
147 |
39385 |
return marks[i]; |
148 |
|
} |
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
|
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 5 |
Complexity Density: 1.25 |
|
154 |
13010 |
public int charsMatched(int i)... |
155 |
|
{ |
156 |
13010 |
if (marks == null || i > numSubs_ || !didMatch_) |
157 |
|
{ |
158 |
0 |
return -1; |
159 |
|
} |
160 |
|
|
161 |
|
|
162 |
13010 |
int mf = matchedFrom(i); |
163 |
13010 |
return mf < 0 ? -1 : marks[i + numSubs_] - matchedFrom(i); |
164 |
|
} |
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
|
169 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 4 |
Complexity Density: 1.33 |
|
170 |
36 |
public int matchedTo(int i)... |
171 |
|
{ |
172 |
36 |
if (marks == null || i > numSubs_ || !didMatch_) |
173 |
|
{ |
174 |
0 |
return -1; |
175 |
|
} |
176 |
36 |
return marks[i + numSubs_]; |
177 |
|
} |
178 |
|
|
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 4 |
Complexity Density: 2 |
|
183 |
13010 |
public String stringMatched(int i)... |
184 |
|
{ |
185 |
13010 |
int mf = matchedFrom(i), cm = charsMatched(i); |
186 |
13010 |
return !didMatch_ || mf < 0 || cm < 0 ? null : src.substring(mf, mf |
187 |
|
+ cm); |
188 |
|
} |
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|
193 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 3 |
Complexity Density: 1.5 |
|
194 |
0 |
public String left()... |
195 |
|
{ |
196 |
0 |
int mf = matchedFrom(); |
197 |
0 |
return !didMatch_ || (mf < 0) ? null : src.substring(0, mf); |
198 |
|
} |
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 3 |
Complexity Density: 1.5 |
|
204 |
0 |
public String left(int i)... |
205 |
|
{ |
206 |
0 |
int mf = matchedFrom(i); |
207 |
0 |
return !didMatch_ || (mf < 0) ? null : src.substring(0, mf); |
208 |
|
} |
209 |
|
|
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 4 |
Complexity Density: 2 |
|
214 |
0 |
public String right()... |
215 |
|
{ |
216 |
0 |
int mf = matchedFrom(), cm = charsMatched(); |
217 |
0 |
return !didMatch_ || mf < 0 || cm < 0 ? null : src.substring(mf + cm, |
218 |
|
src.length()); |
219 |
|
} |
220 |
|
|
221 |
|
|
222 |
|
|
223 |
|
|
224 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 4 |
Complexity Density: 2 |
|
225 |
0 |
public String right(int i)... |
226 |
|
{ |
227 |
0 |
int mf = matchedFrom(i), cm = charsMatched(i); |
228 |
0 |
return !didMatch_ || mf < 0 || cm < 0 ? null : src.substring(mf + cm, |
229 |
|
src.length()); |
230 |
|
} |
231 |
|
|
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
236 |
454 |
public int matchedFrom()... |
237 |
|
{ |
238 |
454 |
return !didMatch_ ? -1 : matchFrom_; |
239 |
|
} |
240 |
|
|
241 |
|
|
242 |
|
|
243 |
|
|
244 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 3 |
Complexity Density: 3 |
|
245 |
77 |
public int charsMatched()... |
246 |
|
{ |
247 |
77 |
return !didMatch_ || matchFrom_ < 0 ? -1 : charsMatched_; |
248 |
|
} |
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
|
253 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
254 |
10388 |
public int matchedTo()... |
255 |
|
{ |
256 |
10388 |
return !didMatch_ ? -1 : matchFrom_ + charsMatched_; |
257 |
|
} |
258 |
|
|
259 |
|
|
260 |
|
|
261 |
|
|
262 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
263 |
76 |
public int numSubs()... |
264 |
|
{ |
265 |
76 |
return numSubs_; |
266 |
|
} |
267 |
|
|
268 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
269 |
3 |
public boolean didMatch()... |
270 |
|
{ |
271 |
3 |
return didMatch_; |
272 |
|
} |
273 |
|
|
274 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
275 |
0 |
public int matchFrom()... |
276 |
|
{ |
277 |
0 |
return matchedFrom(); |
278 |
|
} |
279 |
|
|
280 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
281 |
0 |
public String substring()... |
282 |
|
{ |
283 |
0 |
return stringMatched(); |
284 |
|
} |
285 |
|
|
286 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
287 |
0 |
public int matchFrom(int i)... |
288 |
|
{ |
289 |
0 |
return matchedFrom(i); |
290 |
|
} |
291 |
|
|
292 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
293 |
0 |
public String substring(int i)... |
294 |
|
{ |
295 |
0 |
return stringMatched(i); |
296 |
|
} |
297 |
|
} |