Top Description Fields Constructors Methods
com.fasterxml.jackson.databind.node

public abstract Class NumericNode

extends ValueNode
Class Inheritance
Known Direct Subclasses
com.fasterxml.jackson.databind.node.ShortNode, com.fasterxml.jackson.databind.node.BigIntegerNode, com.fasterxml.jackson.databind.node.DecimalNode, com.fasterxml.jackson.databind.node.DoubleNode, com.fasterxml.jackson.databind.node.FloatNode, com.fasterxml.jackson.databind.node.IntNode, com.fasterxml.jackson.databind.node.LongNode
Imports
java.math.BigDecimal, .BigInteger, com.fasterxml.jackson.core.JsonParser

Intermediate value node used for numeric nodes.

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public final double
asDouble()

Overrides com.fasterxml.jackson.databind.JsonNode.asDouble.

Method that will try to convert value of this node to a Java double.
public final double
asDouble(double defaultValue)

Overrides com.fasterxml.jackson.databind.JsonNode.asDouble.

Method that will try to convert value of this node to a Java double.
public final int
asInt()

Overrides com.fasterxml.jackson.databind.JsonNode.asInt.

Method that will try to convert value of this node to a Java int.
public final int
asInt(int defaultValue)

Overrides com.fasterxml.jackson.databind.JsonNode.asInt.

Method that will try to convert value of this node to a Java int.
public final long
asLong()

Overrides com.fasterxml.jackson.databind.JsonNode.asLong.

Method that will try to convert value of this node to a Java long.
public final long
asLong(long defaultValue)

Overrides com.fasterxml.jackson.databind.JsonNode.asLong.

Method that will try to convert value of this node to a Java long.
public abstract String
asText()

Implements abstract com.fasterxml.jackson.databind.JsonNode.asText.

Method that will return a valid String representation of the container value, if the node is a value node (method isValueNode returns true), otherwise empty String.
public abstract BigInteger
bigIntegerValue()

Overrides com.fasterxml.jackson.databind.JsonNode.bigIntegerValue.

Returns integer value for this node (as BigInteger), if and only if this node is numeric (isNumber returns true).
public abstract boolean
canConvertToInt()

Overrides com.fasterxml.jackson.databind.JsonNode.canConvertToInt.

Method that can be used to check whether this node is a numeric node (isNumber would return true) AND its value fits within Java's 32-bit signed integer type, int.
public abstract boolean
canConvertToLong()

Overrides com.fasterxml.jackson.databind.JsonNode.canConvertToLong.

Method that can be used to check whether this node is a numeric node (isNumber would return true) AND its value fits within Java's 64-bit signed integer type, long.
public abstract BigDecimal
decimalValue()

Overrides com.fasterxml.jackson.databind.JsonNode.decimalValue.

Returns floating point value for this node (as BigDecimal), if and only if this node is numeric (isNumber returns true).
public abstract double
doubleValue()

Overrides com.fasterxml.jackson.databind.JsonNode.doubleValue.

Returns 64-bit floating point (double) value for this node, if and only if this node is numeric (isNumber returns true).
public final JsonNodeType
getNodeType()

Implements abstract com.fasterxml.jackson.databind.JsonNode.getNodeType.

Return the type of this node
public abstract int
intValue()

Overrides com.fasterxml.jackson.databind.JsonNode.intValue.

Returns integer value for this node, if and only if this node is numeric (isNumber returns true).
public boolean
isNaN()

Convenience method for checking whether this node is a FloatNode or DoubleNode that contains "not-a-number" (NaN) value.

public abstract long
longValue()

Overrides com.fasterxml.jackson.databind.JsonNode.longValue.

Returns 64-bit long value for this node, if and only if this node is numeric (isNumber returns true).
public abstract JsonParser.NumberType
numberType()

Redeclares com.fasterxml.jackson.core.TreeNode.numberType.

Overrides com.fasterxml.jackson.databind.node.BaseJsonNode.numberType.

Returns code that identifies type of underlying numeric value, if (and only if) node is a number node.
public abstract Number
numberValue()

Overrides com.fasterxml.jackson.databind.JsonNode.numberValue.

Returns numeric value for this node, if and only if this node is numeric (isNumber returns true); otherwise returns null
Inherited from com.fasterxml.jackson.databind.node.ValueNode:
_atasTokendeepCopyfindParentfindParentsfindValuefindValuesfindValuesAsTextgetgethashashasNonNullhasNonNullisEmptypathpathserializeWithType

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.fasterxml.jackson.databind.node.ValueNode.serialVersionUID.

Constructor Detail

NumericNodeback to summary
protected NumericNode()

Method Detail

asDoubleback to summary
public final double asDouble()

Overrides com.fasterxml.jackson.databind.JsonNode.asDouble.

Doc from com.fasterxml.jackson.databind.JsonNode.asDouble.

Method that will try to convert value of this node to a Java double. Numbers are coerced using default Java rules; booleans convert to 0.0 (false) and 1.0 (true), and Strings are parsed using default Java language integer parsing rules.

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.

Annotations
@Override
asDoubleback to summary
public final double asDouble(double defaultValue)

Overrides com.fasterxml.jackson.databind.JsonNode.asDouble.

Doc from com.fasterxml.jackson.databind.JsonNode.asDouble.

Method that will try to convert value of this node to a Java double. Numbers are coerced using default Java rules; booleans convert to 0.0 (false) and 1.0 (true), and Strings are parsed using default Java language integer parsing rules.

