| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
package com.stevesoft.pat; |
| 9 |
|
|
| 10 |
|
import java.util.Hashtable; |
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| |
|
| 46.4% |
Uncovered Elements: 74 (138) |
Complexity: 33 |
Complexity Density: 0.42 |
|
| 16 |
|
class DotMulti extends PatternSub |
| 17 |
|
{ |
| 18 |
|
patInt fewestMatches, mostMatches; |
| 19 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 20 |
0 |
public patInt minChars()... |
| 21 |
|
{ |
| 22 |
0 |
return fewestMatches; |
| 23 |
|
} |
| 24 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 25 |
0 |
public patInt maxChars()... |
| 26 |
|
{ |
| 27 |
0 |
return mostMatches; |
| 28 |
|
} |
| 29 |
|
|
| 30 |
|
public boolean matchFewest = false; |
| 31 |
|
|
| 32 |
|
StringLike src = null; |
| 33 |
|
|
| 34 |
|
int srclength = 0; |
| 35 |
|
|
| 36 |
|
boolean dotDoesntMatchCR = true; |
| 37 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 38 |
371 |
DotMulti(patInt a, patInt b)... |
| 39 |
|
{ |
| 40 |
371 |
fewestMatches = a; |
| 41 |
371 |
mostMatches = b; |
| 42 |
|
} |
| 43 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 44 |
0 |
public String toString()... |
| 45 |
|
{ |
| 46 |
0 |
return ".{" + fewestMatches + "," + mostMatches + "}" |
| 47 |
0 |
+ (matchFewest ? "?" : "") + "(?# <= dot multi)" + nextString(); |
| 48 |
|
} |
| 49 |
|
|
| |
|
| 75% |
Uncovered Elements: 3 (12) |
Complexity: 4 |
Complexity Density: 0.67 |
|
| 50 |
118907 |
final int submatchInternal(int pos, Pthings pt)... |
| 51 |
|
{ |
| 52 |
118907 |
if (pos < srclength) |
| 53 |
|
{ |
| 54 |
115767 |
if (dotDoesntMatchCR) |
| 55 |
|
{ |
| 56 |
115767 |
if (src.charAt(pos) != '\n') |
| 57 |
|
{ |
| 58 |
115767 |
return 1 + pos; |
| 59 |
|
} |
| 60 |
|
} |
| 61 |
|
else |
| 62 |
|
{ |
| 63 |
0 |
return 1 + pos; |
| 64 |
|
} |
| 65 |
|
} |
| 66 |
3140 |
return -1; |
| 67 |
|
} |
| 68 |
|
|
| 69 |
|
final static int step = 1; |
| 70 |
|
|
| 71 |
|
static int idcount = 1; |
| 72 |
|
|
| |
|
| 45.9% |
Uncovered Elements: 59 (109) |
Complexity: 23 |
Complexity Density: 0.35 |
|
| 73 |
3167 |
public int matchInternal(int pos, Pthings pt)... |
| 74 |
|
{ |
| 75 |
3167 |
int m = -1; |
| 76 |
3167 |
int i = pos; |
| 77 |
3167 |
src = pt.src; |
| 78 |
3167 |
srclength = src.length(); |
| 79 |
3167 |
dotDoesntMatchCR = pt.dotDoesntMatchCR; |
| 80 |
3167 |
if (matchFewest) |
| 81 |
|
{ |
| 82 |
0 |
int nMatches = 0; |
| 83 |
0 |
while (fewestMatches.intValue() > nMatches) |
| 84 |
|
{ |
| 85 |
0 |
i = submatchInternal(i, pt); |
| 86 |
0 |
if (i < 0) |
| 87 |
|
{ |
| 88 |
0 |
return -1; |
| 89 |
|
} |
| 90 |
0 |
nMatches++; |
| 91 |
|
} |
| 92 |
0 |
if (i < 0) |
| 93 |
|
{ |
| 94 |
0 |
return -1; |
| 95 |
|
} |
| 96 |
0 |
int ii = nextMatch(i, pt); |
| 97 |
0 |
if (ii >= 0) |
| 98 |
|
{ |
| 99 |
0 |
return ii; |
| 100 |
|
} |
| 101 |
0 |
if (!mostMatches.finite()) |
| 102 |
|
{ |
| 103 |
0 |
while (i >= 0) |
| 104 |
|
{ |
| 105 |
0 |
i = submatchInternal(i, pt); |
| 106 |
0 |
if (i < 0) |
| 107 |
|
{ |
| 108 |
0 |
return -1; |
| 109 |
|
} |
| 110 |
0 |
ii = nextMatch(i, pt); |
| 111 |
0 |
if (ii >= 0) |
| 112 |
|
{ |
| 113 |
0 |
return ii; |
| 114 |
|
} |
| 115 |
|
} |
| 116 |
|
} |
| 117 |
|
else |
| 118 |
|
{ |
| 119 |
0 |
while (i > 0) |
| 120 |
|
{ |
| 121 |
0 |
i = submatchInternal(i, pt); |
| 122 |
0 |
if (i < 0) |
| 123 |
|
{ |
| 124 |
0 |
return -1; |
| 125 |
|
} |
| 126 |
0 |
nMatches++; |
| 127 |
0 |
if (nMatches > mostMatches.intValue()) |
| 128 |
|
{ |
| 129 |
0 |
return -1; |
| 130 |
|
} |
| 131 |
0 |
ii = nextMatch(i, pt); |
| 132 |
0 |
if (ii >= 0) |
| 133 |
|
{ |
| 134 |
0 |
return ii; |
| 135 |
|
} |
| 136 |
|
} |
| 137 |
|
} |
| 138 |
0 |
return -1; |
| 139 |
|
} |
| 140 |
3167 |
int nMatches = 0; |
| 141 |
3171 |
while (fewestMatches.intValue() > nMatches) |
| 142 |
|
{ |
| 143 |
22 |
i = submatchInternal(i, pt); |
| 144 |
22 |
if (i >= 0) |
| 145 |
|
{ |
| 146 |
4 |
nMatches++; |
| 147 |
|
} |
| 148 |
|
else |
| 149 |
|
{ |
| 150 |
18 |
return -1; |
| 151 |
|
} |
| 152 |
|
} |
| 153 |
3149 |
m = i; |
| 154 |
3149 |
if (mostMatches.finite()) |
| 155 |
|
{ |
| 156 |
54 |
while (nMatches < mostMatches.intValue()) |
| 157 |
|
{ |
| 158 |
27 |
i = submatchInternal(i, pt); |
| 159 |
27 |
if (i >= 0) |
| 160 |
|
{ |
| 161 |
27 |
m = i; |
| 162 |
27 |
nMatches++; |
| 163 |
|
} |
| 164 |
|
else |
| 165 |
|
{ |
| 166 |
0 |
break; |
| 167 |
|
} |
| 168 |
|
} |
| 169 |
|
} |
| 170 |
|
else |
| 171 |
|
{ |
| 172 |
3122 |
while (true) |
| 173 |
|
{ |
| 174 |
118858 |
i = submatchInternal(i, pt); |
| 175 |
118858 |
if (i >= 0) |
| 176 |
|
{ |
| 177 |
115736 |
m = i; |
| 178 |
115736 |
nMatches++; |
| 179 |
|
} |
| 180 |
|
else |
| 181 |
|
{ |
| 182 |
3122 |
break; |
| 183 |
|
} |
| 184 |
|
} |
| 185 |
|
} |
| 186 |
3327 |
while (m >= pos) |
| 187 |
|
{ |
| 188 |
3327 |
int r = nextMatch(m, pt); |
| 189 |
3327 |
if (r >= 0) |
| 190 |
|
{ |
| 191 |
3122 |
return r; |
| 192 |
|
} |
| 193 |
205 |
m -= step; |
| 194 |
205 |
nMatches--; |
| 195 |
205 |
if (nMatches < fewestMatches.intValue()) |
| 196 |
|
{ |
| 197 |
27 |
return -1; |
| 198 |
|
} |
| 199 |
|
} |
| 200 |
0 |
return -1; |
| 201 |
|
} |
| 202 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 203 |
0 |
Pattern clone1(Hashtable h)... |
| 204 |
|
{ |
| 205 |
0 |
DotMulti dm = new DotMulti(fewestMatches, mostMatches); |
| 206 |
0 |
dm.matchFewest = matchFewest; |
| 207 |
0 |
return dm; |
| 208 |
|
} |
| 209 |
|
} |