AMETAS.data
Class AMETASMessage

java.lang.Object
  extended byAMETAS.data.AMETASMessage
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class AMETASMessage
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

Message object. Place User merely communicate by sending and receiving these objects. All AMETAS messages are instances of this class. The message exchange is organized by the PostOffice of the place which stores deposited messages and holds them for retrieval by the recipient.

A message consists of a fixed-format header and a payload (aka body). Each message may be specified by the category, the subcategory, and further elements in the body. The first element of the body is commonly a String which is called specification. The first body object, however, need not necessarily be such a String. Furthermore, it is up to the application to evaluate other parts of the body to derive the message type.

There are six message categories which are predefined in this class. They declare the origin of the message. The specification may then refine this simple classification and help the recipient to correctly process the message.

Note that by using Strings for the specification, the risk of unintentional reuse of the same specification is smaller than when using numbers. Furthermore, Strings are easier to read, preventing programming errors. However, you must make sure that the sender actually knows the Strings which are used in your messages. See the respective explanations in the context of the Hybrid type system.

Some important notes on header fields.

There is no constructor offering to set the sender ID. Although there is a method which seems to allow that, it is useless to call this method because the Place User driver will fill in this field. This is not only easier for the implementor; it also prevents errors or spoofing.

The category field cannot be set by the Place User; it is set by the driver. All agents and user adapters always send APPLICATION messages, regardless of the recipient. Services only send SERVICE messages. Only the place is able to set the category itself, so producing PLACE or SECURITY messages.

The subcategory field specifies the meaning of this message in terms of how it should control the processing, regardless of the contents or the category. Normal messages are REQUESTs, but the subcategory may be set to RESPONSE to give the receiver a hint that this message is a response to a prior request. An INIT message always goes to a Place User just after creation but before invocation. Finally, EXIT_SESSION is important for ServiceManagers which, on receiving, terminate the session of a service object with a client.

The option field is currently used to mark the message as to not being delivered to the sender itself, even though the sender could match the receiver mask. Future extensions may add other options here.

See Also:
Serialized Form

Field Summary
static short APPLICATION
          Message category declaring an agent or user adapater as origin.
static short DELBY_ANY_PLACEUSER
          Delete information on general deletability.
static short DELBY_NOONE
          Delete information for non-deletability.
static short DELBY_RECEIVER
          Delete information on receiver deletability.
static short DELBY_SENDER
          Delete information on sender deletability.
static java.lang.String ERR_AGENT_NOT_ACK
          Specification of the category PLACE, sent on reject of an agent.
static java.lang.String ERR_BAD_SERVICE_PARAMS
          Specification of the category SERVICE, sent on invalid parameters.
static java.lang.String ERR_INVOKE
          Specification of the category PLACE, sent on execution error.
static java.lang.String ERR_NO_CONNECT
          Specification of the category PLACE, sent on a failed connection attempt.
static java.lang.String ERR_NO_PNS
          Specification of the category PLACE, sent on failing PlaceNameService.
static java.lang.String ERR_NO_SERVICE_PARAMS
          Specification of the category SERVICE, sent on missing parameters.
static java.lang.String ERR_PARAM_MISMATCH
          Specification of the category SERVICE, sent on invalid request parameters.
static java.lang.String ERR_UNAUTHORIZED_ACCESS
          Specification of the categories PLACE or SERVICE, sent on unauthorized access.
static java.lang.String ERR_UNKNOWN_HOST
          Specification of the category PLACE, sent on unknown target host.
static java.lang.String ERR_UNKNOWN_PLACE
          Specification of the category PLACE, sent on unknown place name.
static java.lang.String ERR_UNKNOWN_PROTOCOL
          Specification of the category PLACE, sent on unknown migration protocol.
static short ERROR
          Subcategory which announces an application-dependent error condition.
static long ERROR_TTL
          Expiration time for error messages.
static short EXIT_SESSION
          Subcategory which is used for terminating a session between two Place Users.
static short INFO
          Subcategory which declares this message to be an informational message.
static java.lang.String INFO_KILLED_PU_LIST
          Specification of the category PLACE, sent on killed Place Users.
static java.lang.String INFO_PLACE_SHUTDOWN
          Specification of the category PLACE on place shutdown.
