TokenFilterContext (Jackson-core 2.14.0 API)

com.fasterxml.jackson.core.filter

## Class TokenFilterContext

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

-     public class TokenFilterContext
      extends JsonStreamContext

  Alternative variant of `JsonStreamContext`, used when filtering content being read or written (based on `TokenFilter`).
  Since:
    2.6

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected TokenFilterContext` | `_child`
    `protected String` | `_currentName` Name of the field of which value is to be parsed; only used for OBJECT contexts
    `protected TokenFilter` | `_filter` Filter to use for items in this state (for properties of Objects, elements of Arrays, and root-level values of root context)
    `protected boolean` | `_needToHandleName` Flag that indicates that the current name of this context still needs to be read/written, if path from root down to included leaf is to be exposed.
    `protected TokenFilterContext` | `_parent` Parent context for this context; null for root context.
    `protected boolean` | `_startHandled` Flag that indicates that start token has been read/written, so that matching close token needs to be read/written as well when context is getting closed.

    - ### Fields inherited from class com.fasterxml.jackson.core.JsonStreamContext

      `_index, _type, TYPE_ARRAY, TYPE_OBJECT, TYPE_ROOT`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `TokenFilterContext(int type, TokenFilterContext parent, TokenFilter filter, boolean startHandled)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `appendDesc(StringBuilder sb)`
    `TokenFilter` | `checkValue(TokenFilter filter)` Method called to check whether value is to be included at current output position, either as Object property, Array element, or root value.
    `TokenFilterContext` | `closeArray(JsonGenerator gen)`
    `TokenFilterContext` | `closeObject(JsonGenerator gen)`
    `TokenFilterContext` | `createChildArrayContext(TokenFilter filter, boolean writeStart)`
    `TokenFilterContext` | `createChildObjectContext(TokenFilter filter, boolean writeStart)`
    `static TokenFilterContext` | `createRootContext(TokenFilter filter)`
    `void` | `ensureFieldNameWritten(JsonGenerator gen)` Method called to ensure that field name, if present, has been written; may result (but does not always) in a call using given generator
    `TokenFilterContext` | `findChildOf(TokenFilterContext parent)`
    `String` | `getCurrentName()` Method for accessing name associated with the current location.
    `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.
    `TokenFilter` | `getFilter()`
    `TokenFilterContext` | `getParent()` Accessor for finding parent context of this context; will return null for root context.
    `boolean` | `hasCurrentName()`
    `boolean` | `isStartHandled()`
    `JsonToken` | `nextTokenToRead()`
    `protected TokenFilterContext` | `reset(int type, TokenFilter filter, boolean startWritten)`
    `void` | `setCurrentValue(Object v)` Method to call to pass value to be returned via `JsonStreamContext.getCurrentValue()`; typically called indirectly through `JsonParser.setCurrentValue(java.lang.Object)` or `JsonGenerator.setCurrentValue(java.lang.Object)`).
    `TokenFilter` | `setFieldName(String name)`
    `void` | `skipParentChecks()`
    `String` | `toString()` Overridden to provide developer readable "JsonPath" representation of the context.
    `void` | `writePath(JsonGenerator gen)` Method called to ensure that parent path from root is written up to and including this node.

    - ### Methods inherited from class com.fasterxml.jackson.core.JsonStreamContext

      `getCurrentIndex, getEntryCount, getStartLocation, getTypeDesc, hasCurrentIndex, hasPathSegment, inArray, inObject, inRoot, pathAsPointer, pathAsPointer, startLocation, typeDesc`

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

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

- - ### Field Detail

    - #### _parent

          protected final TokenFilterContext _parent

      Parent context for this context; null for root context.

    - #### _child

          protected TokenFilterContext _child

    - #### _currentName

          protected String _currentName

      Name of the field of which value is to be parsed; only used for OBJECT contexts

    - #### _filter

          protected TokenFilter _filter

      Filter to use for items in this state (for properties of Objects, elements of Arrays, and root-level values of root context)

    - #### _startHandled

          protected boolean _startHandled

      Flag that indicates that start token has been read/written, so that matching close token needs to be read/written as well when context is getting closed.

    - #### _needToHandleName

          protected boolean _needToHandleName

      Flag that indicates that the current name of this context still needs to be read/written, if path from root down to included leaf is to be exposed.

  - ### Constructor Detail

    - #### TokenFilterContext

          protected TokenFilterContext(int type,
                                       TokenFilterContext parent,
                                       TokenFilter filter,
                                       boolean startHandled)

  - ### Method Detail

    - #### reset

          protected TokenFilterContext reset(int type,
                                             TokenFilter filter,
                                             boolean startWritten)

    - #### createRootContext

          public static TokenFilterContext createRootContext(TokenFilter filter)

    - #### createChildArrayContext

          public TokenFilterContext createChildArrayContext(TokenFilter filter,
                                                            boolean writeStart)

    - #### createChildObjectContext

          public TokenFilterContext createChildObjectContext(TokenFilter filter,
                                                             boolean writeStart)

    - #### setFieldName

          public TokenFilter setFieldName(String name)
                                   throws JsonProcessingException

      Throws:
        `JsonProcessingException`

    - #### checkValue

          public TokenFilter checkValue(TokenFilter filter)

      Method called to check whether value is to be included at current output position, either as Object property, Array element, or root value.
      Parameters:
        `filter` - Currently active filter
      Returns:
        Filter to use for value

    - #### ensureFieldNameWritten

          public void ensureFieldNameWritten(JsonGenerator gen)
                                      throws IOException

      Method called to ensure that field name, if present, has been written; may result (but does not always) in a call using given generator
      Parameters:
        `gen` - Generator to use to write the property name, if necessary
      Throws:
        `IOException` - If there is a problem writing property name (typically thrown by `JsonGenerator`)

    - #### writePath

          public void writePath(JsonGenerator gen)
                         throws IOException

      Method called to ensure that parent path from root is written up to and including this node.
      Parameters:
        `gen` - Generator to use to write the path, if necessary
      Throws:
        `IOException` - If there is a problem writing property name (typically thrown by `JsonGenerator`)

    - #### closeArray

          public TokenFilterContext closeArray(JsonGenerator gen)
                                        throws IOException

      Throws:
        `IOException`

    - #### closeObject

          public TokenFilterContext closeObject(JsonGenerator gen)
                                         throws IOException

      Throws:
        `IOException`

    - #### skipParentChecks

          public void skipParentChecks()

    - #### getCurrentValue

          public Object getCurrentValue()

      Description copied from class: `JsonStreamContext`
      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.

      Overrides:
        `getCurrentValue` in class `JsonStreamContext`
      Returns:
        Currently active value, if one has been assigned.

    - #### setCurrentValue

          public void setCurrentValue(Object v)

      Description copied from class: `JsonStreamContext`
      Method to call to pass value to be returned via `JsonStreamContext.getCurrentValue()`; typically called indirectly through `JsonParser.setCurrentValue(java.lang.Object)` or `JsonGenerator.setCurrentValue(java.lang.Object)`).
      Overrides:
        `setCurrentValue` in class `JsonStreamContext`
      Parameters:
        `v` - Current value to assign to this context

    - #### getParent

          public final TokenFilterContext getParent()

      Description copied from class: `JsonStreamContext`
      Accessor for finding parent context of this context; will return null for root context.
      Specified by:
        `getParent` in class `JsonStreamContext`
      Returns:
        Parent context of this context, if any; `null` for Root contexts

    - #### getCurrentName

          public final String getCurrentName()

      Description copied from class: `JsonStreamContext`
      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.
      Specified by:
        `getCurrentName` in class `JsonStreamContext`
      Returns:
        Current field name within context, if any; `null` if none

    - #### hasCurrentName

          public boolean hasCurrentName()

      Overrides:
        `hasCurrentName` in class `JsonStreamContext`
      Returns:
        `True` if a call to `JsonStreamContext.getCurrentName()` would return non-`null` name; `false` otherwise

    - #### getFilter

          public TokenFilter getFilter()

    - #### isStartHandled

          public boolean isStartHandled()

    - #### nextTokenToRead

          public JsonToken nextTokenToRead()

    - #### findChildOf

          public TokenFilterContext findChildOf(TokenFilterContext parent)

    - #### appendDesc

          protected void appendDesc(StringBuilder sb)

    - #### toString

          public String toString()

      Description copied from class: `JsonStreamContext`
      Overridden to provide developer readable "JsonPath" representation of the context.
      Overrides:
        `toString` in class `JsonStreamContext`
      Returns:
        Simple developer-readable description this context layer (note: NOT constructed with parents, unlike `JsonStreamContext.pathAsPointer()`)

Copyright © 2008–2022 FasterXML. All rights reserved.