Apache Lucene open-source search software
LUCENE-1244: don't use hard-coded path in AnalysisTest
Michael McCandless0bd6f8ec0436
diff --git a/src/java/org/apache/lucene/analysis/Token.java b/src/java/org/apache/lucene/analysis/Token.javaindex d0507b2d18e..8bc0bd4cdb5 100644--- a/src/java/org/apache/lucene/analysis/Token.java+++ b/src/java/org/apache/lucene/analysis/Token.java@@ -18,7 +18,7 @@ package org.apache.lucene.analysis;*/import org.apache.lucene.index.Payload;-import org.apache.lucene.index.TermPositions;+import org.apache.lucene.index.TermPositions; // for javadoc/** A Token is an occurence of a term from the text of a field. It consists ofa term's text, the start and end offset of the term in the text of the field,@@ -226,8 +226,12 @@ public class Token implements Cloneable {/** Returns the Token's term text.*- * @deprecated Use {@link #termBuffer()} and {@link- * #termLength()} instead. */+ * @deprecated This method now has a performance penalty+ * because the text is stored internally in a char[]. If+ * possible, use {@link #termBuffer()} and {@link+ * #termLength()} directly instead. If you really need a+ * String, use <b>new String(token.termBuffer(), 0, token.termLength())</b>+ */public final String termText() {if (termText == null && termBuffer != null)termText = new String(termBuffer, 0, termLength);diff --git a/src/java/org/apache/lucene/document/Document.java b/src/java/org/apache/lucene/document/Document.javaindex 4e48de2c148..85bb1eaceee 100644--- a/src/java/org/apache/lucene/document/Document.java+++ b/src/java/org/apache/lucene/document/Document.java@@ -18,6 +18,9 @@ package org.apache.lucene.document;*/import java.util.*; // for javadoc+import org.apache.lucene.search.Hits; // for javadoc+import org.apache.lucene.search.Searcher; // for javadoc+import org.apache.lucene.index.IndexReader; // for javadoc/** Documents are the unit of indexing and search.*diff --git a/src/test/org/apache/lucene/AnalysisTest.java b/src/test/org/apache/lucene/AnalysisTest.javaindex 7998e0df256..13f06bfa878 100644--- a/src/test/org/apache/lucene/AnalysisTest.java+++ b/src/test/org/apache/lucene/AnalysisTest.java@@ -31,15 +31,17 @@ import java.io.InputStreamReader;import java.util.Date;class AnalysisTest {+ static File tmpFile;public static void main(String[] args) {try {test("This is a test", true);- // FIXME: OG: what's with this hard-coded file name??- test(new File("words.txt"), false);+ tmpFile = File.createTempFile("words", ".txt");+ test(tmpFile, false);} catch (Exception e) {System.out.println(" caught a " + e.getClass() +"\n with message: " + e.getMessage());}+ tmpFile.deleteOnExit();}static void test(File file, boolean verbose)@@ -70,7 +72,7 @@ class AnalysisTest {int count = 0;for (Token t = stream.next(); t!=null; t = stream.next()) {if (verbose) {- System.out.println("Text=" + t.termText()+ System.out.println("Text=" + new String(t.termBuffer(), 0, t.termLength())+ " start=" + t.startOffset()+ " end=" + t.endOffset());}