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 a valid String representation of
the container value, if the node is a value node
(method
JsonNode.isValueNode() returns true),
otherwise empty String. |
abstract BigInteger |
bigIntegerValue() |
abstract boolean |
canConvertToInt()
Method that can be used to check whether this node is a numeric
node (
JsonNode.isNumber() would return true) AND its value fits
within Java's 32-bit signed integer type, int. |
abstract boolean |
canConvertToLong()
Method that can be used to check whether this node is a numeric
node (
JsonNode.isNumber() would return true) AND its value fits
within Java's 64-bit signed integer type, long. |
abstract BigDecimal |
decimalValue() |
abstract double |
doubleValue() |
abstract int |
intValue()
Returns integer value for this node, if and only if
this node is numeric (
JsonNode.isNumber() returns true). |
boolean |
isNumber() |
abstract long |
longValue() |
abstract JsonParser.NumberType |
numberType()
Returns code that identifies type of underlying numeric
value, if (and only if) node is a number node.
|
abstract Number |
numberValue()
Returns numeric value for this node, if and only if
this node is numeric (
JsonNode.isNumber() returns true); otherwise
returns null |
asToken, deepCopy, isValueNode, path, path, serializeWithType, toStringfindParent, findParents, findPath, findValue, findValues, findValuesAsText, serialize, traverseasBoolean, asBoolean, binaryValue, booleanValue, elements, equals, fieldNames, fields, findParents, findValues, findValuesAsText, get, get, has, has, hasNonNull, hasNonNull, isArray, isBigDecimal, isBigInteger, isBinary, isBoolean, isContainerNode, isDouble, isFloatingPointNumber, isInt, isIntegralNumber, isLong, isMissingNode, isNull, isObject, isPojo, isTextual, iterator, size, textValue, with, withArraypublic final boolean isNumber()
public abstract JsonParser.NumberType numberType()
BaseJsonNodenumberType in interface TreeNodenumberType in class BaseJsonNodepublic abstract Number numberValue()
JsonNodeJsonNode.isNumber() returns true); otherwise
returns nullnumberValue in class JsonNodepublic abstract int intValue()
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.public abstract double doubleValue()
doubleValue in class JsonNodepublic abstract BigDecimal decimalValue()
decimalValue in class JsonNodepublic abstract BigInteger bigIntegerValue()
bigIntegerValue in class JsonNodepublic abstract boolean canConvertToInt()
JsonNodeJsonNode.isNumber() would return true) AND its value fits
within Java's 32-bit signed integer type, int.
Note that floating-point numbers are convertible if the integral
part fits without overflow (as per standard Java coercion rules)canConvertToInt in class JsonNodepublic abstract boolean canConvertToLong()
JsonNodeJsonNode.isNumber() would return true) AND its value fits
within Java's 64-bit signed integer type, long.
Note that floating-point numbers are convertible if the integral
part fits without overflow (as per standard Java coercion rules)canConvertToLong in class JsonNodepublic abstract String asText()
JsonNodeJsonNode.isValueNode() returns true),
otherwise empty String.public final 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 final 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 final 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 final 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 final 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 final 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.
Copyright © 2012 FasterXML. All Rights Reserved.