public class AXmlAdapterNumber extends XmlAdapter<String,Number>
The maximum and minimum digit lengths plus inclusive values are identified in the constructor.
Where applicable, the types UN and SN may be followed by an additional range constraint in the form [a .. b] meaning that the value is restricted to be between a and b inclusive. They may also be followed by an additional unit in parenthesis. Example: Sensitivity value: SN(5.2) [-140.00 .. -30.00] (dBm)
Constructor and Description |
---|
AXmlAdapterNumber(Integer totalDigits,
Integer fractionDigits)
Construct a new Number adapter.
|
AXmlAdapterNumber(Integer totalDigits,
Integer fractionDigits,
Integer minInclusive,
Integer maxInclusive)
Construct a new Number adapter.
|
Modifier and Type | Method and Description |
---|---|
protected Number |
convert(Number v)
Internal method to perform the validation.
|
Number |
getMaxInclusive()
Get the maximum (inclusive) value allowed by this adapter.
|
Number |
getMinInclusive()
Get the minimum (inclusive) value allowed by this adapter.
|
String |
marshal(Number v)
Convert a bound type to a value type.
|
Number |
unmarshal(String v)
Convert a value type to a bound type.
|
public AXmlAdapterNumber(Integer totalDigits, Integer fractionDigits)
totalDigits
- The maximum number of total digits in the number,
inclusive of fraction digits. e.g. 123.456 contains 6
digits.fractionDigits
- The maximum number of fraction digits - number of
digits to the right of the decimal. e.g. 123.456
contains 3 fraction digits.public AXmlAdapterNumber(Integer totalDigits, Integer fractionDigits, Integer minInclusive, Integer maxInclusive)
totalDigits
- The maximum number of total digits in the number,
inclusive of fraction digits. e.g. 123.456 contains 6
digits.fractionDigits
- The maximum number of fraction digits - number of
digits to the right of the decimal. e.g. 123.456
contains 3 fraction digits.minInclusive
- The minimum inclusive value.maxInclusive
- The maximum inclusive value.public String marshal(Number v) throws Exception
This is called when converting an object to XML.
marshal
in class XmlAdapter<String,Number>
v
- The value to be convereted. Can be null.Exception
- if there's an error during the conversion. The caller is
responsible for reporting the error to the user through
ValidationEventHandler.public Number unmarshal(String v) throws Exception
This is called with converting XML to an object.
unmarshal
in class XmlAdapter<String,Number>
v
- The value to be converted. Can be null.Exception
- if there's an error during the conversion. The caller is
responsible for reporting the error to the user through
ValidationEventHandler.protected Number convert(Number v) throws Exception
v
- The value to be converted. Can be null.Exception
- if there's an error during the conversion. The caller is
responsible for reporting the error to the user through
ValidationEventHandler.public Number getMaxInclusive()
If the inclusive maximum value is not specifically declared then it is calculated from the total and fraction digits declaration (if present).
public Number getMinInclusive()
If the inclusive minimum value is not specifically declared then it is calculated from the total and fraction digits declaration (if present).
Copyright © 2016 OpenSSRF.org. All rights reserved.