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

public Class BooleanNode

extends ValueNode
Class Inheritance
Imports
java.io.IOException, com.fasterxml.jackson.core.*, com.fasterxml.jackson.databind.SerializerProvider

This concrete value class is used to contain boolean (true / false) values. Only two instances are ever created, to minimize memory usage.

Field Summary

Modifier and TypeField and Description
private final boolean
public static final BooleanNode
private static final long
public static final BooleanNode

Constructor Summary

AccessConstructor and Description
protected
BooleanNode(boolean v)

Note

visibility raised to `protected` in 2.9.3 to allow custom subtypes.

Method Summary

Modifier and TypeMethod and Description
public boolean
asBoolean()

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

Method that will try to convert value of this node to a Java boolean.
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 double
asDouble(double defaultValue)

Overrides com.fasterxml.jackson.databind.JsonNode.asDouble.

Method that will try to convert value of this node to a Java double.
public int
asInt(int defaultValue)

Overrides com.fasterxml.jackson.databind.JsonNode.asInt.

Method that will try to convert value of this node to a Java int.
public long
asLong(long defaultValue)

Overrides com.fasterxml.jackson.databind.JsonNode.asLong.

Method that will try to convert value of this node to a Java long.
public String
asText()

Implements abstract 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.
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 boolean
booleanValue()

Overrides com.fasterxml.jackson.databind.JsonNode.booleanValue.

Method to use for accessing JSON boolean values (value literals 'true' and 'false').
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 static BooleanNode
public JsonNodeType
getNodeType()

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

Return the type of this node
public static BooleanNode
public int
hashCode()

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

Returns a hash code value for the object.
protected Object
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 static BooleanNode
valueOf(boolean b)

Inherited from com.fasterxml.jackson.databind.node.ValueNode:
_atdeepCopyfindParentfindParentsfindValuefindValuesfindValuesAsTextgetgethashashasNonNullhasNonNullisEmptypathpathserializeWithType

Field Detail

_valueback to summary
private final boolean _value
FALSEback to summary
public static final BooleanNode FALSE
serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.fasterxml.jackson.databind.node.ValueNode.serialVersionUID.

TRUEback to summary
public static final BooleanNode TRUE

Constructor Detail

BooleanNodeback to summary
protected BooleanNode(boolean v)

Note

visibility raised to `protected` in 2.9.3 to allow custom subtypes.

Method Detail

asBooleanback to summary
public boolean asBoolean()

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), default value of false will be returned; no exceptions are thrown.

Annotations
@Override
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
asDoubleback to summary
public double asDouble(double defaultValue)

Overrides com.fasterxml.jackson.databind.JsonNode.asDouble.

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

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 cannot be converted to an int (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.

Annotations
@Override
asIntback to summary
public int asInt(int defaultValue)

Overrides com.fasterxml.jackson.databind.JsonNode.asInt.

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

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 cannot be converted to an int (including structured types like Objects and Arrays), specified defaultValue will be returned; no exceptions are thrown.

Annotations
@Override
asLongback to summary
public long asLong(long defaultValue)

Overrides com.fasterxml.jackson.databind.JsonNode.asLong.

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

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 cannot be converted to a long (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.JsonNode.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
booleanValueback to summary
public boolean booleanValue()

Overrides com.fasterxml.jackson.databind.JsonNode.booleanValue.

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

Method to use for accessing JSON boolean values (value literals 'true' and 'false'). For other types, always returns false.

Returns:boolean

Textual value this node contains, iff it is a textual json node (comes from JSON String value entry)

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
getFalseback to summary
public static BooleanNode getFalse()
getNodeTypeback to summary
public JsonNodeType getNodeType()

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

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

Return the type of this node

Returns:JsonNodeType

the node type as a JsonNodeType enum value

Annotations
@Override
getTrueback to summary
public static BooleanNode getTrue()
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 the 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
readResolveback to summary
protected Object readResolve()
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
valueOfback to summary
public static BooleanNode valueOf(boolean b)