Top Inners Fields Constructors Methods
com.fasterxml.jackson.dataformat.avro.ser

public abstract Class AvroWriteContext

extends JsonStreamContext
Class Inheritance
Known Direct Subclasses
com.fasterxml.jackson.dataformat.avro.ser.AvroWriteContext.NullContext, com.fasterxml.jackson.dataformat.avro.ser.KeyValueContext, com.fasterxml.jackson.dataformat.avro.ser.NopWriteContext, com.fasterxml.jackson.dataformat.avro.ser.RootContext, com.fasterxml.jackson.dataformat.avro.ser.ArrayWriteContext
Imports
java.io.IOException, java.math.BigDecimal, java.util.Arrays, .List, .Map, org.apache.avro.Schema, .Schema.Type, .UnresolvedUnionException, org.apache.avro.generic.GenericArray, .GenericData, .GenericRecord, org.apache.avro.io.BinaryEncoder, org.apache.avro.reflect.ReflectData, com.fasterxml.jackson.core.JsonStreamContext, com.fasterxml.jackson.databind.JsonMappingException, com.fasterxml.jackson.dataformat.avro.AvroGenerator, com.fasterxml.jackson.dataformat.avro.schema.AvroSchemaHelper

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
AvroWriteContext.NullContext

Virtual context implementation used when there is no real root context available.

Field Summary

Modifier and TypeField and Description
protected Object
protected final AvroGenerator
protected final AvroWriteContext
protected final Schema
private static final Class<?>
private static final Class<?>
private static final Class<?>
private static final Class<?>
Inherited from com.fasterxml.jackson.core.JsonStreamContext:
_index_nestingDepth_typeTYPE_ARRAYTYPE_OBJECTTYPE_ROOT

Constructor Summary

AccessConstructor and Description
protected
AvroWriteContext(int type, AvroWriteContext parent, AvroGenerator generator, Schema schema, Object currValue)

Method Summary

Modifier and TypeMethod and Description
protected GenericArray<Object>
protected AvroWriteContext
_createObjectContext(Schema schema, Object currValue)

protected GenericRecord
_createRecord(Schema schema, Object currValue)

protected GenericRecord
private static Schema
private static int
protected Schema
private static int
_resolveArrayIndex(Schema unionSchema, List<Schema> types, GenericData.Array<?> value)

private static int
_resolveBigDecimalIndex(Schema unionSchema, List<Schema> types, BigDecimal value)

private static int
_resolveMapIndex(Schema unionSchema, List<Schema> types, Object value)

private static int
private static int
_resolveStringIndex(Schema unionSchema, List<Schema> types, String value)

protected abstract void
public boolean
public void
public abstract AvroWriteContext
public abstract AvroWriteContext
public static AvroWriteContext
public String
getCurrentName()

Implements abstract com.fasterxml.jackson.core.JsonStreamContext.getCurrentName.

Method for accessing name associated with the current location.

public Object
getCurrentValue()

Overrides com.fasterxml.jackson.core.JsonStreamContext.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.

public final AvroWriteContext
getParent()

Implements abstract com.fasterxml.jackson.core.JsonStreamContext.getParent.

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

public static AvroWriteContext
nullContext()

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

public abstract Object
rawValue()

Accessor called to link data being built with resulting object.

public static int

Returns:

Index into unionSchema.getTypes() that matches datum
resolveUnionIndex
(Schema
Union of schemas from which to choose
unionSchema
,
Object
Object that needs to map to one of the schemas in unionSchema
datum
)

Resolves the sub-schema from a union that should correspond to the datum.

public static Schema

Returns:

Schema that matches datum
resolveUnionSchema
(Schema
Union of schemas from which to choose
unionSchema
,
Object
Object that needs to map to one of the schemas in unionSchema
datum
)

Resolves the sub-schema from a union that should correspond to the datum.

public static Schema
resolveUnionType(Schema unionSchema, Object datum)

public void
setCurrentValue(Object
Current value to assign to this context
v
)

Overrides com.fasterxml.jackson.core.JsonStreamContext.setCurrentValue.

Method to call to pass value to be returned via getCurrentValue; typically called indirectly through JsonParser#setCurrentValue or JsonGenerator#setCurrentValue).

public final String
toString()

Overrides com.fasterxml.jackson.core.JsonStreamContext.toString.

Overridden to provide developer writeable "JsonPath" representation of the context.

public void
writeBinary(byte[] data, int offset, int len)

public boolean

Returns:

True if writing succeeded (for ObjectWriteContext, iff column was recognized)
writeFieldName
(String name)

Method that writer is to call before it writes a field name.

