@Test public void testNextWithNullTokenAndWordInList() throws IOException { final Token token = new Token(null, 0, 0); List<Token> tokens = new ArrayList<Token>(); tokenStream = new TokenStreamTestHelper(tokens); final List<String> wordsToInject = new ArrayList<String>(); wordsToInject.add("FOOOO"); WordListInjectionTokenizer sut = new WordListInjectionTokenizer(wordsToInject, tokenStream); assertSame(token, sut.next(token)); assertEquals("FOOOO", token.term()); assertEquals(0, token.startOffset()); assertEquals("FOOOO".length(), token.endOffset()); assertEquals(0, wordsToInject.size()); }
@Override public final Token next(final Token reusableToken) throws IOException { assert reusableToken != null; Token token = input.next(reusableToken); if (token == null && wordList.size() > 0) { String word = wordList.get(0); wordList.remove(0); reusableToken.reinit(word, 0, word.length()); token = reusableToken; } return token; }
WordListInjectionTokenizer extends TokenFilter { @Override public final Token next(final Token reusableToken) throws IOException { assert reusableToken != null; Token token = input.next(reusableToken); if (token == null && wordList.size() > 0) { String word = wordList.get(0); wordList.remove(0); reusableToken.reinit(word, 0, word.length()); token = reusableToken; } return token; } }
WordListInjectionTokenizer extends TokenFilter { @Override public final Token next(final Token reusableToken) throws IOException { assert reusableToken != null; Token token = input.next(reusableToken); if (token == null && wordList.size() > 0) { String word = wordList.get(0); wordList.remove(0); reusableToken.reinit(word, 0, word.length()); token = reusableToken; } return token; } WordListInjectionTokenizer(final List<String> inWordList, final TokenStream inInput); }
WordListInjectionTokenizer extends TokenFilter { @Override public final Token next(final Token reusableToken) throws IOException { assert reusableToken != null; Token token = input.next(reusableToken); if (token == null && wordList.size() > 0) { String word = wordList.get(0); wordList.remove(0); reusableToken.reinit(word, 0, word.length()); token = reusableToken; } return token; } WordListInjectionTokenizer(final List<String> inWordList, final TokenStream inInput); @Override final Token next(final Token reusableToken); }
WordListInjectionTokenizer extends TokenFilter { @Override public final Token next(final Token reusableToken) throws IOException { assert reusableToken != null; Token token = input.next(reusableToken); if (token == null && wordList.size() > 0) { String word = wordList.get(0); wordList.remove(0); reusableToken.reinit(word, 0, word.length()); token = reusableToken; } return token; } WordListInjectionTokenizer(final List<String> inWordList, final TokenStream inInput); @Override final Token next(final Token reusableToken);  }