static java.lang.String INFO_RELAYED_PLACE_ACTIVE
          Specification of the category PLACE, sent on temporary place restart.
static short INIT
          Subcategory which declares this message to be an initialization message.
static short MANAGER_STARTUP
          Subcategory which refers to the ServiceManager startup.
static short MESSAGE
          Message category which declares further messages to be included in this message.
static int OPT_NONE
          Option value for no option set.
static int OPT_NOTME
          Option value for no self addressing.
static short PLACE
          Message category declaring the place as origin.
static short REQUEST
          Subcategory which declares this message to be a request.
static short RESPONSE
          Subcategory which declares this message to be a response.
static short SECURITY
          Message category declaring the security subsystem as origin.
static short SERVICE
          Message category declaring a service as origin.
static long SERVICE_REQUEST_TTL
          Expiration time for service requests.
static long SERVICE_STARTUP_TTL
          Expiration time for service manager startup messages.
static short TRADING
          Message category declaring the mediation subsystem as origin.
static short UNSPECIFIED
          Subcategory which does not provide any further specification.
 
Constructor Summary
AMETASMessage(AMETASPlaceUserID idReceiver, AMETASMessageID midInReplyTo, long nTTL, java.lang.Object[] aBody)
          Creates a new message, initializing it with the provided values.
AMETASMessage(AMETASPlaceUserID idReceiver, AMETASMessageID midInReplyTo, java.lang.Object[] aBody)
          Creates a new message, initializing it with the provided values.
AMETASMessage(AMETASPlaceUserIDMask idmReceiver, AMETASMessageID midInReplyTo, java.lang.Object[] aBody)
          Creates a new message, initializing it with the provided values.
AMETASMessage(AMETASPlaceUserIDMask idm, AMETASMessageID midInReplyTo, short nDelBy, long nTTL, int nOptions, java.lang.Object[] aBody)
          Creates a new message, initializing it with the provided values.
AMETASMessage(AMETASPlaceUserID idReceiver, java.lang.Object[] aBody)
          Creates a new message, initializing it with the provided values.
 
Method Summary
static java.lang.String categoryToString(short nCategory)
          Translates the category into a readable String.
 java.lang.Object clone()
          Creates a clone of this message.
static java.lang.String deletableToString(short nDeletable)
          Translates the deletable information into a readable String.
 java.lang.Object[] getBody()
          Returns the body Object array.
 java.lang.Object getBodyObj(int nIndex)
          Returns the object at a given position in the message body.
 int getBodySize()
          Delivers the number of objects in the payload array.
 java.util.Vector getBodyVector()
          Returns the body as a vector.
 short getCategory()
          Returns the category of this message.
 short getDeletable()
          Returns the deletability information.
 java.lang.String getDeliveryPlace()
          Returns the place name where this message has been retrieved.
 AMETASMessageID getID()
          Returns the ID of this message.
 java.lang.Object getNextBodyObj(boolean bReset)
          Delivers the next element of the body Object array.
 int getOptions()
          Returns the options.
 AMETASPrivilegeList getPrivileges()
          Returns the privileges of the sender at the moment of submission.
 int getReceiverContextID()
          Returns the receiver context ID.
 AMETASPlaceUserIDMask getReceiverMask()
          Returns the receiver mask.
 AMETASMessageID getRepliedMsg()
          Returns the ID of the message which is replied by this message.
 int getSenderContextID()
          Returns the sender context ID.
 AMETASPlaceUserID getSenderID()
          Returns the ID of the message sender.
 java.lang.String getSenderPlace()
          Deprecated. The concept of remote messages should be replaced by a pure agent-based solution.
 java.lang.String getSpecification()
          Delivers the specification of this message.
 short getSubcategory()
          Returns the subcategory of this message.
 long getTimeStamp()
          Returns the timestamp of this message.
 long getTTL()
          Returns the Time-To-Live of this message.
 boolean includesOption(int nOption)
          Checks whether a given option has been set.
 boolean isRemote()
          Deprecated. The concept of remote messages should be replaced by a pure agent-based solution.
