public class

NumberTools

extends Object
java.lang.Object
   ↳ org.apache.lucene.document.NumberTools

This class is deprecated.
For new indexes use NumericUtils instead, which provides a sortable binary representation (prefix encoded) of numeric values. To index and efficiently query numeric values use NumericField and NumericRangeQuery. This class is included for use with existing indices and will be removed in a future release (possibly Lucene 4.0).

Class Overview

Provides support for converting longs to Strings, and back again. The strings are structured so that lexicographic sorting order is preserved.

That is, if l1 is less than l2 for any two longs l1 and l2, then NumberTools.longToString(l1) is lexicographically less than NumberTools.longToString(l2). (Similarly for "greater than" and "equals".)

This class handles all long values (unlike DateField).

Summary

Constants
String MAX_STRING_VALUE Equivalent to longToString(Long.MAX_VALUE)
String MIN_STRING_VALUE Equivalent to longToString(Long.MIN_VALUE)
Fields
public static final int STR_SIZE The length of (all) strings returned by longToString(long)
Public Constructors
NumberTools()
Public Methods
static String longToString(long l)
Converts a long to a String suitable for indexing.
static long stringToLong(String str)
Converts a String that was returned by longToString(long) back to a long.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String MAX_STRING_VALUE

Equivalent to longToString(Long.MAX_VALUE)

Constant Value: "01y2p0ij32e8e7"

public static final String MIN_STRING_VALUE

Equivalent to longToString(Long.MIN_VALUE)

Constant Value: "-0000000000000"

Fields

public static final int STR_SIZE

The length of (all) strings returned by longToString(long)

Public Constructors

public NumberTools ()

Public Methods

public static String longToString (long l)

Converts a long to a String suitable for indexing.

public static long stringToLong (String str)

Converts a String that was returned by longToString(long) back to a long.

Throws
IllegalArgumentException if the input is null
NumberFormatException if the input does not parse (it was not a String returned by longToString()).