public abstract class NumericNode extends ValueNode
JsonSerializable.Base| 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()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 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
  FloatNodeorDoubleNodethat 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 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, isEmpty, path, path, serializeWithTypefindPath, hashCode, required, required, serialize, toPrettyString, toString, traverse, traverse_reportRequiredViolation, _this, 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, withArrayisEmptyclone, finalize, getClass, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic final JsonNodeType getNodeType()
JsonNodegetNodeType in class JsonNodeJsonNodeType enum valuepublic abstract JsonParser.NumberType numberType()
BaseJsonNodenumberType in interface TreeNodenumberType in class BaseJsonNodepublic abstract Number numberValue()
JsonNodeJsonNode.isNumber() returns true); otherwise
 returns nullnumberValue in class JsonNodepublic abstract int intValue()
JsonNodeJsonNode.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()
JsonNodeJsonNode.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()
JsonNodeJsonNode.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 JsonNodepublic abstract BigDecimal decimalValue()
JsonNodeBigDecimal), if and only if
 this node is numeric (JsonNode.isNumber() returns true). For other
 types returns BigDecimal.ZERO.decimalValue in class JsonNodeBigDecimal value this node contains, if numeric node; BigDecimal.ZERO for non-number nodes.public abstract BigInteger bigIntegerValue()
JsonNodeBigDecimal), if and only if
 this node is numeric (JsonNode.isNumber() returns true). For other
 types returns BigInteger.ZERO.bigIntegerValue in class JsonNodeBigInteger value this node contains, if numeric node; BigInteger.ZERO for non-number nodes.public abstract boolean canConvertToInt()
JsonNodeJsonNode.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 JsonNodepublic abstract boolean canConvertToLong()
JsonNodeJsonNode.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 JsonNodepublic abstract String asText()
JsonNodeJsonNode.isValueNode() returns true),
 otherwise empty String.public final int asInt()
JsonNodeIf 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)
JsonNodeIf 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()
JsonNodeIf 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)
JsonNodeIf 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()
JsonNodeIf 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)
JsonNodeIf 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 © 2008–2020 FasterXML. All rights reserved.