com.fasterxml.jackson.dataformat.smile

## Class SmileWriteContext

- java.lang.Object
- - com.fasterxml.jackson.core.JsonStreamContext
  - - com.fasterxml.jackson.dataformat.smile.SmileWriteContext

-     public final class SmileWriteContext
      extends com.fasterxml.jackson.core.JsonStreamContext

  Replacement for `JsonWriteContext`; while not strictly needed is more streamlined, optimal since there's no need to keep track of separators etc.
  Since:
    2.10

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected SmileWriteContext` | `_childToRecycle`
    `protected String` | `_currentName` Name of the field of which value is to be written; only used for OBJECT contexts
    `protected Object` | `_currentValue`
    `protected com.fasterxml.jackson.core.json.DupDetector` | `_dups`
    `protected boolean` | `_gotFieldId` Marker used to indicate that we just wrote a field name (or Map name / id) and now expect a value to write
    `protected SmileWriteContext` | `_parent` Parent context for this context; null for root context.

    - ### 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` | `SmileWriteContext(int type, SmileWriteContext parent, com.fasterxml.jackson.core.json.DupDetector dups, Object currentValue)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `SmileWriteContext` | `clearAndGetParent()` Method that can be used to both clear the accumulated references (specifically value set with `setCurrentValue(Object)`) that should not be retained, and returns parent (as would `getParent()` do).
    `SmileWriteContext` | `createChildArrayContext(Object currentValue)`
    `SmileWriteContext` | `createChildObjectContext(Object currentValue)`
    `static SmileWriteContext` | `createRootContext(com.fasterxml.jackson.core.json.DupDetector dd)`
    `String` | `getCurrentName()`
    `Object` | `getCurrentValue()`
    `com.fasterxml.jackson.core.json.DupDetector` | `getDupDetector()`
    `SmileWriteContext` | `getParent()`
    `boolean` | `hasCurrentName()`
    `void` | `setCurrentValue(Object v)`
    `SmileWriteContext` | `withDupDetector(com.fasterxml.jackson.core.json.DupDetector dups)`
    `boolean` | `writeFieldName(String name)` Method that writer is to call before it writes a field name.
    `boolean` | `writeValue()`

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

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

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

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

- - ### Field Detail

    - #### _parent

          protected final SmileWriteContext _parent

      Parent context for this context; null for root context.

    - #### _dups

          protected com.fasterxml.jackson.core.json.DupDetector _dups

    - #### _childToRecycle

          protected SmileWriteContext _childToRecycle

    - #### _currentName

          protected String _currentName

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

    - #### _currentValue

          protected Object _currentValue

    - #### _gotFieldId

          protected boolean _gotFieldId

      Marker used to indicate that we just wrote a field name (or Map name / id) and now expect a value to write

  - ### Constructor Detail

    - #### SmileWriteContext

          protected SmileWriteContext(int type,
                                      SmileWriteContext parent,
                                      com.fasterxml.jackson.core.json.DupDetector dups,
                                      Object currentValue)

  - ### Method Detail

    - #### withDupDetector

          public SmileWriteContext withDupDetector(com.fasterxml.jackson.core.json.DupDetector dups)

    - #### getCurrentValue

          public Object getCurrentValue()

      Overrides:
        `getCurrentValue` in class `com.fasterxml.jackson.core.JsonStreamContext`

    - #### setCurrentValue

          public void setCurrentValue(Object v)

      Overrides:
        `setCurrentValue` in class `com.fasterxml.jackson.core.JsonStreamContext`

    - #### createRootContext

          public static SmileWriteContext createRootContext(com.fasterxml.jackson.core.json.DupDetector dd)

    - #### createChildArrayContext

          public SmileWriteContext createChildArrayContext(Object currentValue)

    - #### createChildObjectContext

          public SmileWriteContext createChildObjectContext(Object currentValue)

    - #### getParent

          public final SmileWriteContext getParent()

      Specified by:
        `getParent` in class `com.fasterxml.jackson.core.JsonStreamContext`

    - #### getCurrentName

          public final String getCurrentName()

      Specified by:
        `getCurrentName` in class `com.fasterxml.jackson.core.JsonStreamContext`

    - #### hasCurrentName

          public boolean hasCurrentName()

      Overrides:
        `hasCurrentName` in class `com.fasterxml.jackson.core.JsonStreamContext`

    - #### clearAndGetParent

          public SmileWriteContext clearAndGetParent()

      Method that can be used to both clear the accumulated references (specifically value set with `setCurrentValue(Object)`) that should not be retained, and returns parent (as would `getParent()` do). Typically called when closing the active context when encountering `JsonToken.END_ARRAY` or `JsonToken.END_OBJECT`.

    - #### getDupDetector

          public com.fasterxml.jackson.core.json.DupDetector getDupDetector()

    - #### writeFieldName

          public boolean writeFieldName(String name)
                                 throws com.fasterxml.jackson.core.JsonProcessingException

      Method that writer is to call before it writes a field name.
      Returns:
        Ok if name writing should proceed
      Throws:
        `com.fasterxml.jackson.core.JsonProcessingException`

    - #### writeValue

          public boolean writeValue()

Copyright © 2019 FasterXML. All rights reserved.