/** * Walks forward until the caret points at a whitespace character. * * @return true if a whitespace character was found */ public boolean walkToWhitespace() { while (!endReached() && !Character.isWhitespace(src.charAt(offset))) { offset++; } return !endReached(); }
/** * Walks forward with the caret until it points at the given character. Case-Sensitive * comparison is used. * * @param c * the character to walk to * @return true if the character was found, false if the end of the string was reached while * searching */ public boolean walkToCharCheckCase(char c) { while (!endReached() && (src.charAt(offset) != c)) { offset++; } return !endReached(); }
/** * Walks forward until the caret points at a non-whitespace character. */ public void walkAfterWhitespaces() { while (!endReached() && Character.isWhitespace(src.charAt(offset))) { offset++; } }
/** * Walks forward with the caret until it points at a position which matches the given string. * Case-Insensitive comparison is used. * * @param strToMatch * the string to match * @return true if the string was found, false if the end of the string was reached while * searching */ public boolean walkToMatchIgnoreCase(String strToMatch) { while (!endReached() && !startsWithIgnoreCase(strToMatch)) { offset++; } return !endReached(); }
/** * Walks forward with the caret until it points at a position which matches the given string. * Case-sensitive comparison is used. * * @param strToMatch * the string to match * @return true if the string was found, false if the end of the string was reached while * searching */ public boolean walkToMatchCheckCase(String strToMatch) { while (!endReached() && !startsWithCheckCase(strToMatch)) { offset++; } return !endReached(); }
@Test public void test() { String test = "0123456789"; Caret c1 = new Caret(test, 2); assertThat(c1.endReached(), equalTo(false)); c1.goTo(10); assertThat(c1.endReached(), equalTo(true)); c1.goTo(5); assertThat(c1.endReached(), equalTo(false)); } }
@Test public void test() { String test = " ABCDEFGH\t\r\nabcdefg"; Caret c = new Caret(test); assertThat(c.walkToCharCheckCase('C'), equalTo(true)); assertThat(c.get(0), equalTo('C')); c.goTo(0); assertThat(c.walkToCharCheckCase('c'), equalTo(true)); assertThat(c.get(0), equalTo('c')); c.goTo(0); assertThat(c.walkToCharCheckCase('z'), equalTo(false)); assertThat(c.endReached(), equalTo(true)); } }
@Test public void test() { String test = " ABCDEFGH\t\r\nabcdefg"; Caret c = new Caret(test); assertThat(c.walkAfterCharCheckCase('C'), equalTo(true)); assertThat(c.get(0), equalTo('D')); c.goTo(0); assertThat(c.walkAfterCharCheckCase('c'), equalTo(true)); assertThat(c.get(0), equalTo('d')); c.goTo(0); assertThat(c.walkAfterCharCheckCase('z'), equalTo(false)); assertThat(c.endReached(), equalTo(true)); } }
@Test public void test() { String test = " ABCDEFGH\t\r \nabcdefg "; Caret c = new Caret(test); c.walkAfterWhitespaces(); assertThat(c.get(0), equalTo('A')); c.walkAfterWhitespaces(); assertThat(c.get(0), equalTo('A')); c.walkAfterCharCheckCase('H'); c.walkAfterWhitespaces(); assertThat(c.get(0), equalTo('a')); c.walkAfterCharCheckCase('g'); c.walkAfterWhitespaces(); assertThat(c.endReached(), equalTo(true)); } }
if (((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))) { caret.goN(1); if (caret.endReached()) { caret.goTo(begin); return false;
if (caret.endReached()) { return false;
if (caret.endReached()) { caret.goTo(argumentsBegin); return false;