V
- The type of numeric valuepublic abstract class NumberConverter<V extends Number> extends AbstractConverter<V>
Converter
implementation for all
java.lang.Number
types.Modifier and Type | Class and Description |
---|---|
static class |
NumberConverter.DecimalType<V extends Number>
This class provides base
NumberConverter implementation for
all decimal types. |
static class |
NumberConverter.IntegerType<V extends Number>
This class provides base
NumberConverter implementation for
all integer types. |
Modifier and Type | Field and Description |
---|---|
protected String |
pattern
java.text.DecimalFormat number pattern. |
Modifier | Constructor and Description |
---|---|
protected |
NumberConverter(String pattern)
Constructs a new
NumberConverter with the specified number
pattern. |
Modifier and Type | Method and Description |
---|---|
boolean |
appendMessageArguments(ValidationContext<?> context,
Map<String,Object> arguments)
In case of localized conversion appends
pattern argument
that contains localized number pattern. |
protected <T> V |
doDecode(String value,
ValidationContext<T> context)
Converts string representation of numeric value into
java.lang.Number object. |
protected abstract V |
doDecodeDefault(String value)
Converts default string representation of numeric value into
java.lang.Number object. |
protected <T> String |
doEncode(V value,
ValidationContext<T> context)
Converts
java.lang.Number object into string representation. |
protected String |
doEncodeDefault(V value)
Converts
java.lang.Number object into default string
representation. |
protected abstract NumberFormat |
getFormat(ValidationContext<?> context)
Returns number format for the specified context and this converter
configuration.
|
decode, encode
getMessageTemplate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMessageTemplate, getType
protected final String pattern
java.text.DecimalFormat
number pattern.protected NumberConverter(String pattern)
NumberConverter
with the specified number
pattern.pattern
- java.text.DecimalFormat
number pattern or
null
if context pattern should be used.IllegalArgumentException
- if the specified pattern is invalid.public boolean appendMessageArguments(ValidationContext<?> context, Map<String,Object> arguments)
pattern
argument
that contains localized number pattern.appendMessageArguments
in interface Converter<V extends Number>
appendMessageArguments
in interface Validation<V extends Number>
appendMessageArguments
in class AbstractValidation<V extends Number>
context
- Validation context.arguments
- Arguments to be substituted into the error message
template.true
.protected <T> V doDecode(String value, ValidationContext<T> context)
java.lang.Number
object.doDecode
in class AbstractConverter<V extends Number>
T
- The type of validated entity.value
- String representation of numeric value.context
- Validation context.java.lang.Number
object.MalformedValueException
- if the specified string could not be
parsed as a number.doDecodeDefault(String)
protected abstract V doDecodeDefault(String value)
java.lang.Number
object.value
- Default string representation of numeric value.java.lang.Number
object.NumberFormatException
- if the specified string could not be
parsed as a number.protected <T> String doEncode(V value, ValidationContext<T> context)
java.lang.Number
object into string representation.doEncode
in class AbstractConverter<V extends Number>
T
- The type of validated entity.value
- java.lang.Number
object to be encoded.context
- Validation context.doEncodeDefault(Number)
protected String doEncodeDefault(V value)
java.lang.Number
object into default string
representation.value
- java.lang.Number
object to be encoded.protected abstract NumberFormat getFormat(ValidationContext<?> context)
context
- Validation context.Copyright © 2011–2020 FoxLabs. All rights reserved.