- All Implemented Interfaces:
Serializable,Iterable<JsonNode>,TreeNode,JacksonSerializable
Numeric node that contains values that do not fit in simple
floating point (double) values.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class tools.jackson.databind.JsonNode
JsonNode.OverwriteModeNested classes/interfaces inherited from interface tools.jackson.databind.JacksonSerializable
JacksonSerializable.Base -
Field Summary
FieldsFields inherited from class tools.jackson.databind.node.ValueNode
BD_MAX_INTEGER, BD_MAX_LONG, BD_MAX_SHORT, BD_MIN_INTEGER, BD_MIN_LONG, BD_MIN_SHORT, BI_MAX_INTEGER, BI_MAX_LONG, BI_MAX_SHORT, BI_MIN_INTEGER, BI_MIN_LONG, BI_MIN_SHORT, MISSINGFields inherited from class tools.jackson.databind.node.BaseJsonNode
OPT_FALSE, OPT_TRUE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected BigIntegerMethod for sub-classes to implement; returns the underlying value as aBigIntegerwithout any checks (wrt NaN), so caller must ensure validity prior to callingprotected BigDecimalMethod for sub-classes to implement; returns the underlying value as aBigDecimalwithout any checks (wrt NaN), so caller must ensure validity prior to callingintMethod for sub-classes to implement; returns the underlying value as aintwithout any checks (wrt NaN or value range), so caller must ensure validity prior to callinglongMethod for sub-classes to implement; returns the underlying value as alongwithout any checks (wrt NaN or value range), so caller must ensure validity prior to callingshortMethod for sub-classes to implement; returns the underlying value as ashortwithout any checks (wrt NaN or value range), so caller must ensure validity prior to callingMethod sub-classes should override if they can produceStringvalues viaBaseJsonNode.asString()-- if not, returnnull(in which case appropriate error will be thrown or default value returned).Method that will try to access value of this node as aBigDecimal: but if node value cannot be expressed exactly as aBigDecimal, aJsonNodeExceptionwill be thrown.asDecimal(BigDecimal defaultValue) Method similar toJsonNode.asDecimal(), but that will returndefaultValueif this node cannot be coerced to JavaBigDecimal.Method similar toJsonNode.asDecimal(), but that will return emptyOptional(Optional.empty()) if this node cannot be coerced toBigDecimal.doubleasDouble()Method similar toJsonNode.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 to0.0d) POJO nodes that contain Number valuesdoubleasDouble(double defaultValue) Method similar toJsonNode.asDouble(), but that will returndefaultValueif this node cannot be coerced todouble.Method similar toJsonNode.asDouble(), but that will return (OptionalDouble.empty()) if this node cannot be coerced todouble.floatasFloat()Method similar toJsonNode.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 to0.0f) POJO nodes that contain Number valuesfloatasFloat(float defaultValue) Method similar toJsonNode.asFloat(), but that will returndefaultValueif this node cannot be coerced tofloat.Method similar toJsonNode.asFloat(), but that will return (Optional.empty()) if this node cannot be coerced tofloat.Method that will try to access value of this node as a JavaBigDecimal: but if node value cannot be expressed exactly as aBigDecimal, aJsonNodeExceptionwill be thrown.decimalValue(BigDecimal defaultValue) Method similar toJsonNode.decimalValue(), but that will returndefaultValueif this node cannot be coerced to JavaBigDecimal.Method similar toJsonNode.decimalValue(), but that will return emptyOptional(Optional.empty()) if this node cannot be coerced toBigDecimal.doubleMethod that will try to access value of this node as adouble: but if node value cannot be expressed exactly as adouble, aJsonNodeExceptionwill be thrown.doubledoubleValue(double defaultValue) Method similar toJsonNode.doubleValue(), but that will return specifieddefaultValueif this node cannot be converted todouble.Method similar toJsonNode.doubleValue(), but that will return emptyOptionalLong(OptionalDouble.empty()) if this node cannot be converted to Javadouble.booleanEquality for node objects is defined as full (deep) value equality.floatMethod that will try to access value of this node as a Javafloat: but if node value cannot be expressed exactly as afloat, aJsonNodeExceptionwill be thrown.floatfloatValue(float defaultValue) Method similar toJsonNode.floatValue(), but that will return specifieddefaultValueif this node cannot be converted tofloat.Method similar toJsonNode.floatValue(), but that will return emptyOptional<Float>(Optional.empty()) if this node cannot be converted to Javafloat.booleanConvenience method for checking whether this node is aNumericFPNodethat contains non-zero fractional part (as opposed to only integer part).inthashCode()booleanMethod that can be used to determine whether this numeric value's in part fits within Java 32-bitinttype.booleanMethod that can be used to determine whether this numeric value's in part fits within Java 64-bitlongtype.booleanMethod that can be used to determine whether this numeric value's in part fits within Java 16-bitshorttype.booleanbooleanisNaN()Convenience method for checking whether this node is aFloatNodeorDoubleNodethat contains "not-a-number" (NaN) value.Returns code that identifies type of underlying numeric value, if (and only if) node is a number node.Method that will try to access value of this node asNumberthat accurately represents its value, if (and only if) this is a number node (returnstrueforJsonNode.isNumber()).final voidserialize(JsonGenerator g, SerializationContext provider) Method called to serialize node instances using given generator.static DecimalNodeMethods inherited from class tools.jackson.databind.node.NumericFPNode
asBigInteger, asBigInteger, asBigIntegerOpt, asInt, asInt, asIntOpt, asLong, asLong, asLongOpt, asShort, asShort, asShortOpt, asToken, bigIntegerValue, bigIntegerValue, bigIntegerValueOpt, canConvertToExactIntegral, canConvertToInt, canConvertToLong, canConvertToShort, intValue, intValue, intValueOpt, isFloatingPointNumber, longValue, longValue, longValueOpt, shortValue, shortValue, shortValueOptMethods inherited from class tools.jackson.databind.node.NumericNode
_valueDesc, deepCopy, getNodeTypeMethods inherited from class tools.jackson.databind.node.ValueNode
_at, findParent, findParents, findValue, findValues, findValuesAsString, get, get, has, has, hasNonNull, hasNonNull, isEmpty, path, path, serializeWithTypeMethods inherited from class tools.jackson.databind.node.BaseJsonNode
_asBoolean, _jsonPointerIfValid, _reportBigDecimalCoercionNaNFail, _reportBigIntegerCoercionFractionFail, _reportBigIntegerCoercionNaNFail, _reportCoercionFail, _reportDoubleCoercionRangeFail, _reportFloatCoercionRangeFail, _reportIntCoercionFractionFail, _reportIntCoercionNaNFail, _reportIntCoercionRangeFail, _reportLongCoercionFractionFail, _reportLongCoercionNaNFail, _reportLongCoercionRangeFail, _reportShortCoercionFractionFail, _reportShortCoercionRangeFail, _reportWrongNodeType, _withArray, _withObject, _withXxxMayReplace, _withXxxVerifyReplace, asBoolean, asBoolean, asBooleanOpt, asString, asString, asStringOpt, binaryValue, booleanValue, booleanValue, booleanValueOpt, findPath, isEmbeddedValue, isMissingNode, required, required, stringValue, stringValue, stringValueOpt, toPrettyString, toString, traverse, withArray, withObjectMethods inherited from class tools.jackson.databind.JsonNode
_reportRequiredViolation, _reportUnsupportedOperation, _this, asOptional, asText, asText, at, at, equals, findParents, findValues, findValuesAsString, forEachEntry, isArray, isBigInteger, isBinary, isBoolean, isContainer, isDouble, isFloat, isInt, isIntegralNumber, isLong, isNull, isNumber, isObject, isPojo, isShort, isString, isTextual, isValueNode, iterator, optional, optional, properties, propertyNames, propertyStream, require, requiredAt, requiredAt, requireNonNull, size, spliterator, textValue, values, valueStream, withArray, withArray, withArray, withArrayProperty, withObject, withObject, withObject, withObjectPropertyMethods inherited from class tools.jackson.databind.JacksonSerializable.Base
isEmpty
-
Field Details
-
ZERO
-
_value
-
-
Constructor Details
-
DecimalNode
-
-
Method Details
-
valueOf
-
numberType
Description copied from class:BaseJsonNodeReturns code that identifies type of underlying numeric value, if (and only if) node is a number node.- Specified by:
numberTypein interfaceTreeNode- Specified by:
numberTypein classNumericNode
-
isBigDecimal
public boolean isBigDecimal()- Overrides:
isBigDecimalin classJsonNode
-
isNaN
public boolean isNaN()Description copied from class:NumericNodeConvenience method for checking whether this node is aFloatNodeorDoubleNodethat contains "not-a-number" (NaN) value.- Specified by:
isNaNin classNumericNode
-
_asString
Description copied from class:BaseJsonNodeMethod sub-classes should override if they can produceStringvalues viaBaseJsonNode.asString()-- if not, returnnull(in which case appropriate error will be thrown or default value returned).- Specified by:
_asStringin classNumericNode- Returns:
- Coerced value if possible; otherwise
nullto indicate this node cannot be coerced.
-
numberValue
Description copied from class:JsonNodeMethod that will try to access value of this node asNumberthat accurately represents its value, if (and only if) this is a number node (returnstrueforJsonNode.isNumber()). If this node is NOT a number node, aJsonNodeExceptionwill be thrown.- Specified by:
numberValuein classNumericNode- Returns:
- Number value this node contains, if numeric node
-
floatValue
public float floatValue()Description copied from class:JsonNodeMethod that will try to access value of this node as a Javafloat: but if node value cannot be expressed exactly as afloat, aJsonNodeExceptionwill be thrown. Access works for following cases:- JSON Floating-point values that fit in Java 32-bit
doublerange - JSON Integer values that fit in Java 32-bit
doublerange
- Specified by:
floatValuein classNumericNode- Returns:
Floatvalue this node represents, if possible to accurately represent
- JSON Floating-point values that fit in Java 32-bit
-
floatValue
public float floatValue(float defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.floatValue(), but that will return specifieddefaultValueif this node cannot be converted tofloat.- Specified by:
floatValuein classNumericNode- Parameters:
defaultValue- Value to return if this node cannot be converted tofloat- Returns:
floatvalue this node represents, if possible to accurately represent;defaultValueotherwise
-
floatValueOpt
Description copied from class:JsonNodeMethod similar toJsonNode.floatValue(), but that will return emptyOptional<Float>(Optional.empty()) if this node cannot be converted to Javafloat.- Specified by:
floatValueOptin classNumericNode- Returns:
- Java
floatvalue this node represents, asOptional<Float>, if possible to accurately represent;Optional.empty()otherwise
-
asFloat
public float asFloat()Description copied from class:JsonNodeMethod similar toJsonNode.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
- Specified by:
asFloatin classNumericNode- Returns:
floatvalue this node represents, if possible to accurately represent
-
asFloat
public float asFloat(float defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.asFloat(), but that will returndefaultValueif this node cannot be coerced tofloat.- Specified by:
asFloatin classNumericNode- Returns:
floatvalue this node represents, if possible to accurately represent;defaultValueotherwise
-
asFloatOpt
Description copied from class:JsonNodeMethod similar toJsonNode.asFloat(), but that will return (Optional.empty()) if this node cannot be coerced tofloat.- Specified by:
asFloatOptin classNumericNode- Returns:
Optional<Float>value this node represents, if possible to accurately represent;Optional.empty()otherwise
-
doubleValue
public double doubleValue()Description copied from class:JsonNodeMethod that will try to access value of this node as adouble: but if node value cannot be expressed exactly as adouble, aJsonNodeExceptionwill be thrown. Access works for following cases:- JSON Floating-point values that fit in Java 64-bit
doublerange - JSON Integer values that fit in Java 64-bit
doublerange
NOTE: for more lenient conversions, use
JsonNode.asDouble()- Specified by:
doubleValuein classNumericNode- Returns:
Doublevalue this node represents, if possible to accurately represent
- JSON Floating-point values that fit in Java 64-bit
-
doubleValue
public double doubleValue(double defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.doubleValue(), but that will return specifieddefaultValueif this node cannot be converted todouble.- Specified by:
doubleValuein classNumericNode- Parameters:
defaultValue- Value to return if this node cannot be converted todouble- Returns:
doublevalue this node represents, if possible to accurately represent;defaultValueotherwise
-
doubleValueOpt
Description copied from class:JsonNodeMethod similar toJsonNode.doubleValue(), but that will return emptyOptionalLong(OptionalDouble.empty()) if this node cannot be converted to Javadouble.- Specified by:
doubleValueOptin classNumericNode- Returns:
- Java
doublevalue this node represents, asOptionalDouble, if possible to accurately represent;OptionalDouble.empty()otherwise
-
asDouble
public double asDouble()Description copied from class:JsonNodeMethod similar toJsonNode.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
- Specified by:
asDoublein classNumericNode- Returns:
doublevalue this node represents, if possible to accurately represent
-
asDouble
public double asDouble(double defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.asDouble(), but that will returndefaultValueif this node cannot be coerced todouble.- Specified by:
asDoublein classNumericNode- Returns:
doublevalue this node represents, if possible to accurately represent;defaultValueotherwise
-
asDoubleOpt
Description copied from class:JsonNodeMethod similar toJsonNode.asDouble(), but that will return (OptionalDouble.empty()) if this node cannot be coerced todouble.- Specified by:
asDoubleOptin classNumericNode- Returns:
OptionalDoublevalue this node represents, if possible to accurately represent;OptionalDouble.empty()otherwise
-
decimalValue
Description copied from class:JsonNodeMethod that will try to access value of this node as a JavaBigDecimal: but if node value cannot be expressed exactly as aBigDecimal, aJsonNodeExceptionwill be thrown. Access works for following cases:- All JSON Number values
NOTE: for more lenient conversions, use
JsonNode.asDecimal()- Overrides:
decimalValuein classNumericFPNode- Returns:
BigDecimalvalue this node represents, if possible to accurately represent
-
decimalValue
Description copied from class:JsonNodeMethod similar toJsonNode.decimalValue(), but that will returndefaultValueif this node cannot be coerced to JavaBigDecimal.- Overrides:
decimalValuein classNumericFPNode- Returns:
BigDecimalvalue this node represents, if possible to accurately represent;defaultValueotherwise
-
decimalValueOpt
Description copied from class:JsonNodeMethod similar toJsonNode.decimalValue(), but that will return emptyOptional(Optional.empty()) if this node cannot be coerced toBigDecimal.- Overrides:
decimalValueOptin classNumericFPNode- Returns:
- Java
BigDecimalvalue this node represents, asOptional<BigDecimal>, if possible to accurately represent;Optional.empty()otherwise
-
asDecimal
Description copied from class:JsonNodeMethod that will try to access value of this node as aBigDecimal: but if node value cannot be expressed exactly as aBigDecimal, aJsonNodeExceptionwill 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
- Overrides:
asDecimalin classNumericFPNode- Returns:
BigDecimalvalue this node represents, if possible to accurately represent
-
asDecimal
Description copied from class:JsonNodeMethod similar toJsonNode.asDecimal(), but that will returndefaultValueif this node cannot be coerced to JavaBigDecimal.- Overrides:
asDecimalin classNumericFPNode- Returns:
BigDecimalvalue this node represents, if possible to accurately represent;defaultValueotherwise
-
asDecimalOpt
Description copied from class:JsonNodeMethod similar toJsonNode.asDecimal(), but that will return emptyOptional(Optional.empty()) if this node cannot be coerced toBigDecimal.- Overrides:
asDecimalOptin classNumericFPNode- Returns:
- Java
BigDecimalvalue this node represents, asOptional<BigDecimal>, if possible to accurately represent;Optional.empty()otherwise
-
_asShortValueUnchecked
public short _asShortValueUnchecked()Description copied from class:NumericNodeMethod for sub-classes to implement; returns the underlying value as ashortwithout any checks (wrt NaN or value range), so caller must ensure validity prior to calling- Specified by:
_asShortValueUncheckedin classNumericNode
-
_asIntValueUnchecked
public int _asIntValueUnchecked()Description copied from class:NumericNodeMethod for sub-classes to implement; returns the underlying value as aintwithout any checks (wrt NaN or value range), so caller must ensure validity prior to calling- Specified by:
_asIntValueUncheckedin classNumericNode
-
_asLongValueUnchecked
public long _asLongValueUnchecked()Description copied from class:NumericNodeMethod for sub-classes to implement; returns the underlying value as alongwithout any checks (wrt NaN or value range), so caller must ensure validity prior to calling- Specified by:
_asLongValueUncheckedin classNumericNode
-
_asBigIntegerValueUnchecked
Description copied from class:NumericFPNodeMethod for sub-classes to implement; returns the underlying value as aBigIntegerwithout any checks (wrt NaN), so caller must ensure validity prior to calling- Specified by:
_asBigIntegerValueUncheckedin classNumericFPNode
-
_asDecimalValueUnchecked
Description copied from class:NumericFPNodeMethod for sub-classes to implement; returns the underlying value as aBigDecimalwithout any checks (wrt NaN), so caller must ensure validity prior to calling- Specified by:
_asDecimalValueUncheckedin classNumericFPNode
-
hasFractionalPart
public boolean hasFractionalPart()Description copied from class:NumericNodeConvenience method for checking whether this node is aNumericFPNodethat contains non-zero fractional part (as opposed to only integer part). Always returns false for integralNumericNodes (that is, s).- Specified by:
hasFractionalPartin classNumericNode
-
inShortRange
public boolean inShortRange()Description copied from class:NumericNodeMethod that can be used to determine whether this numeric value's in part fits within Java 16-bitshorttype.- Specified by:
inShortRangein classNumericNode
-
inIntRange
public boolean inIntRange()Description copied from class:NumericNodeMethod that can be used to determine whether this numeric value's in part fits within Java 32-bitinttype.- Specified by:
inIntRangein classNumericNode
-
inLongRange
public boolean inLongRange()Description copied from class:NumericNodeMethod that can be used to determine whether this numeric value's in part fits within Java 64-bitlongtype.- Specified by:
inLongRangein classNumericNode
-
serialize
Description copied from class:BaseJsonNodeMethod called to serialize node instances using given generator.- Specified by:
serializein interfaceJacksonSerializable- Specified by:
serializein classBaseJsonNode- Throws:
JacksonException
-
equals
Description copied from class:JsonNodeEquality for node objects is defined as full (deep) value equality. This means that it is possible to compare complete JSON trees for equality by comparing equality of root nodes.Note: marked as abstract to ensure all implementation classes define it properly and not rely on definition from
Object. -
hashCode
public int hashCode()- Specified by:
hashCodein classBaseJsonNode
-