public abstract void
public abstract void
public abstract void
Inherited from com.fasterxml.jackson.core.JsonStreamContext:
getCurrentIndexgetEntryCountgetNestingDepthgetStartLocationgetTypeDeschasCurrentIndexhasCurrentNamehasPathSegmentinArrayinObjectinRootpathAsPointerpathAsPointerstartLocationtypeDesc

Field Detail

_currentValueback to summary
protected Object _currentValue
Since
2.9
_generatorback to summary
protected final AvroGenerator _generator
_parentback to summary
protected final AvroWriteContext _parent
_schemaback to summary
protected final Schema _schema
CLS_BIG_DECIMALback to summary
private static final Class<?> CLS_BIG_DECIMAL
CLS_GENERIC_ARRAYback to summary
private static final Class<?> CLS_GENERIC_ARRAY
CLS_GENERIC_RECORDback to summary
private static final Class<?> CLS_GENERIC_RECORD
CLS_STRINGback to summary
private static final Class<?> CLS_STRING

Constructor Detail

AvroWriteContextback to summary
protected AvroWriteContext(int type, AvroWriteContext parent, AvroGenerator generator, Schema schema, Object currValue)

Method Detail

_createArrayback to summary
protected GenericArray<Object> _createArray(Schema schema)
_createObjectContextback to summary
protected AvroWriteContext _createObjectContext(Schema schema, Object currValue) throws JsonMappingException
_createRecordback to summary
protected GenericRecord _createRecord(Schema schema, Object currValue) throws JsonMappingException
_createRecordback to summary
protected GenericRecord _createRecord(Schema schema) throws JsonMappingException
_findNotNullback to summary
private static Schema _findNotNull(List<Schema> types)
_findNotNullIndexback to summary
private static int _findNotNullIndex(List<Schema> types)
_recordOrMapFromUnionback to summary
protected Schema _recordOrMapFromUnion(Schema unionSchema)
_resolveArrayIndexback to summary
private static int _resolveArrayIndex(Schema unionSchema, List<Schema> types, GenericData.Array<?> value)
_resolveBigDecimalIndexback to summary
private static int _resolveBigDecimalIndex(Schema unionSchema, List<Schema> types, BigDecimal value)
_resolveMapIndexback to summary
private static int _resolveMapIndex(Schema unionSchema, List<Schema> types, Object value)
_resolveRecordIndexback to summary
private static int _resolveRecordIndex(Schema unionSchema, List<Schema> types, GenericData.Record value)
_resolveStringIndexback to summary
private static int _resolveStringIndex(Schema unionSchema, List<Schema> types, String value)
appendDescback to summary
protected abstract void appendDesc(StringBuilder sb)
canCloseback to summary
public boolean canClose()
completeback to summary
public void complete() throws IOException
createChildArrayContextback to summary
public abstract AvroWriteContext createChildArrayContext(Object currValue) throws JsonMappingException
createChildObjectContextback to summary
public abstract AvroWriteContext createChildObjectContext(Object currValue) throws JsonMappingException
createRootContextback to summary
public static AvroWriteContext createRootContext(AvroGenerator generator, Schema schema, BinaryEncoder encoder)
getCurrentNameback to summary
public String getCurrentName()

Implements abstract com.fasterxml.jackson.core.JsonStreamContext.getCurrentName.

Doc from com.fasterxml.jackson.core.JsonStreamContext.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.

Returns:String

Current field name within context, if any; null if none

Annotations
@Override
getCurrentValueback to summary
public Object getCurrentValue()

Overrides com.fasterxml.jackson.core.JsonStreamContext.getCurrentValue.

Doc from com.fasterxml.jackson.core.JsonStreamContext.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:Object

Currently active value, if one has been assigned.

Annotations
@Override
getParentback to summary
public final AvroWriteContext getParent()

Implements abstract com.fasterxml.jackson.core.JsonStreamContext.getParent.

Doc from com.fasterxml.jackson.core.JsonStreamContext.getParent.

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

Returns:AvroWriteContext

Parent context of this context, if any; null for Root contexts

Annotations
@Override
nullContextback to summary
public static AvroWriteContext nullContext()

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

rawValueback to summary
public abstract Object rawValue()

Accessor called to link data being built with resulting object.

resolveUnionIndexback to summary
public static int resolveUnionIndex(Schema unionSchema, Object datum)

Resolves the sub-schema from a union that should correspond to the datum.

Parameters
unionSchema:Schema

Union of schemas from which to choose

datum:Object

Object that needs to map to one of the schemas in unionSchema

Returns:int

Index into unionSchema.getTypes() that matches datum

Exceptions
UnresolvedUnionException:
if unionSchema does not have a schema that can encode datum
See Also
resolveUnionSchema(Schema, Object)
resolveUnionSchemaback to summary
public static Schema resolveUnionSchema(Schema unionSchema, Object datum)

Resolves the sub-schema from a union that should correspond to the datum.

