org.vfny.geoserver.zserver
Class NumericField

java.lang.Object
  extended byorg.vfny.geoserver.zserver.NumericField

public class NumericField
extends java.lang.Object

Implements a way to turn numbers into comparable strings and vice versa, so that they can be indexed and compared by lucene.


Field Summary
protected static int defaultLeft
          The number of significant digits to the left of the decimal.
protected static int defaultRight
          The number of digits to the right of the decimal.
protected static char NORM
          The char to normalize against.
 
Constructor Summary
NumericField()
           
 
Method Summary
protected static char fixupChar(char digit, int signMultiplier)
          Normalizes the digit into a character.
static java.lang.String numberToString(java.lang.Double num)
          Calls numberToString with default values for the left and right significant digits.
static java.lang.String numberToString(java.lang.String numString)
          Convenience method for the numberToString that takes a double.
static java.lang.Double stringToNumber(java.lang.String s)
          Calls stringToNumber with default values for the left and right significant digits.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NORM

protected static final char NORM
The char to normalize against.

See Also:
Constant Field Values

defaultLeft

protected static final int defaultLeft
The number of significant digits to the left of the decimal.

See Also:
Constant Field Values

defaultRight

protected static final int defaultRight
The number of digits to the right of the decimal.

See Also:
Constant Field Values
Constructor Detail

NumericField

public NumericField()
Method Detail

fixupChar

protected static char fixupChar(char digit,
                                int signMultiplier)
Normalizes the digit into a character. The signMultiplier tells which way to normalize, up for positive, down for negative.

Parameters:
digit - The character of the digit to be fixed up.
signMultiplier - should be 1 for positives, -1 for negatives.
Returns:
the char that is 'digit' chars away from the NORM, in the direction of the signMultiplier.

numberToString

public static java.lang.String numberToString(java.lang.String numString)
                                       throws java.lang.NumberFormatException
Convenience method for the numberToString that takes a double. Simply does the parsing on the string, passes it to numberToString.

Parameters:
numString - the string representation of a number.
Returns:
the lucene comparable string.
Throws:
java.lang.NumberFormatException - if the passed in string can't be parsed.

numberToString

public static java.lang.String numberToString(java.lang.Double num)
Calls numberToString with default values for the left and right significant digits.

Parameters:
num - the number to convert.
Returns:
the lucene comparable string.

stringToNumber

public static java.lang.Double stringToNumber(java.lang.String s)
Calls stringToNumber with default values for the left and right significant digits.

Parameters:
s - the lucene searchable string to be converted to a double.
Returns:
the Double represented by s.