gate.util
Class Jacl

java.lang.Object
  |
  +--gate.util.Jacl

public class Jacl
extends Object

This class provides access to the Jacl Tcl interpreter, and caters for loading any Tcl scripts that live in the GATE source. It also serves as examples of how Tcl can be used from Java using the Jacl library (which is my excuse for those cases where there was an obvious easier way!).

Note that all GATE Tcl scripts should be in the namespace "GATE".


Field Summary
private static boolean DEBUG
          Debug flag
private  String findTclScript
          Some Tcl code to find all the .tcl files under a directory.
private  List gateScriptsList
          This is a list of all the .tcl files in the GATE source, used by the loadScripts() method.
(package private)  String goToGateSrcScript
          Some Tcl code to get us into the gate/src directory (from gate or a subdir).
private  tcl.lang.Interp interp
          The Tcl interpreter
private  String nl
          Local fashion for newlines
 
Constructor Summary
Jacl()
          Construction
 
Method Summary
(package private)  void copyGateScripts(List scriptPaths)
          Copy scripts from the GATE source tree into the classes dir, so that they will make it into gate.jar, and so that getResource (used by Interp.evalResource) will find them.
 List findScripts()
          Locate any files named .tcl in the directory hierarchy under .
 List findScripts(String prelimScript)
          Locate any files named .tcl in the directory hierarchy under .
 tcl.lang.Interp getInterp()
          Get the interpreter
(package private)  void listGateScripts()
          Set up the gateScriptsList member.
 void loadScripts()
          Loads all the scripts in the GATE source.
 void loadScripts(List scriptPaths)
          Load a list of Tcl scripts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
Debug flag

See Also:
Constant Field Values

interp

private tcl.lang.Interp interp
The Tcl interpreter


nl

private String nl
Local fashion for newlines


goToGateSrcScript

String goToGateSrcScript
Some Tcl code to get us into the gate/src directory (from gate or a subdir).


findTclScript

private String findTclScript
Some Tcl code to find all the .tcl files under a directory.


gateScriptsList

private List gateScriptsList
This is a list of all the .tcl files in the GATE source, used by the loadScripts() method.

Constructor Detail

Jacl

public Jacl()
Construction

Method Detail

getInterp

public tcl.lang.Interp getInterp()
Get the interpreter


findScripts

public List findScripts()
                 throws tcl.lang.TclException
Locate any files named .tcl in the directory hierarchy under . and return a list of them.

tcl.lang.TclException

findScripts

public List findScripts(String prelimScript)
                 throws tcl.lang.TclException
Locate any files named .tcl in the directory hierarchy under . and return a list of them. The prelimScript parameter should be a non-null string containing Tcl code that will be evaluated before the finder script runs (so it can be used to change directory, for e.g.).

tcl.lang.TclException

copyGateScripts

void copyGateScripts(List scriptPaths)
               throws tcl.lang.TclException
Copy scripts from the GATE source tree into the classes dir, so that they will make it into gate.jar, and so that getResource (used by Interp.evalResource) will find them.

tcl.lang.TclException

loadScripts

public void loadScripts(List scriptPaths)
                 throws tcl.lang.TclException
Load a list of Tcl scripts. The class loader is used to find the scripts, so they must be on the class path, preferably in the same code base as this class. Naming: each path in the list should be the path to the script relative to the CLASSPATH. So, for e.g., if you have MyJar.jar on the classpath, and it contains a script housed in package x.y called z.tcl, the name should be x/y/z.tcl. (The class loader can then be asked to retrieve /x/y/z.tcl and will find the file in the jar.)

tcl.lang.TclException

loadScripts

public void loadScripts()
                 throws tcl.lang.TclException
Loads all the scripts in the GATE source. So to get a Tcl interpreter that's fully initialised with all the GATE Tcl code do:
 Jacl jacl = new Jacl();
 jacl.loadScripts();
 

tcl.lang.TclException

listGateScripts

void listGateScripts()
               throws tcl.lang.TclException
Set up the gateScriptsList member. This uses the ScriptsList.tcl script, which is built by "make tcl".

tcl.lang.TclException