public class Protocol extends JsonProperties
A protocol consists of:
schemas
;
schemas
for exceptions;
Modifier and Type | Class and Description |
---|---|
class |
Protocol.Message
A protocol message.
|
JsonProperties.Null
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.
|
NULL_VALUE
Constructor and Description |
---|
Protocol(Protocol p)
Constructs a similar Protocol instance with the same
name ,
doc , and namespace as {code p} has. |
Protocol(String name,
String namespace) |
Protocol(String name,
String doc,
String namespace) |
Modifier and Type | Method and Description |
---|---|
Protocol.Message |
createMessage(Protocol.Message m,
Schema request)
Create a one-way message using the
name , doc , and
props of m . |
Protocol.Message |
createMessage(Protocol.Message m,
Schema request,
Schema response,
Schema errors)
Create a two-way message using the
name , doc , and
props of m . |
<T> Protocol.Message |
createMessage(String name,
String doc,
JsonProperties propMap,
Schema request)
Create a one-way message.
|
<T> Protocol.Message |
createMessage(String name,
String doc,
JsonProperties propMap,
Schema request,
Schema response,
Schema errors)
Create a two-way message.
|
<T> Protocol.Message |
createMessage(String name,
String doc,
Map<String,?> propMap,
Schema request)
Create a one-way message.
|
<T> Protocol.Message |
createMessage(String name,
String doc,
Map<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.
|
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.
|
static Protocol |
parse(String string,
String... more)
Read a protocol from one or more json strings
|
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.
|
addAllProps, addProp, addProp, getObjectProp, getObjectProps, getProp, hasProps, putAll
public static final long VERSION
public static final Schema SYSTEM_ERROR
public static final Schema SYSTEM_ERRORS
public Protocol(Protocol p)
name
,
doc
, and namespace
as {code p} has. It also copies all the
props
.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(Protocol.Message m, Schema request)
name
, doc
, and
props
of m
.public <T> Protocol.Message createMessage(String name, String doc, JsonProperties propMap, Schema request)
public <T> Protocol.Message createMessage(String name, String doc, Map<String,?> propMap, Schema request)
@Deprecated public Protocol.Message createMessage(String name, String doc, Schema request, Schema response, Schema errors)
public Protocol.Message createMessage(Protocol.Message m, Schema request, Schema response, Schema errors)
name
, doc
, and
props
of m
.public <T> Protocol.Message createMessage(String name, String doc, JsonProperties propMap, Schema request, Schema response, Schema errors)
public <T> Protocol.Message createMessage(String name, String doc, Map<String,?> propMap, Schema request, Schema response, Schema errors)
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
public static Protocol parse(String string, String... more)
Copyright © 2009–2022 The Apache Software Foundation. All rights reserved.