JsonStreamContext
Date: 2016-12-03

com.fasterxml.jackson.core

## Class JsonStreamContext

- java.lang.Object
- - com.fasterxml.jackson.core.JsonStreamContext

- Direct Known Subclasses:
    JsonReadContext, JsonWriteContext, TokenFilterContext

      public abstract class JsonStreamContext
      extends java.lang.Object

  Shared base class for streaming processing contexts used during reading and writing of Json content using Streaming API. This context is also exposed to applications: context object can be used by applications to get an idea of relative position of the parser/generator within json content being processed. This allows for some contextual processing: for example, output within Array context can differ from that of Object context.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `_index` Index of the currently processed entry.
    `protected int` | `_type`
    `protected static int` | `TYPE_ARRAY`
    `protected static int` | `TYPE_OBJECT`
    `protected static int` | `TYPE_ROOT`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `JsonStreamContext()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getCurrentIndex()`
    `abstract java.lang.String` | `getCurrentName()` Method for accessing name associated with the current location.
    `java.lang.Object` | `getCurrentValue()` Method for accessing currently active value being used by data-binding (as the source of streaming data to write, or destination of data being read), at this level in hierarchy.
    `int` | `getEntryCount()`
    `abstract JsonStreamContext` | `getParent()` Accessor for finding parent context of this context; will return null for root context.
    `java.lang.String` | `getTypeDesc()` Deprecated. Since 2.8 use `typeDesc()` instead
    `boolean` | `inArray()` Method that returns true if this context is an Array context; that is, content is being read from or written to a Json Array.
    `boolean` | `inObject()` Method that returns true if this context is an Object context; that is, content is being read from or written to a Json Object.
    `boolean` | `inRoot()` Method that returns true if this context is a Root context; that is, content is being read from or written to without enclosing array or object structure.
    `void` | `setCurrentValue(java.lang.Object v)` Method to call to pass value to be returned via `getCurrentValue()`; typically called indirectly through `JsonParser.setCurrentValue(java.lang.Object)` or `JsonGenerator.setCurrentValue(java.lang.Object)`).
    `java.lang.String` | `typeDesc()`

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### TYPE_ROOT

          protected static final int TYPE_ROOT

      See Also:
        Constant Field Values

    - #### TYPE_ARRAY

          protected static final int TYPE_ARRAY

      See Also:
        Constant Field Values

    - #### TYPE_OBJECT

          protected static final int TYPE_OBJECT

      See Also:
        Constant Field Values

    - #### _type

          protected int _type

    - #### _index

          protected int _index

      Index of the currently processed entry. Starts with -1 to signal that no entries have been started, and gets advanced each time a new entry is started, either by encountering an expected separator, or with new values if no separators are expected (the case for root context).

  - ### Constructor Detail

    - #### JsonStreamContext

          protected JsonStreamContext()

  - ### Method Detail

    - #### getParent

          public abstract JsonStreamContext getParent()

      Accessor for finding parent context of this context; will return null for root context.

    - #### inArray

          public final boolean inArray()

      Method that returns true if this context is an Array context; that is, content is being read from or written to a Json Array.

    - #### inRoot

          public final boolean inRoot()

      Method that returns true if this context is a Root context; that is, content is being read from or written to without enclosing array or object structure.

    - #### inObject

          public final boolean inObject()

      Method that returns true if this context is an Object context; that is, content is being read from or written to a Json Object.

    - #### getTypeDesc

          @Deprecated
          public final java.lang.String getTypeDesc()

      Deprecated. Since 2.8 use `typeDesc()` instead
      Method for accessing simple type description of current context; either ROOT (for root-level values), OBJECT (for field names and values of JSON Objects) or ARRAY (for values of JSON Arrays)

    - #### typeDesc

          public java.lang.String typeDesc()

      Since:
        2.8

    - #### getEntryCount

          public final int getEntryCount()

      Returns:
        Number of entries that are complete and started.

    - #### getCurrentIndex

          public final int getCurrentIndex()

      Returns:
        Index of the currently processed entry, if any

    - #### getCurrentName

          public abstract java.lang.String getCurrentName()

      Method for accessing name associated with the current location. Non-null for `FIELD_NAME` and value events that directly follow field names; null for root level and array values.

    - #### getCurrentValue

          public java.lang.Object getCurrentValue()

      Method for accessing currently active value being used by data-binding (as the source of streaming data to write, or destination of data being read), at this level in hierarchy.

      Note that "current value" is NOT populated (or used) by Streaming parser or generator; it is only used by higher-level data-binding functionality. The reason it is included here is that it can be stored and accessed hierarchically, and gets passed through data-binding.

      Returns:
        Currently active value, if one has been assigned.
      Since:
        2.5

    - #### setCurrentValue

          public void setCurrentValue(java.lang.Object v)

      Method to call to pass value to be returned via `getCurrentValue()`; typically called indirectly through `JsonParser.setCurrentValue(java.lang.Object)` or `JsonGenerator.setCurrentValue(java.lang.Object)`).
      Since:
        2.5