static java.lang.String optionsToString(int nOptions)
          Translates the options into a readable String.
 boolean senderHasPrivilege(java.lang.String sPrivilegeName)
          Checks whether the given privilege is contained in the set of privileges of the sender.
 void setBody(java.lang.Object[] aBody)
          Sets the message payload.
 void setCategory(short nCategory)
          Sets the message category.
 void setDeletable(short nDelBy)
          Defines who may delete this message.
 void setDeliveryPlace(java.lang.String sPlaceName)
          Sets the delivery place.
 void setInReplyTo(AMETASMessageID midInReplyTo)
          Defines which message this message is related to.
 void setOptions(int nOptions)
          Declares the options.
 void setPrivileges(AMETASPrivilegeList prl)
          Defines the list of privileges.
 void setReceiver(AMETASPlaceUserID idReceiver)
          Sets the receiver.
 void setReceiverContextID(int nContextID)
          Defines the receiver context.
 void setReceiverMask(AMETASPlaceUserIDMask idmReceiver)
          Sets the receiver mask.
 void setSenderContextID(int nContextID)
          Defines the sender context.
 void setSenderID(AMETASPlaceUserID id)
          Sets the sender ID.
 void setSenderPlace(java.lang.String sSenderPlace)
          Deprecated. The concept of remote messaging should be replaced by a pure agent-based solution.
 void setSubcategory(short nSubcategory)
          Sets the subcategory of this message.
 void setTTL(long nTTL)
          Sets the Time-To-Live of this message.
static java.lang.String subcatToString(short nSubcategory)
          Translates the subcategory into a readable String.
 java.lang.String toString()
          Returns a String representation of this message.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PLACE

public static final short PLACE
Message category declaring the place as origin. Used e.g. for error messages.

See Also:
Constant Field Values

SERVICE

public static final short SERVICE
Message category declaring a service as origin.

See Also:
Constant Field Values

APPLICATION

public static final short APPLICATION
Message category declaring an agent or user adapater as origin.

See Also:
Constant Field Values

SECURITY

public static final short SECURITY
Message category declaring the security subsystem as origin.

See Also:
Constant Field Values

TRADING

public static final short TRADING
Message category declaring the mediation subsystem as origin. This category is currently unused.

See Also:
Constant Field Values

MESSAGE

public static final short MESSAGE
Message category which declares further messages to be included in this message. This category is currently unused.

See Also:
Constant Field Values

UNSPECIFIED

public static final short UNSPECIFIED
Subcategory which does not provide any further specification.

See Also:
Constant Field Values

MANAGER_STARTUP

public static final short MANAGER_STARTUP
Subcategory which refers to the ServiceManager startup. Currently unused.

See Also:
Constant Field Values

REQUEST

public static final short REQUEST
Subcategory which declares this message to be a request. This is the default.

See Also:
Constant Field Values

RESPONSE

public static final short RESPONSE
Subcategory which declares this message to be a response. This must be set explicitely, unless this message is sent by a service.

See Also:
Constant Field Values

INIT

public static final short INIT
Subcategory which declares this message to be an initialization message. The behavior of the recipient depends on its implementation. This subcategory is used by requestPUStartup and spawnAgent.

See Also:
Constant Field Values

EXIT_SESSION

public static final short EXIT_SESSION
Subcategory which is used for terminating a session between two Place Users. Currently this is only used for sessions between a Place User and a service.

See Also:
Constant Field Values

ERROR

public static final short ERROR
Subcategory which announces an application-dependent error condition. The actual error is explained in the body.

See Also:
Constant Field Values

INFO

public static final short INFO
Subcategory which declares this message to be an informational message. The actual information is located in the body. Informational messages are not expected to be responded.

See Also:
Constant Field Values

ERR_PARAM_MISMATCH

public static final java.lang.String ERR_PARAM_MISMATCH
Specification of the category SERVICE, sent on invalid request parameters. Services may decide to use it when the argument list in the body of the request was considered invalid by the service.

See Also:
Constant Field Values

ERR_NO_SERVICE_PARAMS

public static final java.lang.String ERR_NO_SERVICE_PARAMS
Specification of the category SERVICE, sent on missing parameters. Services may decide to use it when the argument list in the body of the request was incomplete.

See Also:
Constant Field Values

ERR_BAD_SERVICE_PARAMS

public static final java.lang.String ERR_BAD_SERVICE_PARAMS
Specification of the category SERVICE, sent on invalid parameters. Services may decide to use it when it did not find those parameters it expected.

See Also:
Constant Field Values

