Class SimulationAdapter

All Implemented Interfaces:
EventListener, SimulationListener

public class SimulationAdapter extends DefaultSimAdapter
This class provides the additional methods needed for drama-based simulation flavors for an adapter for simulation-state events. Most of the methods are provided by the superclass.
  • Constructor Details

    • SimulationAdapter

      public SimulationAdapter()
      Constructor. This creates an adapter with no scripting support.
    • SimulationAdapter

      public SimulationAdapter(ExpressionParser.ESPObject scriptObject)
      Constructor with only a script object. This creates an adapter for use with the ESP scripting language.

      Note: This is equivalent to using the constructor SimulationAdapter(ScriptingContext,Object) with a null first argument.

      Parameters:
      scriptObject - the scripting-language object implementing the listener interface for this adapter.
    • SimulationAdapter

      public SimulationAdapter(ScriptingContext context, Object scriptObject) throws IllegalArgumentException
      Constructor given a scripting context and script object. This constructor implements the adapter using a scripting language provided its arguments are not null. If a method is added to the script object after this constructor is called, that method will be ignored, so all of the methods the adapter implements must be defined by the script object when this constructor is called.

      If ESP is the scripting language, the context may be null provided that scriptObject is an ESP object. This special case is provided for use with ObjectNamerLauncher and the yrunner program.

      Parameters:
      context - the scripting context for this adapter
      scriptObject - the scripting-language object implementing the listener interface for this adapter.
      Throws:
      IllegalArgumentException - the script object was ill formed
  • Method Details

    • stateChanged

      public final void stateChanged(SimulationStateEvent e)
      Process a simulation-state-change event. The implementation dispatches the processing to the superclass and if the superclass does not respond to an event with the current event's type, the event-types handled by this class are tried. then other methods in this class, based on the event type.
      Specified by:
      stateChanged in interface SimulationListener
      Overrides:
      stateChanged in class DefaultSimAdapter
      Parameters:
      e - the event
    • messageReceiveStart

      public void messageReceiveStart(Simulation sim, MessageRecipient from, MessageRecipient to, Object msg)
      Indicate that an agent or group is receiving a message.
      Parameters:
      sim - the simulation
      from - the message sender
      to - the message recipient
      msg - the message itself
    • messageReceiveEnd

      public void messageReceiveEnd(Simulation sim, MessageRecipient from, MessageRecipient to, Object msg)
      Indicate that an agent or group has completed receiving a message.
      Parameters:
      sim - the simulation
      from - the message sender
      to - the message recipient
      msg - the message itself