Class NumericNode
- java.lang.Object
-
- org.codehaus.jackson.JsonNode
-
- org.codehaus.jackson.node.BaseJsonNode
-
- org.codehaus.jackson.node.ValueNode
-
- org.codehaus.jackson.node.NumericNode
-
- All Implemented Interfaces:
java.lang.Iterable<JsonNode>
,JsonSerializable
,JsonSerializableWithType
- Direct Known Subclasses:
BigIntegerNode
,DecimalNode
,DoubleNode
,IntNode
,LongNode
public abstract class NumericNode extends ValueNode
Intermediate value node used for numeric nodes.
-
-
Field Summary
-
Fields inherited from class org.codehaus.jackson.JsonNode
NO_NODES, NO_STRINGS
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
NumericNode()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method 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 java.lang.String
asText()
Method that will return valid String representation of the container value, if the node is a value node (methodJsonNode.isValueNode()
returns true), otherwise empty String.abstract java.math.BigInteger
getBigIntegerValue()
abstract java.math.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 perJsonNode.isNumber()
), returns native type that node uses to store the numeric value.abstract java.lang.Number
getNumberValue()
Returns numeric value for this node, if and only if this node is numeric (JsonNode.isNumber()
returns true); otherwise returns nullboolean
isNumber()
-
Methods inherited from class org.codehaus.jackson.node.ValueNode
asToken, isValueNode, path, path, serializeWithType, toString
-
Methods inherited from class org.codehaus.jackson.node.BaseJsonNode
findParent, findParents, findPath, findValue, findValues, findValuesAsText, serialize, traverse
-
Methods inherited from class org.codehaus.jackson.JsonNode
asBoolean, 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, with
-
-
-
-
Method Detail
-
isNumber
public final boolean isNumber()
-
getNumberType
public abstract JsonParser.NumberType getNumberType()
Description copied from class:JsonNode
If this node is a numeric type (as perJsonNode.isNumber()
), returns native type that node uses to store the numeric value.- Overrides:
getNumberType
in classBaseJsonNode
-
getNumberValue
public abstract java.lang.Number getNumberValue()
Description copied from class:JsonNode
Returns numeric value for this node, if and only if this node is numeric (JsonNode.isNumber()
returns true); otherwise returns null- Overrides:
getNumberValue
in classJsonNode
- Returns:
- Number value this node contains, if any (null for non-number nodes).
-
getIntValue
public abstract int getIntValue()
Description copied from class:JsonNode
Returns integer value for this node, if and only if this node is numeric (JsonNode.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.- Overrides:
getIntValue
in classJsonNode
- Returns:
- Integer value this node contains, if any; 0 for non-number nodes.
-
getLongValue
public abstract long getLongValue()
- Overrides:
getLongValue
in classJsonNode
-
getDoubleValue
public abstract double getDoubleValue()
- Overrides:
getDoubleValue
in classJsonNode
-
getDecimalValue
public abstract java.math.BigDecimal getDecimalValue()
- Overrides:
getDecimalValue
in classJsonNode
-
getBigIntegerValue
public abstract java.math.BigInteger getBigIntegerValue()
- Overrides:
getBigIntegerValue
in classJsonNode
-
asText
public abstract java.lang.String asText()
Description copied from class:JsonNode
Method that will return valid String representation of the container value, if the node is a value node (methodJsonNode.isValueNode()
returns true), otherwise empty String.
-
asInt
public int asInt()
Description copied from class:JsonNode
Method that will try to convert value of this node to a Java int. Numbers are coerced using default Java rules; booleans convert to 0 (false) and 1 (true), and Strings are parsed using default Java language integer parsing rules.If 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.
-
asInt
public int asInt(int defaultValue)
Description copied from class:JsonNode
Method that will try to convert value of this node to a Java int. Numbers are coerced using default Java rules; booleans convert to 0 (false) and 1 (true), and Strings are parsed using default Java language integer parsing rules.If representation can not be converted to an int (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.
-
asLong
public long asLong()
Description copied from class:JsonNode
Method that will try to convert value of this node to a Java long. Numbers are coerced using default Java rules; booleans convert to 0 (false) and 1 (true), and Strings are parsed using default Java language integer parsing rules.If 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.
-
asLong
public long asLong(long defaultValue)
Description copied from class:JsonNode
Method that will try to convert value of this node to a Java long. Numbers are coerced using default Java rules; booleans convert to 0 (false) and 1 (true), and Strings are parsed using default Java language integer parsing rules.If representation can not be converted to an long (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.
-
asDouble
public double asDouble()
Description copied from class:JsonNode
Method that will try to convert value of this node to a Java double. Numbers are coerced using default Java rules; booleans convert to 0.0 (false) and 1.0 (true), and Strings are parsed using default Java language integer parsing rules.If 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.
-
asDouble
public double asDouble(double defaultValue)
Description copied from class:JsonNode
Method that will try to convert value of this node to a Java double. Numbers are coerced using default Java rules; booleans convert to 0.0 (false) and 1.0 (true), and Strings are parsed using default Java language integer parsing rules.If representation can not be converted to an int (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.
-
-