ERR_AGENT_NOT_ACK

public static final java.lang.String ERR_AGENT_NOT_ACK
Specification of the category PLACE, sent on reject of an agent. The receiving place has rejected the incoming agent.

See Also:
Constant Field Values

ERR_NO_CONNECT

public static final java.lang.String ERR_NO_CONNECT
Specification of the category PLACE, sent on a failed connection attempt. The connection to the receiving place was not established.

See Also:
Constant Field Values

ERR_UNKNOWN_HOST

public static final java.lang.String ERR_UNKNOWN_HOST
Specification of the category PLACE, sent on unknown target host.

See Also:
Constant Field Values

ERR_UNKNOWN_PLACE

public static final java.lang.String ERR_UNKNOWN_PLACE
Specification of the category PLACE, sent on unknown place name.

See Also:
Constant Field Values

ERR_UNKNOWN_PROTOCOL

public static final java.lang.String ERR_UNKNOWN_PROTOCOL
Specification of the category PLACE, sent on unknown migration protocol.

See Also:
Constant Field Values

ERR_UNAUTHORIZED_ACCESS

public static final java.lang.String ERR_UNAUTHORIZED_ACCESS
Specification of the categories PLACE or SERVICE, sent on unauthorized access. The operation was not permitted.

See Also:
Constant Field Values

ERR_INVOKE

public static final java.lang.String ERR_INVOKE
Specification of the category PLACE, sent on execution error. There has been an error on executing the invoke method of the Place User.

See Also:
Constant Field Values

ERR_NO_PNS

public static final java.lang.String ERR_NO_PNS
Specification of the category PLACE, sent on failing PlaceNameService.

See Also:
Constant Field Values

INFO_KILLED_PU_LIST

public static final java.lang.String INFO_KILLED_PU_LIST
Specification of the category PLACE, sent on killed Place Users. One or more Place Users have been forcefully terminated.

See Also:
Constant Field Values

INFO_PLACE_SHUTDOWN

public static final java.lang.String INFO_PLACE_SHUTDOWN
Specification of the category PLACE on place shutdown.

See Also:
Constant Field Values

INFO_RELAYED_PLACE_ACTIVE

public static final java.lang.String INFO_RELAYED_PLACE_ACTIVE
Specification of the category PLACE, sent on temporary place restart. A temporary place has restarted. Waiting agents may now migrate to this place.

See Also:
Constant Field Values

DELBY_NOONE

public static final short DELBY_NOONE
Delete information for non-deletability. The message cannot be deleted except by the cleanup.

See Also:
Constant Field Values

DELBY_SENDER

public static final short DELBY_SENDER
Delete information on sender deletability. Only the sender may delete the message. If this has not occured before the expiration time, the cleanup may dispose of this message.

See Also:
Constant Field Values

DELBY_RECEIVER

public static final short DELBY_RECEIVER
Delete information on receiver deletability. The sender and receiver of this message may delete the message. If this has not occured before the expiration time, the cleanup may dispose of this message.

See Also:
Constant Field Values

DELBY_ANY_PLACEUSER

public static final short DELBY_ANY_PLACEUSER
Delete information on general deletability. All Place Users and the cleanup may remove this message.

See Also:
Constant Field Values

ERROR_TTL

public static final long ERROR_TTL
Expiration time for error messages. Error messages may remain in the receiver mailbox for 10 minutes and will then be removed by the cleanup.

See Also:
Constant Field Values

SERVICE_REQUEST_TTL

public static final long SERVICE_REQUEST_TTL
Expiration time for service requests. Service requests may remain in the receiver mailbox for 10 minutes and will then be removed by the cleanup.

See Also:
Constant Field Values

SERVICE_STARTUP_TTL

public static final long SERVICE_STARTUP_TTL
Expiration time for service manager startup messages. Startup messages may remain in the service manager mailbox for 10 minutes and will then be removed by the cleanup.

See Also:
Constant Field Values

OPT_NONE

public static final int OPT_NONE
Option value for no option set.

See Also:
Constant Field Values

OPT_NOTME

public static final int OPT_NOTME
Option value for no self addressing. Used when the message shall never be delivered to the sender itself even when the sender ID matches the receiver ID mask.

See Also:
Constant Field Values
Constructor Detail

