Top Description Fields Constructors Methods
com.fasterxml.jackson.databind.node

public Class IntNode

extends NumericNode
Class Inheritance
Annotations
@SuppressWarnings:serial
Imports
java.io.IOException, java.math.BigDecimal, .BigInteger, com.fasterxml.jackson.core.*, com.fasterxml.jackson.core.io.NumberOutput, com.fasterxml.jackson.databind.SerializerProvider

Numeric node that contains simple 32-bit integer values.

Field Summary

Modifier and TypeField and Description
protected final int
_value

Integer value this node contains

private static final IntNode[]
pack-priv static final int
pack-priv static final int

Constructor Summary

AccessConstructor and Description
public
IntNode(int v)

Method Summary

Modifier and TypeMethod and Description
public boolean
asBoolean(boolean defaultValue)

Overrides com.fasterxml.jackson.databind.JsonNode.asBoolean.

Method that will try to convert value of this node to a Java boolean.

public String
asText()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.asText.

Method that will return a valid String representation of the container value, if the node is a value node (method isValueNode returns true), otherwise empty String.

public JsonToken
asToken()

Implements abstract com.fasterxml.jackson.databind.node.ValueNode.asToken.

Implements com.fasterxml.jackson.core.TreeNode.asToken.

Method that can be used for efficient type detection when using stream abstraction for traversing nodes.

public BigInteger
bigIntegerValue()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.bigIntegerValue.

Returns integer value for this node (as BigInteger), if and only if this node is numeric (isNumber returns true).

public boolean
canConvertToInt()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.canConvertToInt.

Method that can be used to check whether this node is a numeric node (isNumber would return true) AND its value fits within Java's 32-bit signed integer type, int.

public boolean
canConvertToLong()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.canConvertToLong.

Method that can be used to check whether this node is a numeric node (isNumber would return true) AND its value fits within Java's 64-bit signed integer type, long.

public BigDecimal
decimalValue()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.decimalValue.

Returns floating point value for this node (as BigDecimal), if and only if this node is numeric (isNumber returns true).

public double
doubleValue()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.doubleValue.

Returns 64-bit floating point (double) value for this node, if and only if this node is numeric (isNumber returns true).

public boolean
equals(Object
the reference object with which to compare.
o
)

Implements abstract com.fasterxml.jackson.databind.JsonNode.equals.

Equality for node objects is defined as full (deep) value equality.

public float
floatValue()

Overrides com.fasterxml.jackson.databind.JsonNode.floatValue.

Returns 32-bit floating value for this node, if and only if this node is numeric (isNumber returns true).

public int
hashCode()

Implements abstract com.fasterxml.jackson.databind.node.BaseJsonNode.hashCode.

Returns a hash code value for this object.

public int
intValue()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.intValue.

Returns integer value for this node, if and only if this node is numeric (isNumber returns true).

public boolean
isInt()

Overrides com.fasterxml.jackson.databind.JsonNode.isInt.

Method that can be used to check whether contained value is a number represented as Java int.

public boolean
public long
longValue()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.longValue.

Returns 64-bit long value for this node, if and only if this node is numeric (isNumber returns true).

public JsonParser.NumberType
numberType()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.numberType.

Implements com.fasterxml.jackson.core.TreeNode.numberType.

Returns code that identifies type of underlying numeric value, if (and only if) node is a number node.

public Number
numberValue()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.numberValue.

Returns numeric value for this node, if and only if this node is numeric (isNumber returns true); otherwise returns null

public final void
serialize(JsonGenerator g, SerializerProvider provider)

Implements abstract com.fasterxml.jackson.databind.node.BaseJsonNode.serialize.

Implements com.fasterxml.jackson.databind.JsonSerializable.serialize.

Method called to serialize node instances using given generator.

public short
shortValue()

Overrides com.fasterxml.jackson.databind.JsonNode.shortValue.

Returns 16-bit short value for this node, if and only if this node is numeric (isNumber returns true).

public static IntNode
valueOf(int i)

Inherited from com.fasterxml.jackson.databind.node.NumericNode:
asDoubleasDoubleasIntasIntasLongasLonggetNodeTypeisNaN

