public class ReflectData extends SpecificData
Modifier and Type | Class and Description |
---|---|
static class |
ReflectData.AllowNull
ReflectData implementation that permits null field values. |
SpecificData.SchemaConstructable
GenericData.Array<T>, GenericData.EnumSymbol, GenericData.Fixed, GenericData.Record, GenericData.StringType
stringableClasses
STRING_PROP, STRING_TYPE_STRING
Constructor and Description |
---|
ReflectData()
For subclasses.
|
ReflectData(ClassLoader classLoader)
Construct with a particular classloader.
|
Modifier and Type | Method and Description |
---|---|
ReflectData |
addStringable(Class c)
Cause a class to be treated as though it had an
Stringable
annotation. |
protected int |
compare(Object o1,
Object o2,
Schema s,
boolean equals)
Comparison implementation.
|
DatumReader |
createDatumReader(Schema schema)
Returns a
DatumReader for this kind of data. |
DatumReader |
createDatumReader(Schema writer,
Schema reader)
Returns a
DatumReader for this kind of data. |
DatumWriter |
createDatumWriter(Schema schema)
Returns a
DatumWriter for this kind of data. |
protected Schema |
createFieldSchema(Field field,
Map<String,Schema> names)
Create a schema for a field.
|
protected Schema |
createSchema(Type type,
Map<String,Schema> names)
Create the schema for a Java type.
|
static ReflectData |
get()
Return the singleton instance.
|
Class |
getClass(Schema schema)
Return the class that implements a schema, or null if none exists.
|
Object |
getField(Object record,
String name,
int position)
Called by
GenericDatumReader.readRecord(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder) to retrieve a record
field value from a reused instance. |
protected Object |
getField(Object record,
String name,
int pos,
Object state)
Version of
GenericData.getField(java.lang.Object, java.lang.String, int) that has state. |
Protocol |
getProtocol(Class iface)
Return the protocol for a Java interface.
|
protected Schema |
getRecordSchema(Object record)
Called to obtain the schema of a record.
|
protected Object |
getRecordState(Object record,
Schema schema)
Produce state for repeated calls to
GenericData.getField(Object,String,int,Object) and GenericData.setField(Object,String,int,Object,Object) on the same record. |
protected boolean |
isArray(Object datum)
Called by the default implementation of
GenericData.instanceOf(org.apache.avro.Schema, java.lang.Object) . |
protected boolean |
isBytes(Object datum)
Called by the default implementation of
GenericData.instanceOf(org.apache.avro.Schema, java.lang.Object) . |
protected boolean |
isRecord(Object datum)
Called by the default implementation of
GenericData.instanceOf(org.apache.avro.Schema, java.lang.Object) . |
protected boolean |
isStringable(Class<?> c)
True iff a class should be serialized with toString().
|
static Schema |
makeNullable(Schema schema)
Create and return a union of the null schema and the provided schema.
|
void |
setField(Object record,
String name,
int position,
Object o)
Called by
GenericDatumReader.readRecord(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder) to set a record fields
value to a record instance. |
protected void |
setField(Object record,
String name,
int pos,
Object o,
Object state)
Version of
GenericData.setField(java.lang.Object, java.lang.String, int, java.lang.Object) that has state. |
boolean |
validate(Schema schema,
Object datum)
Returns true if a Java datum matches a schema.
|
createEnum, createFixed, getClassName, getEnumSchema, getSchema, getSchemaName, isEnum, newInstance, newRecord
compare, createFixed, deepCopy, getClassLoader, getDefaultValue, getFixedSchema, hashCode, hashCodeAdd, induce, instanceOf, isBoolean, isDouble, isFixed, isFloat, isInteger, isLong, isMap, isString, resolveUnion, setStringType, toString, toString
public ReflectData()
get()
.public ReflectData(ClassLoader classLoader)
public static ReflectData get()
public ReflectData addStringable(Class c)
Stringable
annotation.public DatumReader createDatumReader(Schema schema)
GenericData
DatumReader
for this kind of data.createDatumReader
in class SpecificData
public DatumReader createDatumReader(Schema writer, Schema reader)
GenericData
DatumReader
for this kind of data.createDatumReader
in class SpecificData
public DatumWriter createDatumWriter(Schema schema)
GenericData
DatumWriter
for this kind of data.createDatumWriter
in class SpecificData
public void setField(Object record, String name, int position, Object o)
GenericData
GenericDatumReader.readRecord(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder)
to set a record fields
value to a record instance. The default implementation is for IndexedRecord
.setField
in class GenericData
protected void setField(Object record, String name, int pos, Object o, Object state)
GenericData
GenericData.setField(java.lang.Object, java.lang.String, int, java.lang.Object)
that has state.setField
in class GenericData
public Object getField(Object record, String name, int position)
GenericData
GenericDatumReader.readRecord(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder)
to retrieve a record
field value from a reused instance. The default implementation is for
IndexedRecord
.getField
in class GenericData
protected Object getField(Object record, String name, int pos, Object state)
GenericData
GenericData.getField(java.lang.Object, java.lang.String, int)
that has state.getField
in class GenericData
protected boolean isRecord(Object datum)
GenericData
GenericData.instanceOf(org.apache.avro.Schema, java.lang.Object)
.isRecord
in class GenericData
protected boolean isArray(Object datum)
GenericData
GenericData.instanceOf(org.apache.avro.Schema, java.lang.Object)
.isArray
in class GenericData
protected boolean isBytes(Object datum)
GenericData
GenericData.instanceOf(org.apache.avro.Schema, java.lang.Object)
.isBytes
in class GenericData
protected Schema getRecordSchema(Object record)
GenericData
getRecordSchema
in class GenericData
public boolean validate(Schema schema, Object datum)
GenericData
validate
in class GenericData
public Class getClass(Schema schema)
SpecificData
getClass
in class SpecificData
protected Schema createSchema(Type type, Map<String,Schema> names)
SpecificData
createSchema
in class SpecificData
protected boolean isStringable(Class<?> c)
SpecificData
isStringable
in class SpecificData
public static Schema makeNullable(Schema schema)
protected Schema createFieldSchema(Field field, Map<String,Schema> names)
public Protocol getProtocol(Class iface)
Note that this requires that Paranamer is run over compiled interface declarations, since Java 6 reflection does not provide access to method parameter names. See Avro's build.xml for an example.
getProtocol
in class SpecificData
protected int compare(Object o1, Object o2, Schema s, boolean equals)
GenericData
compare
in class SpecificData
protected Object getRecordState(Object record, Schema schema)
GenericData
GenericData.getField(Object,String,int,Object)
and GenericData.setField(Object,String,int,Object,Object)
on the same record.getRecordState
in class GenericData
Copyright © 2009-2014 The Apache Software Foundation. All Rights Reserved.