org.apache.lucene.document

Class NumberTools

public class NumberTools extends Object

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 {@link org.apache.lucene.document.DateField}).

Author: Matt Quail (spud at madbean dot com)

Field Summary
static StringMAX_STRING_VALUE
Equivalent to longToString(Long.MAX_VALUE)
static StringMIN_STRING_VALUE
Equivalent to longToString(Long.MIN_VALUE)
static intSTR_SIZE
The length of (all) strings returned by {@link #longToString}
Method Summary
static StringlongToString(long l)
Converts a long to a String suitable for indexing.
static longstringToLong(String str)
Converts a String that was returned by {@link #longToString} back to a long.

Field Detail

MAX_STRING_VALUE

public static final String MAX_STRING_VALUE
Equivalent to longToString(Long.MAX_VALUE)

MIN_STRING_VALUE

public static final String MIN_STRING_VALUE
Equivalent to longToString(Long.MIN_VALUE)

STR_SIZE

public static final int STR_SIZE
The length of (all) strings returned by {@link #longToString}

Method Detail

longToString

public static String longToString(long l)
Converts a long to a String suitable for indexing.

stringToLong

public static long stringToLong(String str)
Converts a String that was returned by {@link #longToString} 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()).

Copyright © 2000-2007 Apache Software Foundation. All Rights Reserved.