Terms { public abstract int indexOf(String term);  void initialize(); abstract int indexOf(String term); abstract void indexOf(MutableIntSet results, String term, MatchSensitivity sensitivity); abstract void clear(); abstract void write(File termsFile); abstract String get(int id); abstract int numberOfTerms(); abstract int idToSortPosition(int id, MatchSensitivity sensitivity); void toSortOrder(int[] termId, int[] sortOrder, MatchSensitivity sensitivity); int compareSortPosition(int termId1, int termId2, MatchSensitivity sensitivity); static Terms openForReading(Collators collators, File termsFile, boolean useBlockBasedTermsFile, boolean buildTermIndexesOnInit); static Terms openForWriting(Collators collators, File termsFile, boolean useBlockBasedTermsFile); abstract boolean termsEqual(int[] termId, MatchSensitivity sensitivity); int deserializeToken(String term); String serializeTerm(int valueTokenId); static final int NO_TERM; }
@Test public void testIndexOf() { String[] input = { "the", "quick", "brown", "fox", "jumps", "over", "lazy", "dog" }; int[] expected = { 0, 1, 2, 3, 4, 5, 6, 7 }; for (int i = 0; i < expected.length; i++) { Assert.assertEquals(expected[i], t.indexOf(input[i])); } }
@Test public void testIndexOfInsensitive() { String[] input = { "the", "quick", "brown", "fox", "jumps", "over", "lazy", "dog" }; int[] expected = { 0, 1, 2, 3, 4, 5, 6, 7 }; for (int i = 0; i < expected.length; i++) { MutableIntSet results = new IntHashSet(); t.indexOf(results, input[i], MatchSensitivity.INSENSITIVE); Assert.assertEquals(expected[i], results.intIterator().next()); } }