gate
Class Factory

java.lang.Object
  |
  +--gate.Factory

public abstract class Factory
extends Object

Provides static methods for the creation of Resources.


Constructor Summary
Factory()
           
 
Method Summary
static void addCreoleListener(CreoleListener l)
          Add a listener
static DataStore createDataStore(String dataStoreClassName, URL storageUrl)
          Create a new DataStore and open it.
static Resource createResource(String resourceClassName)
          Create an instance of a resource using default parameter values.
static Resource createResource(String resourceClassName, FeatureMap parameterValues)
          Create an instance of a resource, and return it.
static Resource createResource(String resourceClassName, FeatureMap parameterValues, FeatureMap features)
          Create an instance of a resource, and return it.
static Resource createResource(String resourceClassName, FeatureMap parameterValues, FeatureMap features, Map listeners)
          Create an instance of a resource, and return it.
static Resource createResource(String resourceClassName, FeatureMap parameterValues, Map listeners)
          Create an instance of a resource, and return it.
static void deleteResource(Resource resource)
          Delete an instance of a resource.
static Corpus newCorpus(String name)
          Create a new transient Corpus.
static Document newDocument(String content)
          Create a new transient textual Document from a string.
static Document newDocument(URL sourceUrl)
          Create a new transient Document from a URL.
static Document newDocument(URL sourceUrl, String encoding)
          Create a new transient Document from a URL and an encoding.
static FeatureMap newFeatureMap()
          Create a new FeatureMap.
static DataStore openDataStore(String dataStoreClassName, URL storageUrl)
          Open an existing DataStore.
static void removeResourceListeners(Resource resource, Map listeners)
          Removes listeners from a resource.
static void setResourceInittimeParameters(Resource resource, FeatureMap parameterValues)
          For each paramter, set the appropriate property on the resource using bean-style reflection.
static void setResourceListeners(Resource resource, Map listeners)
          Adds listeners to a resource.
static void setResourceRuntimeParameters(Resource resource, FeatureMap parameterValues)
          For each paramter, set the appropriate property on the resource using bean-style reflection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Factory

public Factory()
Method Detail

createResource

public static Resource createResource(String resourceClassName)
                               throws ResourceInstantiationException
Create an instance of a resource using default parameter values.
See Also:
createResource(String,FeatureMap)

createResource

public static Resource createResource(String resourceClassName,
                                      FeatureMap parameterValues,
                                      Map listeners)
                               throws ResourceInstantiationException
Create an instance of a resource, and return it. Callers of this method are responsible for querying the resource's parameter lists, putting together a set that is complete apart from runtime parameters, and passing a feature map containing these parameter settings.
Parameters:
resourceClassName - the name of the class implementing the resource.
parameterValues - the feature map containing intialisation time parameterValues for the resource.
listeners - The listeners to be registered with the resource during its initialisation. A Map that maps from fully qualified class name (as a string) to listener (of the type declared by the key).
Returns:
an instantiated resource.

createResource

public static Resource createResource(String resourceClassName,
                                      FeatureMap parameterValues,
                                      FeatureMap features)
                               throws ResourceInstantiationException
Create an instance of a resource, and return it. Callers of this method are responsible for querying the resource's parameter lists, putting together a set that is complete apart from runtime parameters, and passing a feature map containing these parameter settings.
Parameters:
resourceClassName - the name of the class implementing the resource.
parameterValues - the feature map containing intialisation time parameterValues for the resource.
features - the features for the new resource
Returns:
an instantiated resource.

createResource

public static Resource createResource(String resourceClassName,
                                      FeatureMap parameterValues,
                                      FeatureMap features,
                                      Map listeners)
                               throws ResourceInstantiationException
Create an instance of a resource, and return it. Callers of this method are responsible for querying the resource's parameter lists, putting together a set that is complete apart from runtime parameters, and passing a feature map containing these parameter settings.
Parameters:
resourceClassName - the name of the class implementing the resource.
parameterValues - the feature map containing intialisation time parameterValues for the resource.
listeners - The listeners to be registered with the resource during its initialisation. A Map that maps freom fully qualified class name (as a string) to listener (of the type declared by the key).
features - the features for the new resource
Returns:
an instantiated resource.

createResource

public static Resource createResource(String resourceClassName,
                                      FeatureMap parameterValues)
                               throws ResourceInstantiationException
Create an instance of a resource, and return it. Callers of this method are responsible for querying the resource's parameter lists, putting together a set that is complete apart from runtime parameters, and passing a feature map containing these parameter settings.
Parameters:
resourceClassName - the name of the class implementing the resource.
parameterValues - the feature map containing intialisation time parameterValues for the resource.
Returns:
an instantiated resource.

deleteResource

public static void deleteResource(Resource resource)
Delete an instance of a resource. This involves removing it from the stack of instantiations maintained by this resource type's resource data. Deletion does not guarantee that the resource will become a candidate for garbage collection, just that the GATE framework is no longer holding references to the resource.
Parameters:
resource - the resource to be deleted.

setResourceInittimeParameters

public static void setResourceInittimeParameters(Resource resource,
                                                 FeatureMap parameterValues)
                                          throws ResourceInstantiationException
For each paramter, set the appropriate property on the resource using bean-style reflection. This method will read the defaults where safe to do so (i.e. not for parameters disjunctions) which will get overriden by any values provided by the user.
Parameters:
resource - the resource to be parameterised.
parameterValues - the parameters and their values.
See Also:
java.beans.Introspector

setResourceRuntimeParameters

public static void setResourceRuntimeParameters(Resource resource,
                                                FeatureMap parameterValues)
                                         throws ResourceInstantiationException
For each paramter, set the appropriate property on the resource using bean-style reflection. This method will read the defaults where safe to do so (i.e. not for parameters disjunctions) which will get overriden by any values provided by the user.
Parameters:
resource - the resource to be parameterised.
parameterValues - the parameters and their values.
See Also:
java.beans.Introspector

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.

newCorpus

public static Corpus newCorpus(String name)
                        throws ResourceInstantiationException
Create a new transient Corpus.

newDocument

public static Document newDocument(URL sourceUrl)
                            throws ResourceInstantiationException
Create a new transient Document from a URL.

newDocument

public static Document newDocument(URL sourceUrl,
                                   String encoding)
                            throws ResourceInstantiationException
Create a new transient Document from a URL and an encoding.

newDocument

public static Document newDocument(String content)
                            throws ResourceInstantiationException
Create a new transient textual Document from a string.

newFeatureMap

public static FeatureMap newFeatureMap()
Create a new FeatureMap.

openDataStore

public static DataStore openDataStore(String dataStoreClassName,
                                      URL storageUrl)
                               throws PersistenceException
Open an existing DataStore.

createDataStore

public static DataStore createDataStore(String dataStoreClassName,
                                        URL storageUrl)
                                 throws PersistenceException,
                                        UnsupportedOperationException
Create a new DataStore and open it. NOTE: for some data stores creation is an system administrator task; in such cases this method will throw an UnsupportedOperationException.

addCreoleListener

public static void addCreoleListener(CreoleListener l)
Add a listener