com.ibm.agletx.util
Class SeqItinerary

java.lang.Object
  extended bycom.ibm.aglet.event.MobilityAdapter
      extended bycom.ibm.agletx.util.SeqItinerary
All Implemented Interfaces:
java.util.EventListener, MobilityListener, java.io.Serializable
Direct Known Subclasses:
MeetingsItinerary, MessengerItinerary, SeqPlanItinerary, SlaveItinerary

public abstract class SeqItinerary
extends MobilityAdapter
implements java.io.Serializable

Define an abstract interface for an aglet's itinerary. An Itinerary is a set of pairs of the form [host, task] where the task should be performed upon arrival of the aglet to the host.

Version:
1.10 $Date: 2001/07/28 06:33:36 $
Author:
Yariv Aridor
See Also:
Task, Serialized Form

Field Summary
protected  Aglet aglet
           
protected  AgletProxy currentTarget
           
private  java.util.Vector hosts
           
private  int index
           
private  java.lang.String origin
           
private  boolean repeat
           
(package private) static long serialVersionUID
           
private  java.util.Vector tasks
           
 
Constructor Summary
SeqItinerary(Aglet aglet)
          Constructor.
 
Method Summary
 void addAddress(java.lang.String address)
          Add a new destination
 java.util.Enumeration addresses()
          Return an enumeration of all the addresses
 void addTask(java.lang.String address, Task task)
          Add a new task
 boolean atLastDestination()
          Check if at the last destination
 void clear()
          Empty the itineray
 java.lang.String getAddressAt(int index)
          Return the address at the specified index.
 java.lang.String getCurrentAddress()
          Return the address of the current destination
protected  Task getCurrentTask()
          Return the task to be preformed at the current destination
 java.lang.String getOrigin()
          Return the address of the origin
 AgletProxy getOwnerAglet()
          Return the Proxy of the owner aglet
 Task getTaskAt(int index)
          Return the task at a specific index
 void goToNext()
          Go to the next address and perform the next task
 void handleException(java.lang.Throwable ex)
          Handle exception during task execution
 void handleTripException(java.lang.Throwable ex)
          Handle exception during the travelling of the owner aglet (try to dispatch to the next destination).
(package private)  void incIndex()
           
 int indexOf(java.lang.String address)
          Return the index of a specific address
 int indexOf(Task task)
          Return the index of a specific task
 boolean isRepeat()
          Check if the itinerary is a cyclic one.
 void onArrival(MobilityEvent ev)
          This is not normally used by aglets programmers.
protected  void onTermination()
           
 void removeTaskAt(int index)
          Remove a task at a specific index
 void setRepeat(boolean b)
          Define whether the itinerary is to be repeated (cyclic)
 int size()
          Return the size of the aglet's itinerary.
 void startTrip()
          Start the trip defined in this itinerary
private  void tryNext()
           
 
Methods inherited from class com.ibm.aglet.event.MobilityAdapter
onDispatching, onReverting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

aglet

protected Aglet aglet

tasks

private java.util.Vector tasks

hosts

private java.util.Vector hosts

index

private int index

currentTarget

protected transient AgletProxy currentTarget

repeat

private boolean repeat

origin

private java.lang.String origin
Constructor Detail

SeqItinerary

public SeqItinerary(Aglet aglet)
Constructor.

Parameters:
aglet - the owner aglet
Method Detail

addAddress

public void addAddress(java.lang.String address)
Add a new destination


addresses

public java.util.Enumeration addresses()
Return an enumeration of all the addresses


addTask

public void addTask(java.lang.String address,
                    Task task)
Add a new task

Parameters:
task - the task to be added

atLastDestination

public boolean atLastDestination()
Check if at the last destination


clear

public void clear()
Empty the itineray


getAddressAt

public java.lang.String getAddressAt(int index)
Return the address at the specified index.


getCurrentAddress

public java.lang.String getCurrentAddress()
Return the address of the current destination


getCurrentTask

protected Task getCurrentTask()
Return the task to be preformed at the current destination


getOrigin

public java.lang.String getOrigin()
Return the address of the origin


getOwnerAglet

public AgletProxy getOwnerAglet()
Return the Proxy of the owner aglet


getTaskAt

public Task getTaskAt(int index)
Return the task at a specific index


goToNext

public void goToNext()
Go to the next address and perform the next task


handleException

public void handleException(java.lang.Throwable ex)
Handle exception during task execution

Parameters:
ex - the exception

handleTripException

public void handleTripException(java.lang.Throwable ex)
Handle exception during the travelling of the owner aglet (try to dispatch to the next destination).

Parameters:
ex - the exception

incIndex

void incIndex()

indexOf

public int indexOf(Task task)
Return the index of a specific task


indexOf

public int indexOf(java.lang.String address)
Return the index of a specific address


isRepeat

public boolean isRepeat()
Check if the itinerary is a cyclic one.


onArrival

public void onArrival(MobilityEvent ev)
This is not normally used by aglets programmers.

Specified by:
onArrival in interface MobilityListener
Overrides:
onArrival in class MobilityAdapter

onTermination

protected void onTermination()

removeTaskAt

public void removeTaskAt(int index)
Remove a task at a specific index


setRepeat

public void setRepeat(boolean b)
Define whether the itinerary is to be repeated (cyclic)


size

public int size()
Return the size of the aglet's itinerary.


startTrip

public void startTrip()
Start the trip defined in this itinerary


tryNext

private void tryNext()