From 3ef76ae033b8a6e77b5469233cf130a74550b0e2 Mon Sep 17 00:00:00 2001 From: Uwe Schindler Date: Tue, 14 Apr 2009 00:36:02 +0000 Subject: [PATCH] Small documentation updates, test fixed according to attributes documentation git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@764654 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/lucene/search/trie/IntTrieTokenStream.java | 4 ++-- .../org/apache/lucene/search/trie/LongTrieTokenStream.java | 4 ++-- .../org/apache/lucene/search/trie/TestIntTrieTokenStream.java | 3 +-- .../apache/lucene/search/trie/TestLongTrieTokenStream.java | 3 +-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/contrib/queries/src/java/org/apache/lucene/search/trie/IntTrieTokenStream.java b/contrib/queries/src/java/org/apache/lucene/search/trie/IntTrieTokenStream.java index cd602e51be8..597664a056c 100644 --- a/contrib/queries/src/java/org/apache/lucene/search/trie/IntTrieTokenStream.java +++ b/contrib/queries/src/java/org/apache/lucene/search/trie/IntTrieTokenStream.java @@ -50,12 +50,12 @@ import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute; * Field field = new Field(name, stream); * field.setOmitNorms(true); * field.setOmitTermFreqAndPositions(true); + * Document doc = new Document(); + * document.add(field); * // use this code to index many documents: * stream.setValue(value1) - * document.add(field); * writer.addDocument(document); * stream.setValue(value2) - * document.add(field); * writer.addDocument(document); * ... * diff --git a/contrib/queries/src/java/org/apache/lucene/search/trie/LongTrieTokenStream.java b/contrib/queries/src/java/org/apache/lucene/search/trie/LongTrieTokenStream.java index 8a116dd8f73..0ca6ef704c3 100644 --- a/contrib/queries/src/java/org/apache/lucene/search/trie/LongTrieTokenStream.java +++ b/contrib/queries/src/java/org/apache/lucene/search/trie/LongTrieTokenStream.java @@ -50,12 +50,12 @@ import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute; * Field field = new Field(name, stream); * field.setOmitNorms(true); * field.setOmitTermFreqAndPositions(true); + * Document doc = new Document(); + * document.add(field); * // use this code to index many documents: * stream.setValue(value1) - * document.add(field); * writer.addDocument(document); * stream.setValue(value2) - * document.add(field); * writer.addDocument(document); * ... * diff --git a/contrib/queries/src/test/org/apache/lucene/search/trie/TestIntTrieTokenStream.java b/contrib/queries/src/test/org/apache/lucene/search/trie/TestIntTrieTokenStream.java index e53b6e22d1e..415798a6876 100644 --- a/contrib/queries/src/test/org/apache/lucene/search/trie/TestIntTrieTokenStream.java +++ b/contrib/queries/src/test/org/apache/lucene/search/trie/TestIntTrieTokenStream.java @@ -29,10 +29,9 @@ public class TestIntTrieTokenStream extends LuceneTestCase { public void testStreamNewAPI() throws Exception { final IntTrieTokenStream stream=new IntTrieTokenStream(value, precisionStep); stream.setUseNewAPI(true); + // use getAttribute to test if attributes really exist, if not an IAE will be throwed final ShiftAttribute shiftAtt = (ShiftAttribute) stream.getAttribute(ShiftAttribute.class); - assertNotNull("Has shift attribute", shiftAtt); final TermAttribute termAtt = (TermAttribute) stream.getAttribute(TermAttribute.class); - assertNotNull("Has term attribute", termAtt); for (int shift=0; shift<32; shift+=precisionStep) { assertTrue("New token is available", stream.incrementToken()); assertEquals("Shift value", shift, shiftAtt.getShift()); diff --git a/contrib/queries/src/test/org/apache/lucene/search/trie/TestLongTrieTokenStream.java b/contrib/queries/src/test/org/apache/lucene/search/trie/TestLongTrieTokenStream.java index e116f9eca66..be8c47b4719 100644 --- a/contrib/queries/src/test/org/apache/lucene/search/trie/TestLongTrieTokenStream.java +++ b/contrib/queries/src/test/org/apache/lucene/search/trie/TestLongTrieTokenStream.java @@ -29,10 +29,9 @@ public class TestLongTrieTokenStream extends LuceneTestCase { public void testStreamNewAPI() throws Exception { final LongTrieTokenStream stream=new LongTrieTokenStream(value, precisionStep); stream.setUseNewAPI(true); + // use getAttribute to test if attributes really exist, if not an IAE will be throwed final ShiftAttribute shiftAtt = (ShiftAttribute) stream.getAttribute(ShiftAttribute.class); - assertNotNull("Has shift attribute", shiftAtt); final TermAttribute termAtt = (TermAttribute) stream.getAttribute(TermAttribute.class); - assertNotNull("Has term attribute", termAtt); for (int shift=0; shift<64; shift+=precisionStep) { assertTrue("New token is available", stream.incrementToken()); assertEquals("Shift value", shift, shiftAtt.getShift());