public abstract class NumericNode extends ValueNode
NO_NODES, NO_STRINGS| Modifier | Constructor and Description |
|---|---|
protected |
NumericNode() |
| Modifier and Type | Method and Description |
|---|---|
double |
asDouble()
Method that will try to convert value of this node to a Java double.
|
double |
asDouble(double defaultValue)
Method that will try to convert value of this node to a Java double.
|
int |
asInt()
Method that will try to convert value of this node to a Java int.
|
int |
asInt(int defaultValue)
Method that will try to convert value of this node to a Java int.
|
long |
asLong()
Method that will try to convert value of this node to a Java long.
|
long |
asLong(long defaultValue)
Method that will try to convert value of this node to a Java long.
|
abstract String |
asText()
Method that will return valid String representation of
the container value, if the node is a value node
(method
JsonNode.isValueNode() returns true), otherwise
empty String. |
abstract BigInteger |
getBigIntegerValue() |
abstract BigDecimal |
getDecimalValue() |
abstract double |
getDoubleValue() |
abstract int |
getIntValue()
Returns integer value for this node, if and only if
this node is numeric (
JsonNode.isNumber() returns true). |
abstract long |
getLongValue() |
abstract JsonParser.NumberType |
getNumberType()
If this node is a numeric type (as per
JsonNode.isNumber()),
returns native type that node uses to store the numeric
value. |
abstract Number |
getNumberValue()
Returns numeric value for this node, if and only if
this node is numeric (
JsonNode.isNumber() returns true); otherwise
returns null |
boolean |
isNumber() |
asToken, isValueNode, path, path, serializeWithType, toStringfindParent, findParents, findPath, findValue, findValues, findValuesAsText, serialize, traverseasBoolean, asBoolean, equals, findParents, findValues, findValuesAsText, get, get, getBinaryValue, getBooleanValue, getElements, getFieldNames, getFields, getPath, getPath, getTextValue, getValueAsBoolean, getValueAsBoolean, getValueAsDouble, getValueAsDouble, getValueAsInt, getValueAsInt, getValueAsLong, getValueAsLong, getValueAsText, has, has, isArray, isBigDecimal, isBigInteger, isBinary, isBoolean, isContainerNode, isDouble, isFloatingPointNumber, isInt, isIntegralNumber, isLong, isMissingNode, isNull, isObject, isPojo, isTextual, iterator, size, withpublic final boolean isNumber()
public abstract JsonParser.NumberType getNumberType()
JsonNodeJsonNode.isNumber()),
returns native type that node uses to store the numeric
value.getNumberType in class BaseJsonNodepublic abstract Number getNumberValue()
JsonNodeJsonNode.isNumber() returns true); otherwise
returns nullgetNumberValue in class JsonNodepublic abstract int getIntValue()
JsonNodeJsonNode.isNumber() returns true). For other
types returns 0.
For floating-point numbers, value is truncated using default
Java coercion, similar to how cast from double to int operates.getIntValue in class JsonNodepublic abstract long getLongValue()
getLongValue in class JsonNodepublic abstract double getDoubleValue()
getDoubleValue in class JsonNodepublic abstract BigDecimal getDecimalValue()
getDecimalValue in class JsonNodepublic abstract BigInteger getBigIntegerValue()
getBigIntegerValue in class JsonNodepublic abstract String asText()
JsonNodeJsonNode.isValueNode() returns true), otherwise
empty String.public int asInt()
JsonNodeIf representation can not be converted to an int (including structured types like Objects and Arrays), default value of 0 will be returned; no exceptions are thrown.
public int asInt(int defaultValue)
JsonNodeIf representation can not be converted to an int (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.
public long asLong()
JsonNodeIf representation can not be converted to an long (including structured types like Objects and Arrays), default value of 0 will be returned; no exceptions are thrown.
public long asLong(long defaultValue)
JsonNodeIf representation can not be converted to an long (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.
public double asDouble()
JsonNodeIf representation can not be converted to an int (including structured types like Objects and Arrays), default value of 0.0 will be returned; no exceptions are thrown.
public double asDouble(double defaultValue)
JsonNodeIf representation can not be converted to an int (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.