Back Previous Next


Linguist basic package - dispatcher

Syntax:

   dispatcher {name} {elements}

Keyword handler:

   net.eclecity.linguist.basic.keyword.BasicKDispatcher.class

Runtime handler(s):

   net.eclecity.linguist.handler.BHDispatcher.class

Function:

Declares a dispatcher or an array of dispatchers. The array size is fixed at time of compilation.

It is frequently necessary to test a string value against a number of different values and select an outcome depending on the value. The traditional method of if ... then ... else if ... is very inefficient for large numbers of choices. A dispatcher is a hashtable that is programmed with each of the alternatives and their corresponding outcome addresses; a much cleaner and faster alternative. See create and send.

Example(s):

   dispatcher DispatchTable
   dispatcher Dispatch 5


Back Previous Next