GATE
Version 3.1-2270

gate.creole
Class AbstractResource

java.lang.Object
  extended by gate.util.AbstractFeatureBearer
      extended by gate.creole.AbstractResource
All Implemented Interfaces:
Resource, FeatureBearer, NameBearer, Serializable
Direct Known Subclasses:
AbstractController, AbstractDocumentView, AbstractLanguageResource, AbstractProcessingResource

public abstract class AbstractResource
extends AbstractFeatureBearer
implements Resource, Serializable

A convenience implementation of Resource with some default code.

See Also:
Serialized Form

Field Summary
protected  String name
           
 
Fields inherited from class gate.util.AbstractFeatureBearer
features
 
Constructor Summary
AbstractResource()
           
 
Method Summary
static boolean checkParameterValues(Resource resource, List parameters)
          Checks whether the provided Resource has values for all the required parameters from the provided list of parameters.
 void cleanup()
          releases the memory allocated to this resource
static BeanInfo getBeanInfo(Class c)
           
 String getName()
          Returns the name of this resource
static Object getParameterValue(Resource resource, String paramaterName)
          Gets the value of a parameter for a resource.
 Object getParameterValue(String paramaterName)
          Gets the value of a parameter of this resource.
 Resource init()
          Initialise this resource, and return it.
static void removeResourceListeners(Resource resource, Map listeners)
          Removes listeners from a resource.
 void setName(String name)
          Sets the name of this resource
static void setParameterValue(Resource resource, BeanInfo resBeanInf, String paramaterName, Object parameterValue)
          Sets the value for a specified parameter for a resource.
 void setParameterValue(String paramaterName, Object parameterValue)
          Sets the value for a specified parameter for this resource.
 void setParameterValues(FeatureMap parameters)
          Sets the values for more parameters for this resource in one step.
static void setParameterValues(Resource resource, FeatureMap parameters)
          Sets the values for more parameters for a resource in one step.
static void setResourceListeners(Resource resource, Map listeners)
          Adds listeners to a resource.
 
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.util.FeatureBearer
getFeatures, setFeatures
 

Field Detail

name

protected String name
Constructor Detail

AbstractResource

public AbstractResource()
Method Detail

init

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

Specified by:
init in interface Resource
Throws:
ResourceInstantiationException

setName

public void setName(String name)
Sets the name of this resource

Specified by:
setName in interface NameBearer

getName

public String getName()
Returns the name of this resource

Specified by:
getName in interface NameBearer

cleanup

public void cleanup()
releases the memory allocated to this resource

Specified by:
cleanup in interface Resource

getParameterValue

public static Object getParameterValue(Resource resource,
                                       String paramaterName)
                                throws ResourceInstantiationException
Gets the value of a parameter for a resource.

Parameters:
resource - the resource from which the parameter value will be obtained
paramaterName - the name of the parameter
Returns:
the current value of the parameter
Throws:
ResourceInstantiationException

setParameterValue

public static void setParameterValue(Resource resource,
                                     BeanInfo resBeanInf,
                                     String paramaterName,
                                     Object parameterValue)
                              throws ResourceInstantiationException
Sets the value for a specified parameter for a resource.

Parameters:
resource - the resource for which the parameter value will be set
paramaterName - the name for the parameter
parameterValue - the value the parameter will receive
Throws:
ResourceInstantiationException

setParameterValues

public static void setParameterValues(Resource resource,
                                      FeatureMap parameters)
                               throws ResourceInstantiationException
Sets the values for more parameters for a resource in one step.

Parameters:
parameters - a feature map that has paramete names as keys and parameter values as values.
Throws:
ResourceInstantiationException

setResourceListeners

public static void setResourceListeners(Resource resource,
                                        Map listeners)
                                 throws IntrospectionException,
                                        InvocationTargetException,
                                        IllegalAccessException,
                                        GateException
Adds listeners to a resource.

Parameters:
listeners - The listeners to be registered with the resource. A Map that maps from fully qualified class name (as a string) to listener (of the type declared by the key).
resource - the resource that listeners will be registered to.
Throws:
IntrospectionException
InvocationTargetException
IllegalAccessException
GateException

removeResourceListeners

public static void removeResourceListeners(Resource resource,
                                           Map listeners)
                                    throws IntrospectionException,
                                           InvocationTargetException,
                                           IllegalAccessException,
                                           GateException
Removes listeners from a resource.

Parameters:
listeners - The listeners to be removed from the resource. A Map that maps from fully qualified class name (as a string) to listener (of the type declared by the key).
resource - the resource that listeners will be removed from.
Throws:
IntrospectionException
InvocationTargetException
IllegalAccessException
GateException

checkParameterValues

public static boolean checkParameterValues(Resource resource,
                                           List parameters)
                                    throws ResourceInstantiationException
Checks whether the provided Resource has values for all the required parameters from the provided list of parameters.

Parameters:
resource - the resource being checked
parameters - is a List of List of Parameter representing a list of parameter disjunctions (e.g. the one returned by ParameterList.getRuntimeParameters()).
Returns:
true if all the required parameters have non null values, false otherwise.
Throws:
{@link - ResourceInstantiationException} if problems occur while inspecting the parameters for the resource. These will normally be introspection problems and are usually caused by the lack of a parameter or of the read accessor for a parameter.
ResourceInstantiationException

getParameterValue

public Object getParameterValue(String paramaterName)
                         throws ResourceInstantiationException
Gets the value of a parameter of this resource.

Specified by:
getParameterValue in interface Resource
Parameters:
paramaterName - the name of the parameter
Returns:
the current value of the parameter
Throws:
ResourceInstantiationException

setParameterValue

public void setParameterValue(String paramaterName,
                              Object parameterValue)
                       throws ResourceInstantiationException
Sets the value for a specified parameter for this resource.

Specified by:
setParameterValue in interface Resource
Parameters:
paramaterName - the name for the parameter
parameterValue - the value the parameter will receive
Throws:
ResourceInstantiationException

setParameterValues

public void setParameterValues(FeatureMap parameters)
                        throws ResourceInstantiationException
Sets the values for more parameters for this resource in one step.

Specified by:
setParameterValues in interface Resource
Parameters:
parameters - a feature map that has paramete names as keys and parameter values as values.
Throws:
ResourceInstantiationException

getBeanInfo

public static BeanInfo getBeanInfo(Class c)
                            throws IntrospectionException
Throws:
IntrospectionException

GATE
Version 3.1-2270