gate.jape
Class DefaultActionContext

java.lang.Object
  extended by gate.jape.DefaultActionContext
All Implemented Interfaces:
ActionContext, Serializable

public class DefaultActionContext
extends Object
implements ActionContext

Default implementation for an action context.
Note: A JAPE RHS should only ever use the methods defined in the ActionContext interface, the additional methods implemented here are for use by the Transducer only.

Author:
Johann Petrak
See Also:
Serialized Form

Field Summary
protected  Controller controller
           
protected  Corpus corpus
           
protected  boolean endPhaseSupported
           
protected  boolean phaseEnded
           
protected  ProcessingResource pr
           
protected  FeatureMap prfeatures
           
protected  String prname
           
 
Constructor Summary
DefaultActionContext()
           
 
Method Summary
 boolean endPhase()
          Request the current JAPE phase to be ended as soon as possible.
 Controller getController()
           
 Corpus getCorpus()
          Provide access to the corpus a JAPE processing resource is running on.
 FeatureMap getPRFeatures()
          Provide access to the feature map associated with the JAPE processing resource.
 String getPRName()
          Provide access to the name of the current transducer PR.
 boolean isPhaseEnded()
           
 boolean isPREnabled()
          Returns true if the PR this transducer is running in has a chance to be run at all in its controller.
 void setController(Controller c)
           
 void setCorpus(Corpus corpus)
           
 void setPhaseEnded(boolean isended)
           
 void setPR(ProcessingResource pr)
           
 void setPRFeatures(FeatureMap features)
           
 void setPRName(String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

corpus

protected Corpus corpus

prfeatures

protected FeatureMap prfeatures

prname

protected String prname

controller

protected Controller controller

endPhaseSupported

protected boolean endPhaseSupported

phaseEnded

protected boolean phaseEnded

pr

protected ProcessingResource pr
Constructor Detail

DefaultActionContext

public DefaultActionContext()
Method Detail

setCorpus

public void setCorpus(Corpus corpus)

setPRFeatures

public void setPRFeatures(FeatureMap features)

setPRName

public void setPRName(String name)

setPR

public void setPR(ProcessingResource pr)

getCorpus

public Corpus getCorpus()
Description copied from interface: ActionContext
Provide access to the corpus a JAPE processing resource is running on.

Specified by:
getCorpus in interface ActionContext
Returns:
the corpus LR the JAPE transducer is processing, null if no such corpus exists.

getPRFeatures

public FeatureMap getPRFeatures()
Description copied from interface: ActionContext
Provide access to the feature map associated with the JAPE processing resource.

Specified by:
getPRFeatures in interface ActionContext
Returns:
the FeatureMap of the processing resource

getPRName

public String getPRName()
Description copied from interface: ActionContext
Provide access to the name of the current transducer PR.

Specified by:
getPRName in interface ActionContext

setController

public void setController(Controller c)

getController

public Controller getController()
Specified by:
getController in interface ActionContext

endPhase

public boolean endPhase()
Description copied from interface: ActionContext
Request the current JAPE phase to be ended as soon as possible. After the current RHS code has returned, the phase will be ended as soon as possible if the JAPE implementation supports this feature. The method returns false if this feature is not supported or if it is known that ending the phase prematurely is not possible, true otherwise.

Specified by:
endPhase in interface ActionContext
Returns:
true if ending the phase prematurely is supported, false otherwise

isPhaseEnded

public boolean isPhaseEnded()

setPhaseEnded

public void setPhaseEnded(boolean isended)

isPREnabled

public boolean isPREnabled()
Description copied from interface: ActionContext
Returns true if the PR this transducer is running in has a chance to be run at all in its controller. This can be false if the PR is set to never run in a conditional controller. In such a case any controllerStarted, and controllerFinished blocks of the JAPE grammer are still run when the controller is starting or finishing. This method can be used in the controllerStarted or controllerFinished blocks to prevent any unwanted processing if the PR is disabled.

Specified by:
isPREnabled in interface ActionContext