gate.jape
Class RightHandSide

java.lang.Object
  |
  +--gate.jape.RightHandSide
All Implemented Interfaces:
JapeConstants, Serializable

public class RightHandSide
extends Object
implements JapeConstants, Serializable

The RHS of a CPSL rule. The action part. Contains an inner class created from the code in the grammar RHS.

See Also:
Serialized Form

Field Summary
private  byte[] actionClassBytes
          The bytes of the compiled action class.
private  String actionClassClassFileName
          Name of the .class file for the action class.
private  String actionClassJavaFileName
          Name of the .java file for the action class.
private  String actionClassName
          The name of the action class.
private static int actionClassNumber
          Cardinality of the action class set.
private  String actionClassQualifiedName
          The qualified name of the action class.
private  StringBuffer actionClassString
          The string we use to create the action class.
private static String actionsDirName
          Package name for action classes.
private  com.objectspace.jgl.HashSet blockNames
          The set of block names.
(package private) static boolean debug
          Debug flag.
private static boolean DEBUG
          Debug flag
private  LeftHandSide lhs
          The LHS of our rule, where we get bindings from.
private  String nl
          Local fashion for newlines.
private static com.objectspace.jgl.Array tempFiles
          A list of the files and directories we create.
private  Class theActionClass
          The "action class" we create to implement the action.
private  Object theActionObject
          An instance of theActionClass.
 
Fields inherited from interface gate.jape.JapeConstants
APPELT_STYLE, BRILL_STYLE, DEFAULT_PRIORITY, FIRST_STYLE, INDENT_PADDING, KLEENE_PLUS, KLEENE_QUERY, KLEENE_STAR, MULTI_SPAN_BINDING, NO_BINDING, NO_KLEENE_OP, SINGLE_SPAN_BINDING
 
Constructor Summary
RightHandSide(String transducerName, String ruleName, LeftHandSide lhs)
          Construction from the transducer name, rule name and the LHS.
 
Method Summary
 void addBlock(String anonymousBlock)
          Add an anonymous block to the action class
 void addBlock(String name, String namedBlock)
          Add a named block to the action class
static void cleanUp()
          Remove class files created for actions.
 void compileActionClass()
          Compile the action class.
 void createActionClass()
          Create the action class and an instance of it.
 void defineActionClass()
          Define the action class (after deserialisation).
 String getActionClassString()
          For debugging.
 void instantiateActionClass()
          Create an instance of the action class.
 void loadActionClass()
          Load the action class.
 void readActionClass()
          Read action class bytes, for storing during serialisation.
static void setActionClassNumber(int n)
          Allow setting of the initial action class number.
 String shortDesc()
          Create a string representation of the object.
 String toString()
          Create a string representation of the object.
 String toString(String pad)
          Create a string representation of the object.
 void transduce(Document doc, AnnotationSet annotations, Map bindings)
          Makes changes to the document, using LHS bindings.
 void writeActionClass()
          Write out the action class file.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
Debug flag

theActionClass

private transient Class theActionClass
The "action class" we create to implement the action. Has a static method that performs the action of the RHS.

theActionObject

private transient Object theActionObject
An instance of theActionClass.

actionClassString

private StringBuffer actionClassString
The string we use to create the action class.

actionClassBytes

private byte[] actionClassBytes
The bytes of the compiled action class.

actionClassName

private String actionClassName
The name of the action class.

actionsDirName

private static String actionsDirName
Package name for action classes. It's called a "dir name" because we used to dump the action classes to disk and compile them there.

actionClassQualifiedName

private String actionClassQualifiedName
The qualified name of the action class.

actionClassJavaFileName

private String actionClassJavaFileName
Name of the .java file for the action class.

actionClassClassFileName

private String actionClassClassFileName
Name of the .class file for the action class.

actionClassNumber

private static int actionClassNumber
Cardinality of the action class set. Used for ensuring class name uniqueness.

blockNames

private com.objectspace.jgl.HashSet blockNames
The set of block names. Used to ensure we only get their annotations once in the action class.

lhs

private LeftHandSide lhs
The LHS of our rule, where we get bindings from.

tempFiles

private static com.objectspace.jgl.Array tempFiles
A list of the files and directories we create.

nl

private final String nl
Local fashion for newlines.

debug

static final boolean debug
Debug flag.
Constructor Detail

RightHandSide

public RightHandSide(String transducerName,
                     String ruleName,
                     LeftHandSide lhs)
Construction from the transducer name, rule name and the LHS.
Method Detail

setActionClassNumber

public static void setActionClassNumber(int n)
Allow setting of the initial action class number. Used for ensuring class name uniqueness when running more than one transducer. The long-term solution is to have separate class loaders for each transducer.

getActionClassString

public String getActionClassString()
For debugging.

addBlock

public void addBlock(String anonymousBlock)
Add an anonymous block to the action class

addBlock

public void addBlock(String name,
                     String namedBlock)
Add a named block to the action class

createActionClass

public void createActionClass()
                       throws JapeException
Create the action class and an instance of it.

writeActionClass

public void writeActionClass()
                      throws JapeException
Write out the action class file.

compileActionClass

public void compileActionClass()
                        throws JapeException
Compile the action class. First tries to use the sun.tools.javac class directly via reflection. If that fails, tries to exec javac as an external process.

readActionClass

public void readActionClass()
                     throws JapeException
Read action class bytes, for storing during serialisation.

loadActionClass

public void loadActionClass()
                     throws JapeException
Load the action class.

defineActionClass

public void defineActionClass()
                       throws JapeException
Define the action class (after deserialisation).

instantiateActionClass

public void instantiateActionClass()
                            throws JapeException
Create an instance of the action class.

cleanUp

public static void cleanUp()
Remove class files created for actions.

transduce

public void transduce(Document doc,
                      AnnotationSet annotations,
                      Map bindings)
               throws JapeException
Makes changes to the document, using LHS bindings.

toString

public String toString()
Create a string representation of the object.
Overrides:
toString in class Object

toString

public String toString(String pad)
Create a string representation of the object.

shortDesc

public String shortDesc()
Create a string representation of the object.