com.fasterxml.jackson.dataformat.avro.ser

## Class AvroWriteContext

- java.lang.Object
- - com.fasterxml.jackson.core.JsonStreamContext
  - - com.fasterxml.jackson.dataformat.avro.ser.AvroWriteContext

- Direct Known Subclasses:
    ArrayWriteContext, MapWriteContext, NopWriteContext, ObjectWriteContext

      public abstract class AvroWriteContext
      extends com.fasterxml.jackson.core.JsonStreamContext

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Object` | `_currentValue`
    `protected AvroGenerator` | `_generator`
    `protected AvroWriteContext` | `_parent`
    `protected org.apache.avro.Schema` | `_schema`

    - ### 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` | `AvroWriteContext(int type, AvroWriteContext parent, AvroGenerator generator, org.apache.avro.Schema schema, Object currValue)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected org.apache.avro.generic.GenericArray<Object>` | `_createArray(org.apache.avro.Schema schema)`
    `protected AvroWriteContext` | `_createObjectContext(org.apache.avro.Schema schema, Object currValue)`
    `protected org.apache.avro.generic.GenericRecord` | `_createRecord(org.apache.avro.Schema schema)`
    `protected org.apache.avro.generic.GenericRecord` | `_createRecord(org.apache.avro.Schema schema, Object currValue)`
    `protected org.apache.avro.Schema` | `_recordOrMapFromUnion(org.apache.avro.Schema unionSchema)`
    `protected abstract void` | `appendDesc(StringBuilder sb)`
    `boolean` | `canClose()`
    `void` | `complete()`
    `abstract AvroWriteContext` | `createChildArrayContext(Object currValue)`
    `abstract AvroWriteContext` | `createChildObjectContext(Object currValue)`
    `static AvroWriteContext` | `createRootContext(AvroGenerator generator, org.apache.avro.Schema schema, org.apache.avro.io.BinaryEncoder encoder)`
    `String` | `getCurrentName()`
    `Object` | `getCurrentValue()`
    `AvroWriteContext` | `getParent()`
    `static AvroWriteContext` | `nullContext()` Factory method called to get a placeholder context that is only in place until actual schema is handed.
    `abstract Object` | `rawValue()` Accessor called to link data being built with resulting object.
    `static int` | `resolveUnionIndex(org.apache.avro.Schema unionSchema, Object datum)` Resolves the sub-schema from a union that should correspond to the `datum`.
    `static org.apache.avro.Schema` | `resolveUnionSchema(org.apache.avro.Schema unionSchema, Object datum)` Resolves the sub-schema from a union that should correspond to the `datum`.
    `static org.apache.avro.Schema` | `resolveUnionType(org.apache.avro.Schema unionSchema, Object datum)`
    `void` | `setCurrentValue(Object v)`
    `String` | `toString()` Overridden to provide developer writeable "JsonPath" representation of the context.
    `boolean` | `writeFieldName(String name)` Method that writer is to call before it writes a field name.
    `abstract void` | `writeNull()`
    `abstract void` | `writeString(String value)`
    `abstract void` | `writeValue(Object value)`

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

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

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

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

