private static final class JsonNumberImpl.JsonLongNumber extends JsonNumberImpl
JsonValue.ValueType| Modifier and Type | Field and Description |
|---|---|
private java.math.BigDecimal |
bigDecimal |
private long |
num |
| Constructor and Description |
|---|
JsonLongNumber(long 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. |
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, hashCode, intValue, intValueExactpublic 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 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