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

java.lang.Object
  extended by org.apache.avro.generic.GenericDatumWriter<T>
      extended by org.apache.avro.specific.SpecificDatumWriter<T>
          extended by 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
  ReflectDatumWriter()
           
  ReflectDatumWriter(Class<T> c)
           
  ReflectDatumWriter(Class<T> c, ReflectData data)
           
protected ReflectDatumWriter(ReflectData reflectData)
           
  ReflectDatumWriter(Schema root)
           
protected ReflectDatumWriter(Schema root, ReflectData reflectData)
           
 
Method Summary
protected  Iterator<Object> getArrayElements(Object array)
          Called by the default implementation of GenericDatumWriter.writeArray(org.apache.avro.Schema, java.lang.Object, org.apache.avro.io.Encoder) to enumerate array elements.
protected  long getArraySize(Object array)
          Called by the default implementation of GenericDatumWriter.writeArray(org.apache.avro.Schema, java.lang.Object, org.apache.avro.io.Encoder) to get the size of an array.
protected  Object getField(Object record, String name, int position)
          Called by the default implementation of GenericDatumWriter.writeRecord(org.apache.avro.Schema, java.lang.Object, org.apache.avro.io.Encoder) to retrieve a record field value.
protected  void write(Schema schema, Object datum, Encoder out)
          Called to write data.
protected  void writeBytes(Object datum, Encoder out)
          Called to write a bytes.
protected  void writeString(Object datum, Encoder out)
          Called to write a string.
protected  void writeString(Schema schema, Object datum, Encoder out)
          Called to write a string.
 
Methods inherited from class org.apache.avro.specific.SpecificDatumWriter
writeEnum
 
Methods inherited from class org.apache.avro.generic.GenericDatumWriter
getMapEntries, getMapSize, setSchema, write, writeArray, writeFixed, writeMap, writeRecord
 
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

protected ReflectDatumWriter(Schema root,
                             ReflectData reflectData)

ReflectDatumWriter

protected ReflectDatumWriter(ReflectData reflectData)
Method Detail

getField

protected Object getField(Object record,
                          String name,
                          int position)
Description copied from class: GenericDatumWriter
Called by the default implementation of GenericDatumWriter.writeRecord(org.apache.avro.Schema, java.lang.Object, org.apache.avro.io.Encoder) to retrieve a record field value. The default implementation is for IndexedRecord.

Overrides:
getField in class SpecificDatumWriter<T>

getArraySize

protected long getArraySize(Object array)
Description copied from class: GenericDatumWriter
Called by the default implementation of GenericDatumWriter.writeArray(org.apache.avro.Schema, java.lang.Object, org.apache.avro.io.Encoder) to get the size of an array. The default implementation is for GenericArray.

Overrides:
getArraySize in class GenericDatumWriter<T>

getArrayElements

protected Iterator<Object> getArrayElements(Object array)
Description copied from class: GenericDatumWriter
Called by the default implementation of GenericDatumWriter.writeArray(org.apache.avro.Schema, java.lang.Object, org.apache.avro.io.Encoder) to enumerate array elements. The default implementation is for GenericArray.

Overrides:
getArrayElements in class GenericDatumWriter<T>

writeString

protected void writeString(Schema schema,
                           Object datum,
                           Encoder out)
                    throws IOException
Description copied from class: GenericDatumWriter
Called to write a string. May be overridden for alternate string representations.

Overrides:
writeString in class GenericDatumWriter<T>
Throws:
IOException

writeString

protected void writeString(Object datum,
                           Encoder out)
                    throws IOException
Description copied from class: GenericDatumWriter
Called to write a string. May be overridden for alternate string representations.

Overrides:
writeString 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


Copyright © 2010 The Apache Software Foundation