Top Description Fields Constructors Methods
tools.jackson.databind.node

public abstract Class NumericNode

extends ValueNode
Class Inheritance
Known Direct Subclasses
tools.jackson.databind.node.NumericFPNode, tools.jackson.databind.node.NumericIntNode
Imports
java.math.BigDecimal, .BigInteger, java.util.Optional, .OptionalDouble, .OptionalInt, .OptionalLong, tools.jackson.core.JsonParser

Intermediate value node used for numeric nodes.

Field Summary

Modifier and TypeField and Description
private static final long
Inherited from tools.jackson.databind.node.ValueNode:
BD_MAX_INTEGERBD_MAX_LONGBD_MAX_SHORTBD_MIN_INTEGERBD_MIN_LONGBD_MIN_SHORTBI_MAX_INTEGERBI_MAX_LONGBI_MAX_SHORTBI_MIN_INTEGERBI_MIN_LONGBI_MIN_SHORTMISSING

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public abstract int
_asIntValueUnchecked()

Method for sub-classes to implement; returns the underlying value as a int without any checks (wrt NaN or value range), so caller must ensure validity prior to calling

public abstract long
_asLongValueUnchecked()

Method for sub-classes to implement; returns the underlying value as a long without any checks (wrt NaN or value range), so caller must ensure validity prior to calling

public abstract short
_asShortValueUnchecked()

Method for sub-classes to implement; returns the underlying value as a short without any checks (wrt NaN or value range), so caller must ensure validity prior to calling

protected abstract String
_asString()

Overrides tools.jackson.databind.node.BaseJsonNode._asString.

Method sub-classes should override if they can produce String values via asString() -- if not, return null (in which case appropriate error will be thrown or default value returned).

protected final String
_valueDesc()

Implements abstract tools.jackson.databind.node.BaseJsonNode._valueDesc.

Method for implementation classes to return a short description of contained value, to be used in error messages.

public abstract BigInteger
asBigInteger()

Overrides tools.jackson.databind.node.BaseJsonNode.asBigInteger.

