Top Description Fields Constructors Methods
tools.jackson.databind.node

public Class JsonNodeFactory

extends Object
implements Serializable, JsonNodeCreator
Class Inheritance
All Implemented Interfaces
tools.jackson.databind.node.JsonNodeCreator, java.io.Serializable
Imports
java.math.BigDecimal, .BigInteger, tools.jackson.databind.JsonNode, tools.jackson.databind.util.RawValue

Base class that specifies methods for getting access to Node instances (newly constructed, or shared, depending on type), as well as basic implementation of the methods. Designed to be sub-classed if extended functionality (additions to behavior of node types, mostly) is needed.

Note that behavior of "exact BigDecimal value" (aka "strip trailing zeroes of BigDecimal or not") changed in 3.0: new tools.jackson.databind.cfg.JsonNodeFeature#STRIP_TRAILING_BIGDECIMAL_ZEROES setting is used to externally configure this behavior. Note, too, that this factory will no longer handle this normalization (if enabled): caller (like tools.jackson.databind.deser.jackson.JsonNodeDeserializer) is expected to handle it.

Field Summary

Modifier and TypeField and Description
public static final JsonNodeFactory
instance

Default singleton instance that construct "standard" node instances: given that this class is stateless, a globally shared singleton can be used.

protected static final int
MAX_ELEMENT_INDEX_FOR_INSERT

Constant that defines maximum JsonPointer element index we use for inserts.

private static final long

Constructor Summary

AccessConstructor and Description
public
JsonNodeFactory()

Default constructor.

Method Summary

Modifier and TypeMethod and Description
protected boolean
_inIntRange(long l)

public ArrayNode
arrayNode()

Implements tools.jackson.databind.node.JsonNodeCreator.arrayNode.

Factory method for constructing an empty JSON Array node

public ArrayNode
arrayNode(int capacity)

Implements tools.jackson.databind.node.JsonNodeCreator.arrayNode.

Factory method for constructing a JSON Array node with an initial capacity

public BinaryNode
binaryNode(byte[] data)

Implements tools.jackson.databind.node.JsonNodeCreator.binaryNode.

Factory method for constructing a node that represents given binary data, and will get serialized as equivalent base64-encoded String value

public BinaryNode
binaryNode(byte[] data, int offset, int length)

Implements tools.jackson.databind.node.JsonNodeCreator.binaryNode.

Factory method for constructing a node that represents given binary data, and will get serialized as equivalent base64-encoded String value

public BooleanNode
booleanNode(boolean v)

Implements tools.jackson.databind.node.JsonNodeCreator.booleanNode.

Factory method for getting an instance of JSON boolean value (either literal 'true' or 'false')

public int
public JsonNode
public NullNode
nullNode()

Implements tools.jackson.databind.node.JsonNodeCreator.nullNode.

Factory method for getting an instance of JSON null node (which represents literal null value)