Field Detail

_valueback to summary
protected final int _value

Integer value this node contains

CANONICALSback to summary
private static final IntNode[] CANONICALS
MAX_CANONICALback to summary
pack-priv static final int MAX_CANONICAL
MIN_CANONICALback to summary
pack-priv static final int MIN_CANONICAL

Constructor Detail

IntNodeback to summary
public IntNode(int v)

Method Detail

asBooleanback to summary
public boolean asBoolean(boolean defaultValue)

Overrides com.fasterxml.jackson.databind.JsonNode.asBoolean.

Doc from com.fasterxml.jackson.databind.JsonNode.asBoolean.

Method that will try to convert value of this node to a Java boolean. JSON booleans map naturally; integer numbers other than 0 map to true, and 0 maps to false and Strings 'true' and 'false' map to corresponding values.

If representation cannot be converted to a boolean value (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.

Annotations
@Override
asTextback to summary
public String asText()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.asText.

Doc from com.fasterxml.jackson.databind.JsonNode.asText.

Method that will return a valid String representation of the container value, if the node is a value node (method isValueNode returns true), otherwise empty String.

Annotations
@Override
asTokenback to summary
public JsonToken asToken()

Implements abstract com.fasterxml.jackson.databind.node.ValueNode.asToken.

Implements com.fasterxml.jackson.core.TreeNode.asToken.

Doc from com.fasterxml.jackson.databind.node.BaseJsonNode.asToken.

Method that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the first JsonToken that equivalent stream event would produce (for most nodes there is just one token but for structured/container types multiple)

Returns:JsonToken

Doc from com.fasterxml.jackson.core.TreeNode.asToken.

JsonToken that is most closely associated with the node type

Annotations
@Override
bigIntegerValueback to summary
public BigInteger bigIntegerValue()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.bigIntegerValue.

Doc from com.fasterxml.jackson.databind.JsonNode.bigIntegerValue.

Returns integer value for this node (as BigInteger), if and only if this node is numeric (isNumber returns true). For other types returns BigInteger.ZERO.

Note

In Jackson 2.x MAY throw com.fasterxml.jackson.core.exc.StreamConstraintsException if the scale of the underlying BigDecimal is too large to convert (NOTE: thrown "sneakily" in Jackson 2.x due to API compatibility restrictions)

Returns:BigInteger

BigInteger value this node contains, if numeric node; BigInteger.ZERO for non-number nodes.

Annotations
@Override
canConvertToIntback to summary
public boolean canConvertToInt()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.canConvertToInt.

Doc from com.fasterxml.jackson.databind.JsonNode.canConvertToInt.

Method that can be used to check whether this node is a numeric node (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)

Note

this method does not consider possible value type conversion from JSON String into Number; so even if this method returns false, it is possible that asInt could still succeed if node is a JSON String representing integral number, or boolean.

Annotations
@Override
canConvertToLongback to summary
public boolean canConvertToLong()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.canConvertToLong.

Doc from com.fasterxml.jackson.databind.JsonNode.canConvertToLong.

Method that can be used to check whether this node is a numeric node (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)

Note

this method does not consider possible value type conversion from JSON String into Number; so even if this method returns false, it is possible that asLong could still succeed if node is a JSON String representing integral number, or boolean.

Annotations
@Override
decimalValueback to summary
public BigDecimal decimalValue()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.decimalValue.

Doc from com.fasterxml.jackson.databind.JsonNode.decimalValue.

Returns floating point value for this node (as BigDecimal), if and only if this node is numeric (isNumber returns true). For other types returns BigDecimal.ZERO.

Returns:BigDecimal

BigDecimal value this node contains, if numeric node; BigDecimal.ZERO for non-number nodes.

Annotations
@Override
doubleValueback to summary
public double doubleValue()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.doubleValue.

Doc from com.fasterxml.jackson.databind.JsonNode.doubleValue.

Returns 64-bit floating point (double) value for this node, if and only if this node is numeric (isNumber returns true). For other types returns 0.0. For integer values, conversion is done using coercion; this may result in overflows with BigInteger values.

Returns:double

64-bit double value this node contains, if any; 0.0 for non-number nodes.

Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Implements abstract com.fasterxml.jackson.databind.JsonNode.equals.

Doc from com.fasterxml.jackson.databind.JsonNode.equals.

Equality 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 java.lang.Object.

Parameters
o:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
floatValueback to summary
public float floatValue()

Overrides com.fasterxml.jackson.databind.JsonNode.floatValue.

Doc from com.fasterxml.jackson.databind.JsonNode.floatValue.

Returns 32-bit floating value for this node, if and only if this node is numeric (isNumber returns true). For other types returns 0.0. For integer values, conversion is done using coercion; this means that an overflow is possible for `long` values

Returns:float

32-bit float value this node contains, if any; 0.0 for non-number nodes.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Implements abstract com.fasterxml.jackson.databind.node.BaseJsonNode.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
intValueback to summary
public int intValue()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.intValue.

Doc from com.fasterxml.jackson.databind.JsonNode.intValue.

Returns integer value for this node, if and only if this node is numeric (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.

Returns:int

Integer value this node contains, if any; 0 for non-number nodes.

Annotations
@Override
isIntback to summary
public boolean isInt()

Overrides com.fasterxml.jackson.databind.JsonNode.isInt.

Doc from com.fasterxml.jackson.databind.JsonNode.isInt.

Method that can be used to check whether contained value is a number represented as Java int. Note, however, that even if this method returns false, it is possible that conversion would be possible from other numeric types -- to check if this is possible, use canConvertToInt() instead.

Returns:boolean

True if the value contained by this node is stored as Java int

Annotations
@Override
isIntegralNumberback to summary
public boolean isIntegralNumber()

Overrides com.fasterxml.jackson.databind.JsonNode.isIntegralNumber.

Returns:boolean

Doc from com.fasterxml.jackson.databind.JsonNode.isIntegralNumber.

True if this node represents an integral (integer) numeric JSON value

Annotations
@Override
longValueback to summary
public long longValue()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.longValue.

Doc from com.fasterxml.jackson.databind.JsonNode.longValue.

Returns 64-bit long value for this node, if and only if this node is numeric (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 long operates.

Returns:long

Long value this node contains, if any; 0 for non-number nodes.

Annotations
@Override
numberTypeback to summary
public JsonParser.NumberType numberType()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.numberType.

Implements com.fasterxml.jackson.core.TreeNode.numberType.

Doc from com.fasterxml.jackson.databind.node.BaseJsonNode.numberType.

Returns code that identifies type of underlying numeric value, if (and only if) node is a number node.

Returns:JsonParser.NumberType

Doc from com.fasterxml.jackson.core.TreeNode.numberType.

Type of number contained, if any; or null if node does not contain numeric value.

Annotations
@Override
numberValueback to summary
public Number numberValue()

Implements abstract com.fasterxml.jackson.databind.node.NumericNode.numberValue.

Doc from com.fasterxml.jackson.databind.JsonNode.numberValue.

Returns numeric value for this node, if and only if this node is numeric (isNumber returns true); otherwise returns null

Returns:Number

Number value this node contains, if any (null for non-number nodes).

Annotations
@Override
serializeback to summary
public final void serialize(JsonGenerator g, SerializerProvider provider) throws IOException

Implements abstract com.fasterxml.jackson.databind.node.BaseJsonNode.serialize.

Implements com.fasterxml.jackson.databind.JsonSerializable.serialize.

Doc from com.fasterxml.jackson.databind.node.BaseJsonNode.serialize.

Method called to serialize node instances using given generator.

Annotations
@Override
shortValueback to summary
public short shortValue()

Overrides com.fasterxml.jackson.databind.JsonNode.shortValue.

Doc from com.fasterxml.jackson.databind.JsonNode.shortValue.

Returns 16-bit short value for this node, if and only if this node is numeric (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 short operates.

Returns:short

Short value this node contains, if any; 0 for non-number nodes.

Annotations
@Override
valueOfback to summary
public static IntNode valueOf(int i)