Parameters
unionSchema:Schema

Union of schemas from which to choose

datum:Object

Object that needs to map to one of the schemas in unionSchema

Returns:Schema

Schema that matches datum

Exceptions
UnresolvedUnionException:
if unionSchema does not have a schema that can encode datum
See Also
resolveUnionIndex(Schema, Object)
resolveUnionTypeback to summary
public static Schema resolveUnionType(Schema unionSchema, Object datum)
setCurrentValueback to summary
public void setCurrentValue(Object v)

Overrides com.fasterxml.jackson.core.JsonStreamContext.setCurrentValue.

Doc from com.fasterxml.jackson.core.JsonStreamContext.setCurrentValue.

Method to call to pass value to be returned via getCurrentValue; typically called indirectly through JsonParser#setCurrentValue or JsonGenerator#setCurrentValue).

Parameters
v:Object

Current value to assign to this context

Annotations
@Override
toStringback to summary
public final String toString()

Overrides com.fasterxml.jackson.core.JsonStreamContext.toString.

Overridden to provide developer writeable "JsonPath" representation of the context.

Returns:String

Doc from com.fasterxml.jackson.core.JsonStreamContext.toString.

Simple developer-readable description this context layer (note: NOT constructed with parents, unlike pathAsPointer)

Annotations
@Override
writeBinaryback to summary
public void writeBinary(byte[] data, int offset, int len) throws IOException
writeFieldNameback to summary
public boolean writeFieldName(String name) throws IOException

Method that writer is to call before it writes a field name.

Returns:boolean

True if writing succeeded (for ObjectWriteContext, iff column was recognized)

writeNullback to summary
public abstract void writeNull() throws IOException
Since
2.8
writeStringback to summary
public abstract void writeString(String value) throws IOException
Since
2.5
writeValueback to summary
public abstract void writeValue(Object value) throws IOException
com.fasterxml.jackson.dataformat.avro.ser back to summary

private final Class AvroWriteContext.NullContext

extends AvroWriteContext
Class Inheritance

Virtual context implementation used when there is no real root context available.

Field Summary

Modifier and TypeField and Description
public static final AvroWriteContext.NullContext
Inherited from com.fasterxml.jackson.dataformat.avro.ser.AvroWriteContext:
_currentValue_generator_parent_schema

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected void
public void
public final AvroWriteContext
public final AvroWriteContext
public Object
rawValue()

Implements abstract com.fasterxml.jackson.dataformat.avro.ser.AvroWriteContext.rawValue.

Accessor called to link data being built with resulting object.

public void
public void
public void
Inherited from com.fasterxml.jackson.dataformat.avro.ser.AvroWriteContext:
_createArray_createObjectContext_createRecord_createRecord_recordOrMapFromUnioncanClosecompletecreateRootContextgetCurrentNamegetCurrentValuegetParentnullContextresolveUnionIndexresolveUnionSchemaresolveUnionTypesetCurrentValuetoStringwriteBinarywriteFieldName

Field Detail

instanceback to summary
public static final AvroWriteContext.NullContext instance

Constructor Detail

NullContextback to summary
private NullContext()

Method Detail

_reportErrorback to summary
protected void _reportError()
appendDescback to summary
public void appendDesc(StringBuilder sb)

Implements abstract com.fasterxml.jackson.dataformat.avro.ser.AvroWriteContext.appendDesc.

Annotations
@Override
createChildArrayContextback to summary
public final AvroWriteContext createChildArrayContext(Object currValue)

Implements abstract com.fasterxml.jackson.dataformat.avro.ser.AvroWriteContext.createChildArrayContext.

Annotations
@Override
createChildObjectContextback to summary
public final AvroWriteContext createChildObjectContext(Object currValue)

Implements abstract com.fasterxml.jackson.dataformat.avro.ser.AvroWriteContext.createChildObjectContext.

Annotations
@Override
rawValueback to summary
public Object rawValue()

Implements abstract com.fasterxml.jackson.dataformat.avro.ser.AvroWriteContext.rawValue.

Doc from com.fasterxml.jackson.dataformat.avro.ser.AvroWriteContext.rawValue.

Accessor called to link data being built with resulting object.

Annotations
@Override
writeNullback to summary
public void writeNull()

Implements abstract com.fasterxml.jackson.dataformat.avro.ser.AvroWriteContext.writeNull.

Annotations
@Override
writeStringback to summary
public void writeString(String value)

Implements abstract com.fasterxml.jackson.dataformat.avro.ser.AvroWriteContext.writeString.

Annotations
@Override
writeValueback to summary
public void writeValue(Object value)

Implements abstract com.fasterxml.jackson.dataformat.avro.ser.AvroWriteContext.writeValue.

Annotations
@Override