AMETAS.util.context
Interface AMETASContext

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
AMETASStandardContext

public interface AMETASContext
extends java.io.Serializable

Represents a context.

Since:
2.6.0

Field Summary
static int CURRENT_CONTEXT
          Constant representing the recently used context.
static int FINAL
          Constant representing a final state.
static int INITIAL
          Constant representing the initial state.
static int NEW_CONTEXT
          Constant representing a new context.
static int NO_CONTEXT
          Constant representing a non-defined context.
static short SEMISTABLE
          Constant representing a semistable state.
static short STABLE
          Constant representing a stable state.
static short UNSTABLE
          Constant representing an unstable state.
 
Method Summary
 int getContextID()
          Returns the ID of this context.
 short getMode()
          Returns the mode of this context (stable, unstable, semistable).
 AMETASPlaceUser getPlaceUser()
          Returns a reference to the Place User.
 AMETASServiceObject getServiceObject()
          Returns the reference to the service object.
 int getStateID()
          Return the current state of the context by its ID.
 void nextState(int nStateID, short nMode)
          Makes the context proceed to the next state.
 void processMessage(AMETASMessage msg)
          Processes the message.
 void setContextID(int nID)
          Sets the ID of this context.
 void setParameters(java.lang.Object[] aParam)
          Set the parameters of the context.
 void setPlaceUser(AMETASPlaceUser pu)
          Sets the reference to the Place User.
 void setServiceObject(AMETASServiceObject so)
          Defines the reference to the service object.
 

Field Detail

NO_CONTEXT

public static final int NO_CONTEXT
Constant representing a non-defined context. Contexts must not have this value (-1) as an ID.

See Also:
Constant Field Values

CURRENT_CONTEXT

public static final int CURRENT_CONTEXT
Constant representing the recently used context. Contexts must not have this value (-2) as an ID.

See Also:
Constant Field Values

NEW_CONTEXT

public static final int NEW_CONTEXT
Constant representing a new context. Contexts must not have this value (-3) as an ID.

See Also:
Constant Field Values

FINAL

public static final int FINAL
Constant representing a final state. States must not be defined by this value (-1) if they are not final.

See Also:
Constant Field Values

INITIAL

public static final int INITIAL
Constant representing the initial state. There should not be another state with this value (0).

See Also:
Constant Field Values

STABLE

public static final short STABLE
Constant representing a stable state.

See Also:
Constant Field Values

UNSTABLE

public static final short UNSTABLE
Constant representing an unstable state.

See Also:
Constant Field Values

SEMISTABLE

public static final short SEMISTABLE
Constant representing a semistable state.

See Also:
Constant Field Values
Method Detail

setContextID

public void setContextID(int nID)
Sets the ID of this context. Subsequent calls of this method are ignored.

Parameters:
nID - Context ID.

getContextID

public int getContextID()
Returns the ID of this context.

Returns:
ID.

setPlaceUser

public void setPlaceUser(AMETASPlaceUser pu)
Sets the reference to the Place User. As the context object may not be designed as an internal class of the Place User, there must be a way for it to get into contact with the Place User.

Parameters:
pu - Reference to the Place User.

getPlaceUser

public AMETASPlaceUser getPlaceUser()
Returns a reference to the Place User. This method is required to allow the context object to access the Place User.

Returns:
Reference to the Place User.

setServiceObject

public void setServiceObject(AMETASServiceObject so)
Defines the reference to the service object. This is required for this context object to access the service object. Due to limitations of the Java language, context classes cannot be implemented as an inner class of the service object.

Since:
2.6.3

getServiceObject

public AMETASServiceObject getServiceObject()
Returns the reference to the service object. This is required for this context object to access the service object. Due to limitations of the Java language, context classes cannot be implemented as an inner class of the service object.

Returns:
Reference to the service object or null if the context belongs to an agent or user adapter.
Since:
2.6.3

getStateID

public int getStateID()
Return the current state of the context by its ID.

Returns:
State ID.

nextState

public void nextState(int nStateID,
                      short nMode)
Makes the context proceed to the next state.

Parameters:
nStateID - ID of the new state.
nMode - Stability of the new state (STABLE, UNSTABLE, SEMISTABLE).

getMode

public short getMode()
Returns the mode of this context (stable, unstable, semistable).

Returns:
STABLE, UNSTABLE, SEMISTABLE.

setParameters

public void setParameters(java.lang.Object[] aParam)
Set the parameters of the context. This might be necessary to retrieve data from objects different from the Place User.

Parameters:
aParam - Parameters.

processMessage

public void processMessage(AMETASMessage msg)
                    throws MessagePushbackException,
                           MessageRejectedException,
                           ContextTerminatedException
Processes the message.

Parameters:
msg - Message to be processed. Must be null when the current state is unstable in this context.
Throws:
MessagePushbackException - when the message is not processed but neither rejected. This is required for semistable states when the state shall proceed along the unstable path even though there were a suitable message.
MessageRejectedException - when the message is not accepted by the context in the current state.
ContextTerminatedException - when the context processing must be aborted.