NodeIDType - EventType - This class is concretized to use integer node IDs, long keys, and
JSON messages, but the PacketType is left generic. The reason is
so that implementors can define and use their own packet types.
Note that it is not possible to extend the enum Packet.PacketType
and it is not modular to have to put *all* packet types in the
Packet class.public abstract class ProtocolPacket<NodeIDType,EventType> extends java.lang.Object implements ThresholdProtocolEvent<NodeIDType,EventType,java.lang.String>
| Modifier and Type | Class and Description |
|---|---|
static class |
ProtocolPacket.Keys |
| Modifier | Constructor and Description |
|---|---|
protected |
ProtocolPacket(org.json.JSONObject json) |
|
ProtocolPacket(org.json.JSONObject json,
Stringifiable<NodeIDType> unstringer) |
|
ProtocolPacket(NodeIDType initiator) |
|
ProtocolPacket(ProtocolPacket<NodeIDType,EventType> pkt) |
| Modifier and Type | Method and Description |
|---|---|
protected NodeIDType |
flip(NodeIDType rcvr) |
NodeIDType |
getInitiator() |
java.lang.String |
getKey() |
java.lang.Object |
getMessage() |
abstract EventType |
getPacketType(org.json.JSONObject json) |
NodeIDType |
getSender() |
EventType |
getType() |
abstract void |
putPacketType(org.json.JSONObject json,
EventType type) |
void |
setKey(java.lang.String key)
Sets the protocol key.
|
protected void |
setSender(NodeIDType id) |
void |
setType(EventType type) |
org.json.JSONObject |
toJSONObject() |
abstract org.json.JSONObject |
toJSONObjectImpl() |
java.lang.String |
toString() |
protected EventType type
public ProtocolPacket(NodeIDType initiator)
public ProtocolPacket(ProtocolPacket<NodeIDType,EventType> pkt)
public ProtocolPacket(org.json.JSONObject json,
Stringifiable<NodeIDType> unstringer)
throws org.json.JSONException
org.json.JSONExceptionprotected ProtocolPacket(org.json.JSONObject json)
throws org.json.JSONException
org.json.JSONExceptionpublic NodeIDType getSender()
getSender in interface ThresholdProtocolEvent<NodeIDType,EventType,java.lang.String>protected void setSender(NodeIDType id)
public NodeIDType getInitiator()
protected NodeIDType flip(NodeIDType rcvr)
public EventType getType()
getType in interface ProtocolEvent<EventType,java.lang.String>public void setType(EventType type)
public abstract org.json.JSONObject toJSONObjectImpl()
throws org.json.JSONException
org.json.JSONExceptionpublic abstract EventType getPacketType(org.json.JSONObject json) throws org.json.JSONException
org.json.JSONExceptionpublic abstract void putPacketType(org.json.JSONObject json,
EventType type)
throws org.json.JSONException
org.json.JSONExceptionpublic org.json.JSONObject toJSONObject()
throws org.json.JSONException
org.json.JSONExceptionpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getKey()
public void setKey(java.lang.String key)
ProtocolEventsetKey in interface ProtocolEvent<EventType,java.lang.String>public java.lang.Object getMessage()
getMessage in interface ProtocolEvent<EventType,java.lang.String>