|
||||||||||
| 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
|
+--org.apache.commons.validator.routines.BigDecimalValidator
|
+--org.apache.commons.validator.routines.CurrencyValidator
Currency Validation and Conversion routines (java.math.BigDecimal).
This is one implementation of a currency validator that has the following features:
java.math.BigDecimalHowever any of the number validators can be used for currency validation.
For example, if you wanted a currency validator that converts to a
java.lang.Integer then you can simply instantiate an
IntegerValidator with the appropriate format type:
... = new IntegerValidator(false, IntegerValidator.CURRENCY_FORMAT);
Pick the appropriate validator, depending on the type (e.g Float, Double, Integer, Long etc) you want the currency converted to. One thing to note - only the CurrencyValidator implements lenient behaviour regarding the currency symbol.
| Fields inherited from class org.apache.commons.validator.routines.AbstractNumberValidator |
CURRENCY_FORMAT, PERCENT_FORMAT, STANDARD_FORMAT |
| Constructor Summary | |
CurrencyValidator()
Construct a strict instance. |
|
CurrencyValidator(boolean strict,
boolean allowFractions)
Construct an instance with the specified strict setting. |
|
| Method Summary | |
static BigDecimalValidator |
getInstance()
Return a singleton instance of this validator. |
protected java.lang.Object |
parse(java.lang.String value,
java.text.Format formatter)
Parse the value with the specified Format. |
| Methods inherited from class org.apache.commons.validator.routines.BigDecimalValidator |
isInRange, maxValue, minValue, processParsedValue, validate, validate, validate, validate |
| Methods inherited from class org.apache.commons.validator.routines.AbstractNumberValidator |
determineScale, getFormat, getFormat, getFormatType, isAllowFractions, isInRange, isValid, maxValue, minValue, parse |
| Methods inherited from class org.apache.commons.validator.routines.AbstractFormatValidator |
format, format, format, format, format, isStrict, isValid, isValid, isValid |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public CurrencyValidator()
public CurrencyValidator(boolean strict,
boolean allowFractions)
strict - true if strict
Format parsing should be used.allowFractions - true if fractions are
allowed or false if integers only.| Method Detail |
public static BigDecimalValidator getInstance()
protected java.lang.Object parse(java.lang.String value,
java.text.Format formatter)
Parse the value with the specified Format.
This implementation is lenient whether the currency symbol
is present or not. The default NumberFormat
behaviour is for the parsing to "fail" if the currency
symbol is missing. This method re-parses with a format
without the currency symbol if it fails initially.
parse in class AbstractFormatValidatorvalue - The value to be parsed.formatter - The Format to parse the value with.null if invalid.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||