public abstract class NumericNode extends ValueNode
Modifier | Constructor and Description |
---|---|
protected |
NumericNode() |
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 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 BigInteger |
bigIntegerValue() |
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 BigDecimal |
decimalValue() |
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). |
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 Number |
numberValue()
Returns numeric value for this node, if and only if
this node is numeric (
JsonNode.isNumber() returns true); otherwise
returns null |
_at, asToken, deepCopy, findParent, findParents, findValue, findValues, findValuesAsText, get, get, has, has, hasNonNull, hasNonNull, path, path, serializeWithType, toString
findPath, serialize, traverse, traverse
asBoolean, asBoolean, asText, at, at, binaryValue, booleanValue, elements, 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, shortValue, size, textValue, with, withArray
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 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 BigDecimal decimalValue()
decimalValue
in class JsonNode
public abstract BigInteger bigIntegerValue()
bigIntegerValue
in class JsonNode
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 String asText()
JsonNode
JsonNode.isValueNode()
returns true),
otherwise empty String.public final int asInt()
JsonNode
If representation can not 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 can not 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 can not 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 can not 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 can not 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 can not be converted to an int (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.
Copyright © 2014 FasterXML. All Rights Reserved.