public abstract class NumericNode extends ValueNode
JsonSerializable.Base
Modifier and Type | Method and Description |
---|---|
double |
asDouble()
Method that will try to convert value of this node to a Java double.
|
double |
asDouble(double defaultValue)
Method that will try to convert value of this node to a Java double.
|
int |
asInt()
Method that will try to convert value of this node to a Java int.
|
int |
asInt(int defaultValue)
Method that will try to convert value of this node to a Java int.
|
long |
asLong()
Method that will try to convert value of this node to a Java long.
|
long |
asLong(long defaultValue)
Method that will try to convert value of this node to a Java long.
|
abstract java.lang.String |
asText()
Method that will return a valid String representation of
the container value, if the node is a value node
(method
JsonNode.isValueNode() returns true),
otherwise empty String. |
abstract java.math.BigInteger |
bigIntegerValue()
Returns integer value for this node (as
BigDecimal ), if and only if
this node is numeric (JsonNode.isNumber() returns true). |
abstract boolean |
canConvertToInt()
Method that can be used to check whether this node is a numeric
node (
JsonNode.isNumber() would return true) AND its value fits
within Java's 32-bit signed integer type, int . |
abstract boolean |
canConvertToLong()
Method that can be used to check whether this node is a numeric
node (
JsonNode.isNumber() would return true) AND its value fits
within Java's 64-bit signed integer type, long . |
abstract java.math.BigDecimal |
decimalValue()
Returns floating point value for this node (as
BigDecimal ), if and only if
this node is numeric (JsonNode.isNumber() returns true). |
abstract double |
doubleValue()
Returns 64-bit floating point (double) value for this node, if and only if
this node is numeric (
JsonNode.isNumber() returns true). |
JsonNodeType |
getNodeType()
Return the type of this node
|
abstract int |
intValue()
Returns integer value for this node, if and only if
this node is numeric (
JsonNode.isNumber() returns true). |
boolean |
isNaN()
Convenience method for checking whether this node is a
FloatNode or DoubleNode that contains
"not-a-number" (NaN) value. |
abstract long |
longValue()
Returns 64-bit long value for this node, if and only if
this node is numeric (
JsonNode.isNumber() returns true). |
abstract JsonParser.NumberType |
numberType()
Returns code that identifies type of underlying numeric
value, if (and only if) node is a number node.
|
abstract java.lang.Number |
numberValue()
Returns numeric value for this node, if and only if
this node is numeric (
JsonNode.isNumber() returns true); otherwise
returns null |
asToken, deepCopy, findParent, findParents, findValue, findValues, findValuesAsText, get, get, has, has, hasNonNull, hasNonNull, isEmpty, path, path, serializeWithType
findPath, hashCode, required, required, serialize, toPrettyString, toString, traverse, traverse
asBoolean, asBoolean, asText, at, at, binaryValue, booleanValue, elements, equals, equals, fieldNames, fields, findParents, findValues, findValuesAsText, floatValue, isArray, isBigDecimal, isBigInteger, isBinary, isBoolean, isContainerNode, isDouble, isFloat, isFloatingPointNumber, isInt, isIntegralNumber, isLong, isMissingNode, isNull, isNumber, isObject, isPojo, isShort, isTextual, isValueNode, iterator, require, requiredAt, requiredAt, requireNonNull, shortValue, size, textValue, with, withArray
isEmpty
public final JsonNodeType getNodeType()
JsonNode
getNodeType
in class JsonNode
JsonNodeType
enum valuepublic abstract JsonParser.NumberType numberType()
BaseJsonNode
numberType
in interface TreeNode
numberType
in class BaseJsonNode
public abstract java.lang.Number numberValue()
JsonNode
JsonNode.isNumber()
returns true); otherwise
returns nullnumberValue
in class JsonNode
public abstract int intValue()
JsonNode
JsonNode.isNumber()
returns true). For other
types returns 0.
For floating-point numbers, value is truncated using default
Java coercion, similar to how cast from double to int operates.public abstract long longValue()
JsonNode
JsonNode.isNumber()
returns true). For other
types returns 0.
For floating-point numbers, value is truncated using default
Java coercion, similar to how cast from double to long operates.public abstract double doubleValue()
JsonNode
JsonNode.isNumber()
returns true). For other
types returns 0.0.
For integer values, conversion is done using coercion; this may result
in overflows with BigInteger
values.doubleValue
in class JsonNode
public abstract java.math.BigDecimal decimalValue()
JsonNode
BigDecimal
), if and only if
this node is numeric (JsonNode.isNumber()
returns true). For other
types returns BigDecimal.ZERO
.decimalValue
in class JsonNode
BigDecimal
value this node contains, if numeric node; BigDecimal.ZERO
for non-number nodes.public abstract java.math.BigInteger bigIntegerValue()
JsonNode
BigDecimal
), if and only if
this node is numeric (JsonNode.isNumber()
returns true). For other
types returns BigInteger.ZERO
.bigIntegerValue
in class JsonNode
BigInteger
value this node contains, if numeric node; BigInteger.ZERO
for non-number nodes.public abstract boolean canConvertToInt()
JsonNode
JsonNode.isNumber()
would return true) AND its value fits
within Java's 32-bit signed integer type, int
.
Note that floating-point numbers are convertible if the integral
part fits without overflow (as per standard Java coercion rules)
NOTE: this method does not consider possible value type conversion
from JSON String into Number; so even if this method returns false,
it is possible that JsonNode.asInt()
could still succeed
if node is a JSON String representing integral number, or boolean.
canConvertToInt
in class JsonNode
public abstract boolean canConvertToLong()
JsonNode
JsonNode.isNumber()
would return true) AND its value fits
within Java's 64-bit signed integer type, long
.
Note that floating-point numbers are convertible if the integral
part fits without overflow (as per standard Java coercion rules)
NOTE: this method does not consider possible value type conversion
from JSON String into Number; so even if this method returns false,
it is possible that JsonNode.asLong()
could still succeed
if node is a JSON String representing integral number, or boolean.
canConvertToLong
in class JsonNode
public abstract java.lang.String asText()
JsonNode
JsonNode.isValueNode()
returns true),
otherwise empty String.public final int asInt()
JsonNode
If representation cannot be converted to an int (including structured types like Objects and Arrays), default value of 0 will be returned; no exceptions are thrown.
public final int asInt(int defaultValue)
JsonNode
If representation cannot be converted to an int (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.
public final long asLong()
JsonNode
If representation cannot be converted to an long (including structured types like Objects and Arrays), default value of 0 will be returned; no exceptions are thrown.
public final long asLong(long defaultValue)
JsonNode
If representation cannot be converted to an long (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.
public final double asDouble()
JsonNode
If representation cannot be converted to an int (including structured types like Objects and Arrays), default value of 0.0 will be returned; no exceptions are thrown.
public final double asDouble(double defaultValue)
JsonNode
If representation cannot be converted to an int (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.
public boolean isNaN()
FloatNode
or DoubleNode
that contains
"not-a-number" (NaN) value.Copyright © 2010 - 2020 Adobe. All Rights Reserved