- - ### Field Detail

    - #### _parent

          protected final AvroWriteContext _parent

    - #### _generator

          protected final AvroGenerator _generator

    - #### _schema

          protected final org.apache.avro.Schema _schema

    - #### _currentValue

          protected Object _currentValue

      Since:
        2.9

  - ### Constructor Detail

    - #### AvroWriteContext

          protected AvroWriteContext(int type,
                                     AvroWriteContext parent,
                                     AvroGenerator generator,
                                     org.apache.avro.Schema schema,
                                     Object currValue)

  - ### Method Detail

    - #### createRootContext

          public static AvroWriteContext createRootContext(AvroGenerator generator,
                                                           org.apache.avro.Schema schema,
                                                           org.apache.avro.io.BinaryEncoder encoder)

    - #### nullContext

          public static AvroWriteContext nullContext()

      Factory method called to get a placeholder context that is only in place until actual schema is handed.

    - #### createChildArrayContext

          public abstract AvroWriteContext createChildArrayContext(Object currValue)
                                                            throws com.fasterxml.jackson.databind.JsonMappingException

      Throws:
        `com.fasterxml.jackson.databind.JsonMappingException`

    - #### createChildObjectContext

          public abstract AvroWriteContext createChildObjectContext(Object currValue)
                                                             throws com.fasterxml.jackson.databind.JsonMappingException

      Throws:
        `com.fasterxml.jackson.databind.JsonMappingException`

    - #### complete

          public void complete()
                        throws IOException

      Throws:
        `IOException`

    - #### 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`

    - #### getParent

          public final AvroWriteContext getParent()

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

    - #### getCurrentName

          public String getCurrentName()

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

    - #### writeFieldName

          public boolean writeFieldName(String name)
                                 throws IOException

      Method that writer is to call before it writes a field name.
      Returns:
        True if writing succeeded (for `ObjectWriteContext`, iff column was recognized)
      Throws:
        `IOException`

    - #### writeValue

          public abstract void writeValue(Object value)
                                   throws IOException

      Throws:
        `IOException`

    - #### writeString

          public abstract void writeString(String value)
                                    throws IOException

      Throws:
        `IOException`
      Since:
        2.5

    - #### writeNull

          public abstract void writeNull()
                                  throws IOException

      Throws:
        `IOException`
      Since:
        2.8

    - #### rawValue

          public abstract Object rawValue()

      Accessor called to link data being built with resulting object.

    - #### canClose

          public boolean canClose()

    - #### appendDesc

          protected abstract void appendDesc(StringBuilder sb)

    - #### toString

          public final String toString()

      Overridden to provide developer writeable "JsonPath" representation of the context.
      Overrides:
        `toString` in class `com.fasterxml.jackson.core.JsonStreamContext`

    - #### _createRecord

          protected org.apache.avro.generic.GenericRecord _createRecord(org.apache.avro.Schema schema,
                                                                        Object currValue)
                                                                 throws com.fasterxml.jackson.databind.JsonMappingException

      Throws:
        `com.fasterxml.jackson.databind.JsonMappingException`

    - #### _createRecord

          protected org.apache.avro.generic.GenericRecord _createRecord(org.apache.avro.Schema schema)
                                                                 throws com.fasterxml.jackson.databind.JsonMappingException

      Throws:
        `com.fasterxml.jackson.databind.JsonMappingException`

    - #### _createArray

          protected org.apache.avro.generic.GenericArray<Object> _createArray(org.apache.avro.Schema schema)

    - #### _createObjectContext

          protected AvroWriteContext _createObjectContext(org.apache.avro.Schema schema,
                                                          Object currValue)
                                                   throws com.fasterxml.jackson.databind.JsonMappingException

      Throws:
        `com.fasterxml.jackson.databind.JsonMappingException`

    - #### _recordOrMapFromUnion

          protected org.apache.avro.Schema _recordOrMapFromUnion(org.apache.avro.Schema unionSchema)

    - #### resolveUnionIndex

          public static int resolveUnionIndex(org.apache.avro.Schema unionSchema,
                                              Object datum)

      Resolves the sub-schema from a union that should correspond to the `datum`.
      Parameters:
        `unionSchema` - Union of schemas from which to choose
        `datum` - Object that needs to map to one of the schemas in `unionSchema`
      Returns:
        Index into `unionSchema.getTypes()` that matches `datum`
      Throws:
        `org.apache.avro.UnresolvedUnionException` - if `unionSchema` does not have a schema that can encode `datum`
      See Also:
        `resolveUnionSchema(Schema, Object)`

    - #### resolveUnionType

          public static org.apache.avro.Schema resolveUnionType(org.apache.avro.Schema unionSchema,
                                                                Object datum)

    - #### resolveUnionSchema

          public static org.apache.avro.Schema resolveUnionSchema(org.apache.avro.Schema unionSchema,
                                                                  Object datum)

      Resolves the sub-schema from a union that should correspond to the `datum`.
      Parameters:
        `unionSchema` - Union of schemas from which to choose
        `datum` - Object that needs to map to one of the schemas in `unionSchema`
      Returns:
        Schema that matches `datum`
      Throws:
        `org.apache.avro.UnresolvedUnionException` - if `unionSchema` does not have a schema that can encode `datum`
      See Also:
        `resolveUnionIndex(Schema, Object)`

Copyright © 2019 FasterXML. All rights reserved.