If representation cannot be converted to an int (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.

Annotations
@Override
asIntback to summary
public final int asInt()

Overrides com.fasterxml.jackson.databind.JsonNode.asInt.

Doc from com.fasterxml.jackson.databind.JsonNode.asInt.

Method that will try to convert value of this node to a Java int. Numbers are coerced using default Java rules; booleans convert to 0 (false) and 1 (true), and Strings are parsed using default Java language integer parsing rules.

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.

Annotations
@Override
asIntback to summary
public final int asInt(int defaultValue)

Overrides com.fasterxml.jackson.databind.JsonNode.asInt.

Doc from com.fasterxml.jackson.databind.JsonNode.asInt.

Method that will try to convert value of this node to a Java int. Numbers are coerced using default Java rules; booleans convert to 0 (false) and 1 (true), and Strings are parsed using default Java language integer parsing rules.

If representation cannot be converted to an int (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.

Annotations
@Override
asLongback to summary
public final long asLong()

Overrides com.fasterxml.jackson.databind.JsonNode.asLong.

Doc from com.fasterxml.jackson.databind.JsonNode.asLong.

Method that will try to convert value of this node to a Java long. Numbers are coerced using default Java rules; booleans convert to 0 (false) and 1 (true), and Strings are parsed using default Java language integer parsing rules.

If representation cannot be converted to a long (including structured types like Objects and Arrays), default value of 0 will be returned; no exceptions are thrown.

Annotations
@Override
asLongback to summary
public final long asLong(long defaultValue)

Overrides com.fasterxml.jackson.databind.JsonNode.asLong.

Doc from com.fasterxml.jackson.databind.JsonNode.asLong.

Method that will try to convert value of this node to a Java long. Numbers are coerced using default Java rules; booleans convert to 0 (false) and 1 (true), and Strings are parsed using default Java language integer parsing rules.

If representation cannot be converted to a long (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.

Annotations
@Override
asTextback to summary
public abstract String asText()

Implements abstract com.fasterxml.jackson.databind.JsonNode.asText.

Doc from com.fasterxml.jackson.databind.JsonNode.asText.

Method that will return a valid String representation of the container value, if the node is a value node (method isValueNode returns true), otherwise empty String.

Annotations
@Override
bigIntegerValueback to summary
public abstract BigInteger bigIntegerValue()

Overrides com.fasterxml.jackson.databind.JsonNode.bigIntegerValue.

Doc from com.fasterxml.jackson.databind.JsonNode.bigIntegerValue.

Returns integer value for this node (as BigInteger), if and only if this node is numeric (isNumber returns true). For other types returns BigInteger.ZERO.

Note

In Jackson 2.x MAY throw com.fasterxml.jackson.core.exc.StreamConstraintsException if the scale of the underlying BigDecimal is too large to convert (NOTE: thrown "sneakily" in Jackson 2.x due to API compatibility restrictions)

Returns:BigInteger

BigInteger value this node contains, if numeric node; BigInteger.ZERO for non-number nodes.

Annotations
@Override
canConvertToIntback to summary
public abstract boolean canConvertToInt()

Overrides com.fasterxml.jackson.databind.JsonNode.canConvertToInt.

Doc from com.fasterxml.jackson.databind.JsonNode.canConvertToInt.

Method that can be used to check whether this node is a numeric node (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 asInt could still succeed if node is a JSON String representing integral number, or boolean.

Annotations
@Override
canConvertToLongback to summary
public abstract boolean canConvertToLong()

Overrides com.fasterxml.jackson.databind.JsonNode.canConvertToLong.

Doc from com.fasterxml.jackson.databind.JsonNode.canConvertToLong.

Method that can be used to check whether this node is a numeric node (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 asLong could still succeed if node is a JSON String representing integral number, or boolean.

Annotations
@Override
decimalValueback to summary
public abstract BigDecimal decimalValue()

Overrides com.fasterxml.jackson.databind.JsonNode.decimalValue.

Doc from com.fasterxml.jackson.databind.JsonNode.decimalValue.

Returns floating point value for this node (as BigDecimal), if and only if this node is numeric (isNumber returns true). For other types returns BigDecimal.ZERO.

Returns:BigDecimal

BigDecimal value this node contains, if numeric node; BigDecimal.ZERO for non-number nodes.

Annotations
@Override
doubleValueback to summary
public abstract double doubleValue()

Overrides com.fasterxml.jackson.databind.JsonNode.doubleValue.

Doc from com.fasterxml.jackson.databind.JsonNode.doubleValue.

Returns 64-bit floating point (double) value for this node, if and only if this node is numeric (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.

Returns:double

64-bit double value this node contains, if any; 0.0 for non-number nodes.

Annotations
@Override
getNodeTypeback to summary
public final JsonNodeType getNodeType()

Implements abstract com.fasterxml.jackson.databind.JsonNode.getNodeType.

Doc from com.fasterxml.jackson.databind.JsonNode.getNodeType.

Return the type of this node

Returns:JsonNodeType

the node type as a JsonNodeType enum value

Annotations
@Override
intValueback to summary
public abstract int intValue()

Overrides com.fasterxml.jackson.databind.JsonNode.intValue.

Doc from com.fasterxml.jackson.databind.JsonNode.intValue.

Returns integer value for this node, if and only if this node is numeric (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.

Returns:int

Integer value this node contains, if any; 0 for non-number nodes.

Annotations
@Override
isNaNback to summary
public boolean isNaN()

Convenience method for checking whether this node is a FloatNode or DoubleNode that contains "not-a-number" (NaN) value.

Since
2.9
longValueback to summary
public abstract long longValue()

Overrides com.fasterxml.jackson.databind.JsonNode.longValue.

Doc from com.fasterxml.jackson.databind.JsonNode.longValue.

Returns 64-bit long value for this node, if and only if this node is numeric (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.

Returns:long

Long value this node contains, if any; 0 for non-number nodes.

Annotations
@Override
numberTypeback to summary
public abstract JsonParser.NumberType numberType()

Redeclares com.fasterxml.jackson.core.TreeNode.numberType.

Overrides com.fasterxml.jackson.databind.node.BaseJsonNode.numberType.

Doc from com.fasterxml.jackson.databind.node.BaseJsonNode.numberType.

Returns code that identifies type of underlying numeric value, if (and only if) node is a number node.

Returns:JsonParser.NumberType

Doc from com.fasterxml.jackson.core.TreeNode.numberType.

Type of number contained, if any; or null if node does not contain numeric value.

Annotations
@Override
numberValueback to summary
public abstract Number numberValue()

Overrides com.fasterxml.jackson.databind.JsonNode.numberValue.

Doc from com.fasterxml.jackson.databind.JsonNode.numberValue.

Returns numeric value for this node, if and only if this node is numeric (isNumber returns true); otherwise returns null

Returns:Number

Number value this node contains, if any (null for non-number nodes).

Annotations
@Override