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

public Class POJONode

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

Value node that contains a wrapped POJO, to be serialized as a JSON constructed through data mapping (usually done by calling com.fasterxml.jackson.databind.ObjectMapper).

Field Summary

Modifier and TypeField and Description
protected final Object
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected 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 String
asText(String defaultValue)

Overrides com.fasterxml.jackson.databind.JsonNode.asText.

Method similar to asText(), except that it will return defaultValue in cases where null value would be returned; either for missing nodes (trying to access missing property, or element at invalid item for array) or explicit nulls.
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 byte[]
binaryValue()

Overrides com.fasterxml.jackson.databind.JsonNode.binaryValue.

As it is possible that some implementations embed byte[] as POJONode (despite optimal being BinaryNode), let's add support for exposing binary data here too.
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 JsonNodeType
getNodeType()

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

Return the type of this node
public Object
getPojo()

Method that can be used to access the POJO this node wraps.

public int
hashCode()

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

Returns a hash code value for the object.
public final void
serialize(JsonGenerator gen, SerializerProvider ctxt)

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.
Inherited from com.fasterxml.jackson.databind.node.ValueNode:
_atdeepCopyfindParentfindParentsfindValuefindValuesfindValuesAsTextgetgethashashasNonNullhasNonNullisEmptypathpathserializeWithType

Field Detail

_valueback to summary
protected final Object _value
serialVersionUIDback to summary
private static final long serialVersionUID

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

Constructor Detail

POJONodeback to summary
public POJONode(Object v)

Method Detail

_pojoEqualsback to summary
protected boolean _pojoEquals(POJONode other)
Since
2.3
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
asTextback to summary
public String asText(String defaultValue)

Overrides com.fasterxml.jackson.databind.JsonNode.asText.

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

Method similar to asText(), except that it will return defaultValue in cases where null value would be returned; either for missing nodes (trying to access missing property, or element at invalid item for array) or explicit nulls.

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
binaryValueback to summary
public byte[] binaryValue() throws IOException

Overrides com.fasterxml.jackson.databind.JsonNode.binaryValue.

As it is possible that some implementations embed byte[] as POJONode (despite optimal being BinaryNode), let's add support for exposing binary data here too.

Returns:byte[]

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

Binary data this node contains, iff it is a binary node; null otherwise

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
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
getPojoback to summary
public Object getPojo()

Method that can be used to access the POJO this node wraps.

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
serializeback to summary
public final void serialize(JsonGenerator gen, SerializerProvider ctxt) 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