Package org.apache.pivot.wtk.validation
Class DecimalValidator
- java.lang.Object
- 
- org.apache.pivot.wtk.validation.FormattedValidator<java.text.NumberFormat>
- 
- org.apache.pivot.wtk.validation.DecimalValidator
 
 
- 
- All Implemented Interfaces:
- Validator
 - Direct Known Subclasses:
- ComparableValidator,- DoubleValidator,- FloatValidator,- IntValidator
 
 public class DecimalValidator extends FormattedValidator<java.text.NumberFormat> A validator for decimal values.
- 
- 
Field Summary- 
Fields inherited from class org.apache.pivot.wtk.validation.FormattedValidatorformat, locale
 
- 
 - 
Constructor SummaryConstructors Constructor Description DecimalValidator()DecimalValidator(java.text.DecimalFormat format)DecimalValidator(java.text.DecimalFormat format, java.util.Locale locale)DecimalValidator(java.util.Locale locale)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisAutoTrim()Tell the autoTrim mode.protected java.lang.NumberparseNumber(java.lang.String text)Helper method that wraps theParseExceptionin aRuntimeException.voidsetAutoTrim(boolean autoTrim)Set the autoTrim mode, before parsing the text (default false).protected java.math.BigDecimaltextToBigDecimal(java.lang.String text)Helper method that returns the widest number real instance, and extract later values depending on the precision needed.- 
Methods inherited from class org.apache.pivot.wtk.validation.FormattedValidatorisValid
 
- 
 
- 
- 
- 
Constructor Detail- 
DecimalValidatorpublic DecimalValidator(java.text.DecimalFormat format) 
 - 
DecimalValidatorpublic DecimalValidator(java.text.DecimalFormat format, java.util.Locale locale)
 - 
DecimalValidatorpublic DecimalValidator() 
 - 
DecimalValidatorpublic DecimalValidator(java.util.Locale locale) 
 
- 
 - 
Method Detail- 
parseNumberprotected final java.lang.Number parseNumber(java.lang.String text) Helper method that wraps theParseExceptionin aRuntimeException.- Parameters:
- text- The text to parse.
- Returns:
- The number parsed from the text.
- Throws:
- java.lang.RuntimeException- if there was a parsing error.
 
 - 
textToBigDecimalprotected final java.math.BigDecimal textToBigDecimal(java.lang.String text) Helper method that returns the widest number real instance, and extract later values depending on the precision needed.- Parameters:
- text- The text to convert.
- Returns:
- The decimal equivalent of the text or nullif the text cannot be converted.
 
 - 
setAutoTrimpublic void setAutoTrim(boolean autoTrim) Set the autoTrim mode, before parsing the text (default false).- Parameters:
- autoTrim- The new auto trim value (- trueto trim leading and trailing blanks before parsing text).
 
 - 
isAutoTrimpublic boolean isAutoTrim() Tell the autoTrim mode.- Returns:
- trueif autoTrim is enabled, otherwise- false(default).
 
 
- 
 
-