de.mud.jta.plugin

Class Script

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 JTA - Telnet/SSH for the JAVA(tm) platform.

Maintainer: Matthias L. Jugel

Version:
$Id: Script.java 499 2005-09-29 08:24:54Z leo $
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, 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)

Methods inherited from class de.mud.jta.Plugin

error, getId

Field Details

source

protected FilterPlugin source
holds the data source for input and output

Constructor Details

Script

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

Method Details

getFilterSource

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

read

public int read(byte[] b)
            throws 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

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

write

public void write(byte[] b)
            throws IOException
Specified by:
write in interface FilterPlugin