java.lang.Object
edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.node.JsonNodeFactory
All Implemented Interfaces:
JsonNodeCreator, Serializable

public class JsonNodeFactory extends Object implements Serializable, JsonNodeCreator
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.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final JsonNodeFactory
    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
    Constant that defines maximum JsonPointer element index we use for inserts.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Default constructor
     
    JsonNodeFactory(boolean bigDecimalExact)
    Main constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    _inIntRange(long l)
     
    Factory method for constructing an empty JSON Array node
    arrayNode(int capacity)
    Factory method for constructing a JSON Array node with an initial capacity
    binaryNode(byte[] data)
    Factory method for constructing a node that represents given binary data, and will get serialized as equivalent base64-encoded String value
    binaryNode(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 value
    booleanNode(boolean v)
    Factory method for getting an instance of JSON boolean value (either literal 'true' or 'false')
    int
     
     
    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 value
    numberNode(double v)
    Factory method for getting an instance of JSON numeric value that expresses given 64-bit floating point value
    numberNode(float v)
    Factory method for getting an instance of JSON numeric value that expresses given 32-bit floating point value
    numberNode(int v)
    Factory method for getting an instance of JSON numeric value that expresses given 32-bit integer value
    numberNode(long v)
    Factory method for getting an instance of JSON numeric value that expresses given 64-bit integer value
    numberNode(short v)
    Factory method for getting an instance of JSON numeric value that expresses given 16-bit integer value
    Alternate factory method that will handle wrapper value, which may be null.
    Alternate factory method that will handle wrapper value, which may be null.
    Alternate factory method that will handle wrapper value, which may be null.
    Alternate factory method that will handle wrapper value, which may be null.
    Alternate factory method that will handle wrapper value, which may be null.
    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 value
    Factory method for getting an instance of JSON numeric value that expresses given unlimited range integer value
    Factory method for constructing an empty JSON Object ("struct") node
    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.
    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 value
    withExactBigDecimals(boolean bigDecimalExact)
    Return a factory instance with the desired behavior for BigDecimals

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_ELEMENT_INDEX_FOR_INSERT

      protected static final int MAX_ELEMENT_INDEX_FOR_INSERT
      Constant that defines maximum JsonPointer element index we use for inserts.
      See Also:
    • instance

      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.
  • Constructor Details

    • JsonNodeFactory

      public JsonNodeFactory(boolean bigDecimalExact)
      Main constructor

      The only argument to this constructor is a boolean telling whether DecimalNode instances must be built with exact representations of BigDecimal 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 with false as an argument.

      Parameters:
      bigDecimalExact - see description
      See Also:
    • JsonNodeFactory

      protected JsonNodeFactory()
      Default constructor

      This calls JsonNodeFactory(boolean) with false as an argument.

  • Method Details

    • withExactBigDecimals

      public static JsonNodeFactory withExactBigDecimals(boolean bigDecimalExact)
      Return a factory instance with the desired behavior for BigDecimals

      See JsonNodeFactory(boolean) for a full description.

      Parameters:
      bigDecimalExact - see description
      Returns:
      a factory instance
    • getMaxElementIndexForInsert

      public int getMaxElementIndexForInsert()
      Since:
      2.14
    • booleanNode

      public BooleanNode booleanNode(boolean v)
      Factory method for getting an instance of JSON boolean value (either literal 'true' or 'false')
      Specified by:
      booleanNode in interface JsonNodeCreator
    • nullNode

      public NullNode nullNode()
      Factory method for getting an instance of JSON null node (which represents literal null value)
      Specified by:
      nullNode in interface JsonNodeCreator
    • missingNode

      public JsonNode missingNode()
    • numberNode

      public NumericNode numberNode(byte v)
      Factory method for getting an instance of JSON numeric value that expresses given 8-bit value
      Specified by:
      numberNode in interface JsonNodeCreator
    • numberNode

      public ValueNode numberNode(Byte value)
      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.
      Specified by:
      numberNode in interface JsonNodeCreator
    • numberNode

      public NumericNode numberNode(short v)
      Factory method for getting an instance of JSON numeric value that expresses given 16-bit integer value
      Specified by:
      numberNode in interface JsonNodeCreator
    • numberNode

      public ValueNode numberNode(Short value)
      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.
      Specified by:
      numberNode in interface JsonNodeCreator
    • numberNode

      public NumericNode numberNode(int v)
      Factory method for getting an instance of JSON numeric value that expresses given 32-bit integer value
      Specified by:
      numberNode in interface JsonNodeCreator
    • numberNode

      public ValueNode numberNode(Integer value)
      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.
      Specified by:
      numberNode in interface JsonNodeCreator
    • numberNode

      public NumericNode numberNode(long v)
      Factory method for getting an instance of JSON numeric value that expresses given 64-bit integer value
      Specified by:
      numberNode in interface JsonNodeCreator
    • numberNode

      public ValueNode numberNode(Long v)
      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.
      Specified by:
      numberNode in interface JsonNodeCreator
    • numberNode

      public ValueNode numberNode(BigInteger v)
      Factory method for getting an instance of JSON numeric value that expresses given unlimited range integer value
      Specified by:
      numberNode in interface JsonNodeCreator
    • numberNode

      public NumericNode numberNode(float v)
      Factory method for getting an instance of JSON numeric value that expresses given 32-bit floating point value
      Specified by:
      numberNode in interface JsonNodeCreator
    • numberNode

      public ValueNode numberNode(Float value)
      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.
      Specified by:
      numberNode in interface JsonNodeCreator
    • numberNode

      public NumericNode numberNode(double v)
      Factory method for getting an instance of JSON numeric value that expresses given 64-bit floating point value
      Specified by:
      numberNode in interface JsonNodeCreator
    • numberNode

      public ValueNode numberNode(Double value)
      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.
      Specified by:
      numberNode in interface JsonNodeCreator
    • numberNode

      public ValueNode numberNode(BigDecimal v)
      Factory method for getting an instance of JSON numeric value that expresses given unlimited precision floating point value

      In 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 interface JsonNodeCreator
      See Also:
    • textNode

      public TextNode textNode(String text)
      Factory method for constructing a node that represents JSON String value
      Specified by:
      textNode in interface JsonNodeCreator
    • binaryNode

      public BinaryNode binaryNode(byte[] data)
      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 interface JsonNodeCreator
    • binaryNode

      public BinaryNode binaryNode(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 value
      Specified by:
      binaryNode in interface JsonNodeCreator
    • arrayNode

      public ArrayNode arrayNode()
      Factory method for constructing an empty JSON Array node
      Specified by:
      arrayNode in interface JsonNodeCreator
    • arrayNode

      public ArrayNode arrayNode(int capacity)
      Factory method for constructing a JSON Array node with an initial capacity
      Specified by:
      arrayNode in interface JsonNodeCreator
      Since:
      2.8
    • objectNode

      public ObjectNode objectNode()
      Factory method for constructing an empty JSON Object ("struct") node
      Specified by:
      objectNode in interface JsonNodeCreator
    • pojoNode

      public ValueNode pojoNode(Object pojo)
      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 interface JsonNodeCreator
    • rawValueNode

      public ValueNode rawValueNode(RawValue value)
      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 interface JsonNodeCreator
    • _inIntRange

      protected boolean _inIntRange(long l)