gate.creole
Class AbstractProcessingResource

java.lang.Object
  extended by gate.util.AbstractFeatureBearer
      extended by gate.creole.AbstractResource
          extended by gate.creole.AbstractProcessingResource
All Implemented Interfaces:
ANNIEConstants, Executable, ProcessingResource, Resource, FeatureBearer, NameBearer, Serializable
Direct Known Subclasses:
AbstractLanguageAnalyser, SearchPR

public abstract class AbstractProcessingResource
extends AbstractResource
implements ProcessingResource, ANNIEConstants

A convenience implementation of ProcessingResource with some default code.

See Also:
Serialized Form

Nested Class Summary
protected  class AbstractProcessingResource.InternalStatusListener
          A simple status listener used to forward the events upstream.
protected  class AbstractProcessingResource.IntervalProgressListener
          A progress listener used to convert a 0..100 interval into a smaller one
 
Field Summary
protected  boolean interrupted
           
 
Fields inherited from class gate.creole.AbstractResource
name
 
Fields inherited from class gate.util.AbstractFeatureBearer
features
 
Fields inherited from interface gate.creole.ANNIEConstants
ANNOTATION_COREF_FEATURE_NAME, DATE_ANNOTATION_TYPE, DATE_POSTED_ANNOTATION_TYPE, DEFAULT_FILE, DOCUMENT_COREF_FEATURE_NAME, JOB_ID_ANNOTATION_TYPE, LOCATION_ANNOTATION_TYPE, LOOKUP_ANNOTATION_TYPE, LOOKUP_CLASS_FEATURE_NAME, LOOKUP_INSTANCE_FEATURE_NAME, LOOKUP_LANGUAGE_FEATURE_NAME, LOOKUP_MAJOR_TYPE_FEATURE_NAME, LOOKUP_MINOR_TYPE_FEATURE_NAME, LOOKUP_ONTOLOGY_FEATURE_NAME, MONEY_ANNOTATION_TYPE, ORGANIZATION_ANNOTATION_TYPE, PERSON_ANNOTATION_TYPE, PERSON_GENDER_FEATURE_NAME, PLUGIN_DIR, PR_NAMES, SENTENCE_ANNOTATION_TYPE, SPACE_TOKEN_ANNOTATION_TYPE, TOKEN_ANNOTATION_TYPE, TOKEN_CATEGORY_FEATURE_NAME, TOKEN_KIND_FEATURE_NAME, TOKEN_LENGTH_FEATURE_NAME, TOKEN_ORTH_FEATURE_NAME, TOKEN_STRING_FEATURE_NAME
 
Constructor Summary
AbstractProcessingResource()
           
 
Method Summary
 void addProgressListener(ProgressListener l)
          Adds a ProgressListener to the list of listeners for this processing resource.
 void addStatusListener(StatusListener l)
          Adds a StatusListener to the list of listeners for this processing resource
 void cleanup()
          should clear all internal data of the resource.
 void execute()
          Run the resource.
protected  void fireProcessFinished()
          Notifies all the ProgressListeners of a progress finished.
protected  void fireProgressChanged(int e)
          Notifies all the ProgressListeners of a progress change event.
protected  void fireStatusChanged(String e)
          Notifies all the StatusListeners of a change of status.
 FeatureMap getRuntimeParameterValues()
          Get the current values for all this resource's registered init-time parameters.
static FeatureMap getRuntimeParameterValues(Resource res)
          Get the current values for all of a specified resource's registered runtime parameters.
 Resource init()
          Initialise this resource, and return it.
 void interrupt()
          Notifies this PR that it should stop its execution as soon as possible.
 boolean isInterrupted()
          Checks whether this PR has been interrupted since the last time its execute() method was called.
 void reInit()
          Reinitialises the processing resource.
 void removeProgressListener(ProgressListener l)
          Removes a ProgressListener from the list of listeners for this processing resource.
 void removeStatusListener(StatusListener l)
          Removes a StatusListener from the list of listeners for this processing resource
 
Methods inherited from class gate.creole.AbstractResource
checkParameterValues, getBeanInfo, getInitParameterValues, getInitParameterValues, getName, getParameterValue, getParameterValue, getParameterValues, removeResourceListeners, setName, setParameterValue, setParameterValue, setParameterValues, setParameterValues, setResourceListeners
 
Methods inherited from class gate.util.AbstractFeatureBearer
getFeatures, setFeatures
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gate.Resource
getParameterValue, setParameterValue, setParameterValues
 
Methods inherited from interface gate.util.FeatureBearer
getFeatures, setFeatures
 
Methods inherited from interface gate.util.NameBearer
getName, setName
 

Field Detail

interrupted

protected volatile boolean interrupted
Constructor Detail

AbstractProcessingResource

public AbstractProcessingResource()
Method Detail

init

public Resource init()
              throws ResourceInstantiationException
Initialise this resource, and return it.

Specified by:
init in interface Resource
Overrides:
init in class AbstractResource
Throws:
ResourceInstantiationException

execute

public void execute()
             throws ExecutionException
Run the resource. It doesn't make sense not to override this in subclasses so the default implementation signals an exception.

Specified by:
execute in interface Executable
Throws:
ExecutionException

reInit

public void reInit()
            throws ResourceInstantiationException
Reinitialises the processing resource. After calling this method the resource should be in the state it is after calling init. If the resource depends on external resources (such as rules files) then the resource will re-read those resources. If the data used to create the resource has changed since the resource has been created then the resource will change too after calling reInit(). The implementation in this class simply calls init(). This functionality must be overriden by derived classes as necessary.

Specified by:
reInit in interface ProcessingResource
Throws:
ResourceInstantiationException

cleanup

public void cleanup()
should clear all internal data of the resource. Does nothing now

Specified by:
cleanup in interface Resource
Overrides:
cleanup in class AbstractResource

isInterrupted

public boolean isInterrupted()
Checks whether this PR has been interrupted since the last time its execute() method was called.

Specified by:
isInterrupted in interface Executable

interrupt

public void interrupt()
Notifies this PR that it should stop its execution as soon as possible.

Specified by:
interrupt in interface Executable

removeStatusListener

public void removeStatusListener(StatusListener l)
Removes a StatusListener from the list of listeners for this processing resource


addStatusListener

public void addStatusListener(StatusListener l)
Adds a StatusListener to the list of listeners for this processing resource


fireStatusChanged

protected void fireStatusChanged(String e)
Notifies all the StatusListeners of a change of status.

Parameters:
e - the message describing the status change

addProgressListener

public void addProgressListener(ProgressListener l)
Adds a ProgressListener to the list of listeners for this processing resource.


removeProgressListener

public void removeProgressListener(ProgressListener l)
Removes a ProgressListener from the list of listeners for this processing resource.


fireProgressChanged

protected void fireProgressChanged(int e)
Notifies all the ProgressListeners of a progress change event.

Parameters:
e - the new value of execution completion

fireProcessFinished

protected void fireProcessFinished()
Notifies all the ProgressListeners of a progress finished.


getRuntimeParameterValues

public static FeatureMap getRuntimeParameterValues(Resource res)
                                            throws ResourceInstantiationException
Get the current values for all of a specified resource's registered runtime parameters.

Throws:
ResourceInstantiationException

getRuntimeParameterValues

public FeatureMap getRuntimeParameterValues()
                                     throws ResourceInstantiationException
Get the current values for all this resource's registered init-time parameters.

Throws:
ResourceInstantiationException