org.apache.tapestry.valid
Class NumberValidator.NumberAdaptor

java.lang.Object
  extended by org.apache.tapestry.valid.NumberValidator.NumberAdaptor
Enclosing class:
NumberValidator

public abstract static class NumberValidator.NumberAdaptor
extends Object

This class is not meant for use outside of NumberValidator; it is public only to fascilitate some unit testing.


Constructor Summary
NumberValidator.NumberAdaptor()
           
 
Method Summary
protected abstract  Number coerce(Number number)
          Invoked when comparing two Numbers of different types.
 int compare(Number left, Number right)
           
abstract  int getNumberType()
          Indicates the type of the number represented -- integer or real.
abstract  Number parse(String value)
          Parses a non-empty String into the correct subclass of Number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberValidator.NumberAdaptor

public NumberValidator.NumberAdaptor()
Method Detail

parse

public abstract Number parse(String value)
Parses a non-empty String into the correct subclass of Number.

Throws:
NumberFormatException - if the String can not be parsed.

getNumberType

public abstract int getNumberType()
Indicates the type of the number represented -- integer or real. The information is used to build the client-side validator. This method could return a boolean, but returns an int to allow future extensions of the validator.

Returns:
one of the predefined number types

compare

public int compare(Number left,
                   Number right)

coerce

protected abstract Number coerce(Number number)
Invoked when comparing two Numbers of different types. The number is cooerced from its ordinary type to the correct type for comparison.

Since:
3.0