@Test public void shouldMatchTokenLongerThanBuffer() { ChannelDispatcher<StringBuilder> dispatcher = ChannelDispatcher.builder().addChannel(new MyLiteralChannel()).build(); StringBuilder output = new StringBuilder(); CodeReaderConfiguration codeReaderConfiguration = new CodeReaderConfiguration(); int literalLength = 100000; String veryLongLiteral = String.format(String.format("%%0%dd", literalLength), 0).replace("0", "a"); assertThat(veryLongLiteral.length(), is(100000)); dispatcher.consume(new CodeReader("\">" + veryLongLiteral + "<\"", codeReaderConfiguration), output); assertThat(output.toString(), is("<literal>\">" + veryLongLiteral + "<\"</literal>")); }
@Override public final boolean consume(CodeReader code, O output) { if (code.popTo(matcher, tmpBuilder) > 0) { consume(tmpBuilder, output); tmpBuilder.delete(0, tmpBuilder.length()); return true; } return false; }
RegexChannel extends Channel<O> { @Override public final boolean consume(CodeReader code, O output) { if (code.popTo(matcher, tmpBuilder) > 0) { consume(tmpBuilder, output); tmpBuilder.delete(0, tmpBuilder.length()); return true; } return false; } }
RegexChannel extends Channel<O> { @Override public final boolean consume(CodeReader code, O output) { if (code.popTo(matcher, tmpBuilder) > 0) { consume(tmpBuilder, output); tmpBuilder.delete(0, tmpBuilder.length()); return true; } return false; } RegexChannel(String regex); }
RegexChannel extends Channel<O> { @Override public final boolean consume(CodeReader code, O output) { if (code.popTo(matcher, tmpBuilder) > 0) { consume(tmpBuilder, output); tmpBuilder.delete(0, tmpBuilder.length()); return true; } return false; } RegexChannel(String regex); @Override final boolean consume(CodeReader code, O output); }
RegexChannel extends Channel<O> { @Override public final boolean consume(CodeReader code, O output) { if (code.popTo(matcher, tmpBuilder) > 0) { consume(tmpBuilder, output); tmpBuilder.delete(0, tmpBuilder.length()); return true; } return false; } RegexChannel(String regex); @Override final boolean consume(CodeReader code, O output);  }