org.apache.avro.specific

## Class SpecificDatumReader<T>

- java.lang.Object
- - org.apache.avro.generic.GenericDatumReader<T>
  - - org.apache.avro.specific.SpecificDatumReader<T>

- All Implemented Interfaces:
    DatumReader<T>
  Direct Known Subclasses:
    ReflectDatumReader

      public class SpecificDatumReader<T>
      extends GenericDatumReader<T>

  `DatumReader` for generated Java classes.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String[]` | `SERIALIZABLE_PACKAGES`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SpecificDatumReader()`
    `SpecificDatumReader(Class<T> c)` Construct for reading instances of a class.
    `SpecificDatumReader(Schema schema)` Construct where the writer's and reader's schemas are the same.
    `SpecificDatumReader(Schema writer, Schema reader)` Construct given writer's and reader's schema.
    `SpecificDatumReader(Schema writer, Schema reader, SpecificData data)` Construct given writer's schema, reader's schema, and a `SpecificData`.
    `SpecificDatumReader(SpecificData data)` Construct given a `SpecificData`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Class` | `findStringClass(Schema schema)` Determines the class to used to represent a string Schema.
    `SpecificData` | `getSpecificData()` Return the contained `SpecificData`.
    `List<String>` | `getTrustedPackages()`
    `protected void` | `readField(Object record, Schema.Field field, Object oldDatum, ResolvingDecoder in, Object state)` Called to read a single field of a record.
    `protected Object` | `readRecord(Object old, Schema expected, ResolvingDecoder in)` Called to read a record instance.
    `void` | `setSchema(Schema actual)` Set the writer's schema.

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

      `addToArray, addToMap, convert, createBytes, createEnum, createFixed, createFixed, createString, getData, getExpected, getResolver, getSchema, newArray, newInstanceFromString, newMap, newRecord, peekArray, read, read, readArray, readBytes, readBytes, readEnum, readFixed, readInt, readMap, readMapKey, readString, readString, readWithConversion, readWithoutConversion, setExpected, skip`

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

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

- - ### Field Detail

    - #### SERIALIZABLE_PACKAGES

          public static final String[] SERIALIZABLE_PACKAGES

  - ### Constructor Detail

    - #### SpecificDatumReader

          public SpecificDatumReader()

    - #### SpecificDatumReader

          public SpecificDatumReader(Class<T> c)

      Construct for reading instances of a class.

    - #### SpecificDatumReader

          public SpecificDatumReader(Schema schema)

      Construct where the writer's and reader's schemas are the same.

    - #### SpecificDatumReader

          public SpecificDatumReader(Schema writer,
                                     Schema reader)

      Construct given writer's and reader's schema.

    - #### SpecificDatumReader

          public SpecificDatumReader(Schema writer,
                                     Schema reader,
                                     SpecificData data)

      Construct given writer's schema, reader's schema, and a `SpecificData`.

    - #### SpecificDatumReader

          public SpecificDatumReader(SpecificData data)

      Construct given a `SpecificData`.

  - ### Method Detail

    - #### getSpecificData

          public SpecificData getSpecificData()

      Return the contained `SpecificData`.

    - #### setSchema

          public void setSchema(Schema actual)

      Description copied from interface: `DatumReader`
      Set the writer's schema.
      Specified by:
        `setSchema` in interface `DatumReader<T>`
      Overrides:
        `setSchema` in class `GenericDatumReader<T>`

    - #### findStringClass

          protected Class findStringClass(Schema schema)

      Description copied from class: `GenericDatumReader`
      Determines the class to used to represent a string Schema. By default uses `GenericData.STRING_PROP` to determine whether `Utf8` or `String` is used. Subclasses may override for alternate representations.
      Overrides:
        `findStringClass` in class `GenericDatumReader<T>`

    - #### getTrustedPackages

          public final List<String> getTrustedPackages()

    - #### readRecord

          protected Object readRecord(Object old,
                                      Schema expected,
                                      ResolvingDecoder in)
                               throws IOException

      Description copied from class: `GenericDatumReader`
      Called to read a record instance. May be overridden for alternate record representations.
      Overrides:
        `readRecord` in class `GenericDatumReader<T>`
      Throws:
        `IOException`

    - #### readField

          protected void readField(Object record,
                                   Schema.Field field,
                                   Object oldDatum,
                                   ResolvingDecoder in,
                                   Object state)
                            throws IOException

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

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