Method similar to bigIntegerValue() but in addition to coercing Number values (same as bigIntegerValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for bigIntegerValue()) will be truncated to integer value (like with BigDecimal#toBigInteger()))
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
public abstract BigInteger
asBigInteger(BigInteger defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asBigInteger.

Method similar to asBigInteger(), but that will return specified defaultValue if this node cannot be converted to BigInteger.

public abstract Optional<BigInteger>
asBigIntegerOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asBigIntegerOpt.

Method similar to bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to Java BigInteger.

public abstract BigDecimal
asDecimal()

Overrides tools.jackson.databind.node.BaseJsonNode.asDecimal.

Method that will try to access value of this node as a BigDecimal: but if node value cannot be expressed exactly as a BigDecimal, a JsonNodeException will be thrown.

public abstract BigDecimal
asDecimal(BigDecimal defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asDecimal.

Method similar to asDecimal(), but that will return defaultValue if this node cannot be coerced to Java BigDecimal.

public abstract Optional<BigDecimal>
asDecimalOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asDecimalOpt.

Method similar to asDecimal(), but that will return empty Optional (Optional.empty()) if this node cannot be coerced to BigDecimal.

public abstract double
asDouble()

Overrides tools.jackson.databind.node.BaseJsonNode.asDouble.

Method similar to doubleValue() but in addition to coercing Number values will also try coerce couple of additional types:

  • JSON String that represents JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0.0d)
  • POJO nodes that contain Number values
public abstract double
asDouble(double defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asDouble.

Method similar to asDouble(), but that will return defaultValue if this node cannot be coerced to double.

public abstract OptionalDouble
asDoubleOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asDoubleOpt.

Method similar to asDouble(), but that will return (OptionalDouble.empty()) if this node cannot be coerced to double.

public abstract float
asFloat()

Overrides tools.jackson.databind.node.BaseJsonNode.asFloat.

Method similar to floatValue() but in addition to coercing Number values will also try coerce couple of additional types:

  • JSON String that represents JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0.0f)
  • POJO nodes that contain Number values
public abstract float
asFloat(float defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asFloat.

Method similar to asFloat(), but that will return defaultValue if this node cannot be coerced to float.

public abstract Optional<Float>
asFloatOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asFloatOpt.

Method similar to asFloat(), but that will return (Optional.empty()) if this node cannot be coerced to float.

public abstract int
asInt()

Overrides tools.jackson.databind.node.BaseJsonNode.asInt.

Method similar to intValue() but in addition to coercing Number values (same as intValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for intValue()) will be truncated to int (if (and only if) they fit in int range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
public abstract int
asInt(int defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asInt.

Method similar to intValue(), but that will return specified defaultValue if this node cannot be converted to int.

public abstract OptionalInt
asIntOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asIntOpt.

Method similar to asInt(), but that will return (OptionalInt.empty()) if this node cannot be coerced to int.

public abstract long
asLong()

Overrides tools.jackson.databind.node.BaseJsonNode.asLong.

Method similar to longValue() but in addition to coercing Number values (same as longValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for longValue()) will be truncated to long (if (and only if) they fit in long range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
public abstract long
asLong(long defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asLong.

Method similar to asLong(), but that will return specified defaultValue if this node cannot be coerced to long (instead of throwing an exception).

public abstract OptionalLong
asLongOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asLongOpt.

Method similar to asLong(), but that will return (OptionalLong.empty()) if this node cannot be coerced to long.

public abstract short
asShort()

Overrides tools.jackson.databind.node.BaseJsonNode.asShort.

Method similar to shortValue() but in addition to coercing Number values (same as shortValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for shortValue()) will be truncated to short (if (and only if) they fit in short range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
public abstract short
asShort(short defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asShort.

Method similar to shortValue(), but that will return specified defaultValue if this node cannot be converted to short.

public abstract Optional<Short>
asShortOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asShortOpt.

Method similar to asShort(), but that will return (Optional.empty()) if this node cannot be coerced to short.

public abstract BigInteger
bigIntegerValue()

Overrides tools.jackson.databind.node.BaseJsonNode.bigIntegerValue.

Method that will try to access value of this node as a BigInteger, but if node value cannot be expressed exactly as a BigInteger, a JsonNodeException will be thrown.

public abstract BigInteger
bigIntegerValue(BigInteger defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.bigIntegerValue.

Method similar to bigIntegerValue(), but that will return specified defaultValue if this node cannot be converted to Java BigInteger.

public abstract Optional<BigInteger>
bigIntegerValueOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.bigIntegerValueOpt.

Method similar to bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to Java BigInteger.

public abstract boolean
canConvertToInt()

Overrides tools.jackson.databind.JsonNode.canConvertToInt.

Method that can be used to check whether this node is a numeric node (isNumber would return true) AND can be converted without loss to int (that is, its value fits in Java's 32-bit signed integer type, int and if it is a floating-point number, it does not have fractional part).

public abstract boolean
canConvertToLong()

Overrides tools.jackson.databind.JsonNode.canConvertToLong.

Method that can be used to check whether this node is a numeric node (isNumber would return true) AND can be converted without loss to long (that is, its value fits in Java's 64-bit signed integer type, long and if it is a floating-point number, it does not have fractional part).

public abstract boolean
canConvertToShort()

Overrides tools.jackson.databind.JsonNode.canConvertToShort.

Method that can be used to check whether this node is a numeric node (isNumber would return true) AND can be converted without loss to short (that is, its value fits in Java's 16-bit signed integer type, short and if it is a floating-point number, it does not have fractional part).

public abstract BigDecimal
decimalValue()

Overrides tools.jackson.databind.node.BaseJsonNode.decimalValue.

Method that will try to access value of this node as a Java BigDecimal: but if node value cannot be expressed exactly as a BigDecimal, a JsonNodeException will be thrown.

public abstract BigDecimal
decimalValue(BigDecimal defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.decimalValue.

Method similar to decimalValue(), but that will return defaultValue if this node cannot be coerced to Java BigDecimal.

public abstract Optional<BigDecimal>
decimalValueOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.decimalValueOpt.

Method similar to decimalValue(), but that will return empty Optional (Optional.empty()) if this node cannot be coerced to BigDecimal.

public NumericNode
deepCopy()

Overrides tools.jackson.databind.node.ValueNode.deepCopy.

All current value nodes are immutable, so we can just return them as is.

public abstract double
doubleValue()

Overrides tools.jackson.databind.node.BaseJsonNode.doubleValue.

Method that will try to access value of this node as a double: but if node value cannot be expressed exactly as a double, a JsonNodeException will be thrown.

public abstract double
doubleValue(double defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.doubleValue.

Method similar to doubleValue(), but that will return specified defaultValue if this node cannot be converted to double.

public abstract OptionalDouble
doubleValueOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.doubleValueOpt.

Method similar to doubleValue(), but that will return empty OptionalLong (OptionalDouble.empty()) if this node cannot be converted to Java double.

public abstract float
floatValue()

Overrides tools.jackson.databind.node.BaseJsonNode.floatValue.

Method that will try to access value of this node as a Java float: but if node value cannot be expressed exactly as a float, a JsonNodeException will be thrown.

public abstract float
floatValue(float defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.floatValue.

Method similar to floatValue(), but that will return specified defaultValue if this node cannot be converted to float.

public abstract Optional<Float>
floatValueOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.floatValueOpt.

Method similar to floatValue(), but that will return empty Optional<Float> (Optional.empty()) if this node cannot be converted to Java float.

public final JsonNodeType
getNodeType()

Implements abstract tools.jackson.databind.JsonNode.getNodeType.

Return the type of this node

public abstract boolean
hasFractionalPart()

Convenience method for checking whether this node is a NumericFPNode that contains non-zero fractional part (as opposed to only integer part).

public abstract boolean
inIntRange()

Method that can be used to determine whether this numeric value's in part fits within Java 32-bitint type.

public abstract boolean
inLongRange()

Method that can be used to determine whether this numeric value's in part fits within Java 64-bit long type.

public abstract boolean
inShortRange()

Method that can be used to determine whether this numeric value's in part fits within Java 16-bit short type.

public abstract int
intValue()

Overrides tools.jackson.databind.node.BaseJsonNode.intValue.

Method that will try to access value of this node as a Java int: but if node value cannot be expressed exactly as an int, a JsonNodeException will be thrown.

public abstract int
intValue(int defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.intValue.

Method similar to intValue(), but that will return specified defaultValue if this node cannot be converted to Java int.

public abstract OptionalInt
intValueOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.intValueOpt.

Method similar to intValue(), but that will return empty OptionalInt (OptionalInt.empty()) if this node cannot be converted to Java int.

public abstract 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 tools.jackson.databind.node.BaseJsonNode.longValue.

Method that will try to access value of this node as a Java long: but if node value cannot be expressed exactly as a long, a JsonNodeException will be thrown.

public abstract long
longValue(long defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.longValue.

Method similar to longValue(), but that will return specified defaultValue if this node cannot be converted to long.

public abstract OptionalLong
longValueOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.longValueOpt.

Method similar to longValue(), but that will return empty OptionalLong (OptionalLong.empty()) if this node cannot be converted to Java long.

public abstract JsonParser.NumberType
numberType()

Redeclares tools.jackson.core.TreeNode.numberType.

Overrides tools.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 tools.jackson.databind.node.BaseJsonNode.numberValue.

Method that will try to access value of this node as Number that accurately represents its value, if (and only if) this is a number node (returns true for isNumber).

public abstract short
shortValue()

Overrides tools.jackson.databind.node.BaseJsonNode.shortValue.

Method that will try to access value of this node as 16-bit signed integer value (Java short): but if node value cannot be expressed exactly as a short, a JsonNodeException will be thrown.

public abstract short
shortValue(short defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.shortValue.

Method similar to shortValue(), but that will return specified defaultValue if this node cannot be converted to Java short.

public abstract Optional<Short>
shortValueOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.shortValueOpt.

Method similar to shortValue(), but that will return empty Optional<Short> (Optional.empty()) if this node cannot be converted to Java short.

Inherited from tools.jackson.databind.node.ValueNode:
_atasTokenfindParentfindParentsfindValuefindValuesfindValuesAsStringgetgethashashasNonNullhasNonNullisEmptypathpathserializeWithType

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides tools.jackson.databind.node.ValueNode.serialVersionUID.

Constructor Detail

NumericNodeback to summary
protected NumericNode()

Method Detail

_asIntValueUncheckedback to summary
public abstract int _asIntValueUnchecked()

Method for sub-classes to implement; returns the underlying value as a int without any checks (wrt NaN or value range), so caller must ensure validity prior to calling

_asLongValueUncheckedback to summary
public abstract long _asLongValueUnchecked()

Method for sub-classes to implement; returns the underlying value as a long without any checks (wrt NaN or value range), so caller must ensure validity prior to calling

_asShortValueUncheckedback to summary
public abstract short _asShortValueUnchecked()

Method for sub-classes to implement; returns the underlying value as a short without any checks (wrt NaN or value range), so caller must ensure validity prior to calling

_asStringback to summary
protected abstract String _asString()

Overrides tools.jackson.databind.node.BaseJsonNode._asString.

Doc from tools.jackson.databind.node.BaseJsonNode._asString.

Method sub-classes should override if they can produce String values via asString() -- if not, return null (in which case appropriate error will be thrown or default value returned).

Annotations
@Override
_valueDescback to summary
protected final String _valueDesc()

Implements abstract tools.jackson.databind.node.BaseJsonNode._valueDesc.

Doc from tools.jackson.databind.node.BaseJsonNode._valueDesc.

Method for implementation classes to return a short description of contained value, to be used in error messages.

Annotations
@Override
asBigIntegerback to summary
public abstract BigInteger asBigInteger()

Overrides tools.jackson.databind.node.BaseJsonNode.asBigInteger.

Doc from tools.jackson.databind.JsonNode.asBigInteger.

Method similar to bigIntegerValue() but in addition to coercing Number values (same as bigIntegerValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for bigIntegerValue()) will be truncated to integer value (like with BigDecimal#toBigInteger()))
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
Annotations
@Override
asBigIntegerback to summary
public abstract BigInteger asBigInteger(BigInteger defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asBigInteger.

Doc from tools.jackson.databind.JsonNode.asBigInteger.

Method similar to asBigInteger(), but that will return specified defaultValue if this node cannot be converted to BigInteger.

Annotations
@Override
asBigIntegerOptback to summary
public abstract Optional<BigInteger> asBigIntegerOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asBigIntegerOpt.

Doc from tools.jackson.databind.JsonNode.asBigIntegerOpt.

Method similar to bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to Java BigInteger.

Annotations
@Override
asDecimalback to summary
public abstract BigDecimal asDecimal()

Overrides tools.jackson.databind.node.BaseJsonNode.asDecimal.

Doc from tools.jackson.databind.JsonNode.asDecimal.

Method that will try to access value of this node as a BigDecimal: but if node value cannot be expressed exactly as a BigDecimal, a JsonNodeException will be thrown. Access works for following cases:

  • JSON Floating-point values (but not "NaN" or "Infinity")
  • JSON Integer values
  • JSON String that represents JSON Numbers ("stringified" numbers)
  • JSON Null (converted to BigDecimal#ZERO))
  • POJO nodes that contain Number values

Annotations
@Override
asDecimalback to summary
public abstract BigDecimal asDecimal(BigDecimal defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asDecimal.

Doc from tools.jackson.databind.JsonNode.asDecimal.

Method similar to asDecimal(), but that will return defaultValue if this node cannot be coerced to Java BigDecimal.

Annotations
@Override
asDecimalOptback to summary
public abstract Optional<BigDecimal> asDecimalOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asDecimalOpt.

Doc from tools.jackson.databind.JsonNode.asDecimalOpt.

Method similar to asDecimal(), but that will return empty Optional (Optional.empty()) if this node cannot be coerced to BigDecimal.

Annotations
@Override
asDoubleback to summary
public abstract double asDouble()

Overrides tools.jackson.databind.node.BaseJsonNode.asDouble.

Doc from tools.jackson.databind.JsonNode.asDouble.

Method similar to doubleValue() but in addition to coercing Number values will also try coerce couple of additional types:

  • JSON String that represents JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0.0d)
  • POJO nodes that contain Number values

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

Overrides tools.jackson.databind.node.BaseJsonNode.asDouble.

Doc from tools.jackson.databind.JsonNode.asDouble.

Method similar to asDouble(), but that will return defaultValue if this node cannot be coerced to double.

Annotations
@Override
asDoubleOptback to summary
public abstract OptionalDouble asDoubleOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asDoubleOpt.

Doc from tools.jackson.databind.JsonNode.asDoubleOpt.

Method similar to asDouble(), but that will return (OptionalDouble.empty()) if this node cannot be coerced to double.

Annotations
@Override
asFloatback to summary
public abstract float asFloat()

Overrides tools.jackson.databind.node.BaseJsonNode.asFloat.

Doc from tools.jackson.databind.JsonNode.asFloat.

Method similar to floatValue() but in addition to coercing Number values will also try coerce couple of additional types:

  • JSON String that represents JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0.0f)
  • POJO nodes that contain Number values

Annotations
@Override
asFloatback to summary
public abstract float asFloat(float defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asFloat.

Doc from tools.jackson.databind.JsonNode.asFloat.

Method similar to asFloat(), but that will return defaultValue if this node cannot be coerced to float.

Annotations
@Override
asFloatOptback to summary
public abstract Optional<Float> asFloatOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asFloatOpt.

Doc from tools.jackson.databind.JsonNode.asFloatOpt.

Method similar to asFloat(), but that will return (Optional.empty()) if this node cannot be coerced to float.

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

Overrides tools.jackson.databind.node.BaseJsonNode.asInt.

Doc from tools.jackson.databind.JsonNode.asInt.

Method similar to intValue() but in addition to coercing Number values (same as intValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for intValue()) will be truncated to int (if (and only if) they fit in int range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
Annotations
@Override
asIntback to summary
public abstract int asInt(int defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asInt.

Doc from tools.jackson.databind.JsonNode.asInt.

Method similar to intValue(), but that will return specified defaultValue if this node cannot be converted to int.

Annotations
@Override
asIntOptback to summary
public abstract OptionalInt asIntOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asIntOpt.

Doc from tools.jackson.databind.JsonNode.asIntOpt.

Method similar to asInt(), but that will return (OptionalInt.empty()) if this node cannot be coerced to int.

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

Overrides tools.jackson.databind.node.BaseJsonNode.asLong.

Doc from tools.jackson.databind.JsonNode.asLong.

Method similar to longValue() but in addition to coercing Number values (same as longValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for longValue()) will be truncated to long (if (and only if) they fit in long range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
Annotations
@Override
asLongback to summary
public abstract long asLong(long defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asLong.

Doc from tools.jackson.databind.JsonNode.asLong.

Method similar to asLong(), but that will return specified defaultValue if this node cannot be coerced to long (instead of throwing an exception).

Annotations
@Override
asLongOptback to summary
public abstract OptionalLong asLongOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asLongOpt.

Doc from tools.jackson.databind.JsonNode.asLongOpt.

Method similar to asLong(), but that will return (OptionalLong.empty()) if this node cannot be coerced to long.

Annotations
@Override
asShortback to summary
public abstract short asShort()

Overrides tools.jackson.databind.node.BaseJsonNode.asShort.

Doc from tools.jackson.databind.JsonNode.asShort.

Method similar to shortValue() but in addition to coercing Number values (same as shortValue()), will also try to coerce a couple of additional types (or cases):

  • JSON Floating-point numbers with fractions (ones without fractions are ok for shortValue()) will be truncated to short (if (and only if) they fit in short range).
  • JSON Strings that represent JSON Numbers ("stringified" numbers)
  • JSON Null (converted to 0))
  • POJO nodes that contain Number values
Annotations
@Override
asShortback to summary
public abstract short asShort(short defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.asShort.

Doc from tools.jackson.databind.JsonNode.asShort.

Method similar to shortValue(), but that will return specified defaultValue if this node cannot be converted to short.

Annotations
@Override
asShortOptback to summary
public abstract Optional<Short> asShortOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.asShortOpt.

Doc from tools.jackson.databind.JsonNode.asShortOpt.

Method similar to asShort(), but that will return (Optional.empty()) if this node cannot be coerced to short.

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

Overrides tools.jackson.databind.node.BaseJsonNode.bigIntegerValue.

Doc from tools.jackson.databind.JsonNode.bigIntegerValue.

Method that will try to access value of this node as a BigInteger, but if node value cannot be expressed exactly as a BigInteger, a JsonNodeException will be thrown. Access works for following cases:

  • JSON Integer values
  • JSON Floating-point values that do not have fractional part.

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

Overrides tools.jackson.databind.node.BaseJsonNode.bigIntegerValue.

Doc from tools.jackson.databind.JsonNode.bigIntegerValue.

Method similar to bigIntegerValue(), but that will return specified defaultValue if this node cannot be converted to Java BigInteger.

Annotations
@Override
bigIntegerValueOptback to summary
public abstract Optional<BigInteger> bigIntegerValueOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.bigIntegerValueOpt.

Doc from tools.jackson.databind.JsonNode.bigIntegerValueOpt.

Method similar to bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to Java BigInteger.

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

Overrides tools.jackson.databind.JsonNode.canConvertToInt.

Doc from tools.jackson.databind.JsonNode.canConvertToInt.

Method that can be used to check whether this node is a numeric node (isNumber would return true) AND can be converted without loss to int (that is, its value fits in Java's 32-bit signed integer type, int and if it is a floating-point number, it does not have fractional part).

Note

this method does not consider possible value type conversion from non-number types like JSON String into Number; so even if this method returns false, it is possible that asInt could still succeed.

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

Overrides tools.jackson.databind.JsonNode.canConvertToLong.

Doc from tools.jackson.databind.JsonNode.canConvertToLong.

Method that can be used to check whether this node is a numeric node (isNumber would return true) AND can be converted without loss to long (that is, its value fits in Java's 64-bit signed integer type, long and if it is a floating-point number, it does not have fractional part).

Note

this method does not consider possible value type conversion from non-number types like JSON String into Number; so even if this method returns false, it is possible that asLong could still succeed.

Annotations
@Override
canConvertToShortback to summary
public abstract boolean canConvertToShort()

Overrides tools.jackson.databind.JsonNode.canConvertToShort.

Doc from tools.jackson.databind.JsonNode.canConvertToShort.

Method that can be used to check whether this node is a numeric node (isNumber would return true) AND can be converted without loss to short (that is, its value fits in Java's 16-bit signed integer type, short and if it is a floating-point number, it does not have fractional part).

Note

this method does not consider possible value type conversion from non-number types like JSON String into Number; so even if this method returns false, it is possible that asShort could still succeed.

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

Overrides tools.jackson.databind.node.BaseJsonNode.decimalValue.

Doc from tools.jackson.databind.JsonNode.decimalValue.

Method that will try to access value of this node as a Java BigDecimal: but if node value cannot be expressed exactly as a BigDecimal, a JsonNodeException will be thrown. Access works for following cases:

  • All JSON Number values

Note

for more lenient conversions, use asDecimal()

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

Overrides tools.jackson.databind.node.BaseJsonNode.decimalValue.

Doc from tools.jackson.databind.JsonNode.decimalValue.

Method similar to decimalValue(), but that will return defaultValue if this node cannot be coerced to Java BigDecimal.

Annotations
@Override
decimalValueOptback to summary
public abstract Optional<BigDecimal> decimalValueOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.decimalValueOpt.

Doc from tools.jackson.databind.JsonNode.decimalValueOpt.

Method similar to decimalValue(), but that will return empty Optional (Optional.empty()) if this node cannot be coerced to BigDecimal.

Annotations
@Override
deepCopyback to summary
public NumericNode deepCopy()

Overrides tools.jackson.databind.node.ValueNode.deepCopy.

Doc from tools.jackson.databind.node.ValueNode.deepCopy.

All current value nodes are immutable, so we can just return them as is.

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

Overrides tools.jackson.databind.node.BaseJsonNode.doubleValue.

Doc from tools.jackson.databind.JsonNode.doubleValue.

Method that will try to access value of this node as a double: but if node value cannot be expressed exactly as a double, a JsonNodeException will be thrown. Access works for following cases:

  • JSON Floating-point values that fit in Java 64-bit double range
  • JSON Integer values that fit in Java 64-bit double range

Note

for more lenient conversions, use asDouble()

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

Overrides tools.jackson.databind.node.BaseJsonNode.doubleValue.

Doc from tools.jackson.databind.JsonNode.doubleValue.

Method similar to doubleValue(), but that will return specified defaultValue if this node cannot be converted to double.

Annotations
@Override
doubleValueOptback to summary
public abstract OptionalDouble doubleValueOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.doubleValueOpt.

Doc from tools.jackson.databind.JsonNode.doubleValueOpt.

Method similar to doubleValue(), but that will return empty OptionalLong (OptionalDouble.empty()) if this node cannot be converted to Java double.

Annotations
@Override
floatValueback to summary
public abstract float floatValue()

Overrides tools.jackson.databind.node.BaseJsonNode.floatValue.

Doc from tools.jackson.databind.JsonNode.floatValue.

Method that will try to access value of this node as a Java float: but if node value cannot be expressed exactly as a float, a JsonNodeException will be thrown. Access works for following cases:

  • JSON Floating-point values that fit in Java 32-bit double range
  • JSON Integer values that fit in Java 32-bit double range

Annotations
@Override
floatValueback to summary
public abstract float floatValue(float defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.floatValue.

Doc from tools.jackson.databind.JsonNode.floatValue.

Method similar to floatValue(), but that will return specified defaultValue if this node cannot be converted to float.

Annotations
@Override
floatValueOptback to summary
public abstract Optional<Float> floatValueOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.floatValueOpt.

Doc from tools.jackson.databind.JsonNode.floatValueOpt.

Method similar to floatValue(), but that will return empty Optional<Float> (Optional.empty()) if this node cannot be converted to Java float.

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

Implements abstract tools.jackson.databind.JsonNode.getNodeType.

Doc from tools.jackson.databind.JsonNode.getNodeType.

Return the type of this node

Annotations
@Override
hasFractionalPartback to summary
public abstract boolean hasFractionalPart()

Convenience method for checking whether this node is a NumericFPNode that contains non-zero fractional part (as opposed to only integer part). Always returns false for integral NumericNodes (that is, {@ode NumericIntNode}s).

inIntRangeback to summary
public abstract boolean inIntRange()

Method that can be used to determine whether this numeric value's in part fits within Java 32-bitint type.

inLongRangeback to summary
public abstract boolean inLongRange()

Method that can be used to determine whether this numeric value's in part fits within Java 64-bit long type.

inShortRangeback to summary
public abstract boolean inShortRange()

Method that can be used to determine whether this numeric value's in part fits within Java 16-bit short type.

intValueback to summary
public abstract int intValue()

Overrides tools.jackson.databind.node.BaseJsonNode.intValue.

Doc from tools.jackson.databind.JsonNode.intValue.

Method that will try to access value of this node as a Java int: but if node value cannot be expressed exactly as an int, a JsonNodeException will be thrown. Access works for following cases:

  • JSON Integer values that fit in Java 32-bit signed int range
  • JSON Floating-point values that fit in Java 32-bit signed int range AND do not have fractional part.

Note

for more lenient conversions, use asInt()

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

Overrides tools.jackson.databind.node.BaseJsonNode.intValue.

Doc from tools.jackson.databind.JsonNode.intValue.

Method similar to intValue(), but that will return specified defaultValue if this node cannot be converted to Java int.

Annotations
@Override
intValueOptback to summary
public abstract OptionalInt intValueOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.intValueOpt.

Doc from tools.jackson.databind.JsonNode.intValueOpt.

Method similar to intValue(), but that will return empty OptionalInt (OptionalInt.empty()) if this node cannot be converted to Java int.

Annotations
@Override
isNaNback to summary
public abstract boolean isNaN()

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

longValueback to summary
public abstract long longValue()

Overrides tools.jackson.databind.node.BaseJsonNode.longValue.

Doc from tools.jackson.databind.JsonNode.longValue.

Method that will try to access value of this node as a Java long: but if node value cannot be expressed exactly as a long, a JsonNodeException will be thrown. Access works for following cases:

  • JSON Integer values that fit in Java 64-bit signed long range
  • JSON Floating-point values that fit in Java 64-bit signed long range AND do not have fractional part.

Note

for more lenient conversions, use asLong()

Annotations
@Override
longValueback to summary
public abstract long longValue(long defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.longValue.

Doc from tools.jackson.databind.JsonNode.longValue.

Method similar to longValue(), but that will return specified defaultValue if this node cannot be converted to long.

Annotations
@Override
longValueOptback to summary
public abstract OptionalLong longValueOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.longValueOpt.

Doc from tools.jackson.databind.JsonNode.longValueOpt.

Method similar to longValue(), but that will return empty OptionalLong (OptionalLong.empty()) if this node cannot be converted to Java long.

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

Redeclares tools.jackson.core.TreeNode.numberType.

Overrides tools.jackson.databind.node.BaseJsonNode.numberType.

Doc from tools.jackson.databind.node.BaseJsonNode.numberType.

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

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

Overrides tools.jackson.databind.node.BaseJsonNode.numberValue.

Doc from tools.jackson.databind.JsonNode.numberValue.

Method that will try to access value of this node as Number that accurately represents its value, if (and only if) this is a number node (returns true for isNumber). If this node is NOT a number node, a JsonNodeException will be thrown.

Annotations
@Override
shortValueback to summary
public abstract short shortValue()

Overrides tools.jackson.databind.node.BaseJsonNode.shortValue.

Doc from tools.jackson.databind.JsonNode.shortValue.

Method that will try to access value of this node as 16-bit signed integer value (Java short): but if node value cannot be expressed exactly as a short, a JsonNodeException will be thrown. Access works for following cases:

  • JSON Integer values that fit in Java 16-bit signed short range
  • JSON Floating-point values that fit in Java 16-bit signed short range AND do not have fractional part.

Annotations
@Override
shortValueback to summary
public abstract short shortValue(short defaultValue)

Overrides tools.jackson.databind.node.BaseJsonNode.shortValue.

Doc from tools.jackson.databind.JsonNode.shortValue.

Method similar to shortValue(), but that will return specified defaultValue if this node cannot be converted to Java short.

Annotations
@Override
shortValueOptback to summary
public abstract Optional<Short> shortValueOpt()

Overrides tools.jackson.databind.node.BaseJsonNode.shortValueOpt.

Doc from tools.jackson.databind.JsonNode.shortValueOpt.

Method similar to shortValue(), but that will return empty Optional<Short> (Optional.empty()) if this node cannot be converted to Java short.

Annotations
@Override