@Test public void testWithoutEnablePositionIncrement() throws IOException { inputTokenStream.reset(); SelectFilter selectFilter = new SelectFilter(false, inputTokenStream, selectedWords, true); TermAttribute tAtt = (TermAttribute) selectFilter .addAttribute(TermAttribute.class); PositionIncrementAttribute posAtt = (PositionIncrementAttribute) selectFilter .addAttribute(PositionIncrementAttribute.class); selectFilter.incrementToken(); assertEquals("Selected Token 1", "positive3", tAtt.term()); assertEquals("Position increment without skipping", 1, posAtt.getPositionIncrement()); selectFilter.incrementToken(); assertEquals("Selected Token 2", "positive1", tAtt.term()); assertEquals("Position increment without skipping", 1, posAtt.getPositionIncrement()); selectFilter.incrementToken(); assertEquals("Selected Token 3", "positive2", tAtt.term()); assertEquals("Position increment without skipping", 1, posAtt.getPositionIncrement()); }
public final boolean incrementToken() throws IOException { int skippedPositions = 0; while (input.incrementToken()) { if (includeWords.contains(termAtt.termBuffer(), 0, termAtt.termLength())) { if (posIncrAtt.getPositionIncrement() == 0 && firstToken) posIncrAtt.setPositionIncrement(1); if (enablePositionIncrements) { posIncrAtt.setPositionIncrement(posIncrAtt .getPositionIncrement() + skippedPositions); } firstToken = false; return true; } skippedPositions += posIncrAtt.getPositionIncrement(); } return false; }
SelectFilter extends TokenFilter { public final boolean incrementToken() throws IOException { int skippedPositions = 0; while (input.incrementToken()) { if (includeWords.contains(termAtt.termBuffer(), 0, termAtt.termLength())) { if (posIncrAtt.getPositionIncrement() == 0 && firstToken) posIncrAtt.setPositionIncrement(1); if (enablePositionIncrements) { posIncrAtt.setPositionIncrement(posIncrAtt .getPositionIncrement() + skippedPositions); } firstToken = false; return true; } skippedPositions += posIncrAtt.getPositionIncrement(); } return false; } }
SelectFilter extends TokenFilter { public final boolean incrementToken() throws IOException { int skippedPositions = 0; while (input.incrementToken()) { if (includeWords.contains(termAtt.termBuffer(), 0, termAtt.termLength())) { if (posIncrAtt.getPositionIncrement() == 0 && firstToken) posIncrAtt.setPositionIncrement(1); if (enablePositionIncrements) { posIncrAtt.setPositionIncrement(posIncrAtt .getPositionIncrement() + skippedPositions); } firstToken = false; return true; } skippedPositions += posIncrAtt.getPositionIncrement(); } return false; } SelectFilter(boolean enablePositionIncrements, TokenStream input,
			Set<?> includeWords, boolean ignoreCase); }
SelectFilter extends TokenFilter { public final boolean incrementToken() throws IOException { int skippedPositions = 0; while (input.incrementToken()) { if (includeWords.contains(termAtt.termBuffer(), 0, termAtt.termLength())) { if (posIncrAtt.getPositionIncrement() == 0 && firstToken) posIncrAtt.setPositionIncrement(1); if (enablePositionIncrements) { posIncrAtt.setPositionIncrement(posIncrAtt .getPositionIncrement() + skippedPositions); } firstToken = false; return true; } skippedPositions += posIncrAtt.getPositionIncrement(); } return false; } SelectFilter(boolean enablePositionIncrements, TokenStream input,
			Set<?> includeWords, boolean ignoreCase); final boolean incrementToken(); }
SelectFilter extends TokenFilter { public final boolean incrementToken() throws IOException { int skippedPositions = 0; while (input.incrementToken()) { if (includeWords.contains(termAtt.termBuffer(), 0, termAtt.termLength())) { if (posIncrAtt.getPositionIncrement() == 0 && firstToken) posIncrAtt.setPositionIncrement(1); if (enablePositionIncrements) { posIncrAtt.setPositionIncrement(posIncrAtt .getPositionIncrement() + skippedPositions); } firstToken = false; return true; } skippedPositions += posIncrAtt.getPositionIncrement(); } return false; } SelectFilter(boolean enablePositionIncrements, TokenStream input,
			Set<?> includeWords, boolean ignoreCase); final boolean incrementToken();  }