public NumericNode
numberNode(byte v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Factory method for getting an instance of JSON numeric value that expresses given 8-bit value

public ValueNode
numberNode(Byte value)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Alternate factory method that will handle wrapper value, which may be null.

public NumericNode
numberNode(short v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Factory method for getting an instance of JSON numeric value that expresses given 16-bit integer value

public ValueNode
numberNode(Short value)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Alternate factory method that will handle wrapper value, which may be null.

public NumericNode
numberNode(int v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Factory method for getting an instance of JSON numeric value that expresses given 32-bit integer value

public ValueNode
numberNode(Integer value)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Alternate factory method that will handle wrapper value, which may be null.

public NumericNode
numberNode(long v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Factory method for getting an instance of JSON numeric value that expresses given 64-bit integer value

public ValueNode
numberNode(Long v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Alternate factory method that will handle wrapper value, which may be null.

public ValueNode
numberNode(BigInteger v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Factory method for getting an instance of JSON numeric value that expresses given unlimited range integer value

public NumericNode
numberNode(float v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Factory method for getting an instance of JSON numeric value that expresses given 32-bit floating point value

public ValueNode
numberNode(Float value)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Alternate factory method that will handle wrapper value, which may be null.

public NumericNode
numberNode(double v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Factory method for getting an instance of JSON numeric value that expresses given 64-bit floating point value

public ValueNode
numberNode(Double value)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Alternate factory method that will handle wrapper value, which may be null.

public ValueNode
numberNode(BigDecimal v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Factory method for getting an instance of JSON numeric value that expresses given unlimited precision floating point value

Note that no normalization is performed here; caller may choose to do that, based on tools.jackson.databind.cfg.JsonNodeFeature#STRIP_TRAILING_BIGDECIMAL_ZEROES setting.

public ObjectNode
objectNode()

Implements tools.jackson.databind.node.JsonNodeCreator.objectNode.

Factory method for constructing an empty JSON Object ("struct") node

public ValueNode
pojoNode(Object pojo)

Implements tools.jackson.databind.node.JsonNodeCreator.pojoNode.

Factory method for constructing a wrapper for POJO ("Plain Old Java Object") objects; these will get serialized using data binding, usually as JSON Objects, but in some cases as JSON Strings or other node types.

public ValueNode
rawValueNode(RawValue value)

Implements tools.jackson.databind.node.JsonNodeCreator.rawValueNode.

Factory method to use for adding "raw values"; pre-encoded values that are included exactly as-is when node is serialized.

public StringNode
stringNode(String text)

Implements tools.jackson.databind.node.JsonNodeCreator.stringNode.

Factory method for constructing a node that represents JSON String value

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

instanceback to summary
public static final JsonNodeFactory instance

Default singleton instance that construct "standard" node instances: given that this class is stateless, a globally shared singleton can be used.

Default for 3.x is to make no changes; no normalization by default.

MAX_ELEMENT_INDEX_FOR_INSERTback to summary
protected static final int MAX_ELEMENT_INDEX_FOR_INSERT

Constant that defines maximum JsonPointer element index we use for inserts.

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

JsonNodeFactoryback to summary
public JsonNodeFactory()

Default constructor.

Method Detail

_inIntRangeback to summary
protected boolean _inIntRange(long l)
arrayNodeback to summary
public ArrayNode arrayNode()

Implements tools.jackson.databind.node.JsonNodeCreator.arrayNode.

Factory method for constructing an empty JSON Array node

Annotations
@Override
arrayNodeback to summary
public ArrayNode arrayNode(int capacity)

Implements tools.jackson.databind.node.JsonNodeCreator.arrayNode.

Factory method for constructing a JSON Array node with an initial capacity

Annotations
@Override
Since
2.8
binaryNodeback to summary
public BinaryNode binaryNode(byte[] data)

Implements tools.jackson.databind.node.JsonNodeCreator.binaryNode.

Factory method for constructing a node that represents given binary data, and will get serialized as equivalent base64-encoded String value

Annotations
@Override
binaryNodeback to summary
public BinaryNode binaryNode(byte[] data, int offset, int length)

Implements tools.jackson.databind.node.JsonNodeCreator.binaryNode.

Factory method for constructing a node that represents given binary data, and will get serialized as equivalent base64-encoded String value

Annotations
@Override
booleanNodeback to summary
public BooleanNode booleanNode(boolean v)

Implements tools.jackson.databind.node.JsonNodeCreator.booleanNode.

Factory method for getting an instance of JSON boolean value (either literal 'true' or 'false')

Annotations
@Override
getMaxElementIndexForInsertback to summary
public int getMaxElementIndexForInsert()
missingNodeback to summary
public JsonNode missingNode()

Implements tools.jackson.databind.node.JsonNodeCreator.missingNode.

Annotations
@Override
nullNodeback to summary
public NullNode nullNode()

Implements tools.jackson.databind.node.JsonNodeCreator.nullNode.

Factory method for getting an instance of JSON null node (which represents literal null value)

Annotations
@Override
numberNodeback to summary
public NumericNode numberNode(byte v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Factory method for getting an instance of JSON numeric value that expresses given 8-bit value

Annotations
@Override
numberNodeback to summary
public ValueNode numberNode(Byte value)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Alternate factory method that will handle wrapper value, which may be null. Due to possibility of null, returning type is not guaranteed to be NumericNode, but just ValueNode.

Annotations
@Override
numberNodeback to summary
public NumericNode numberNode(short v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Factory method for getting an instance of JSON numeric value that expresses given 16-bit integer value

Annotations
@Override
numberNodeback to summary
public ValueNode numberNode(Short value)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Alternate factory method that will handle wrapper value, which may be null. Due to possibility of null, returning type is not guaranteed to be NumericNode, but just ValueNode.

Annotations
@Override
numberNodeback to summary
public NumericNode numberNode(int v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Factory method for getting an instance of JSON numeric value that expresses given 32-bit integer value

Annotations
@Override
numberNodeback to summary
public ValueNode numberNode(Integer value)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Alternate factory method that will handle wrapper value, which may be null. Due to possibility of null, returning type is not guaranteed to be NumericNode, but just ValueNode.

Annotations
@Override
numberNodeback to summary
public NumericNode numberNode(long v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Factory method for getting an instance of JSON numeric value that expresses given 64-bit integer value

Annotations
@Override
numberNodeback to summary
public ValueNode numberNode(Long v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Alternate factory method that will handle wrapper value, which may be null. Due to possibility of null, returning type is not guaranteed to be NumericNode, but just ValueNode.

Annotations
@Override
numberNodeback to summary
public ValueNode numberNode(BigInteger v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Factory method for getting an instance of JSON numeric value that expresses given unlimited range integer value

Annotations
@Override
numberNodeback to summary
public NumericNode numberNode(float v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Factory method for getting an instance of JSON numeric value that expresses given 32-bit floating point value

Annotations
@Override
numberNodeback to summary
public ValueNode numberNode(Float value)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Alternate factory method that will handle wrapper value, which may be null. Due to possibility of null, returning type is not guaranteed to be NumericNode, but just ValueNode.

Annotations
@Override
numberNodeback to summary
public NumericNode numberNode(double v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Factory method for getting an instance of JSON numeric value that expresses given 64-bit floating point value

Annotations
@Override
numberNodeback to summary
public ValueNode numberNode(Double value)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Alternate factory method that will handle wrapper value, which may be null. Due to possibility of null, returning type is not guaranteed to be NumericNode, but just ValueNode.

Annotations
@Override
numberNodeback to summary
public ValueNode numberNode(BigDecimal v)

Implements tools.jackson.databind.node.JsonNodeCreator.numberNode.

Factory method for getting an instance of JSON numeric value that expresses given unlimited precision floating point value

Note that no normalization is performed here; caller may choose to do that, based on tools.jackson.databind.cfg.JsonNodeFeature#STRIP_TRAILING_BIGDECIMAL_ZEROES setting.

Annotations
@Override
objectNodeback to summary
public ObjectNode objectNode()

Implements tools.jackson.databind.node.JsonNodeCreator.objectNode.

Factory method for constructing an empty JSON Object ("struct") node

Annotations
@Override
pojoNodeback to summary
public ValueNode pojoNode(Object pojo)

Implements tools.jackson.databind.node.JsonNodeCreator.pojoNode.

Factory method for constructing a wrapper for POJO ("Plain Old Java Object") objects; these will get serialized using data binding, usually as JSON Objects, but in some cases as JSON Strings or other node types.

Annotations
@Override
rawValueNodeback to summary
public ValueNode rawValueNode(RawValue value)

Implements tools.jackson.databind.node.JsonNodeCreator.rawValueNode.

Doc from tools.jackson.databind.node.JsonNodeCreator.rawValueNode.

Factory method to use for adding "raw values"; pre-encoded values that are included exactly as-is when node is serialized. This may be used, for example, to include fully serialized JSON sub-trees. Note that the concept may not work with all backends, and since no translation of any kinds is done it will not work when converting between data formats.

Annotations
@Override
stringNodeback to summary
public StringNode stringNode(String text)

Implements tools.jackson.databind.node.JsonNodeCreator.stringNode.

Factory method for constructing a node that represents JSON String value

Annotations
@Override