|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--moses.member.Answer
This class provides the callers of the generic_receive_lg method of the Member and ExMember classes with a structured object that stores the answers received from the controller. Internally, a message exchanged between the agent and its controller has several components. These components, reflected in the fields of this object are discussed bellow.
This class implements a single method: the constructor that creates an Answer object provided with a properly filled message object. This method is only called internally, by the Moses software layer, as part of the generic_receive_lg method implementation.
All the variable fields of this object have public access rights. Thus, a user
retrieves the components of a message by accessing these variables directly, in
the following manner:
...
Answer a;
...
String source = a.source;
String destination = a.destination;
if(a.p_type == 0 )
String message = a.s_payload;
...
The choice of making all the member variables public instead of providing setter/getter methods has been made mainly for performance reasons but also for simplicity.
Since this object is designed to accommodate all types of messages exchanged between an actor and its controller, in a particular situation not all the fields have assigned proper values. It is recommended that a null test is performed prior to using any of the fields. Most important, this object can accommodate different types of message payloads. They can be retrieved in one of the following fields:
public byte[] b_payload;
public String s_payload;
public Object o_payload;
The p_type field variable acts as a selector indicating which of the above variable has the proper value in the particular situation (the other two will be initialized with "null")
Thus a value of 0 (defined in moses.util.Const.SPLD) indicates a string payload, a value of 1 (defined in moses.util.Const.BPLD) indicates a byte array payload and a value of 2 (defined in moses.util.Const.OPLD) refers to an object payload.
| Field Summary | |
byte[] |
b_payload
Byte array payload, valid when p_type == 1. |
moses.security.LGICert |
cert
Certificate field, holds a certificate sent by the controller. |
java.lang.String |
dest
The destination of the message. |
java.lang.String |
lname
Law name field, indicates the name of the law the source agent of this message operates under. |
java.lang.Object |
o_payload
Object payload, valid when p_type == 2. |
int |
p_type
The type of payload the corresponding message carries: - 0 ( moses.util.Const.SPLD) : s_payload carries the payload and b_payload = o_payload = null - 1 ( moses.util.Const.BPLD) : b_payload carries the payload and s_payload = o_payload = null - 2 ( moses.util.Const.OPLD) : o_payload carries the payload and s_payload = b_payload = null Any other value than the above ones is invalid and indicates that the message is corrupted. |
java.lang.String |
s_payload
String payload, valid when p_type == 0. |
byte[] |
sign
Signature field, holds a signature over a certificate sent by the controller along with a certificate. |
java.lang.String |
source
The source of the message: this is either the Moses syntax name for the source or another law-replaced string. |
boolean |
stat
The status field of this answer: not utilized in this version. |
int |
type
The type of message received. |
| Constructor Summary | |
Answer(moses.message.Message m)
The class constructor, takes a message and it transfers its fields into the corresponding fields of an Answer class. |
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public boolean stat
public java.lang.String source
public java.lang.String dest
public int type
public int p_type
public byte[] b_payload
public java.lang.String s_payload
public java.lang.Object o_payload
public java.lang.String lname
public moses.security.LGICert cert
public byte[] sign
| Constructor Detail |
public Answer(moses.message.Message m)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||