## gate.creole
Class AbstractResource

    java.lang.Object
      |
      +--gate.util.AbstractFeatureBearer
            |
            +--gate.creole.AbstractResource

All Implemented Interfaces:
  FeatureBearer, NameBearer, Resource, Serializable

Direct Known Subclasses:
  AbstractController, AbstractLanguageResource, AbstractProcessingResource

public abstract class AbstractResource
extends AbstractFeatureBearer
implements Resource, Serializable

A convenience implementation of Resource with some default code.

See Also:
  Serialized Form

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
`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
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface gate.util.FeatureBearer
`getFeatures, setFeatures`

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`

### 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

### 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 parameteer
    `parameterValue` - the value the parameter will receive

### 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.

### 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.

### 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.

### 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
    `paramters` - 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.

### 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

### 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

### 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.