org.apache.avro.reflect

## Class ReflectDatumWriter<T>

- java.lang.Object
- - org.apache.avro.generic.GenericDatumWriter<T>
  - - org.apache.avro.specific.SpecificDatumWriter<T>
    - - org.apache.avro.reflect.ReflectDatumWriter<T>

- All Implemented Interfaces:
    DatumWriter<T>

      public class ReflectDatumWriter<T>
      extends SpecificDatumWriter<T>

  `DatumWriter` for existing classes via Java reflection.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `` | `ReflectDatumWriter()`
    `` | `ReflectDatumWriter(Class<T> c)`
    `` | `ReflectDatumWriter(Class<T> c, ReflectData data)`
    `protected` | `ReflectDatumWriter(ReflectData reflectData)`
    `` | `ReflectDatumWriter(Schema root)`
    `` | `ReflectDatumWriter(Schema root, ReflectData reflectData)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `write(Schema schema, Object datum, Encoder out)` Called to write data.
    `protected void` | `writeArray(Schema schema, Object datum, Encoder out)` Called to write a array.
    `protected void` | `writeBytes(Object datum, Encoder out)` Called to write a bytes.
    `protected void` | `writeField(Object record, Schema.Field f, Encoder out, Object state)` Called to write a single field of a record.

    - ### Methods inherited from class org.apache.avro.specific.SpecificDatumWriter

      `getSpecificData, writeEnum, writeRecord, writeString`

    - ### Methods inherited from class org.apache.avro.generic.GenericDatumWriter

      `addAvroTypeMsg, addClassCastMsg, convert, getArrayElements, getArraySize, getData, getMapEntries, getMapSize, npe, resolveUnion, setSchema, write, writeFixed, writeMap, writeString, writeWithoutConversion`

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

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

- - ### Constructor Detail

    - #### ReflectDatumWriter

          public ReflectDatumWriter()

    - #### ReflectDatumWriter

          public ReflectDatumWriter(Class<T> c)

    - #### ReflectDatumWriter

          public ReflectDatumWriter(Class<T> c,
                                    ReflectData data)

    - #### ReflectDatumWriter

          public ReflectDatumWriter(Schema root)

    - #### ReflectDatumWriter

          public ReflectDatumWriter(Schema root,
                                    ReflectData reflectData)

    - #### ReflectDatumWriter

          protected ReflectDatumWriter(ReflectData reflectData)

  - ### Method Detail

    - #### writeArray

          protected void writeArray(Schema schema,
                                    Object datum,
                                    Encoder out)
                             throws IOException

      Called to write a array. May be overridden for alternate array representations.
      Overrides:
        `writeArray` in class `GenericDatumWriter<T>`
      Throws:
        `IOException`

    - #### writeBytes

          protected void writeBytes(Object datum,
                                    Encoder out)
                             throws IOException

      Description copied from class: `GenericDatumWriter`
      Called to write a bytes. May be overridden for alternate bytes representations.
      Overrides:
        `writeBytes` in class `GenericDatumWriter<T>`
      Throws:
        `IOException`

    - #### write

          protected void write(Schema schema,
                               Object datum,
                               Encoder out)
                        throws IOException

      Description copied from class: `GenericDatumWriter`
      Called to write data.
      Overrides:
        `write` in class `GenericDatumWriter<T>`
      Throws:
        `IOException`

    - #### writeField

          protected void writeField(Object record,
                                    Schema.Field f,
                                    Encoder out,
                                    Object state)
                             throws IOException

      Description copied from class: `GenericDatumWriter`
      Called to write a single field of a record. May be overridden for more efficient or alternate implementations.
      Overrides:
        `writeField` in class `SpecificDatumWriter<T>`
      Throws:
        `IOException`

Copyright © 2009–2024 The Apache Software Foundation. All rights reserved.