org.apache.avro.reflect
Class ReflectData

java.lang.Object
  extended by org.apache.avro.reflect.ReflectData

public class ReflectData
extends Object

Utilities to use existing Java classes and interfaces via reflection.


Method Summary
static Protocol getProtocol(Class iface)
          Generate a protocol for a Java interface.
static Schema getSchema(Type type)
          Generate a schema for a Java type.
static boolean validate(Schema schema, Object datum)
          Returns true if an object matches a schema.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

validate

public static boolean validate(Schema schema,
                               Object datum)
Returns true if an object matches a schema.


getSchema

public static Schema getSchema(Type type)
Generate a schema for a Java type.

For records, declared fields (not inherited) which are not static or transient are used.

Note that unions cannot be automatically generated by this method, since Java provides no representation for unions.


getProtocol

public static Protocol getProtocol(Class iface)
Generate a protocol for a Java interface.

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.



Copyright © 2009 The Apache Software Foundation