@Test public void countPreviousContinuedBackslash_A$String$int$int_intIs2() throws Exception { String str = "test"; int currentNotBackslashCharIndex = 2; int count = 2; int actual = TrimInsideOfStringFilter.countPreviousContinuedBackslash(str, currentNotBackslashCharIndex, count); int expected = 2; assertThat(actual, is(equalTo(expected))); }
static int countPreviousContinuedBackslash(String str, int currentNotBackslashCharIndex, int count) { Assertion.on("currentNotBackslashCharIndex").mustBeGreaterThanOrEqual(currentNotBackslashCharIndex, 0); Assertion.on("count").mustBeGreaterThanOrEqual(count, 0); Character previous = null; if (currentNotBackslashCharIndex > 0) { int previousIndex = currentNotBackslashCharIndex - 1; previous = str.charAt(previousIndex); if (previous == '\\') { return countPreviousContinuedBackslash(str, previousIndex, count + 1); } else { return count; } } return count; }
TrimInsideOfStringFilter implements TrimFilter { static int countPreviousContinuedBackslash(String str, int currentNotBackslashCharIndex, int count) { Assertion.on("currentNotBackslashCharIndex").mustBeGreaterThanOrEqual(currentNotBackslashCharIndex, 0); Assertion.on("count").mustBeGreaterThanOrEqual(count, 0); Character previous = null; if (currentNotBackslashCharIndex > 0) { int previousIndex = currentNotBackslashCharIndex - 1; previous = str.charAt(previousIndex); if (previous == '\\') { return countPreviousContinuedBackslash(str, previousIndex, count + 1); } else { return count; } } return count; } }
TrimInsideOfStringFilter implements TrimFilter { static int countPreviousContinuedBackslash(String str, int currentNotBackslashCharIndex, int count) { Assertion.on("currentNotBackslashCharIndex").mustBeGreaterThanOrEqual(currentNotBackslashCharIndex, 0); Assertion.on("count").mustBeGreaterThanOrEqual(count, 0); Character previous = null; if (currentNotBackslashCharIndex > 0) { int previousIndex = currentNotBackslashCharIndex - 1; previous = str.charAt(previousIndex); if (previous == '\\') { return countPreviousContinuedBackslash(str, previousIndex, count + 1); } else { return count; } } return count; }  }
TrimInsideOfStringFilter implements TrimFilter { static int countPreviousContinuedBackslash(String str, int currentNotBackslashCharIndex, int count) { Assertion.on("currentNotBackslashCharIndex").mustBeGreaterThanOrEqual(currentNotBackslashCharIndex, 0); Assertion.on("count").mustBeGreaterThanOrEqual(count, 0); Character previous = null; if (currentNotBackslashCharIndex > 0) { int previousIndex = currentNotBackslashCharIndex - 1; previous = str.charAt(previousIndex); if (previous == '\\') { return countPreviousContinuedBackslash(str, previousIndex, count + 1); } else { return count; } } return count; }  @Override String trimAll(String src); }
TrimInsideOfStringFilter implements TrimFilter { static int countPreviousContinuedBackslash(String str, int currentNotBackslashCharIndex, int count) { Assertion.on("currentNotBackslashCharIndex").mustBeGreaterThanOrEqual(currentNotBackslashCharIndex, 0); Assertion.on("count").mustBeGreaterThanOrEqual(count, 0); Character previous = null; if (currentNotBackslashCharIndex > 0) { int previousIndex = currentNotBackslashCharIndex - 1; previous = str.charAt(previousIndex); if (previous == '\\') { return countPreviousContinuedBackslash(str, previousIndex, count + 1); } else { return count; } } return count; }  @Override String trimAll(String src);  }