AMETASMessage

public AMETASMessage(AMETASPlaceUserID idReceiver,
                     java.lang.Object[] aBody)
Creates a new message, initializing it with the provided values. This message is a unicast message, valid for 10 minutes. There is no reference to a prior message, the message shall be deletable by the receiver and does not use any options. The subcategory is UNSPECIFIED, the contexts of sender and receiver are undefined (NO_CONTEXT). This constructor provides the simplest version of message creation.

Parameters:
idReceiver - ID of the receiver.
aBody - Payload of the message. If null, an empty Object array is filled in.

AMETASMessage

public AMETASMessage(AMETASPlaceUserID idReceiver,
                     AMETASMessageID midInReplyTo,
                     java.lang.Object[] aBody)
Creates a new message, initializing it with the provided values. This message is a unicast message, valid for 10 minutes. The message shall be deletable by the receiver and does not use any options. The subcategory is UNSPECIFIED, the contexts of sender and receiver are undefined (NO_CONTEXT).

Parameters:
idReceiver - ID of the receiver.
midInReplyTo - Message ID of the message which is replied by this message.
aBody - Payload of the message. If null, an empty Object array is filled in.

AMETASMessage

public AMETASMessage(AMETASPlaceUserIDMask idmReceiver,
                     AMETASMessageID midInReplyTo,
                     java.lang.Object[] aBody)
Creates a new message, initializing it with the provided values. This message is valid for 10 minutes. The message shall be deletable by the receiver and does not use any options. The subcategory is UNSPECIFIED, the contexts of sender and receiver are undefined (NO_CONTEXT).

Parameters:
idmReceiver - ID mask of the receivers.
midInReplyTo - Message ID of the message which is replied by this message.
aBody - Payload of the message. If null, an empty Object array is filled in.

AMETASMessage

public AMETASMessage(AMETASPlaceUserID idReceiver,
                     AMETASMessageID midInReplyTo,
                     long nTTL,
                     java.lang.Object[] aBody)
Creates a new message, initializing it with the provided values. The message shall be deletable by the receiver and does not use any options. The subcategory is UNSPECIFIED, the contexts of sender and receiver are undefined (NO_CONTEXT).

Parameters:
midInReplyTo - Message ID of the message which is replied by this message.
nTTL - Timeout in milliseconds after which the message is removed from the mailbox.
aBody - Payload of the message. If null, an empty Object array is filled in.

AMETASMessage

public AMETASMessage(AMETASPlaceUserIDMask idm,
                     AMETASMessageID midInReplyTo,
                     short nDelBy,
                     long nTTL,
                     int nOptions,
                     java.lang.Object[] aBody)
Creates a new message, initializing it with the provided values. The subcategory is UNSPECIFIED, the contexts of sender and receiver are undefined (NO_CONTEXT). This is the most flexible constructor. Further settings may be done by the respective methods of this class.

Parameters:
midInReplyTo - Message ID of the message which is replied by this message.
nDelBy - Who may delete this message.
nTTL - Timeout in milliseconds after which the message is removed from the mailbox.
nOptions - Options.
aBody - Payload of the message. If null, an empty Object array is filled in.
Method Detail

setSenderID

public void setSenderID(AMETASPlaceUserID id)
Sets the sender ID. A Place User, though, is not capable of effectively setting the sender ID because the driver is the last instance to use this method before the message is submitted.

Parameters:
id - Sender ID.

setReceiverMask

public void setReceiverMask(AMETASPlaceUserIDMask idmReceiver)
Sets the receiver mask. This message may thus be delivered to multiple recipients.

Parameters:
idmReceiver - Receiver mask.

setReceiver

public void setReceiver(AMETASPlaceUserID idReceiver)
Sets the receiver. This method is intended to define this message to be a unicast message.

Parameters:
idReceiver - Receiver ID.

setInReplyTo

public void setInReplyTo(AMETASMessageID midInReplyTo)
Defines which message this message is related to. However, for keeping contextual information, the classes from the Context API of AMETAS are recommended. Keeping contextual information using the referred message may be sufficient for simple protocols.

Parameters:
midInReplyTo - ID of the message which this message replies to.
See Also:
AMETASContext

setCategory

public void setCategory(short nCategory)
Sets the message category. A Place User, though, is not capable of effectively setting the category because the driver is the last instance to use this method before the message is submitted.

