public class Protocol extends Object
A protocol consists of:
schemas
;
schemas
for exceptions;
Modifier and Type | Class and Description |
---|---|
class |
Protocol.Message
A protocol message.
|
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
Protocol(String name,
String namespace) |
Protocol(String name,
String doc,
String namespace) |
Modifier and Type | Method and Description |
---|---|
void |
addProp(String name,
String value)
Adds a property with the given name name and
value value.
|
Protocol.Message |
createMessage(String name,
String doc,
Map<String,String> propMap,
Schema request)
Create a one-way message.
|
Protocol.Message |
createMessage(String name,
String doc,
Map<String,String> propMap,
Schema request,
Schema response,
Schema errors)
Create a two-way message.
|
Protocol.Message |
createMessage(String name,
String doc,
Schema request)
Deprecated.
|
Protocol.Message |
createMessage(String name,
String doc,
Schema request,
Schema response,
Schema errors)
Deprecated.
|
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.
|
String |
getProp(String name)
Returns the value of the named property in this schema.
|
Map<String,String> |
getProps()
Return the defined properties as an unmodifieable Map.
|
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(InputStream stream)
Read a protocol from a Json stream.
|
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.
|
public static final long VERSION
public static final Schema SYSTEM_ERROR
public static final Schema SYSTEM_ERRORS
public String getName()
public String getNamespace()
public String getDoc()
public Collection<Schema> getTypes()
public void setTypes(Collection<Schema> newTypes)
public Map<String,Protocol.Message> getMessages()
@Deprecated public Protocol.Message createMessage(String name, String doc, Schema request)
public Protocol.Message createMessage(String name, String doc, Map<String,String> propMap, Schema request)
@Deprecated public Protocol.Message createMessage(String name, String doc, Schema request, Schema response, Schema errors)
public Protocol.Message createMessage(String name, String doc, Map<String,String> propMap, Schema request, Schema response, Schema errors)
public String getProp(String name)
name
- public void addProp(String name, String value)
name
- The name of the property to addvalue
- The value for the property to addpublic Map<String,String> getProps()
public String toString(boolean pretty)
pretty
- if true, pretty-print JSON.public byte[] getMD5()
public static Protocol parse(File file) throws IOException
IOException
public static Protocol parse(InputStream stream) throws IOException
IOException
Copyright © 2009-2012 The Apache Software Foundation. All Rights Reserved.