moses.member
Class Answer

java.lang.Object
  |
  +--moses.member.Answer

public class Answer
extends java.lang.Object

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

stat

public boolean stat
The status field of this answer: not utilized in this version.


source

public java.lang.String source
The source of the message: this is either the Moses syntax name for the source or another law-replaced string.


dest

public java.lang.String dest
The destination of the message. Usually this is the Moses name of the agent receiving this message. If the law changed the name however prior to delivering the message, this field will contain the law-replaced name.


type

public int type
The type of message received. It can be:


p_type

public int p_type
The type of payload the corresponding message carries: Any other value than the above ones is invalid and indicates that the message is corrupted.


b_payload

public byte[] b_payload
Byte array payload, valid when p_type == 1.


s_payload

public java.lang.String s_payload
String payload, valid when p_type == 0.


o_payload

public java.lang.Object o_payload
Object payload, valid when p_type == 2.


lname

public java.lang.String lname
Law name field, indicates the name of the law the source agent of this message operates under. Valid when type == 2.


cert

public moses.security.LGICert cert
Certificate field, holds a certificate sent by the controller. It has a valid value along with type == 3,4.


sign

public byte[] sign
Signature field, holds a signature over a certificate sent by the controller along with a certificate. It has a valid value along with a message type of 4.

Constructor Detail

Answer

public Answer(moses.message.Message m)
The class constructor, takes a message and it transfers its fields into the corresponding fields of an Answer class. This method is only designed to be used internally by the Moses layer and it is for no interest to the user.