public class JSONNumberValue extends JSONValue
A number can either be a floating point number or an integer number. To avoid platform specific problems, all integer numbers can be up to signed 64 bits, and all floating point values are 64 bits.
| Modifier and Type | Method and Description |
|---|---|
static JSONNumberValue |
fromDouble(double doubleValue)
Factory method for constructing a
JSONNumberValue from a double. |
static JSONNumberValue |
fromLong(long longValue)
Factory method for constructing a
JSONNumberValue from a long. |
static JSONNumberValue |
fromNumberLiteral(java.lang.String literalValue)
Factory method for constructing a
JSONNumberValue from a number literal. |
double |
getDoubleValue()
Get a 64-bit floating point value.
|
float |
getFloatValue()
Get a 32-bit floating point value.
|
int |
getIntValue()
Get a 32-bit integer value.
|
long |
getLongValue()
Get a 64-bit integer value.
|
boolean |
isInteger()
Get a boolean indicating whether this
JSONNumberValue represents an integer value or not. |
boolean |
isIntValue()
Get a boolean indicating whether this
JSONNumberValue represents a 32-bit integer or not. |
boolean |
isNumber()
Get a boolean indicating whether this instance represents a JSON numeric value or not.
|
public static JSONNumberValue fromLong(long longValue)
JSONNumberValue from a long.longValue - The long value.JSONNumberValuepublic static JSONNumberValue fromDouble(double doubleValue)
JSONNumberValue from a double.doubleValue - The double value.JSONNumberValuepublic static JSONNumberValue fromNumberLiteral(java.lang.String literalValue)
JSONNumberValue from a number literal.literalValue - The number literal, which might either be an integer value or a floating point value.null if literalValue is null or does not represent a number
or a newly created JSONNumberValue.public boolean isNumber()
JSONValuepublic boolean isInteger()
JSONNumberValue represents an integer value or not.true if this instance represents an integer value, false otherwise.public boolean isIntValue()
JSONNumberValue represents a 32-bit integer or not.true if this instance represents an integer value, false otherwise.public int getIntValue()
If this instance is representing a double or long value, then the result is the value casted to an int.
public long getLongValue()
If this instance is representing a double, then the result is the value casted to a long.
public float getFloatValue()
public double getDoubleValue()