Parameters:
nCategory - Category.

setSubcategory

public void setSubcategory(short nSubcategory)
Sets the subcategory of this message. The Place User may set this value as required. If left undefined, the driver will set it to REQUEST if the Place User is an agent or user adapter, or to RESPONSE of the PU is a service.

Parameters:
nSubcategory - Subcategory.

setTTL

public void setTTL(long nTTL)
Sets the Time-To-Live of this message. This may be freely set by the Place User.

Parameters:
nTTL - Timeout in milliseconds.

setDeletable

public void setDeletable(short nDelBy)
Defines who may delete this message. This may be freely set by the Place User.

Parameters:
nDelBy - Determines who may delete the message: the sender, the receiver, or both. When the TTL time expires, the message is removed from the mailbox in any case.

setOptions

public void setOptions(int nOptions)
Declares the options. This may be freely set by the Place User.

Parameters:
nOptions - Optionen.

setSenderPlace

public void setSenderPlace(java.lang.String sSenderPlace)
Deprecated. The concept of remote messaging should be replaced by a pure agent-based solution.

Defines the name of the remote place where this message has been submitted. This is useful for remote messages.

Parameters:
sSenderPlace - Remote place name.

setPrivileges

public void setPrivileges(AMETASPrivilegeList prl)
Defines the list of privileges. These privileges may be queried by the receiver to find out whether the sender had enough privileges. The sender PU has no chance to effectively set the list of privileges because its driver is the last instance to modify this field.

Parameters:
prl - List of privileges of the sender.

setBody

public void setBody(java.lang.Object[] aBody)
Sets the message payload. This may be freely set by the Place User. Note that all components of the Object array must be serializable.

Parameters:
aBody - Message body.

setSenderContextID

public void setSenderContextID(int nContextID)
Defines the sender context. This may be freely set by the Place User.

Parameters:
nContextID - Context ID.
Since:
2.6.0
See Also:
AMETASContext

setReceiverContextID

public void setReceiverContextID(int nContextID)
Defines the receiver context. This may be freely set by the Place User.

Parameters:
nContextID - Context ID.
Since:
2.6.0
See Also:
AMETASContext

setDeliveryPlace

public void setDeliveryPlace(java.lang.String sPlaceName)
Sets the delivery place. At this place this message has been retrieved by the receiving Place User. This setting is done by the mailbox.

Parameters:
sPlaceName - Place name.
Since:
2.6.0

getBodySize

public int getBodySize()
Delivers the number of objects in the payload array.

Returns:
Size of the body Object array.

getBodyObj

public java.lang.Object getBodyObj(int nIndex)
                            throws java.lang.ArrayIndexOutOfBoundsException
Returns the object at a given position in the message body. This is a convenience method for retrieving body objects.

Parameters:
nIndex - Array index of the object.
Returns:
Object at this position.
Throws:
java.lang.ArrayIndexOutOfBoundsException - when the index does not point into the body Object array.

getNextBodyObj

public java.lang.Object getNextBodyObj(boolean bReset)
Delivers the next element of the body Object array. When the body Object array is completely stepped through, null is returned. Setting bReset to true will reset the array cursor to the first element. Using this method, the body of the message may conveniently be read by successive calls.

Parameters:
bReset - If true, the array cursor is reset to 0 before reading the array element.
Returns:
Next object in the array, or null if the complete array has been stepped through. The cursor is increased by one.

getSpecification

public java.lang.String getSpecification()
Delivers the specification of this message. The specification is assumed to be at the first body Object array position and to be a String. Whether this assumption is right is determined by the actual implementation. If the first object is no String, null is returned.

Returns:
First body Object cast to String, or null if there is no such String.

getSenderID

public AMETASPlaceUserID getSenderID()
Returns the ID of the message sender.

Returns:
Sender ID.

getReceiverMask

public AMETASPlaceUserIDMask getReceiverMask()
Returns the receiver mask.

Returns:
Receiver ID mask.

getRepliedMsg

public AMETASMessageID getRepliedMsg()
Returns the ID of the message which is replied by this message. However, for keeping contextual information, the classes from the Context API of AMETAS are recommended. Keeping contextual information using the referred message may be sufficient for simple protocols.

