public class CreoleRegisterImpl extends HashMap<String,ResourceData> implements CreoleRegister
The CREOLE register records the set of resources that are currently known to
the system. Each member of the register is a ResourceData
object, indexed by the class name of the resource.
CreoleRegister,
Serialized FormAbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Modifier and Type | Field and Description |
|---|---|
protected Set<String> |
applicationTypes
A list of the types of Packaged Applications in the register
|
protected Set<String> |
controllerTypes
A list of the types of Controller in the register.
|
protected static boolean |
DEBUG
Debug flag
|
protected org.jdom.input.SAXBuilder |
jdomBuilder
The parser for the CREOLE directory files
|
protected static org.slf4j.Logger |
log
A logger to use instead of sending messages to Out or Err
|
protected Set<String> |
lrTypes
A list of the types of LR in the register.
|
static String |
PLUGIN_NAMES_MAPPING_FILE
Name of the plugin-mappings file
|
protected Map<String,String> |
pluginNamesMappings
maps previous plugin names to new plugin names
|
protected Set<Plugin> |
plugins |
protected Set<String> |
prTypes
A list of the types of PR in the register.
|
protected Set<String> |
toolTypes
A list of the types of TOOL in the register.
|
protected List<String> |
vrTypes
A list of the types of VR in the register.
|
| Constructor and Description |
|---|
CreoleRegisterImpl()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCreoleListener(CreoleListener l)
Registers a
CreoleListenerwith this CreoleRegister. |
void |
addPluginListener(PluginListener listener) |
void |
clear()
Overide HashMap's clear to update the list of LR types in the register, and
remove all resources and forgets all directories.
|
void |
datastoreClosed(CreoleEvent e)
Called when a
DataStore has been closed |
void |
datastoreCreated(CreoleEvent e)
Called when a
DataStore has been created |
void |
datastoreOpened(CreoleEvent e)
Called when a
DataStore has been opened |
protected void |
fireDatastoreClosed(CreoleEvent e) |
protected void |
fireDatastoreCreated(CreoleEvent e) |
protected void |
fireDatastoreOpened(CreoleEvent e) |
protected void |
firePluginLoaded(Plugin plugin) |
protected void |
firePluginUnloaded(Plugin plugin) |
protected void |
fireResourceLoaded(CreoleEvent e) |
protected void |
fireResourceRenamed(Resource res,
String oldName,
String newName) |
protected void |
fireResourceUnloaded(CreoleEvent e) |
List<Resource> |
getAllInstances(String type)
Get a list of all the known Resource instances in the register that are of
the specified (class or interface) type or one of its sub-types.
|
List<Resource> |
getAllInstances(String type,
boolean includeHidden) |
List<String> |
getAnnotationVRs()
Returns a list of strings representing class names for annotation VRs that
are able to display/edit all types of annotations.
|
List<String> |
getAnnotationVRs(String annotationType)
Returns a list of strings representing class names for annotation VRs that
are able to display/edit a given annotation type The default VR will be the
first in the returned list.
|
Set<String> |
getApplicationTypes()
Get the list of types of packaged application resources in the register.
|
Set<String> |
getControllerTypes()
Get the list of types of Controller in the register.
|
Set<URL> |
getDirectories()
Deprecated.
|
List<String> |
getLargeVRsForResource(String resourceClassName)
Returns a list of strings representing class names for large VRs valid for
a given type of language/processing resource.
|
List<LanguageResource> |
getLrInstances()
Get a list of all instantiations of LR in the register.
|
List<LanguageResource> |
getLrInstances(String resourceTypeName)
Get a list of all the known Language Resource instances in the register
whose class is
resourceTypeName. |
Set<String> |
getLrTypes()
Get the list of types of LR in the register.
|
Set<Plugin> |
getPlugins() |
List<ProcessingResource> |
getPrInstances()
Get a list of all instantiations of PR in the register.
|
List<ProcessingResource> |
getPrInstances(String resourceTypeName)
Get a list of all the known Processing Resource instances in the register
whose class is
resourceTypeName. |
Set<String> |
getPrTypes()
Get the list of types of PR in the register.
|
List<String> |
getPublicControllerTypes()
Get a list of all non-private types of controller in the register.
|
List<LanguageResource> |
getPublicLrInstances()
Get a list of all non-private instantiations of LR in the register.
|
List<String> |
getPublicLrTypes()
Get a list of all non-private types of LR in the register.
|
List<ProcessingResource> |
getPublicPrInstances()
Get a list of all non-private instantiations of PR in the register.
|
List<String> |
getPublicPrTypes()
Get a list of all non-private types of PR in the register.
|
protected <T> List<T> |
getPublics(List<T> instances)
Get a list of all non-private instantiations.
|
protected List<String> |
getPublicTypes(Collection<String> types)
Gets a list of all non private types from alist of types
|
List<VisualResource> |
getPublicVrInstances()
Get a list of all non-private instantiations of VR in the register.
|
List<String> |
getPublicVrTypes()
Get a list of all non-private types of VR in the register.
|
List<String> |
getSmallVRsForResource(String resourceClassName)
Returns a list of strings representing class names for small VRs valid for
a given type of language/processing resource The default VR will be the
first in the returned list.
|
Set<String> |
getToolTypes()
Get the list of types of TOOL resources in the register.
|
List<String> |
getVREnabledAnnotationTypes()
Returns a list of strings representing annotations types for which there
are custom viewers/editor registered.
|
List<VisualResource> |
getVrInstances()
Get a list of all instantiations of VR in the register.
|
List<VisualResource> |
getVrInstances(String resourceTypeName)
Get a list of all the known Visual Resource instances in the register
whose class is
resourceTypeName. |
Set<String> |
getVrTypes()
Get the list of types of VR in the register.
|
protected void |
parseDirectory(Plugin plugin,
org.jdom.Document jdomDoc,
URL directoryUrl,
URL creoleFileUrl)
Parse a directory file (represented as an open stream), adding resource
data objects to the CREOLE register as they occur.
|
ResourceData |
put(String key,
ResourceData rd)
Overide HashMap's put method to maintain a list of all the types of LR in
the register, and a list of tool types.
|
void |
registerBuiltins()
Register resources that are built in to the GATE distribution.
|
void |
registerComponent(Class<? extends Resource> resourceClass)
Given the class object for a class with
CreoleResource
annotations, register that class as is if it was found in a scanned jar
file with no additional creole.xml information. |
void |
registerDirectories(URL directoryUrl)
Register a single CREOLE directory.
|
void |
registerDirectories(URL directoryUrl,
boolean loadDependencies)
Register a single CREOLE directory.
|
void |
registerPlugin(Plugin plugin) |
void |
registerPlugin(Plugin plugin,
boolean loadDependencies) |
ResourceData |
remove(Object key)
Overide HashMap's delete method to update the lists of types in the
register.
|
void |
removeCreoleListener(CreoleListener l)
Removes a
CreoleListener previously registered with this
CreoleRegister. |
void |
removeDirectory(URL directory)
Deprecated.
|
void |
removePluginListener(PluginListener listener) |
void |
resourceLoaded(CreoleEvent e)
Called when a new
Resource has been loaded into the system |
void |
resourceRenamed(Resource resource,
String oldName,
String newName)
Called when the creole register has renamed a resource.1
|
void |
resourceUnloaded(CreoleEvent e)
Called when a
Resource has been removed from the system |
void |
setResourceName(Resource res,
String newName)
Renames an existing resource.
|
void |
unregisterPlugin(Plugin plugin) |
clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll, size, valuesequals, hashCode, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll, size, valuesprotected static final org.slf4j.Logger log
protected static final boolean DEBUG
protected transient org.jdom.input.SAXBuilder jdomBuilder
public static final String PLUGIN_NAMES_MAPPING_FILE
protected Map<String,String> pluginNamesMappings
protected Set<String> controllerTypes
public CreoleRegisterImpl()
throws GateException
GateException@Deprecated public Set<URL> getDirectories()
getDirectories in interface CreoleRegisterpublic void registerPlugin(Plugin plugin) throws GateException
registerPlugin in interface CreoleRegisterGateExceptionpublic void registerPlugin(Plugin plugin, boolean loadDependencies) throws GateException
registerPlugin in interface CreoleRegisterGateExceptionpublic void registerComponent(Class<? extends Resource> resourceClass) throws GateException
CreoleRegisterCreoleResource
annotations, register that class as is if it was found in a scanned jar
file with no additional creole.xml information.
This API is intended for use in embedded GATE applications where
the 'application' is created via the API. Components registered with this
API won't work in saved applications, but they can be added
to saved applications at runtime.registerComponent in interface CreoleRegisterresourceClass - Class object for class with CreoleResource annotations.GateExceptionpublic void registerDirectories(URL directoryUrl, boolean loadDependencies) throws GateException
creole.xml file at the
URL is parsed, and CreoleData objects added to the register.
If the directory URL has not yet been added it is now added. If any other
plugins that need to be loaded for this plugin to load (specified by
REQUIRES elements in creole.xml) will only be
loaded if the loadDependencies param is true. It is useful to
be able to ignore dependencies when loading an xgapp where we know they
have already been resolved.registerDirectories in interface CreoleRegisterGateExceptionpublic void registerDirectories(URL directoryUrl) throws GateException
creole.xml file at the
URL is parsed, and CreoleData objects added to the register.
If the directory URL has not yet been added it is now added. If any other
plugins that nees top be loaded for this plugin to load (specified by
REQUIRES elements in creole.xml) will also be
loaded.registerDirectories in interface CreoleRegisterGateExceptionprotected void parseDirectory(Plugin plugin, org.jdom.Document jdomDoc, URL directoryUrl, URL creoleFileUrl) throws GateException
GateExceptionpublic void registerBuiltins()
throws GateException
registerBuiltins in interface CreoleRegisterGateExceptionpublic ResourceData put(String key, ResourceData rd)
put in interface Map<String,ResourceData>put in class HashMap<String,ResourceData>public void unregisterPlugin(Plugin plugin)
unregisterPlugin in interface CreoleRegister@Deprecated public void removeDirectory(URL directory)
removeDirectory in interface CreoleRegisterdirectory - public ResourceData remove(Object key)
remove in interface Map<String,ResourceData>remove in class HashMap<String,ResourceData>public void clear()
clear in interface Map<String,ResourceData>clear in class HashMap<String,ResourceData>public Set<String> getLrTypes()
getLrTypes in interface CreoleRegisterpublic Set<String> getPrTypes()
getPrTypes in interface CreoleRegisterpublic Set<String> getVrTypes()
getVrTypes in interface CreoleRegisterpublic Set<String> getControllerTypes()
getControllerTypes in interface CreoleRegisterpublic Set<String> getToolTypes()
getToolTypes in interface CreoleRegisterpublic Set<String> getApplicationTypes()
getApplicationTypes in interface CreoleRegisterpublic List<LanguageResource> getLrInstances()
getLrInstances in interface CreoleRegisterpublic List<ProcessingResource> getPrInstances()
getPrInstances in interface CreoleRegisterpublic List<VisualResource> getVrInstances()
getVrInstances in interface CreoleRegisterpublic List<LanguageResource> getLrInstances(String resourceTypeName)
CreoleRegisterresourceTypeName. This is only direct
instances of the specified class, not its sub-classes, so if
resourceTypeName refers to an interface or abstract class an
empty list will be returned.getLrInstances in interface CreoleRegisterpublic List<ProcessingResource> getPrInstances(String resourceTypeName)
CreoleRegisterresourceTypeName. This is only direct
instances of the specified class, not its sub-classes, so if
resourceTypeName refers to an interface or abstract class an
empty list will be returned.getPrInstances in interface CreoleRegisterpublic List<VisualResource> getVrInstances(String resourceTypeName)
CreoleRegisterresourceTypeName. This is only direct
instances of the specified class, not its sub-classes, so if
resourceTypeName refers to an interface or abstract class an
empty list will be returned.getVrInstances in interface CreoleRegisterpublic List<LanguageResource> getPublicLrInstances()
getPublicLrInstances in interface CreoleRegisterpublic List<ProcessingResource> getPublicPrInstances()
getPublicPrInstances in interface CreoleRegisterpublic List<VisualResource> getPublicVrInstances()
getPublicVrInstances in interface CreoleRegisterpublic List<String> getPublicLrTypes()
getPublicLrTypes in interface CreoleRegisterpublic List<String> getPublicPrTypes()
getPublicPrTypes in interface CreoleRegisterpublic List<String> getPublicVrTypes()
getPublicVrTypes in interface CreoleRegisterpublic List<String> getPublicControllerTypes()
getPublicControllerTypes in interface CreoleRegisterpublic List<Resource> getAllInstances(String type) throws GateException
CreoleRegisterr such that
Gate.getClassLoader().loadClass(type).isInstance(r)Instances that are hidden (
Gate.getHiddenAttribute(r.getFeatures())
== true) are not included in the returned list.getAllInstances in interface CreoleRegisterGateExceptionpublic List<Resource> getAllInstances(String type, boolean includeHidden) throws GateException
GateExceptionpublic List<String> getLargeVRsForResource(String resourceClassName)
getLargeVRsForResource in interface CreoleRegisterresourceClassName - the name of the resource that has large viewers. If
resourceClassName is null then an empty list will be
returned.public List<String> getSmallVRsForResource(String resourceClassName)
getSmallVRsForResource in interface CreoleRegisterresourceClassName - the name of the resource that has large viewers. If
resourceClassName is null then an empty list will be
returned.public List<String> getAnnotationVRs()
getAnnotationVRs in interface CreoleRegisterpublic List<String> getAnnotationVRs(String annotationType)
getAnnotationVRs in interface CreoleRegisterpublic void setResourceName(Resource res, String newName)
setResourceName in interface CreoleRegisterpublic List<String> getVREnabledAnnotationTypes()
getVREnabledAnnotationTypes in interface CreoleRegisterprotected <T> List<T> getPublics(List<T> instances)
protected List<String> getPublicTypes(Collection<String> types)
public void removeCreoleListener(CreoleListener l)
CreoleRegisterCreoleListener previously registered with this
CreoleRegister.removeCreoleListener in interface CreoleRegisterCreoleRegister.addCreoleListener(CreoleListener)public void addCreoleListener(CreoleListener l)
CreoleRegisterCreoleListenerwith this CreoleRegister.
The register will fire events every time a resource is added to or removed
from the system and when a datastore is created, opened or closed.addCreoleListener in interface CreoleRegisterprotected void firePluginLoaded(Plugin plugin)
protected void firePluginUnloaded(Plugin plugin)
public void addPluginListener(PluginListener listener)
addPluginListener in interface CreoleRegisterpublic void removePluginListener(PluginListener listener)
removePluginListener in interface CreoleRegisterprotected void fireResourceLoaded(CreoleEvent e)
protected void fireResourceUnloaded(CreoleEvent e)
protected void fireResourceRenamed(Resource res, String oldName, String newName)
protected void fireDatastoreOpened(CreoleEvent e)
protected void fireDatastoreCreated(CreoleEvent e)
protected void fireDatastoreClosed(CreoleEvent e)
public void resourceLoaded(CreoleEvent e)
CreoleListenerResource has been loaded into the systemresourceLoaded in interface CreoleListenerpublic void resourceUnloaded(CreoleEvent e)
CreoleListenerResource has been removed from the systemresourceUnloaded in interface CreoleListenerpublic void resourceRenamed(Resource resource, String oldName, String newName)
CreoleListenerresourceRenamed in interface CreoleListenerpublic void datastoreOpened(CreoleEvent e)
CreoleListenerDataStore has been openeddatastoreOpened in interface CreoleListenerpublic void datastoreCreated(CreoleEvent e)
CreoleListenerDataStore has been createddatastoreCreated in interface CreoleListenerpublic void datastoreClosed(CreoleEvent e)
CreoleListenerDataStore has been closeddatastoreClosed in interface CreoleListenerpublic Set<Plugin> getPlugins()
getPlugins in interface CreoleRegisterCopyright © 2024 GATE. All rights reserved.