Apache Lucene open-source search software
- LUCENE-593 partial fix (field name interned) - Made vars and LuceneIterator ctor private - Fixed comments
Otis Gospodnetica7151c0767cd
diff --git a/contrib/spellchecker/src/java/org/apache/lucene/search/spell/LuceneDictionary.java b/contrib/spellchecker/src/java/org/apache/lucene/search/spell/LuceneDictionary.javaindex efdec68a900..000e55081f7 100755--- a/contrib/spellchecker/src/java/org/apache/lucene/search/spell/LuceneDictionary.java+++ b/contrib/spellchecker/src/java/org/apache/lucene/search/spell/LuceneDictionary.java@@ -31,12 +31,12 @@ import java.io.*;* @author Nicolas Maisonneuve*/public class LuceneDictionary implements Dictionary {- IndexReader reader;- String field;+ private IndexReader reader;+ private String field;public LuceneDictionary(IndexReader reader, String field) {this.reader = reader;- this.field = field;+ this.field = field.intern();}public final Iterator getWordsIterator() {@@ -49,15 +49,14 @@ public class LuceneDictionary implements Dictionary {private Term actualTerm;private boolean hasNextCalled;- public LuceneIterator() {+ LuceneIterator() {try {termEnum = reader.terms(new Term(field, ""));- } catch (IOException ex) {- ex.printStackTrace();+ } catch (IOException e) {+ e.printStackTrace();}}-public Object next() {if (!hasNextCalled) {hasNext();@@ -66,30 +65,28 @@ public class LuceneDictionary implements Dictionary {return (actualTerm != null) ? actualTerm.text() : null;}-public boolean hasNext() {hasNextCalled = true;try {- // if there is still words+ // if there are no more wordsif (!termEnum.next()) {actualTerm = null;return false;}- // if the next word are in the field+ // if the next word is in the fieldactualTerm = termEnum.term();- String fieldt = actualTerm.field();- if (fieldt != field) {+ String currentField = actualTerm.field();+ if (currentField != field) {actualTerm = null;return false;}return true;- } catch (IOException ex) {- ex.printStackTrace();+ } catch (IOException e) {+ e.printStackTrace();return false;}}- public void remove() {- }+ public void remove() {}}}