Returns:
ID of the referred message.
See Also:
AMETASContext

getDeletable

public short getDeletable()
Returns the deletability information.

Returns:
Information who may delete this message: the sender, the receiver, or both.

getTTL

public long getTTL()
Returns the Time-To-Live of this message.

Returns:
Time-To-Live in milliseconds.

getCategory

public short getCategory()
Returns the category of this message. The receiver may decide how to handle the message using this information.

Returns:
Message category.

getSubcategory

public short getSubcategory()
Returns the subcategory of this message. The receiver may recognize whether this message is a response, an initialization message, or an error or any other kind.

Returns:
Message subcategory.

getOptions

public int getOptions()
Returns the options.

Returns:
Options.

getBodyVector

public java.util.Vector getBodyVector()
Returns the body as a vector. The body Object array is converted to a vector and then returned.

Returns:
Vector which has been constructed from the body Object array. The vector is empty if the Object array is empty.

getBody

public java.lang.Object[] getBody()
Returns the body Object array.

Returns:
Body Object array.

getTimeStamp

public long getTimeStamp()
Returns the timestamp of this message. This timestamp is derived from the message ID.

Returns:
Timestamp of this message.

getID

public AMETASMessageID getID()
Returns the ID of this message.

Returns:
Message ID.

isRemote

public boolean isRemote()
Deprecated. The concept of remote messages should be replaced by a pure agent-based solution.

Determines whether this message has been delivered by the remote message delivery.

Returns:
true if the message was delivered from a remote place.

getSenderPlace

public java.lang.String getSenderPlace()
Deprecated. The concept of remote messages should be replaced by a pure agent-based solution.

Returns the name of the place where this message was remotely deposited.

Returns:
Place name or null if the message was deposited locally.

getPrivileges

public AMETASPrivilegeList getPrivileges()
Returns the privileges of the sender at the moment of submission. This method may be used by the receiving Place User to determine whether the sender had a certain set of privileges when submitting the message.

Returns:
Privilegien des Aufrufers.

includesOption

public boolean includesOption(int nOption)
Checks whether a given option has been set.

Parameters:
nOption - Option to be tested.
Returns:
true if the given option was set, else false.

getSenderContextID

public int getSenderContextID()
Returns the sender context ID. The context ID was set by the sending Place User.

Returns:
Context ID.
Since:
2.6.0
See Also:
AMETASContext

getReceiverContextID

public int getReceiverContextID()
Returns the receiver context ID. The context ID was set by the sending Place User.

Returns:
Context ID.
Since:
2.6.0
See Also:
AMETASContext

getDeliveryPlace

public java.lang.String getDeliveryPlace()
Returns the place name where this message has been retrieved. This setting has been done by the mailbox on getting the messages by the Place User.

Returns:
Place name.
Since:
2.6.0

senderHasPrivilege

public boolean senderHasPrivilege(java.lang.String sPrivilegeName)
Checks whether the given privilege is contained in the set of privileges of the sender. This allows the receiver to determine whether the sender had some specific privileges when submitting its message.

Parameters:
sPrivilegeName - Name of a privilege, like "NETACC".
Returns:
true if the sender had this privilege, else false.
Since:
2.5.0

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates a clone of this message. To make sure that sender and receiver do not share any part of the message, the complete body is serialized and deserialized again to get a deep copy.

Returns:
Clone of this message.
Throws:
java.lang.CloneNotSupportedException - if the message contains nonserializable components.

categoryToString

public static java.lang.String categoryToString(short nCategory)
Translates the category into a readable String.

Parameters:
nCategory - Category as numerical constant.
Returns:
String representation of the category.

subcatToString

public static java.lang.String subcatToString(short nSubcategory)
Translates the subcategory into a readable String.

Parameters:
nSubcategory - Subcategory as a numerical constant.
Returns:
String representation of the subcategory.

deletableToString

public static java.lang.String deletableToString(short nDeletable)
Translates the deletable information into a readable String.

Parameters:
nDeletable - Deletability as a numerical constant.
Returns:
String representation of the deletability.

optionsToString

public static java.lang.String optionsToString(int nOptions)
Translates the options into a readable String.

Returns:
String representation of the options.

toString

public java.lang.String toString()
Returns a String representation of this message.

Returns:
String representation.