| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
package com.stevesoft.pat; |
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| |
|
| 0% |
Uncovered Elements: 86 (86) |
Complexity: 28 |
Complexity Density: 0.53 |
|
| 17 |
|
public class StrPos |
| 18 |
|
{ |
| 19 |
|
String s; |
| 20 |
|
|
| 21 |
|
int pos; |
| 22 |
|
|
| 23 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 24 |
0 |
public int pos()... |
| 25 |
|
{ |
| 26 |
0 |
return pos; |
| 27 |
|
} |
| 28 |
|
|
| 29 |
|
|
| 30 |
|
public char esc = Pattern.ESC; |
| 31 |
|
|
| 32 |
|
char c; |
| 33 |
|
|
| 34 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 35 |
0 |
public char thisChar()... |
| 36 |
|
{ |
| 37 |
0 |
return c; |
| 38 |
|
} |
| 39 |
|
|
| 40 |
|
boolean dontMatch, eos; |
| 41 |
|
|
| 42 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 43 |
0 |
public boolean eos()... |
| 44 |
|
{ |
| 45 |
0 |
return eos; |
| 46 |
|
} |
| 47 |
|
|
| 48 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 49 |
0 |
public StrPos(StrPos sp)... |
| 50 |
|
{ |
| 51 |
0 |
dup(sp); |
| 52 |
|
} |
| 53 |
|
|
| 54 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 55 |
0 |
public void dup(StrPos sp)... |
| 56 |
|
{ |
| 57 |
0 |
s = sp.s; |
| 58 |
0 |
pos = sp.pos; |
| 59 |
0 |
c = sp.c; |
| 60 |
0 |
dontMatch = sp.dontMatch; |
| 61 |
0 |
eos = sp.eos; |
| 62 |
|
} |
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 68 |
0 |
public StrPos(String s, int pos)... |
| 69 |
|
{ |
| 70 |
0 |
this.s = s; |
| 71 |
0 |
this.pos = pos - 1; |
| 72 |
0 |
inc(); |
| 73 |
|
} |
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| |
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.36 |
|
| 79 |
0 |
public StrPos inc()... |
| 80 |
|
{ |
| 81 |
0 |
pos++; |
| 82 |
0 |
if (pos >= s.length()) |
| 83 |
|
{ |
| 84 |
0 |
eos = true; |
| 85 |
0 |
return this; |
| 86 |
|
} |
| 87 |
0 |
eos = false; |
| 88 |
0 |
c = s.charAt(pos); |
| 89 |
0 |
if (c == esc && pos + 1 < s.length()) |
| 90 |
|
{ |
| 91 |
0 |
pos++; |
| 92 |
0 |
c = s.charAt(pos); |
| 93 |
0 |
if (c != esc) |
| 94 |
|
{ |
| 95 |
0 |
dontMatch = true; |
| 96 |
|
} |
| 97 |
|
else |
| 98 |
|
{ |
| 99 |
0 |
dontMatch = false; |
| 100 |
|
} |
| 101 |
|
} |
| 102 |
|
else |
| 103 |
|
{ |
| 104 |
0 |
dontMatch = false; |
| 105 |
|
} |
| 106 |
0 |
return this; |
| 107 |
|
} |
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
| 113 |
0 |
public boolean match(char ch)... |
| 114 |
|
{ |
| 115 |
0 |
if (dontMatch || eos) |
| 116 |
|
{ |
| 117 |
0 |
return false; |
| 118 |
|
} |
| 119 |
0 |
return c == ch; |
| 120 |
|
} |
| 121 |
|
|
| 122 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
| 123 |
0 |
public boolean escMatch(char ch)... |
| 124 |
|
{ |
| 125 |
0 |
if (!dontMatch || eos) |
| 126 |
|
{ |
| 127 |
0 |
return false; |
| 128 |
|
} |
| 129 |
0 |
return c == ch; |
| 130 |
|
} |
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 135 |
0 |
public boolean escaped()... |
| 136 |
|
{ |
| 137 |
0 |
return dontMatch; |
| 138 |
|
} |
| 139 |
|
|
| 140 |
|
|
| 141 |
|
|
| 142 |
|
|
| 143 |
|
|
| 144 |
|
|
| 145 |
|
|
| 146 |
|
|
| 147 |
|
|
| 148 |
|
|
| |
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
| 149 |
0 |
public boolean incMatch(String st)... |
| 150 |
|
{ |
| 151 |
0 |
StrPos sp = new StrPos(this); |
| 152 |
0 |
int i; |
| 153 |
0 |
for (i = 0; i < st.length(); i++) |
| 154 |
|
{ |
| 155 |
0 |
if (!sp.match(st.charAt(i))) |
| 156 |
|
{ |
| 157 |
0 |
return false; |
| 158 |
|
} |
| 159 |
0 |
sp.inc(); |
| 160 |
|
} |
| 161 |
0 |
dup(sp); |
| 162 |
0 |
return true; |
| 163 |
|
} |
| 164 |
|
|
| 165 |
|
|
| |
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 6 |
Complexity Density: 0.55 |
|
| 166 |
0 |
public patInt getPatInt()... |
| 167 |
|
{ |
| 168 |
0 |
if (incMatch("inf")) |
| 169 |
|
{ |
| 170 |
0 |
return new patInf(); |
| 171 |
|
} |
| 172 |
0 |
int i, cnt = 0; |
| 173 |
0 |
StrPos sp = new StrPos(this); |
| 174 |
0 |
for (i = 0; !sp.eos && sp.c >= '0' && sp.c <= '9'; i++) |
| 175 |
|
{ |
| 176 |
0 |
cnt = 10 * cnt + sp.c - '0'; |
| 177 |
0 |
sp.inc(); |
| 178 |
|
} |
| 179 |
0 |
if (i == 0) |
| 180 |
|
{ |
| 181 |
0 |
return null; |
| 182 |
|
} |
| 183 |
0 |
dup(sp); |
| 184 |
0 |
return new patInt(cnt); |
| 185 |
|
} |
| 186 |
|
|
| 187 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 188 |
0 |
public String getString()... |
| 189 |
|
{ |
| 190 |
0 |
return s; |
| 191 |
|
} |
| 192 |
|
}; |