search the stream for a match to a string @param string The string to match @return true is one is found, the current position in stream is positioned after the search string, false otherwise, position in stream unchanged.
(String string)
| 285 | * string, <strong> false</strong> otherwise, position in stream unchanged. |
| 286 | */ |
| 287 | boolean matches(String string) { |
| 288 | int len = string.length(); |
| 289 | int cursor = current.cursor; |
| 290 | int streamSize = current.stream.length; |
| 291 | if (cursor + len < streamSize) { // Try to scan in memory |
| 292 | int line = current.line; |
| 293 | int col = current.col; |
| 294 | int ch; |
| 295 | int i = 0; |
| 296 | for (; i < len; i++) { |
| 297 | ch = current.stream[i + cursor]; |
| 298 | if (string.charAt(i) != ch) { |
| 299 | return false; |
| 300 | } |
| 301 | if (ch == '\n') { |
| 302 | line++; |
| 303 | col = 0; |
| 304 | } else { |
| 305 | col++; |
| 306 | } |
| 307 | } |
| 308 | current.update(i + cursor, line, col); |
| 309 | } else { |
| 310 | Mark mark = mark(); |
| 311 | int ch; |
| 312 | int i = 0; |
| 313 | do { |
| 314 | ch = nextChar(); |
| 315 | if (((char) ch) != string.charAt(i++)) { |
| 316 | setCurrent(mark); |
| 317 | return false; |
| 318 | } |
| 319 | } while (i < len); |
| 320 | } |
| 321 | return true; |
| 322 | } |
| 323 | |
| 324 | boolean matchesETag(String tagName) { |
| 325 | Mark mark = mark(); |
no test coverage detected