org.apache.avro.specific
Class SpecificDatumReader<T>

java.lang.Object
  extended by org.apache.avro.generic.GenericDatumReader<T>
      extended by 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.


Nested Class Summary
static interface SpecificDatumReader.SchemaConstructable
          Tag interface that indicates that a class has a one-argument constructor that accepts a Schema.
 
Constructor Summary
  SpecificDatumReader()
           
  SpecificDatumReader(Class<T> c)
           
  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.
protected SpecificDatumReader(Schema writer, Schema reader, SpecificData data)
           
 
Method Summary
protected  Object createEnum(String symbol, Schema schema)
          Called to create an enum value.
protected  Object createFixed(Object old, Schema schema)
          Called to create an fixed value.
protected static Object newInstance(Class c, Schema s)
          Create an instance of a class.
protected  Object newRecord(Object old, Schema schema)
          Called to create new record instances.
 
Methods inherited from class org.apache.avro.generic.GenericDatumReader
addToArray, addToMap, createBytes, createFixed, createString, getData, getResolver, newArray, newMap, peekArray, read, read, readArray, readBytes, readEnum, readFixed, readInt, readMap, readRecord, readString, readString, setExpected, setSchema, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpecificDatumReader

public SpecificDatumReader()

SpecificDatumReader

public SpecificDatumReader(Class<T> c)

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

protected SpecificDatumReader(Schema writer,
                              Schema reader,
                              SpecificData data)
Method Detail

newRecord

protected Object newRecord(Object old,
                           Schema schema)
Description copied from class: GenericDatumReader
Called to create new record instances. Subclasses may override to use a different record implementation. The returned instance must conform to the schema provided. If the old object contains fields not present in the schema, they should either be removed from the old object, or it should create a new instance that conforms to the schema. By default, this returns a GenericData.Record.

Overrides:
newRecord in class GenericDatumReader<T>

createEnum

protected Object createEnum(String symbol,
                            Schema schema)
Description copied from class: GenericDatumReader
Called to create an enum value. May be overridden for alternate enum representations. By default, returns a GenericEnumSymbol.

Overrides:
createEnum in class GenericDatumReader<T>

createFixed

protected Object createFixed(Object old,
                             Schema schema)
Description copied from class: GenericDatumReader
Called to create an fixed value. May be overridden for alternate fixed representations. By default, returns GenericFixed.

Overrides:
createFixed in class GenericDatumReader<T>

newInstance

protected static Object newInstance(Class c,
                                    Schema s)
Create an instance of a class. If the class implements SpecificDatumReader.SchemaConstructable, call a constructor with a Schema parameter, otherwise use a no-arg constructor.



Copyright © 2011 The Apache Software Foundation. All Rights Reserved.