Class AvroWriteContext

java.lang.Object
tools.jackson.core.TokenStreamContext
tools.jackson.dataformat.avro.ser.AvroWriteContext
Direct Known Subclasses:
ArrayWriteContext, MapWriteContext, NopWriteContext, ObjectWriteContext

public abstract class AvroWriteContext extends tools.jackson.core.TokenStreamContext
  • Field Details

    • _parent

      protected final AvroWriteContext _parent
    • _generator

      protected final AvroGenerator _generator
    • _schema

      protected final org.apache.avro.Schema _schema
    • _currentValue

      protected Object _currentValue
  • Constructor Details

  • Method Details

    • 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)
    • createChildObjectContext

      public abstract AvroWriteContext createChildObjectContext(Object currValue)
    • complete

      public void complete() throws IOException
      Throws:
      IOException
    • currentValue

      public Object currentValue()
      Overrides:
      currentValue in class tools.jackson.core.TokenStreamContext
    • assignCurrentValue

      public void assignCurrentValue(Object v)
      Overrides:
      assignCurrentValue in class tools.jackson.core.TokenStreamContext
    • getParent

      public final AvroWriteContext getParent()
      Specified by:
      getParent in class tools.jackson.core.TokenStreamContext
    • currentName

      public String currentName()
      Specified by:
      currentName in class tools.jackson.core.TokenStreamContext
    • writeName

      public boolean writeName(String name) throws IOException
      Method that writer is to call before it writes an Object property 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
    • writeBinary

      public void writeBinary(byte[] data, int offset, int len) throws IOException
      Throws:
      IOException
    • writeString

      public abstract void writeString(String value) throws IOException
      Throws:
      IOException
    • writeNull

      public abstract void writeNull() throws IOException
      Throws:
      IOException
    • 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 tools.jackson.core.TokenStreamContext
    • _createRecord

      protected org.apache.avro.generic.GenericRecord _createRecord(org.apache.avro.Schema schema, Object currValue)
    • _createRecord

      protected org.apache.avro.generic.GenericRecord _createRecord(org.apache.avro.Schema schema)
    • _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)
    • _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:
    • 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: