- All Implemented Interfaces:
Serializable,Iterable<JsonNode>,TreeNode,JacksonSerializable
- Direct Known Subclasses:
NumericFPNode,NumericIntNode
- 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
Fields 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 TypeMethodDescriptionabstract intMethod 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 callingabstract longMethod 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 callingabstract shortMethod 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 callingprotected abstract StringMethod 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).protected final StringMethod for implementation classes to return a short description of contained value, to be used in error messages.abstract BigIntegerMethod similar toJsonNode.bigIntegerValue()but in addition to coercing Number values (same asJsonNode.bigIntegerValue()), will also try to coerce a couple of additional types (or cases): JSON Floating-point numbers with fractions (ones without fractions are ok forJsonNode.bigIntegerValue()) will be truncated to integer value (like withBigDecimal.toBigInteger())) JSON Strings that represent JSON Numbers ("stringified" numbers) JSON Null (converted to0)) POJO nodes that contain Number valuesabstract BigIntegerasBigInteger(BigInteger defaultValue) Method similar toJsonNode.asBigInteger(), but that will return specifieddefaultValueif this node cannot be converted toBigInteger.abstract Optional<BigInteger>Method similar toJsonNode.bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to JavaBigInteger.abstract BigDecimalMethod that will try to access value of this node as aBigDecimal: but if node value cannot be expressed exactly as aBigDecimal, aJsonNodeExceptionwill be thrown.abstract BigDecimalasDecimal(BigDecimal defaultValue) Method similar toJsonNode.asDecimal(), but that will returndefaultValueif this node cannot be coerced to JavaBigDecimal.abstract Optional<BigDecimal>Method similar toJsonNode.asDecimal(), but that will return emptyOptional(Optional.empty()) if this node cannot be coerced toBigDecimal.abstract 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 valuesabstract doubleasDouble(double defaultValue) Method similar toJsonNode.asDouble(), but that will returndefaultValueif this node cannot be coerced todouble.abstract OptionalDoubleMethod similar toJsonNode.asDouble(), but that will return (OptionalDouble.empty()) if this node cannot be coerced todouble.abstract 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 valuesabstract floatasFloat(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.abstract intasInt()Method similar toJsonNode.intValue()but in addition to coercing Number values (same asJsonNode.intValue()), will also try to coerce a couple of additional types (or cases): JSON Floating-point numbers with fractions (ones without fractions are ok forJsonNode.intValue()) will be truncated toint(if (and only if) they fit inintrange).abstract intasInt(int defaultValue) Method similar toJsonNode.intValue(), but that will return specifieddefaultValueif this node cannot be converted toint.abstract OptionalIntasIntOpt()Method similar toJsonNode.asInt(), but that will return (OptionalInt.empty()) if this node cannot be coerced toint.abstract longasLong()Method similar toJsonNode.longValue()but in addition to coercing Number values (same asJsonNode.longValue()), will also try to coerce a couple of additional types (or cases): JSON Floating-point numbers with fractions (ones without fractions are ok forJsonNode.longValue()) will be truncated tolong(if (and only if) they fit inlongrange).abstract longasLong(long defaultValue) Method similar toJsonNode.asLong(), but that will return specifieddefaultValueif this node cannot be coerced tolong(instead of throwing an exception).abstract OptionalLongMethod similar toJsonNode.asLong(), but that will return (OptionalLong.empty()) if this node cannot be coerced tolong.abstract shortasShort()Method similar toJsonNode.shortValue()but in addition to coercing Number values (same asJsonNode.shortValue()), will also try to coerce a couple of additional types (or cases): JSON Floating-point numbers with fractions (ones without fractions are ok forJsonNode.shortValue()) will be truncated toshort(if (and only if) they fit inshortrange).abstract shortasShort(short defaultValue) Method similar toJsonNode.shortValue(), but that will return specifieddefaultValueif this node cannot be converted toshort.Method similar toJsonNode.asShort(), but that will return (Optional.empty()) if this node cannot be coerced toshort.abstract BigIntegerMethod that will try to access value of this node as aBigInteger, but if node value cannot be expressed exactly as aBigInteger, aJsonNodeExceptionwill be thrown.abstract BigIntegerbigIntegerValue(BigInteger defaultValue) Method similar toJsonNode.bigIntegerValue(), but that will return specifieddefaultValueif this node cannot be converted to JavaBigInteger.abstract Optional<BigInteger>Method similar toJsonNode.bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to JavaBigInteger.abstract booleanMethod that can be used to check whether this node is a numeric node (JsonNode.isNumber()would return true) AND can be converted without loss toint(that is, its value fits in Java's 32-bit signed integer type,intand if it is a floating-point number, it does not have fractional part).abstract booleanMethod that can be used to check whether this node is a numeric node (JsonNode.isNumber()would return true) AND can be converted without loss tolong(that is, its value fits in Java's 64-bit signed integer type,longand if it is a floating-point number, it does not have fractional part).abstract booleanMethod that can be used to check whether this node is a numeric node (JsonNode.isNumber()would return true) AND can be converted without loss toshort(that is, its value fits in Java's 16-bit signed integer type,shortand if it is a floating-point number, it does not have fractional part).abstract BigDecimalMethod 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.abstract BigDecimaldecimalValue(BigDecimal defaultValue) Method similar toJsonNode.decimalValue(), but that will returndefaultValueif this node cannot be coerced to JavaBigDecimal.abstract Optional<BigDecimal>Method similar toJsonNode.decimalValue(), but that will return emptyOptional(Optional.empty()) if this node cannot be coerced toBigDecimal.deepCopy()All current value nodes are immutable, so we can just return them as is.abstract 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.abstract doubledoubleValue(double defaultValue) Method similar toJsonNode.doubleValue(), but that will return specifieddefaultValueif this node cannot be converted todouble.abstract OptionalDoubleMethod similar toJsonNode.doubleValue(), but that will return emptyOptionalLong(OptionalDouble.empty()) if this node cannot be converted to Javadouble.abstract 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.abstract 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.final JsonNodeTypeReturn the type of this nodeabstract booleanConvenience method for checking whether this node is aNumericFPNodethat contains non-zero fractional part (as opposed to only integer part).abstract booleanMethod that can be used to determine whether this numeric value's in part fits within Java 32-bitinttype.abstract booleanMethod that can be used to determine whether this numeric value's in part fits within Java 64-bitlongtype.abstract booleanMethod that can be used to determine whether this numeric value's in part fits within Java 16-bitshorttype.abstract intintValue()Method that will try to access value of this node as a Javaint: but if node value cannot be expressed exactly as anint, aJsonNodeExceptionwill be thrown.abstract intintValue(int defaultValue) Method similar toJsonNode.intValue(), but that will return specifieddefaultValueif this node cannot be converted to Javaint.abstract OptionalIntMethod similar toJsonNode.intValue(), but that will return emptyOptionalInt(OptionalInt.empty()) if this node cannot be converted to Javaint.abstract booleanisNaN()Convenience method for checking whether this node is aFloatNodeorDoubleNodethat contains "not-a-number" (NaN) value.abstract longMethod that will try to access value of this node as a Javalong: but if node value cannot be expressed exactly as along, aJsonNodeExceptionwill be thrown.abstract longlongValue(long defaultValue) Method similar toJsonNode.longValue(), but that will return specifieddefaultValueif this node cannot be converted tolong.abstract OptionalLongMethod similar toJsonNode.longValue(), but that will return emptyOptionalLong(OptionalLong.empty()) if this node cannot be converted to Javalong.abstract JsonParser.NumberTypeReturns code that identifies type of underlying numeric value, if (and only if) node is a number node.abstract NumberMethod 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()).abstract shortMethod that will try to access value of this node as 16-bit signed integer value (Javashort): but if node value cannot be expressed exactly as ashort, aJsonNodeExceptionwill be thrown.abstract shortshortValue(short defaultValue) Method similar toJsonNode.shortValue(), but that will return specifieddefaultValueif this node cannot be converted to Javashort.Method similar toJsonNode.shortValue(), but that will return emptyOptional<Short>(Optional.empty()) if this node cannot be converted to Javashort.Methods inherited from class tools.jackson.databind.node.ValueNode
_at, asToken, 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, hashCode, isEmbeddedValue, isMissingNode, required, required, serialize, stringValue, stringValue, stringValueOpt, toPrettyString, toString, traverse, withArray, withObjectMethods inherited from class tools.jackson.databind.JsonNode
_reportRequiredViolation, _reportUnsupportedOperation, _this, asOptional, asText, asText, at, at, canConvertToExactIntegral, equals, equals, findParents, findValues, findValuesAsString, forEachEntry, isArray, isBigDecimal, isBigInteger, isBinary, isBoolean, isContainer, isDouble, isFloat, isFloatingPointNumber, 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
-
Constructor Details
-
NumericNode
protected NumericNode()
-
-
Method Details
-
getNodeType
Description copied from class:JsonNodeReturn the type of this node- Specified by:
getNodeTypein classJsonNode- Returns:
- the node type as a
JsonNodeTypeenum value
-
deepCopy
Description copied from class:ValueNodeAll current value nodes are immutable, so we can just return them as is. -
_valueDesc
Description copied from class:BaseJsonNodeMethod for implementation classes to return a short description of contained value, to be used in error messages.- Specified by:
_valueDescin classBaseJsonNode
-
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- Overrides:
numberTypein classBaseJsonNode
-
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.- Overrides:
numberValuein classBaseJsonNode- Returns:
- Number value this node contains, if numeric node
-
shortValue
public abstract short shortValue()Description copied from class:JsonNodeMethod that will try to access value of this node as 16-bit signed integer value (Javashort): but if node value cannot be expressed exactly as ashort, aJsonNodeExceptionwill be thrown. Access works for following cases:- JSON Integer values that fit in Java 16-bit signed
shortrange - JSON Floating-point values that fit in Java 16-bit signed
shortrange AND do not have fractional part.
- Overrides:
shortValuein classBaseJsonNode- Returns:
Shortvalue this node represents, if possible to accurately represent
- JSON Integer values that fit in Java 16-bit signed
-
shortValue
public abstract short shortValue(short defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.shortValue(), but that will return specifieddefaultValueif this node cannot be converted to Javashort.- Overrides:
shortValuein classBaseJsonNode- Parameters:
defaultValue- Value to return if this node cannot be converted to Javashort- Returns:
- Java
shortvalue this node represents, if possible to accurately represent;defaultValueotherwise
-
shortValueOpt
Description copied from class:JsonNodeMethod similar toJsonNode.shortValue(), but that will return emptyOptional<Short>(Optional.empty()) if this node cannot be converted to Javashort.- Overrides:
shortValueOptin classBaseJsonNode- Returns:
- Java
shortvalue this node represents, asOptional<Short>, if possible to accurately represent;Optional.empty()otherwise
-
asShort
public abstract short asShort()Description copied from class:JsonNodeMethod similar toJsonNode.shortValue()but in addition to coercing Number values (same asJsonNode.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
JsonNode.shortValue()) will be truncated toshort(if (and only if) they fit inshortrange). - JSON Strings that represent JSON Numbers ("stringified" numbers)
- JSON Null (converted to
0)) - POJO nodes that contain Number values
- Overrides:
asShortin classBaseJsonNode- Returns:
shortvalue this node represents, if possible to accurately represent
- JSON Floating-point numbers with fractions (ones without fractions
are ok for
-
asShort
public abstract short asShort(short defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.shortValue(), but that will return specifieddefaultValueif this node cannot be converted toshort.- Overrides:
asShortin classBaseJsonNode- Parameters:
defaultValue- Value to return if this node cannot be converted toshort- Returns:
shortvalue this node represents, if possible to accurately represent;defaultValueotherwise
-
asShortOpt
Description copied from class:JsonNodeMethod similar toJsonNode.asShort(), but that will return (Optional.empty()) if this node cannot be coerced toshort.- Overrides:
asShortOptin classBaseJsonNode- Returns:
Optional<Short>value this node represents, if possible to accurately represent;Optional.empty()otherwise
-
intValue
public abstract int intValue()Description copied from class:JsonNodeMethod that will try to access value of this node as a Javaint: but if node value cannot be expressed exactly as anint, aJsonNodeExceptionwill be thrown. Access works for following cases:- JSON Integer values that fit in Java 32-bit signed
intrange - JSON Floating-point values that fit in Java 32-bit signed
intrange AND do not have fractional part.
NOTE: for more lenient conversions, use
JsonNode.asInt()- Overrides:
intValuein classBaseJsonNode- Returns:
Intvalue this node represents, if possible to accurately represent
- JSON Integer values that fit in Java 32-bit signed
-
intValue
public abstract int intValue(int defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.intValue(), but that will return specifieddefaultValueif this node cannot be converted to Javaint.- Overrides:
intValuein classBaseJsonNode- Parameters:
defaultValue- Value to return if this node cannot be converted to Javaint- Returns:
- Java
intvalue this node represents, if possible to accurately represent;defaultValueotherwise
-
intValueOpt
Description copied from class:JsonNodeMethod similar toJsonNode.intValue(), but that will return emptyOptionalInt(OptionalInt.empty()) if this node cannot be converted to Javaint.- Overrides:
intValueOptin classBaseJsonNode- Returns:
- Java
intvalue this node represents, asOptionalInt, if possible to accurately represent;OptionalInt.empty()otherwise
-
asInt
public abstract int asInt()Description copied from class:JsonNodeMethod similar toJsonNode.intValue()but in addition to coercing Number values (same asJsonNode.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
JsonNode.intValue()) will be truncated toint(if (and only if) they fit inintrange). - JSON Strings that represent JSON Numbers ("stringified" numbers)
- JSON Null (converted to
0)) - POJO nodes that contain Number values
- Overrides:
asIntin classBaseJsonNode- Returns:
intvalue this node represents, if possible to accurately represent
- JSON Floating-point numbers with fractions (ones without fractions
are ok for
-
asInt
public abstract int asInt(int defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.intValue(), but that will return specifieddefaultValueif this node cannot be converted toint.- Overrides:
asIntin classBaseJsonNode- Parameters:
defaultValue- Value to return if this node cannot be converted toint- Returns:
intvalue this node represents, if possible to accurately represent;defaultValueotherwise
-
asIntOpt
Description copied from class:JsonNodeMethod similar toJsonNode.asInt(), but that will return (OptionalInt.empty()) if this node cannot be coerced toint.- Overrides:
asIntOptin classBaseJsonNode- Returns:
OptionalIntvalue this node represents, if possible to accurately represent;OptionalInt.empty()otherwise
-
longValue
public abstract long longValue()Description copied from class:JsonNodeMethod that will try to access value of this node as a Javalong: but if node value cannot be expressed exactly as along, aJsonNodeExceptionwill be thrown. Access works for following cases:- JSON Integer values that fit in Java 64-bit signed
longrange - JSON Floating-point values that fit in Java 64-bit signed
longrange AND do not have fractional part.
NOTE: for more lenient conversions, use
JsonNode.asLong()- Overrides:
longValuein classBaseJsonNode- Returns:
Longvalue this node represents, if possible to accurately represent
- JSON Integer values that fit in Java 64-bit signed
-
longValue
public abstract long longValue(long defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.longValue(), but that will return specifieddefaultValueif this node cannot be converted tolong.- Overrides:
longValuein classBaseJsonNode- Parameters:
defaultValue- Value to return if this node cannot be converted tolong- Returns:
longvalue this node represents, if possible to accurately represent;defaultValueotherwise
-
longValueOpt
Description copied from class:JsonNodeMethod similar toJsonNode.longValue(), but that will return emptyOptionalLong(OptionalLong.empty()) if this node cannot be converted to Javalong.- Overrides:
longValueOptin classBaseJsonNode- Returns:
- Java
longvalue this node represents, asOptionalLong, if possible to accurately represent;OptionalLong.empty()otherwise
-
asLong
public abstract long asLong()Description copied from class:JsonNodeMethod similar toJsonNode.longValue()but in addition to coercing Number values (same asJsonNode.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
JsonNode.longValue()) will be truncated tolong(if (and only if) they fit inlongrange). - JSON Strings that represent JSON Numbers ("stringified" numbers)
- JSON Null (converted to
0)) - POJO nodes that contain Number values
- Overrides:
asLongin classBaseJsonNode- Returns:
longvalue this node represents, if possible to accurately represent
- JSON Floating-point numbers with fractions (ones without fractions
are ok for
-
asLong
public abstract long asLong(long defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.asLong(), but that will return specifieddefaultValueif this node cannot be coerced tolong(instead of throwing an exception).- Overrides:
asLongin classBaseJsonNode- Parameters:
defaultValue- Value to return if this node cannot be coerced tolong- Returns:
longvalue this node represents, if possible to accurately represent;defaultValueotherwise
-
asLongOpt
Description copied from class:JsonNodeMethod similar toJsonNode.asLong(), but that will return (OptionalLong.empty()) if this node cannot be coerced tolong.- Overrides:
asLongOptin classBaseJsonNode- Returns:
OptionalLongvalue this node represents (or can be coerced to),OptionalLong.empty()otherwise
-
bigIntegerValue
Description copied from class:JsonNodeMethod that will try to access value of this node as aBigInteger, but if node value cannot be expressed exactly as aBigInteger, aJsonNodeExceptionwill be thrown. Access works for following cases:- JSON Integer values
- JSON Floating-point values that do not have fractional part.
- Overrides:
bigIntegerValuein classBaseJsonNode- Returns:
BigIntegervalue this node represents, if possible to accurately represent
-
bigIntegerValue
Description copied from class:JsonNodeMethod similar toJsonNode.bigIntegerValue(), but that will return specifieddefaultValueif this node cannot be converted to JavaBigInteger.- Overrides:
bigIntegerValuein classBaseJsonNode- Parameters:
defaultValue- Value to return if this node cannot be converted to JavaBigInteger- Returns:
- Java
BigIntegervalue this node represents, if possible to accurately represent;defaultValueotherwise
-
bigIntegerValueOpt
Description copied from class:JsonNodeMethod similar toJsonNode.bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to JavaBigInteger.- Overrides:
bigIntegerValueOptin classBaseJsonNode- Returns:
- Java
BigIntegervalue this node represents, asOptional<BigInteger>, if possible to accurately represent;Optional.empty()otherwise
-
asBigInteger
Description copied from class:JsonNodeMethod similar toJsonNode.bigIntegerValue()but in addition to coercing Number values (same asJsonNode.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
JsonNode.bigIntegerValue()) will be truncated to integer value (like withBigDecimal.toBigInteger())) - JSON Strings that represent JSON Numbers ("stringified" numbers)
- JSON Null (converted to
0)) - POJO nodes that contain Number values
- Overrides:
asBigIntegerin classBaseJsonNode- Returns:
BigIntegervalue this node represents, if possible to accurately convert;defaultValueotherwise
- JSON Floating-point numbers with fractions (ones without fractions
are ok for
-
asBigInteger
Description copied from class:JsonNodeMethod similar toJsonNode.asBigInteger(), but that will return specifieddefaultValueif this node cannot be converted toBigInteger.- Overrides:
asBigIntegerin classBaseJsonNode- Parameters:
defaultValue- Value to return if this node cannot be converted toBigInteger- Returns:
BigIntegervalue this node represents, if possible to accurately convert;defaultValueotherwise
-
asBigIntegerOpt
Description copied from class:JsonNodeMethod similar toJsonNode.bigIntegerValue(), but that will return empty (Optional.empty()) if this node cannot be converted to JavaBigInteger.- Overrides:
asBigIntegerOptin classBaseJsonNode- Returns:
BigIntegervalue this node represents, asOptional<BigInteger>, if possible to accurately represent;Optional.empty()otherwise.
-
floatValue
public abstract 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
- Overrides:
floatValuein classBaseJsonNode- Returns:
Floatvalue this node represents, if possible to accurately represent
- JSON Floating-point values that fit in Java 32-bit
-
floatValue
public abstract float floatValue(float defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.floatValue(), but that will return specifieddefaultValueif this node cannot be converted tofloat.- Overrides:
floatValuein classBaseJsonNode- 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.- Overrides:
floatValueOptin classBaseJsonNode- Returns:
- Java
floatvalue this node represents, asOptional<Float>, if possible to accurately represent;Optional.empty()otherwise
-
asFloat
public abstract 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
- Overrides:
asFloatin classBaseJsonNode- Returns:
floatvalue this node represents, if possible to accurately represent
-
asFloat
public abstract float asFloat(float defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.asFloat(), but that will returndefaultValueif this node cannot be coerced tofloat.- Overrides:
asFloatin classBaseJsonNode- 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.- Overrides:
asFloatOptin classBaseJsonNode- Returns:
Optional<Float>value this node represents, if possible to accurately represent;Optional.empty()otherwise
-
doubleValue
public abstract 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()- Overrides:
doubleValuein classBaseJsonNode- Returns:
Doublevalue this node represents, if possible to accurately represent
- JSON Floating-point values that fit in Java 64-bit
-
doubleValue
public abstract double doubleValue(double defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.doubleValue(), but that will return specifieddefaultValueif this node cannot be converted todouble.- Overrides:
doubleValuein classBaseJsonNode- 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.- Overrides:
doubleValueOptin classBaseJsonNode- Returns:
- Java
doublevalue this node represents, asOptionalDouble, if possible to accurately represent;OptionalDouble.empty()otherwise
-
asDouble
public abstract 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
- Overrides:
asDoublein classBaseJsonNode- Returns:
doublevalue this node represents, if possible to accurately represent
-
asDouble
public abstract double asDouble(double defaultValue) Description copied from class:JsonNodeMethod similar toJsonNode.asDouble(), but that will returndefaultValueif this node cannot be coerced todouble.- Overrides:
asDoublein classBaseJsonNode- 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.- Overrides:
asDoubleOptin classBaseJsonNode- 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 classBaseJsonNode- 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 classBaseJsonNode- 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 classBaseJsonNode- 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 classBaseJsonNode- 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 classBaseJsonNode- 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 classBaseJsonNode- Returns:
- Java
BigDecimalvalue this node represents, asOptional<BigDecimal>, if possible to accurately represent;Optional.empty()otherwise
-
canConvertToShort
public abstract boolean canConvertToShort()Description copied from class:JsonNodeMethod that can be used to check whether this node is a numeric node (JsonNode.isNumber()would return true) AND can be converted without loss toshort(that is, its value fits in Java's 16-bit signed integer type,shortand 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
JsonNode.asShort()could still succeed.- Overrides:
canConvertToShortin classJsonNode
-
canConvertToInt
public abstract boolean canConvertToInt()Description copied from class:JsonNodeMethod that can be used to check whether this node is a numeric node (JsonNode.isNumber()would return true) AND can be converted without loss toint(that is, its value fits in Java's 32-bit signed integer type,intand 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
JsonNode.asInt()could still succeed.- Overrides:
canConvertToIntin classJsonNode
-
canConvertToLong
public abstract boolean canConvertToLong()Description copied from class:JsonNodeMethod that can be used to check whether this node is a numeric node (JsonNode.isNumber()would return true) AND can be converted without loss tolong(that is, its value fits in Java's 64-bit signed integer type,longand 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
JsonNode.asLong()could still succeed.- Overrides:
canConvertToLongin classJsonNode
-
_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).- Overrides:
_asStringin classBaseJsonNode- Returns:
- Coerced value if possible; otherwise
nullto indicate this node cannot be coerced.
-
hasFractionalPart
public abstract boolean hasFractionalPart()Convenience 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). -
inShortRange
public abstract boolean inShortRange()Method that can be used to determine whether this numeric value's in part fits within Java 16-bitshorttype. -
inIntRange
public abstract boolean inIntRange()Method that can be used to determine whether this numeric value's in part fits within Java 32-bitinttype. -
inLongRange
public abstract boolean inLongRange()Method that can be used to determine whether this numeric value's in part fits within Java 64-bitlongtype. -
isNaN
public abstract boolean isNaN()Convenience method for checking whether this node is aFloatNodeorDoubleNodethat contains "not-a-number" (NaN) value. -
_asShortValueUnchecked
public abstract short _asShortValueUnchecked()Method 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 -
_asIntValueUnchecked
public abstract int _asIntValueUnchecked()Method 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 -
_asLongValueUnchecked
public abstract long _asLongValueUnchecked()Method 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
-