public final class NumberValidator extends Object implements IValidator
Constructor and Description |
---|
NumberValidator()
Creates a new NumberValidator instance for integer decimal values.
|
NumberValidator(Class<?> aType)
Creates a new NumberValidator instance for numeric (decimal) values of the
given type.
|
NumberValidator(Class<?> aType,
int aRadix)
Creates a new NumberValidator instance for numeric values of the given type
and radix.
|
NumberValidator(int aRadix)
Creates a new NumberValidator instance for integer values with a given
radix.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
isFloatType(Class<?> aType)
Returns whether or not the given type represents a numeric floating-point
type.
|
static boolean |
isIntegerType(Class<?> aType)
Returns whether or not the given type represents a numeric integer-like
type.
|
static boolean |
isNumericType(Class<?> aType)
Returns whether or not the given type represents a numeric type.
|
protected Number |
parse(String aInputText)
Parses the given input to a number, if possible.
|
boolean |
validate(Object aValue)
Validates the given value.
|
public NumberValidator()
public NumberValidator(Class<?> aType)
aType
- the numeric type (Integer, Long, ...) to expect.public NumberValidator(Class<?> aType, int aRadix)
aType
- the numeric type (Integer, Long, ...) to expect;aRadix
- the radix of the values to expect (2, 8, 10, 16).IllegalArgumentException
- in case the given type was either a float or double and
the radix is not 10.public NumberValidator(int aRadix)
aRadix
- the radix of the values to expect (2, 8, 10, 16).public static boolean isFloatType(Class<?> aType)
aType
- the type to test, can be null
.true
if the given type represents a floating-point
type, false
otherwise.public static boolean isIntegerType(Class<?> aType)
aType
- the type to test, can be null
.true
if the given type represents a integer-like type,
false
otherwise.public static boolean isNumericType(Class<?> aType)
aType
- the type to test, can be null
.true
if the given type represents a numeric type,
false
otherwise.public boolean validate(Object aValue)
IValidator
validate
in interface IValidator
aValue
- the value to validate, can be null
or any object.true
if the given value is correct, false
otherwise.IValidator.validate(java.lang.Object)
Copyright © 2015 L'Xtreme IT consultancy. All rights reserved.