private static final class JsonNumberImpl.JsonIntNumber extends JsonNumberImpl
JsonValue.ValueType| Modifier and Type | Field and Description |
|---|---|
private java.math.BigDecimal |
bigDecimal |
private int |
num |
| Constructor and Description |
|---|
JsonIntNumber(int num) |
| Modifier and Type | Method and Description |
|---|---|
java.math.BigDecimal |
bigDecimalValue()
Returns this JSON number as a
BigDecimal object. |
double |
doubleValue()
Returns this JSON number as a
double. |
int |
intValue()
Returns this JSON number as an
int. |
int |
intValueExact()
Returns this JSON number as an
int. |
boolean |
isIntegral()
Returns true if this JSON number is a integral number.
|
long |
longValue()
Returns this JSON number as a
long. |
long |
longValueExact()
Returns this JSON number as a
long. |
java.lang.String |
toString()
Returns a JSON text representation of the JSON number.
|
bigIntegerValue, bigIntegerValueExact, equals, getJsonNumber, getJsonNumber, getJsonNumber, getJsonNumber, getJsonNumber, getValueType, hashCodepublic boolean isIntegral()
JsonNumberbigDecimalValue().scale(). If the
scale is zero, then it is considered integral type. This integral type
information can be used to invoke an appropriate accessor method to
obtain a numeric value as in the following example:
JsonNumber num = ...
if (num.isIntegral()) {
num.longValue(); // or other methods to get integral value
} else {
num.doubleValue(); // or other methods to get decimal number value
}
isIntegral in interface JsonNumberisIntegral in class JsonNumberImplpublic int intValue()
JsonNumberint. Note that this conversion
can lose information about the overall magnitude and precision of the
number value as well as return a result with the opposite sign.intValue in interface JsonNumberintValue in class JsonNumberImplint representation of the JSON numberBigDecimal.intValue()public int intValueExact()
JsonNumberint.intValueExact in interface JsonNumberintValueExact in class JsonNumberImplint representation of the JSON numberBigDecimal.intValueExact()public long longValue()
JsonNumberlong. Note that this conversion
can lose information about the overall magnitude and precision of the
number value as well as return a result with the opposite sign.longValue in interface JsonNumberlongValue in class JsonNumberImpllong representation of the JSON number.BigDecimal.longValue()public long longValueExact()
JsonNumberlong.longValueExact in interface JsonNumberlongValueExact in class JsonNumberImpllong representation of the JSON numberBigDecimal.longValueExact()public double doubleValue()
JsonNumberdouble. This is a
a convenience method for bigDecimalValue().doubleValue().
Note that this conversion can lose information about the overall
magnitude and precision of the number value as well as return a result
with the opposite sign.doubleValue in interface JsonNumberdoubleValue in class JsonNumberImpldouble representation of the JSON numberBigDecimal.doubleValue()public java.math.BigDecimal bigDecimalValue()
JsonNumberBigDecimal object.BigDecimal representation of the JSON numberpublic java.lang.String toString()
JsonNumberBigDecimal.toString().toString in interface JsonNumbertoString in interface JsonValuetoString in class JsonNumberImpl