de.mud.jta.plugin
Class Script

java.lang.Object
  |
  +--de.mud.jta.Plugin
        |
        +--de.mud.jta.plugin.Script
All Implemented Interfaces:
FilterPlugin

public class Script
extends Plugin
implements FilterPlugin

The script plugin takes a series of match and answer pairs to compare the incoming data with the matches and if it succeeds writes the answers back. It then moves on to the next match until all script elements have matched.

The script property Script.script should contain | separated strings where each two represent a match and answer pair. A newline will be appended to each answer!

If the first matching string is empty, the answer string will be sent upon connect. The script is very basic but is a very good example how to write a plugin for The Javatm Telnet Application.

Maintainer: Matthias L. Jugel

Version:
$Id: Script.java,v 2.9 2002/05/06 07:24:20 leo Exp $
Author:
Matthias L. Jugel, Marcus Meißner

Field Summary
protected  FilterPlugin source
          holds the data source for input and output
 
Fields inherited from class de.mud.jta.Plugin
bus, id
 
Constructor Summary
Script(PluginBus bus, java.lang.String id)
          Create a new scripting plugin.
 
Method Summary
 FilterPlugin getFilterSource()
           
 int read(byte[] b)
          Read an array of bytes from the back end and put it through the script parser to see if it matches.
 void setFilterSource(FilterPlugin plugin)
          Set the filter source where we can read data from and where to write the script answer to.
 void write(byte[] b)
          Write a block of data to the back end.
 
Methods inherited from class de.mud.jta.Plugin
error, getId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

source

protected FilterPlugin source
holds the data source for input and output

Constructor Detail

Script

public Script(PluginBus bus,
              java.lang.String id)
Create a new scripting plugin.

Method Detail

setFilterSource

public void setFilterSource(FilterPlugin plugin)
Set the filter source where we can read data from and where to write the script answer to.

Specified by:
setFilterSource in interface FilterPlugin
Parameters:
plugin - the filter plugin we use as source

getFilterSource

public FilterPlugin getFilterSource()
Specified by:
getFilterSource in interface FilterPlugin

read

public int read(byte[] b)
         throws java.io.IOException
Read an array of bytes from the back end and put it through the script parser to see if it matches. It will send the answer immediately to the filter source if a match occurs.

Specified by:
read in interface FilterPlugin
Parameters:
b - the array where to read the bytes in
Returns:
the amount of bytes actually read
java.io.IOException

write

public void write(byte[] b)
           throws java.io.IOException
Description copied from interface: FilterPlugin
Write a block of data to the back end.

Specified by:
write in interface FilterPlugin
Parameters:
b - the buffer to be sent
java.io.IOException