com.fasterxml.jackson.databind.node

## Class ContainerNode<T extends ContainerNode<T>>

- java.lang.Object
- - com.fasterxml.jackson.databind.JsonSerializable.Base
  - - com.fasterxml.jackson.databind.JsonNode
    - - com.fasterxml.jackson.databind.node.BaseJsonNode
      - - com.fasterxml.jackson.databind.node.ContainerNode<T>

- All Implemented Interfaces:
    com.fasterxml.jackson.core.TreeNode, JsonSerializable, JsonNodeCreator, java.lang.Iterable<JsonNode>
  Direct Known Subclasses:
    ArrayNode, ObjectNode

      public abstract class ContainerNode<T extends ContainerNode<T>>
      extends BaseJsonNode
      implements JsonNodeCreator

  This intermediate base class is used for all container nodes, specifically, array and object nodes.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.fasterxml.jackson.databind.JsonSerializable

      `JsonSerializable.Base`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected JsonNodeFactory` | `_nodeFactory` We will keep a reference to the Object (usually TreeMapper) that can construct instances of nodes to add to this container node.

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `ContainerNode(JsonNodeFactory nc)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `ArrayNode` | `arrayNode()` Factory method that constructs and returns an empty `ArrayNode` Construction is done using registered `JsonNodeFactory`.
    `ArrayNode` | `arrayNode(int capacity)` Factory method that constructs and returns an `ArrayNode` with an initial capacity Construction is done using registered `JsonNodeFactory`
    `java.lang.String` | `asText()` Method that will return a valid String representation of the container value, if the node is a value node (method `JsonNode.isValueNode()` returns true), otherwise empty String.
    `abstract com.fasterxml.jackson.core.JsonToken` | `asToken()` Method that can be used for efficient type detection when using stream abstraction for traversing nodes.
    `BinaryNode` | `binaryNode(byte[] data)`
    `BinaryNode` | `binaryNode(byte[] data, int offset, int length)`
    `BooleanNode` | `booleanNode(boolean v)`
    `abstract JsonNode` | `get(int index)` Method for accessing value of the specified element of an array node.
    `abstract JsonNode` | `get(java.lang.String fieldName)` Method for accessing value of the specified field of an object node.
    `NullNode` | `nullNode()`
    `NumericNode` | `numberNode(java.math.BigDecimal v)`
    `NumericNode` | `numberNode(java.math.BigInteger v)`
    `NumericNode` | `numberNode(byte v)`
    `ValueNode` | `numberNode(java.lang.Byte v)`
    `NumericNode` | `numberNode(double v)`
    `ValueNode` | `numberNode(java.lang.Double v)`
    `NumericNode` | `numberNode(float v)`
    `ValueNode` | `numberNode(java.lang.Float v)`
    `NumericNode` | `numberNode(int v)`
    `ValueNode` | `numberNode(java.lang.Integer v)`
    `NumericNode` | `numberNode(long v)`
    `ValueNode` | `numberNode(java.lang.Long v)`
    `NumericNode` | `numberNode(short v)`
    `ValueNode` | `numberNode(java.lang.Short v)`
    `ObjectNode` | `objectNode()` Factory method that constructs and returns an empty `ObjectNode` Construction is done using registered `JsonNodeFactory`.
    `ValueNode` | `pojoNode(java.lang.Object pojo)`
    `ValueNode` | `rawValueNode(RawValue value)` Factory method to use for adding "raw values"; pre-encoded values that are included exactly as-is when node is serialized.
    `abstract T` | `removeAll()` Method for removing all children container has (if any)
    `abstract int` | `size()`
    `TextNode` | `textNode(java.lang.String text)`

    - ### Methods inherited from class com.fasterxml.jackson.databind.node.BaseJsonNode

      `findPath, hashCode, numberType, serialize, serializeWithType, traverse, traverse`

    - ### Methods inherited from class com.fasterxml.jackson.databind.JsonNode

      `_at, asBoolean, asBoolean, asDouble, asDouble, asInt, asInt, asLong, asLong, asText, at, at, bigIntegerValue, binaryValue, booleanValue, canConvertToInt, canConvertToLong, decimalValue, deepCopy, doubleValue, elements, equals, equals, fieldNames, fields, findParent, findParents, findParents, findValue, findValues, findValues, findValuesAsText, findValuesAsText, floatValue, getNodeType, has, has, hasNonNull, hasNonNull, intValue, isArray, isBigDecimal, isBigInteger, isBinary, isBoolean, isContainerNode, isDouble, isFloat, isFloatingPointNumber, isInt, isIntegralNumber, isLong, isMissingNode, isNull, isNumber, isObject, isPojo, isShort, isTextual, isValueNode, iterator, longValue, numberValue, path, path, shortValue, textValue, toString, with, withArray`

    - ### Methods inherited from class com.fasterxml.jackson.databind.JsonSerializable.Base

      `isEmpty`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### _nodeFactory

          protected final JsonNodeFactory _nodeFactory

      We will keep a reference to the Object (usually TreeMapper) that can construct instances of nodes to add to this container node.

  - ### Constructor Detail

    - #### ContainerNode

          protected ContainerNode(JsonNodeFactory nc)

  - ### Method Detail

    - #### asToken

          public abstract com.fasterxml.jackson.core.JsonToken asToken()

      Description copied from class: `BaseJsonNode`
      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)
      Specified by:
        `asToken` in interface `com.fasterxml.jackson.core.TreeNode`
      Specified by:
        `asToken` in class `BaseJsonNode`

    - #### asText

          public java.lang.String asText()

      Description copied from class: `JsonNode`
      Method that will return a valid String representation of the container value, if the node is a value node (method `JsonNode.isValueNode()` returns true), otherwise empty String.
      Specified by:
        `asText` in class `JsonNode`

    - #### size

          public abstract int size()

      Specified by:
        `size` in interface `com.fasterxml.jackson.core.TreeNode`
      Overrides:
        `size` in class `JsonNode`

    - #### get

          public abstract JsonNode get(int index)

      Description copied from class: `JsonNode`
      Method for accessing value of the specified element of an array node. For other nodes, null is always returned.

      For array nodes, index specifies exact location within array and allows for efficient iteration over child elements (underlying storage is guaranteed to be efficiently indexable, i.e. has random-access to elements). If index is less than 0, or equal-or-greater than `node.size()`, null is returned; no exception is thrown for any index.

      NOTE: if the element value has been explicitly set as `null` (which is different from removal!), a `NullNode` will be returned, not null.

      Specified by:
        `get` in interface `com.fasterxml.jackson.core.TreeNode`
      Specified by:
        `get` in class `JsonNode`
      Returns:
        Node that represent value of the specified element, if this node is an array and has specified element. Null otherwise.

    - #### get

          public abstract JsonNode get(java.lang.String fieldName)

      Description copied from class: `JsonNode`
      Method for accessing value of the specified field of an object node. If this node is not an object (or it does not have a value for specified field name), or if there is no field with such name, null is returned.

      NOTE: if the property value has been explicitly set as `null` (which is different from removal!), a `NullNode` will be returned, not null.

      Specified by:
        `get` in interface `com.fasterxml.jackson.core.TreeNode`
      Overrides:
        `get` in class `JsonNode`
      Returns:
        Node that represent value of the specified field, if this node is an object and has value for the specified field. Null otherwise.

    - #### arrayNode

          public final ArrayNode arrayNode()

      Factory method that constructs and returns an empty `ArrayNode` Construction is done using registered `JsonNodeFactory`.
      Specified by:
        `arrayNode` in interface `JsonNodeCreator`

    - #### arrayNode

          public final ArrayNode arrayNode(int capacity)

      Factory method that constructs and returns an `ArrayNode` with an initial capacity Construction is done using registered `JsonNodeFactory`
      Specified by:
        `arrayNode` in interface `JsonNodeCreator`
      Parameters:
        `capacity` - the initial capacity of the ArrayNode

    - #### objectNode

          public final ObjectNode objectNode()

      Factory method that constructs and returns an empty `ObjectNode` Construction is done using registered `JsonNodeFactory`.
      Specified by:
        `objectNode` in interface `JsonNodeCreator`

    - #### nullNode

          public final NullNode nullNode()

      Specified by:
        `nullNode` in interface `JsonNodeCreator`

    - #### booleanNode

          public final BooleanNode booleanNode(boolean v)

      Specified by:
        `booleanNode` in interface `JsonNodeCreator`

    - #### numberNode

          public final NumericNode numberNode(byte v)

      Specified by:
        `numberNode` in interface `JsonNodeCreator`

    - #### numberNode

          public final NumericNode numberNode(short v)

      Specified by:
        `numberNode` in interface `JsonNodeCreator`

    - #### numberNode

          public final NumericNode numberNode(int v)

      Specified by:
        `numberNode` in interface `JsonNodeCreator`

    - #### numberNode

          public final NumericNode numberNode(long v)

      Specified by:
        `numberNode` in interface `JsonNodeCreator`

    - #### numberNode

          public final NumericNode numberNode(java.math.BigInteger v)

      Specified by:
        `numberNode` in interface `JsonNodeCreator`

    - #### numberNode

          public final NumericNode numberNode(float v)

      Specified by:
        `numberNode` in interface `JsonNodeCreator`

    - #### numberNode

          public final NumericNode numberNode(double v)

      Specified by:
        `numberNode` in interface `JsonNodeCreator`

    - #### numberNode

          public final NumericNode numberNode(java.math.BigDecimal v)

      Specified by:
        `numberNode` in interface `JsonNodeCreator`

    - #### numberNode

          public final ValueNode numberNode(java.lang.Byte v)

      Specified by:
        `numberNode` in interface `JsonNodeCreator`

    - #### numberNode

          public final ValueNode numberNode(java.lang.Short v)

      Specified by:
        `numberNode` in interface `JsonNodeCreator`

    - #### numberNode

          public final ValueNode numberNode(java.lang.Integer v)

      Specified by:
        `numberNode` in interface `JsonNodeCreator`

    - #### numberNode

          public final ValueNode numberNode(java.lang.Long v)

      Specified by:
        `numberNode` in interface `JsonNodeCreator`

    - #### numberNode

          public final ValueNode numberNode(java.lang.Float v)

      Specified by:
        `numberNode` in interface `JsonNodeCreator`

    - #### numberNode

          public final ValueNode numberNode(java.lang.Double v)

      Specified by:
        `numberNode` in interface `JsonNodeCreator`

    - #### textNode

          public final TextNode textNode(java.lang.String text)

      Specified by:
        `textNode` in interface `JsonNodeCreator`

    - #### binaryNode

          public final BinaryNode binaryNode(byte[] data)

      Specified by:
        `binaryNode` in interface `JsonNodeCreator`

    - #### binaryNode

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

      Specified by:
        `binaryNode` in interface `JsonNodeCreator`

    - #### pojoNode

          public final ValueNode pojoNode(java.lang.Object pojo)

      Specified by:
        `pojoNode` in interface `JsonNodeCreator`

    - #### rawValueNode

          public final 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`

    - #### removeAll

          public abstract T removeAll()

      Method for removing all children container has (if any)
      Returns:
        Container node itself (to allow method call chaining)