org.apache.avro.specific
Class SpecificData

java.lang.Object
  extended by org.apache.avro.generic.GenericData
      extended by org.apache.avro.specific.SpecificData
Direct Known Subclasses:
ReflectData

public class SpecificData
extends GenericData

Utilities for generated Java classes and interfaces.


Nested Class Summary
static interface SpecificData.SchemaConstructable
          Tag interface that indicates that a class has a one-argument constructor that accepts a Schema.
 
Nested classes/interfaces inherited from class org.apache.avro.generic.GenericData
GenericData.Array<T>, GenericData.EnumSymbol, GenericData.Fixed, GenericData.Record, GenericData.StringType
 
Field Summary
 
Fields inherited from class org.apache.avro.generic.GenericData
STRING_PROP, STRING_TYPE_STRING
 
Constructor Summary
protected SpecificData()
          For subclasses.
  SpecificData(ClassLoader classLoader)
          Construct with a specific classloader.
 
Method Summary
protected  int compare(Object o1, Object o2, Schema s, boolean eq)
          Comparison implementation.
 Object createFixed(Object old, Schema schema)
          Called to create an fixed value.
protected  Schema createSchema(Type type, Map<String,Schema> names)
          Create the schema for a Java type.
static SpecificData get()
          Return the singleton instance.
 Class getClass(Schema schema)
          Return the class that implements a schema, or null if none exists.
static String getClassName(Schema schema)
          Returns the Java class name indicated by a schema's name and namespace.
protected  Schema getEnumSchema(Object datum)
          Called to obtain the schema of a enum.
 Protocol getProtocol(Class iface)
          Return the protocol for a Java interface.
 Schema getSchema(Type type)
          Find the schema for a Java type.
protected  boolean isEnum(Object datum)
          Called by the default implementation of GenericData.instanceOf(org.apache.avro.Schema, java.lang.Object).
static Object newInstance(Class c, Schema s)
          Create an instance of a class.
 Object newRecord(Object old, Schema schema)
          Called to create new record instances.
 
Methods inherited from class org.apache.avro.generic.GenericData
compare, createFixed, deepCopy, getField, getField, getFixedSchema, getRecordSchema, getRecordState, getSchemaName, hashCode, hashCodeAdd, induce, instanceOf, isArray, isBytes, isFixed, isMap, isRecord, isString, resolveUnion, setField, setField, setStringType, toString, toString, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpecificData

protected SpecificData()
For subclasses. Applications normally use get().


SpecificData

public SpecificData(ClassLoader classLoader)
Construct with a specific classloader.

Method Detail

get

public static SpecificData get()
Return the singleton instance.


isEnum

protected boolean isEnum(Object datum)
Description copied from class: GenericData
Called by the default implementation of GenericData.instanceOf(org.apache.avro.Schema, java.lang.Object).

Overrides:
isEnum in class GenericData

getEnumSchema

protected Schema getEnumSchema(Object datum)
Description copied from class: GenericData
Called to obtain the schema of a enum. By default calls {GenericContainer#getSchema(). May be overridden for alternate enum representations.

Overrides:
getEnumSchema in class GenericData

getClass

public Class getClass(Schema schema)
Return the class that implements a schema, or null if none exists.


getClassName

public static String getClassName(Schema schema)
Returns the Java class name indicated by a schema's name and namespace.


getSchema

public Schema getSchema(Type type)
Find the schema for a Java type.


createSchema

protected Schema createSchema(Type type,
                              Map<String,Schema> names)
Create the schema for a Java type.


getProtocol

public Protocol getProtocol(Class iface)
Return the protocol for a Java interface.


compare

protected int compare(Object o1,
                      Object o2,
                      Schema s,
                      boolean eq)
Description copied from class: GenericData
Comparison implementation. When equals is true, only checks for equality, not for order.

Overrides:
compare in class GenericData

newInstance

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


createFixed

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

Overrides:
createFixed in class GenericData

newRecord

public Object newRecord(Object old,
                        Schema schema)
Description copied from class: GenericData
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 GenericData


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