|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--org.apache.commons.validator.routines.AbstractFormatValidator
|
+--org.apache.commons.validator.routines.AbstractNumberValidator
Abstract class for Number Validation.
This is a base class for building Number Validators using format parsing.
| Field Summary | |
static int |
CURRENCY_FORMAT
Currency NumberFormat type |
static int |
PERCENT_FORMAT
Percent NumberFormat type |
static int |
STANDARD_FORMAT
Standard NumberFormat type |
| Constructor Summary | |
AbstractNumberValidator(boolean strict,
int formatType,
boolean allowFractions)
Construct an instance with specified strict and decimal parameters. |
|
| Method Summary | |
protected int |
determineScale(java.text.NumberFormat format)
Returns the multiplier of the NumberFormat. |
protected java.text.Format |
getFormat(java.util.Locale locale)
Returns a NumberFormat for the specified Locale. |
protected java.text.Format |
getFormat(java.lang.String pattern,
java.util.Locale locale)
Returns a NumberFormat for the specified pattern
and/or Locale. |
int |
getFormatType()
Indicates the type of NumberFormat created
by this validator instance. |
boolean |
isAllowFractions()
Indicates whether the number being validated is a decimal or integer. |
boolean |
isInRange(java.lang.Number value,
java.lang.Number min,
java.lang.Number max)
Check if the value is within a specified range. |
boolean |
isValid(java.lang.String value,
java.lang.String pattern,
java.util.Locale locale)
Validate using the specified Locale. |
boolean |
maxValue(java.lang.Number value,
java.lang.Number max)
Check if the value is less than or equal to a maximum. |
boolean |
minValue(java.lang.Number value,
java.lang.Number min)
Check if the value is greater than or equal to a minimum. |
protected java.lang.Object |
parse(java.lang.String value,
java.lang.String pattern,
java.util.Locale locale)
Parse the value using the specified pattern. |
protected abstract java.lang.Object |
processParsedValue(java.lang.Object value,
java.text.Format formatter)
Process the parsed value, performing any further validation and type conversion required. |
| Methods inherited from class org.apache.commons.validator.routines.AbstractFormatValidator |
format, format, format, format, format, isStrict, isValid, isValid, isValid, parse |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int STANDARD_FORMAT
NumberFormat typepublic static final int CURRENCY_FORMAT
NumberFormat typepublic static final int PERCENT_FORMAT
NumberFormat type| Constructor Detail |
public AbstractNumberValidator(boolean strict,
int formatType,
boolean allowFractions)
strict - true if strict
Format parsing should be used.formatType - The NumberFormat type to
create for validation, default is STANDARD_FORMAT.allowFractions - true if fractions are
allowed or false if integers only.| Method Detail |
public boolean isAllowFractions()
Indicates whether the number being validated is a decimal or integer.
true if decimals are allowed
or false if the number is an integer.public int getFormatType()
Indicates the type of NumberFormat created
by this validator instance.
public boolean isValid(java.lang.String value,
java.lang.String pattern,
java.util.Locale locale)
Validate using the specified Locale.
isValid in class AbstractFormatValidatorvalue - The value validation is being performed on.pattern - The pattern used to validate the value against, or the
default for the Locale if null.locale - The locale to use for the date format, system default if null.true if the value is valid.
public boolean isInRange(java.lang.Number value,
java.lang.Number min,
java.lang.Number max)
value - The value validation is being performed on.min - The minimum value of the range.max - The maximum value of the range.true if the value is within the
specified range.
public boolean minValue(java.lang.Number value,
java.lang.Number min)
value - The value validation is being performed on.min - The minimum value.true if the value is greater than
or equal to the minimum.
public boolean maxValue(java.lang.Number value,
java.lang.Number max)
value - The value validation is being performed on.max - The maximum value.true if the value is less than
or equal to the maximum.
protected java.lang.Object parse(java.lang.String value,
java.lang.String pattern,
java.util.Locale locale)
Parse the value using the specified pattern.
value - The value validation is being performed on.pattern - The pattern used to validate the value against, or the
default for the Locale if null.locale - The locale to use for the date format, system default if null.null if invalid.
protected abstract java.lang.Object processParsedValue(java.lang.Object value,
java.text.Format formatter)
Process the parsed value, performing any further validation and type conversion required.
processParsedValue in class AbstractFormatValidatorvalue - The parsed object created.formatter - The Format used to parse the value with.null if invalid.
protected java.text.Format getFormat(java.lang.String pattern,
java.util.Locale locale)
Returns a NumberFormat for the specified pattern
and/or Locale.
getFormat in class AbstractFormatValidatorpattern - The pattern used to validate the value against or
null to use the default for the Locale.locale - The locale to use for the currency format, system default if null.NumberFormat to created.protected int determineScale(java.text.NumberFormat format)
Returns the multiplier of the NumberFormat.
format - The NumberFormat to determine the
multiplier of.protected java.text.Format getFormat(java.util.Locale locale)
Returns a NumberFormat for the specified Locale.
locale - The locale a NumberFormat is required for,
system default if null.NumberFormat to created.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||