org.apache.avro
Class Protocol

java.lang.Object
  extended by org.apache.avro.Protocol

public class Protocol
extends Object

A set of messages forming an application protocol.

A protocol consists of:


Nested Class Summary
 class Protocol.Message
          A protocol message.
 
Field Summary
static Schema SYSTEM_ERROR
          An error that can be thrown by any message.
static Schema SYSTEM_ERRORS
          Union type for generating system errors.
static long VERSION
          The version of the protocol specification implemented here.
 
Constructor Summary
Protocol(String name, String namespace)
           
 
Method Summary
 Protocol.Message createMessage(String name, String doc, Schema request)
          Create a one-way message.
 Protocol.Message createMessage(String name, String doc, Schema request, Schema response, Schema errors)
          Create a two-way message.
 boolean equals(Object o)
           
 String getDoc()
          Doc string for this protocol.
 byte[] getMD5()
          Return the MD5 hash of the text of this protocol.
 Map<String,Protocol.Message> getMessages()
          The messages of this protocol.
 String getName()
          The name of this protocol.
 String getNamespace()
          The namespace of this protocol.
 Schema getType(String name)
          Returns the named type.
 Collection<Schema> getTypes()
          The types of this protocol.
 int hashCode()
           
static void main(String[] args)
           
static Protocol parse(File file)
          Read a protocol from a Json file.
static Protocol parse(String string)
          Read a protocol from a Json string.
 void setTypes(Collection<Schema> newTypes)
          Set the types of this protocol.
 String toString()
          Render this as JSON.
 String toString(boolean pretty)
          Render this as JSON.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION

public static final long VERSION
The version of the protocol specification implemented here.

See Also:
Constant Field Values

SYSTEM_ERROR

public static final Schema SYSTEM_ERROR
An error that can be thrown by any message.


SYSTEM_ERRORS

public static final Schema SYSTEM_ERRORS
Union type for generating system errors.

Constructor Detail

Protocol

public Protocol(String name,
                String namespace)
Method Detail

getName

public String getName()
The name of this protocol.


getNamespace

public String getNamespace()
The namespace of this protocol. Qualifies its name.


getDoc

public String getDoc()
Doc string for this protocol.


getTypes

public Collection<Schema> getTypes()
The types of this protocol.


getType

public Schema getType(String name)
Returns the named type.


setTypes

public void setTypes(Collection<Schema> newTypes)
Set the types of this protocol.


getMessages

public Map<String,Protocol.Message> getMessages()
The messages of this protocol.


createMessage

public Protocol.Message createMessage(String name,
                                      String doc,
                                      Schema request)
Create a one-way message.


createMessage

public Protocol.Message createMessage(String name,
                                      String doc,
                                      Schema request,
                                      Schema response,
                                      Schema errors)
Create a two-way message.


equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Render this as JSON.

Overrides:
toString in class Object

toString

public String toString(boolean pretty)
Render this as JSON.

Parameters:
pretty - if true, pretty-print JSON.

getMD5

public byte[] getMD5()
Return the MD5 hash of the text of this protocol.


parse

public static Protocol parse(File file)
                      throws IOException
Read a protocol from a Json file.

Throws:
IOException

parse

public static Protocol parse(String string)
Read a protocol from a Json string.


main

public static void main(String[] args)
                 throws Exception
Throws:
Exception


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