org.apache.avro.reflect
Class ReflectDatumReader<T>

java.lang.Object
  extended by org.apache.avro.generic.GenericDatumReader<T>
      extended by org.apache.avro.specific.SpecificDatumReader<T>
          extended by org.apache.avro.reflect.ReflectDatumReader<T>
All Implemented Interfaces:
DatumReader<T>

public class ReflectDatumReader<T>
extends SpecificDatumReader<T>

DatumReader for existing classes via Java reflection.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.avro.specific.SpecificDatumReader
SpecificDatumReader.SchemaConstructable
 
Constructor Summary
  ReflectDatumReader()
           
  ReflectDatumReader(Class<T> c)
           
  ReflectDatumReader(Schema root)
          Construct where the writer's and reader's schemas are the same.
  ReflectDatumReader(Schema writer, Schema reader)
          Construct given writer's and reader's schema.
protected ReflectDatumReader(Schema writer, Schema reader, ReflectData data)
           
 
Method Summary
protected  void addToArray(Object array, long pos, Object e)
          Called by the default implementation of GenericDatumReader.readArray(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder) to add a value.
protected  Object createString(String value)
          Called to create a string from a default value.
protected  Object newArray(Object old, int size, Schema schema)
          Called to create new array instances.
protected  Object peekArray(Object array)
          Called by the default implementation of GenericDatumReader.readArray(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder) to retrieve a value from a reused instance.
protected  Object readBytes(Object old, Decoder in)
          Called to read byte arrays.
protected  Object readInt(Object old, Schema expected, Decoder in)
          Called to read integers.
protected  Object readString(Object old, Decoder in)
          Called to read strings.
protected  Object readString(Object old, Schema s, Decoder in)
          Called to read strings.
 
Methods inherited from class org.apache.avro.specific.SpecificDatumReader
createEnum, createFixed, newInstance, newRecord
 
Methods inherited from class org.apache.avro.generic.GenericDatumReader
addToMap, createBytes, createFixed, getData, getResolver, newMap, read, read, readArray, readEnum, readFixed, readMap, readRecord, setExpected, setSchema, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectDatumReader

public ReflectDatumReader()

ReflectDatumReader

public ReflectDatumReader(Class<T> c)

ReflectDatumReader

public ReflectDatumReader(Schema root)
Construct where the writer's and reader's schemas are the same.


ReflectDatumReader

public ReflectDatumReader(Schema writer,
                          Schema reader)
Construct given writer's and reader's schema.


ReflectDatumReader

protected ReflectDatumReader(Schema writer,
                             Schema reader,
                             ReflectData data)
Method Detail

newArray

protected Object newArray(Object old,
                          int size,
                          Schema schema)
Description copied from class: GenericDatumReader
Called to create new array instances. Subclasses may override to use a different array implementation. By default, this returns a GenericData.Array.

Overrides:
newArray in class GenericDatumReader<T>

peekArray

protected Object peekArray(Object array)
Description copied from class: GenericDatumReader
Called by the default implementation of GenericDatumReader.readArray(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder) to retrieve a value from a reused instance. The default implementation is for GenericArray.

Overrides:
peekArray in class GenericDatumReader<T>

addToArray

protected void addToArray(Object array,
                          long pos,
                          Object e)
Description copied from class: GenericDatumReader
Called by the default implementation of GenericDatumReader.readArray(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder) to add a value. The default implementation is for Collection.

Overrides:
addToArray in class GenericDatumReader<T>

readString

protected Object readString(Object old,
                            Schema s,
                            Decoder in)
                     throws IOException
Description copied from class: GenericDatumReader
Called to read strings. Subclasses may override to use a different string representation. By default, this calls GenericDatumReader.readString(Object,Decoder).

Overrides:
readString in class GenericDatumReader<T>
Throws:
IOException

readString

protected Object readString(Object old,
                            Decoder in)
                     throws IOException
Description copied from class: GenericDatumReader
Called to read strings. Subclasses may override to use a different string representation. By default, this calls Decoder.readString(Utf8).

Overrides:
readString in class GenericDatumReader<T>
Throws:
IOException

createString

protected Object createString(String value)
Description copied from class: GenericDatumReader
Called to create a string from a default value. Subclasses may override to use a different string representation. By default, this calls Utf8.Utf8(String).

Overrides:
createString in class GenericDatumReader<T>

readBytes

protected Object readBytes(Object old,
                           Decoder in)
                    throws IOException
Description copied from class: GenericDatumReader
Called to read byte arrays. Subclasses may override to use a different byte array representation. By default, this calls Decoder.readBytes(ByteBuffer).

Overrides:
readBytes in class GenericDatumReader<T>
Throws:
IOException

readInt

protected Object readInt(Object old,
                         Schema expected,
                         Decoder in)
                  throws IOException
Description copied from class: GenericDatumReader
Called to read integers. Subclasses may override to use a different integer representation. By default, this calls Decoder.readInt().

Overrides:
readInt in class GenericDatumReader<T>
Throws:
IOException


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