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