Class JsonNodeFactory
- All Implemented Interfaces:
JsonNodeCreator
,Serializable
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final JsonNodeFactory
Default singleton instance that construct "standard" node instances: given that this class is stateless, a globally shared singleton can be used. -
Constructor Summary
ModifierConstructorDescriptionprotected
Default constructorJsonNodeFactory
(boolean bigDecimalExact) Main constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
_inIntRange
(long l) Factory method for constructing an empty JSON Array nodearrayNode
(int capacity) Factory method for constructing a JSON Array node with an initial capacitybinaryNode
(byte[] data) Factory method for constructing a node that represents given binary data, and will get serialized as equivalent base64-encoded String valuebinaryNode
(byte[] data, int offset, int length) Factory method for constructing a node that represents given binary data, and will get serialized as equivalent base64-encoded String valuebooleanNode
(boolean v) Factory method for getting an instance of JSON boolean value (either literal 'true' or 'false')nullNode()
Factory method for getting an instance of JSON null node (which represents literal null value)numberNode
(byte v) Factory method for getting an instance of JSON numeric value that expresses given 8-bit valuenumberNode
(double v) Factory method for getting an instance of JSON numeric value that expresses given 64-bit floating point valuenumberNode
(float v) Factory method for getting an instance of JSON numeric value that expresses given 32-bit floating point valuenumberNode
(int v) Factory method for getting an instance of JSON numeric value that expresses given 32-bit integer valuenumberNode
(long v) Factory method for getting an instance of JSON numeric value that expresses given 64-bit integer valuenumberNode
(short v) Factory method for getting an instance of JSON numeric value that expresses given 16-bit integer valuenumberNode
(Byte value) Alternate factory method that will handle wrapper value, which may be null.numberNode
(Double value) Alternate factory method that will handle wrapper value, which may be null.numberNode
(Float value) Alternate factory method that will handle wrapper value, which may be null.numberNode
(Integer value) Alternate factory method that will handle wrapper value, which may be null.numberNode
(Long v) Alternate factory method that will handle wrapper value, which may be null.numberNode
(Short value) Alternate factory method that will handle wrapper value, which may be null.Factory method for getting an instance of JSON numeric value that expresses given unlimited precision floating point valueFactory method for getting an instance of JSON numeric value that expresses given unlimited range integer valueFactory method for constructing an empty JSON Object ("struct") nodeFactory 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.rawValueNode
(RawValue value) Factory method to use for adding "raw values"; pre-encoded values that are included exactly as-is when node is serialized.Factory method for constructing a node that represents JSON String valuestatic JsonNodeFactory
withExactBigDecimals
(boolean bigDecimalExact) Return a factory instance with the desired behavior for BigDecimals
-
Field Details
-
instance
Default singleton instance that construct "standard" node instances: given that this class is stateless, a globally shared singleton can be used.
-
-
Constructor Details
-
JsonNodeFactory
public JsonNodeFactory(boolean bigDecimalExact) Main constructorThe only argument to this constructor is a boolean telling whether
DecimalNode
instances must be built with exact representations ofBigDecimal
instances.This has quite an influence since, for instance, a BigDecimal (and, therefore, a DecimalNode) constructed from input string
"1.0"
and another constructed with input string"1.00"
will not be equal, since their scale differs (1 in the first case, 2 in the second case).Note that setting the argument to
true
does not guarantee a strict inequality between JSON representations: input texts"0.1"
and"1e-1"
, for instance, yield two equivalent BigDecimal instances since they have the same scale (1).The no-arg constructor (and the default
instance
) calls this constructor withfalse
as an argument.- Parameters:
bigDecimalExact
- see description- See Also:
-
JsonNodeFactory
protected JsonNodeFactory()Default constructorThis calls
JsonNodeFactory(boolean)
withfalse
as an argument.
-
-
Method Details
-
withExactBigDecimals
Return a factory instance with the desired behavior for BigDecimalsSee
JsonNodeFactory(boolean)
for a full description.- Parameters:
bigDecimalExact
- see description- Returns:
- a factory instance
-
booleanNode
Factory method for getting an instance of JSON boolean value (either literal 'true' or 'false')- Specified by:
booleanNode
in interfaceJsonNodeCreator
-
nullNode
Factory method for getting an instance of JSON null node (which represents literal null value)- Specified by:
nullNode
in interfaceJsonNodeCreator
-
missingNode
-
numberNode
Factory method for getting an instance of JSON numeric value that expresses given 8-bit value- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
Alternate factory method that will handle wrapper value, which may be null. Due to possibility of null, returning type is not guaranteed to beNumericNode
, but justValueNode
.- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
Factory method for getting an instance of JSON numeric value that expresses given 16-bit integer value- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
Alternate factory method that will handle wrapper value, which may be null. Due to possibility of null, returning type is not guaranteed to beNumericNode
, but justValueNode
.- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
Factory method for getting an instance of JSON numeric value that expresses given 32-bit integer value- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
Alternate factory method that will handle wrapper value, which may be null. Due to possibility of null, returning type is not guaranteed to beNumericNode
, but justValueNode
.- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
Factory method for getting an instance of JSON numeric value that expresses given 64-bit integer value- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
Alternate factory method that will handle wrapper value, which may be null. Due to possibility of null, returning type is not guaranteed to beNumericNode
, but justValueNode
.- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
Factory method for getting an instance of JSON numeric value that expresses given unlimited range integer value- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
Factory method for getting an instance of JSON numeric value that expresses given 32-bit floating point value- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
Alternate factory method that will handle wrapper value, which may be null. Due to possibility of null, returning type is not guaranteed to beNumericNode
, but justValueNode
.- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
Factory method for getting an instance of JSON numeric value that expresses given 64-bit floating point value- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
Alternate factory method that will handle wrapper value, which may be null. Due to possibility of null, returning type is not guaranteed to beNumericNode
, but justValueNode
.- Specified by:
numberNode
in interfaceJsonNodeCreator
-
numberNode
Factory method for getting an instance of JSON numeric value that expresses given unlimited precision floating point valueIn the event that the factory has been built to normalize decimal values, the BigDecimal argument will be stripped off its trailing zeroes, using
BigDecimal.stripTrailingZeros()
.- Specified by:
numberNode
in interfaceJsonNodeCreator
- See Also:
-
textNode
Factory method for constructing a node that represents JSON String value- Specified by:
textNode
in interfaceJsonNodeCreator
-
binaryNode
Factory method for constructing a node that represents given binary data, and will get serialized as equivalent base64-encoded String value- Specified by:
binaryNode
in interfaceJsonNodeCreator
-
binaryNode
Factory method for constructing a node that represents given binary data, and will get serialized as equivalent base64-encoded String value- Specified by:
binaryNode
in interfaceJsonNodeCreator
-
arrayNode
Factory method for constructing an empty JSON Array node- Specified by:
arrayNode
in interfaceJsonNodeCreator
-
arrayNode
Factory method for constructing a JSON Array node with an initial capacity- Specified by:
arrayNode
in interfaceJsonNodeCreator
- Since:
- 2.8
-
objectNode
Factory method for constructing an empty JSON Object ("struct") node- Specified by:
objectNode
in interfaceJsonNodeCreator
-
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.- Specified by:
pojoNode
in interfaceJsonNodeCreator
-
rawValueNode
Description copied from interface:JsonNodeCreator
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.- Specified by:
rawValueNode
in interfaceJsonNodeCreator
-
_inIntRange
protected boolean _inIntRange(long l)
-