Class JSONNumberValue
- java.lang.Object
-
- com.dynatrace.openkit.util.json.objects.JSONValue
-
- com.dynatrace.openkit.util.json.objects.JSONNumberValue
-
public class JSONNumberValue extends JSONValue
JSON value class representing a number value.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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JSONNumberValuefromDouble(double doubleValue)Factory method for constructing aJSONNumberValuefrom adouble.static JSONNumberValuefromLong(long longValue)Factory method for constructing aJSONNumberValuefrom along.static JSONNumberValuefromNumberLiteral(java.lang.String literalValue)Factory method for constructing aJSONNumberValuefrom a number literal.doublegetDoubleValue()Get a 64-bit floating point value.floatgetFloatValue()Get a 32-bit floating point value.intgetIntValue()Get a 32-bit integer value.longgetLongValue()Get a 64-bit integer value.booleanisFinite()Checks if the number is finite.booleanisInteger()Get a boolean indicating whether thisJSONNumberValuerepresents an integer value or not.booleanisIntValue()Get a boolean indicating whether thisJSONNumberValuerepresents a 32-bit integer or not.booleanisNumber()Get a boolean indicating whether this instance represents a JSON numeric value or not.
-
-
-
Method Detail
-
fromLong
public static JSONNumberValue fromLong(long longValue)
Factory method for constructing aJSONNumberValuefrom along.- Parameters:
longValue- The long value.- Returns:
- Newly created
JSONNumberValue
-
fromDouble
public static JSONNumberValue fromDouble(double doubleValue)
Factory method for constructing aJSONNumberValuefrom adouble.- Parameters:
doubleValue- The double value.- Returns:
- Newly created
JSONNumberValue
-
fromNumberLiteral
public static JSONNumberValue fromNumberLiteral(java.lang.String literalValue)
Factory method for constructing aJSONNumberValuefrom a number literal.- Parameters:
literalValue- The number literal, which might either be an integer value or a floating point value.- Returns:
nullifliteralValueisnullor does not represent a number or a newly createdJSONNumberValue.
-
isNumber
public boolean isNumber()
Description copied from class:JSONValueGet a boolean indicating whether this instance represents a JSON numeric value or not.
-
isInteger
public boolean isInteger()
Get a boolean indicating whether thisJSONNumberValuerepresents an integer value or not.- Returns:
trueif this instance represents an integer value,falseotherwise.
-
isIntValue
public boolean isIntValue()
Get a boolean indicating whether thisJSONNumberValuerepresents a 32-bit integer or not.- Returns:
trueif this instance represents an integer value,falseotherwise.
-
getIntValue
public int getIntValue()
Get a 32-bit integer value.If this instance is representing a double or long value, then the result is the value casted to an
int.- Returns:
- 32-bit integer value represented by this instance.
-
getLongValue
public long getLongValue()
Get a 64-bit integer value.If this instance is representing a double, then the result is the value casted to a
long.- Returns:
- 64-bit integer value represented by this instance.
-
getFloatValue
public float getFloatValue()
Get a 32-bit floating point value.- Returns:
- 32-bit floating point value represented by this instance.
-
getDoubleValue
public double getDoubleValue()
Get a 64-bit floating point value.- Returns:
- 64-bit floating point value represented by this instance.
-
isFinite
public boolean isFinite()
Checks if the number is finite.- Returns:
- True if number is finite.
-
-