Index: src/java/org/apache/lucene/document/NumericField.java =================================================================== --- src/java/org/apache/lucene/document/NumericField.java (revision 962932) +++ src/java/org/apache/lucene/document/NumericField.java (working copy) @@ -237,8 +237,20 @@ fieldsData = Long.valueOf(value); return this; } - + /** + * Initializes the field with the supplied long value. + * @param value the numeric value, must not be null + * @return this instance, because of this you can use it the following way: + * document.add(new NumericField(name, precisionStep).setLongValue(value)) + */ + public NumericField setLongValue(final Long value) { + tokenStream.setLongValue(value.longValue()); + fieldsData = value; + return this; + } + + /** * Initializes the field with the supplied int value. * @param value the numeric value * @return this instance, because of this you can use it the following way: @@ -249,8 +261,20 @@ fieldsData = Integer.valueOf(value); return this; } - + /** + * Initializes the field with the supplied int value. + * @param value the numeric value, must not be null + * @return this instance, because of this you can use it the following way: + * document.add(new NumericField(name, precisionStep).setIntValue(value)) + */ + public NumericField setIntValue(final Integer value) { + tokenStream.setIntValue(value.intValue()); + fieldsData = value; + return this; + } + + /** * Initializes the field with the supplied double value. * @param value the numeric value * @return this instance, because of this you can use it the following way: @@ -261,8 +285,20 @@ fieldsData = Double.valueOf(value); return this; } - + /** + * Initializes the field with the supplied double value. + * @param value the numeric value, must not be null + * @return this instance, because of this you can use it the following way: + * document.add(new NumericField(name, precisionStep).setDoubleValue(value)) + */ + public NumericField setDoubleValue(final Double value) { + tokenStream.setDoubleValue(value.doubleValue()); + fieldsData = value; + return this; + } + + /** * Initializes the field with the supplied float value. * @param value the numeric value * @return this instance, because of this you can use it the following way: @@ -274,4 +310,16 @@ return this; } + /** + * Initializes the field with the supplied float value. + * @param value the numeric value, must not be null + * @return this instance, because of this you can use it the following way: + * document.add(new NumericField(name, precisionStep).setFloatValue(value)) + */ + public NumericField setFloatValue(final Float value) { + tokenStream.setFloatValue(value.floatValue()); + fieldsData = value; + return this; + } + }