You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by us...@apache.org on 2009/08/26 01:12:22 UTC
svn commit: r807849 -
/lucene/java/trunk/src/java/org/apache/lucene/analysis/NumericTokenStream.java
Author: uschindler
Date: Tue Aug 25 23:12:22 2009
New Revision: 807849
URL: http://svn.apache.org/viewvc?rev=807849&view=rev
Log:
LUCENE-1826: NumericTokenStream is not a Tokenizer subclass but source of tokens
and should therefore also have AttributeSource/AttributeFactory ctors.
Modified:
lucene/java/trunk/src/java/org/apache/lucene/analysis/NumericTokenStream.java
Modified: lucene/java/trunk/src/java/org/apache/lucene/analysis/NumericTokenStream.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/analysis/NumericTokenStream.java?rev=807849&r1=807848&r2=807849&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/analysis/NumericTokenStream.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/analysis/NumericTokenStream.java Tue Aug 25 23:12:22 2009
@@ -17,6 +17,7 @@
* limitations under the License.
*/
+import org.apache.lucene.util.AttributeSource;
import org.apache.lucene.util.NumericUtils;
import org.apache.lucene.document.NumericField; // for javadocs
import org.apache.lucene.search.NumericRangeQuery; // for javadocs
@@ -110,12 +111,37 @@
* before using set a value using the various set<em>???</em>Value() methods.
*/
public NumericTokenStream(final int precisionStep) {
+ super();
+ this.precisionStep = precisionStep;
+ if (precisionStep < 1)
+ throw new IllegalArgumentException("precisionStep must be >=1");
+ }
+
+ /**
+ * Expert: Creates a token stream for numeric values with the specified
+ * <code>precisionStep</code> using the given {@link AttributeSource}.
+ * The stream is not yet initialized,
+ * before using set a value using the various set<em>???</em>Value() methods.
+ */
+ public NumericTokenStream(AttributeSource source, final int precisionStep) {
+ super(source);
+ this.precisionStep = precisionStep;
+ if (precisionStep < 1)
+ throw new IllegalArgumentException("precisionStep must be >=1");
+ }
+
+ /**
+ * Expert: Creates a token stream for numeric values with the specified
+ * <code>precisionStep</code> using the given
+ * {@link org.apache.lucene.util.AttributeSource.AttributeFactory}.
+ * The stream is not yet initialized,
+ * before using set a value using the various set<em>???</em>Value() methods.
+ */
+ public NumericTokenStream(AttributeFactory factory, final int precisionStep) {
+ super(factory);
this.precisionStep = precisionStep;
if (precisionStep < 1)
throw new IllegalArgumentException("precisionStep must be >=1");
- termAtt = (TermAttribute) addAttribute(TermAttribute.class);
- typeAtt = (TypeAttribute) addAttribute(TypeAttribute.class);
- posIncrAtt = (PositionIncrementAttribute) addAttribute(PositionIncrementAttribute.class);
}
/**
@@ -216,9 +242,9 @@
}
// members
- private final TermAttribute termAtt;
- private final TypeAttribute typeAtt;
- private final PositionIncrementAttribute posIncrAtt;
+ private final TermAttribute termAtt = (TermAttribute) addAttribute(TermAttribute.class);
+ private final TypeAttribute typeAtt = (TypeAttribute) addAttribute(TypeAttribute.class);
+ private final PositionIncrementAttribute posIncrAtt = (PositionIncrementAttribute) addAttribute(PositionIncrementAttribute.class);
private int shift = 0, valSize = 0; // valSize==0 means not initialized
private final int precisionStep;