Class AnnotatorContext_impl
- java.lang.Object
-
- org.apache.uima.analysis_engine.impl.AnnotatorContext_impl
-
- All Implemented Interfaces:
AnnotatorContext
public class AnnotatorContext_impl extends java.lang.Object implements AnnotatorContext
Reference implementation ofAnnotatorContext
.
-
-
Field Summary
Fields Modifier and Type Field Description private UimaContextAdmin
mUimaContext
The UimaContextAdmin that this AnnotatorContext wraps.
-
Constructor Summary
Constructors Constructor Description AnnotatorContext_impl(UimaContextAdmin aUimaContext)
Creates a new AnnotatorContext_impl.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.String[]
getConfigParameterNames()
Gets the names of all configuration parameters that are not declared in a group.java.lang.String[]
getConfigParameterNames(java.lang.String aGroup)
Gets the names of all configuration parameters in the specified group.java.lang.Object
getConfigParameterValue(java.lang.String aName)
Retrieves the value for a configuration parameter that is not defined in any group or is defined in the default group.java.lang.Object
getConfigParameterValue(java.lang.String aGroupName, java.lang.String aParamName)
Retrieves the value for a configuration parameter in a particular group.java.lang.String[]
getConfigurationGroupNames()
Gets the names of all configuration parameter groups.java.lang.String
getDataPath()
Gets the data path used to locate resources.InstrumentationFacility
getInstrumentationFacility()
Gets the InstrumentationFacility to be used within this AnalysisEngine.Logger
getLogger()
Gets theLogger
to which this annotator should send its log output.java.io.InputStream
getResourceAsStream(java.lang.String aKey)
Acquires Resource InputStreams using the ResourceManager, or, if that fails, the ClassLoader.java.io.InputStream
getResourceAsStream(java.lang.String aKey, java.lang.String[] aParams)
Retrieves an InputStream for reading from the named resource.java.lang.String
getResourceFilePath(java.lang.String aKey)
Retrieves the absolute file path to the named resource.java.lang.String
getResourceFilePath(java.lang.String aKey, java.lang.String[] aParams)
Retrieves the absolute file path to the named resource.java.lang.Object
getResourceObject(java.lang.String aKey)
Acquires a Resource object using the ResourceManager.java.lang.Object
getResourceObject(java.lang.String aKey, java.lang.String[] aParams)
Retrieves the named resource object.java.net.URI
getResourceURI(java.lang.String aKey)
Retrieves the URI to the named resource.java.net.URI
getResourceURI(java.lang.String aKey, java.lang.String[] aParams)
Retrieves the URI to the named resource.java.net.URL
getResourceURL(java.lang.String aKey)
Locates Resource URL's using the ResourceManager, or, if that fails, the ClassLoader.java.net.URL
getResourceURL(java.lang.String aKey, java.lang.String[] aParams)
Retrieves the URL to the named resource.SofaID[]
getSofaMappings()
Deprecated.SofaID
mapToSofaID(java.lang.String aSofaName)
Deprecated.void
setProcessTrace(ProcessTrace aProcessTrace)
Sets the current ProcessTrace object, which will receive trace events generated by the InstrumentationFacility.
-
-
-
Field Detail
-
mUimaContext
private UimaContextAdmin mUimaContext
The UimaContextAdmin that this AnnotatorContext wraps.
-
-
Constructor Detail
-
AnnotatorContext_impl
public AnnotatorContext_impl(UimaContextAdmin aUimaContext)
Creates a new AnnotatorContext_impl.- Parameters:
aUimaContext
- the UIMA Context that this AnnotatorContext wraps.
-
-
Method Detail
-
getConfigParameterValue
public java.lang.Object getConfigParameterValue(java.lang.String aName)
Description copied from interface:AnnotatorContext
Retrieves the value for a configuration parameter that is not defined in any group or is defined in the default group.This method returns
null
if the parameter is optional and has not been assigned a value. (For mandatory parameters, an exception is thrown during initialization if no value has been assigned.) This method also returnsnull
if there is no declared configuration parameter with the specified name.- Specified by:
getConfigParameterValue
in interfaceAnnotatorContext
- Parameters:
aName
- the name of the parameter to look up- Returns:
- the value of the parameter with the given name. The annotator is expected to know the
data type of its parameters. Returns
null
if the parameter does not exist or has not been assigned a value. - See Also:
AnnotatorContext.getConfigParameterValue(String)
-
getConfigParameterValue
public java.lang.Object getConfigParameterValue(java.lang.String aGroupName, java.lang.String aParamName)
Description copied from interface:AnnotatorContext
Retrieves the value for a configuration parameter in a particular group. If that group contains no value for the specified parameter, the fallback strategy specified by the Analysis Engine'sConfigurationParameterDeclarations.getSearchStrategy()
property will be used. The search strategy can be specified in the Analysis Engine Descriptor.This method returns
null
if the parameter is optional and has not been assigned a value. (For mandatory parameters, an exception is thrown during initialization if no value has been assigned.) This method also returnsnull
if there is no declared configuration parameter with the specified name.- Specified by:
getConfigParameterValue
in interfaceAnnotatorContext
- Parameters:
aGroupName
- the name of the group containing the parameteraParamName
- the name of the parameter to look up- Returns:
- the value of the parameter with the given name. The annotator is expected to know the
data type of its parameters. Returns
null
if the parameter does not exist or has not been assigned a value. - See Also:
AnnotatorContext.getConfigParameterValue(java.lang.String, java.lang.String)
-
getLogger
public Logger getLogger()
Description copied from interface:AnnotatorContext
Gets theLogger
to which this annotator should send its log output. Annotators should use this facility rather than writing to their own log files (or to stdout).- Specified by:
getLogger
in interfaceAnnotatorContext
- Returns:
- an instance of a logger for use by this annotator.
- See Also:
AnnotatorContext.getLogger()
-
getInstrumentationFacility
public InstrumentationFacility getInstrumentationFacility()
Gets the InstrumentationFacility to be used within this AnalysisEngine.- Specified by:
getInstrumentationFacility
in interfaceAnnotatorContext
- Returns:
- the InstrumentationFacility to be used within this AnalysisEngine
-
getConfigurationGroupNames
public java.lang.String[] getConfigurationGroupNames()
Description copied from interface:AnnotatorContext
Gets the names of all configuration parameter groups.- Specified by:
getConfigurationGroupNames
in interfaceAnnotatorContext
- Returns:
- an array containing the names of all configuration groups that exist for this annotator. Returns an empty array if no groups are declared.
-
getConfigParameterNames
public java.lang.String[] getConfigParameterNames()
Description copied from interface:AnnotatorContext
Gets the names of all configuration parameters that are not declared in a group.- Specified by:
getConfigParameterNames
in interfaceAnnotatorContext
- Returns:
- an array containing the names of all configuration parameters not declared in any group. Returns an empty array if there are none.
-
getConfigParameterNames
public java.lang.String[] getConfigParameterNames(java.lang.String aGroup)
Description copied from interface:AnnotatorContext
Gets the names of all configuration parameters in the specified group.- Specified by:
getConfigParameterNames
in interfaceAnnotatorContext
- Parameters:
aGroup
- the group name- Returns:
- an array containing the names of all configuration parameters declared in
{
aGroup
. Note that this does include parameters with null values. Returns an empty array if there are none (including if the group does not exist).
-
getResourceURL
public java.net.URL getResourceURL(java.lang.String aKey) throws AnnotatorContextException
Locates Resource URL's using the ResourceManager, or, if that fails, the ClassLoader.- Specified by:
getResourceURL
in interfaceAnnotatorContext
- Parameters:
aKey
- the key by which the resource is identified. This key should be declared in the <externalResourceDependencies> section of the descriptor.- Returns:
- the
URL
at which the named resource is located,null
if the named resource could not be found. - Throws:
AnnotatorContextException
- if there's a problem- See Also:
AnnotatorContext.getResourceURL(String)
-
getResourceURI
public java.net.URI getResourceURI(java.lang.String aKey) throws AnnotatorContextException
Description copied from interface:AnnotatorContext
Retrieves the URI to the named resource. This can be used, for example, to locate configuration or authority files. The resource should be declared in the <externalResourceDependencies> section of the descriptor.This method is safer than
AnnotatorContext.getResourceURL(String)
in its treatment of file paths containing spaces. This is because theURI.getPath()
does perform URL decoding of that path (decoding %20 sequences to spaces) whereasURL.getPath()
does not.For backwards compatibility, if the key is not declared as a resource dependency, it is looked up directly in the
data path
and the class path. However, this usage is deprecated and support may be dropped in future versions. ALL external resource dependencies should be declared in the descriptor.- Specified by:
getResourceURI
in interfaceAnnotatorContext
- Parameters:
aKey
- the key by which the resource is identified. This key should be declared in the <externalResourceDependencies> section of the descriptor.- Returns:
- the
URI
at which the named resource is located,null
if the named resource could not be found. - Throws:
AnnotatorContextException
- if there's an exception- See Also:
UimaContext.getResourceURI(String)
-
getResourceFilePath
public java.lang.String getResourceFilePath(java.lang.String aKey) throws AnnotatorContextException
Description copied from interface:AnnotatorContext
Retrieves the absolute file path to the named resource. This can be used, for example, to locate configuration or authority files. The resource should be declared in the <externalResourceDependencies> section of the descriptor.This only works if the resource is a local file. If the resource is not a local file (for example, it could be an
http
URL, then an exception will be thrown.URL decoding will be done on the file path, so it is safe to use this method for file paths that contain spaces. For backwards compatibility, if the key is not declared as a resource dependency, it is looked up directly in the
data path
and the class path. However, this usage is deprecated and support may be dropped in future versions. ALL external resource dependencies should be declared in the descriptor.- Specified by:
getResourceFilePath
in interfaceAnnotatorContext
- Parameters:
aKey
- the key by which the resource is identified. This key should be declared in the <externalResourceDependencies> section of the descriptor.- Returns:
- the absolute file path at which the named resource is located,
null
if the named resource could not be found. - Throws:
AnnotatorContextException
- if there's an exception- See Also:
UimaContext.getResourceFilePath(String)
-
getResourceAsStream
public java.io.InputStream getResourceAsStream(java.lang.String aKey) throws AnnotatorContextException
Acquires Resource InputStreams using the ResourceManager, or, if that fails, the ClassLoader.- Specified by:
getResourceAsStream
in interfaceAnnotatorContext
- Parameters:
aKey
- the key by which the resource is identified. This key should be declared in the <externalResourceDependencies> section of the descriptor.- Returns:
- an
InputStream
for reading from the named resource,null
if the named resource could not be found. It is the caller's responsibility to close this stream once it is no longer needed. - Throws:
AnnotatorContextException
- if an error occurs- See Also:
AnnotatorContext.getResourceAsStream(String)
-
getResourceObject
public java.lang.Object getResourceObject(java.lang.String aKey) throws AnnotatorContextException
Acquires a Resource object using the ResourceManager.- Specified by:
getResourceObject
in interfaceAnnotatorContext
- Parameters:
aKey
- the key by which the resource is identified. This key should be declared in the <externalResourceDependencies> section of the descriptor.- Returns:
- the object bound to
aName
,null
if none. - Throws:
AnnotatorContextException
- if an error occurs- See Also:
AnnotatorContext.getResourceObject(String)
-
getResourceAsStream
public java.io.InputStream getResourceAsStream(java.lang.String aKey, java.lang.String[] aParams) throws AnnotatorContextException
Description copied from interface:AnnotatorContext
Retrieves an InputStream for reading from the named resource. This can be used, for example, to locate configuration or authority files. The resource should be declared in the <externalResourceDependencies> section of the descriptor.For backwards compatibility, if the key is not declared as a resource dependency, it is looked up directly in the
data path
and the class path. However, this usage is deprecated and support may be dropped in future versions. ALL external resource dependencies should be declared in the descriptor.This version of this method takes an array of parameters used to further identify the resource. This can be used, for example, with resources that vary depending on the language of the document being analyzed, such as when the <fileLanguageResourceSpecifier> element is used in the component descriptor.
- Specified by:
getResourceAsStream
in interfaceAnnotatorContext
- Parameters:
aKey
- the key by which the resource is identified. This key should bd declared in the <externalResourceDependencies> section of the descriptor.aParams
- parameters used to further identify the resource. When used to identify the language for a <fileLanguageResourceSpecifier>, this array should contain a single element, the ISO language code for the language of the document (e.g. "en", "de").- Returns:
- an
InputStream
for reading from the named resource,null
if the named resource could not be found. It is the caller's responsibility to close this stream once it is no longer needed. - Throws:
AnnotatorContextException
- if an error occurs- See Also:
AnnotatorContext.getResourceAsStream(java.lang.String, java.lang.String[])
-
getResourceObject
public java.lang.Object getResourceObject(java.lang.String aKey, java.lang.String[] aParams) throws AnnotatorContextException
Description copied from interface:AnnotatorContext
Retrieves the named resource object. This can be used to acquire references to external resources. The resource should be declared in the <externalResourceDependencies> section of the descriptor.This version of this method takes an array of parameters used to further identify the resource. This can be used, for example, with resources that vary depending on the language of the document being analyzed, such as when the <fileLanguageResourceSpecifier> element is used in the component descriptor.
- Specified by:
getResourceObject
in interfaceAnnotatorContext
- Parameters:
aKey
- the key by which the resource is identified. This key should be declared in the <externalResourceDependencies> section of the descriptor.aParams
- parameters used to further identify the resource. When used to identify the language for a <fileLanguageResourceSpecifier>, this array should contain a single element, the ISO language code for the language of the document (e.g. "en", "de").- Returns:
- the object bound to
aName
,null
if none. - Throws:
AnnotatorContextException
- if an error occurs- See Also:
AnnotatorContext.getResourceObject(java.lang.String, java.lang.String[])
-
getResourceURL
public java.net.URL getResourceURL(java.lang.String aKey, java.lang.String[] aParams) throws AnnotatorContextException
Description copied from interface:AnnotatorContext
Retrieves the URL to the named resource. This can be used, for example, to locate configuration or authority files. The resource should be declared in the <externalResourceDependencies> section of the descriptor.Note that if the URL contains spaces may be encoded as %20. The
URL.getPath()
method does NOT decode these sequences, therefore it is not safe to callgetResourceURL().getPath()
and attempt to use the result as a file path. Instead, you may useAnnotatorContext.getResourceURI(String)
orAnnotatorContext.getResourceFilePath(String)
.For backwards compatibility, if the key is not declared as a resource dependency, it is looked up directly in the
data path
and the class path. However, this usage is deprecated and support may be dropped in future versions. ALL external resource dependencies should be declared in the descriptor.This version of this method takes an array of parameters used to further identify the resource. This can be used, for example, with resources that vary depending on the language of the document being analyzed, such as when the <fileLanguageResourceSpecifier> element is used in the component descriptor.
- Specified by:
getResourceURL
in interfaceAnnotatorContext
- Parameters:
aKey
- the key by which the resource is identified. This key should be declared in the <externalResourceDependencies> section of the descriptor.aParams
- parameters used to further identify the resource. When used to identify the language for a <fileLanguageResourceSpecifier>, this array should contain a single element, the ISO language code for the language of the document (e.g. "en", "de").- Returns:
- the
URL
at which the named resource is located,null
if the named resource could not be found. - Throws:
AnnotatorContextException
- if an error occurs- See Also:
AnnotatorContext.getResourceURL(java.lang.String, java.lang.String[])
-
getResourceURI
public java.net.URI getResourceURI(java.lang.String aKey, java.lang.String[] aParams) throws AnnotatorContextException
Description copied from interface:AnnotatorContext
Retrieves the URI to the named resource. This can be used, for example, to locate configuration or authority files. The resource should be declared in the <externalResourceDependencies> section of the descriptor.This method is safer than
AnnotatorContext.getResourceURL(String)
in its treatment of file paths containing spaces. This is because theURI.getPath()
does perform URL decoding of that path (decoding %20 sequences to spaces) whereasURL.getPath()
does not.For backwards compatibility, if the key is not declared as a resource dependency, it is looked up directly in the
data path
and the class path. However, this usage is deprecated and support may be dropped in future versions. ALL external resource dependencies should be declared in the descriptor.This version of this method takes an array of parameters used to further identify the resource. This can be used, for example, with resources that vary depending on the language of the document being analyzed, such as when the <fileLanguageResourceSpecifier> element is used in the component descriptor.
- Specified by:
getResourceURI
in interfaceAnnotatorContext
- Parameters:
aKey
- the key by which the resource is identified. This key should be declared in the <externalResourceDependencies> section of the descriptor.aParams
- the additional parameters to further identify the resource- Returns:
- the
URI
at which the named resource is located,null
if the named resource could not be found. - Throws:
AnnotatorContextException
- if an error occurs- See Also:
UimaContext.getResourceURI(String,String[])
-
getResourceFilePath
public java.lang.String getResourceFilePath(java.lang.String aKey, java.lang.String[] aParams) throws AnnotatorContextException
Description copied from interface:AnnotatorContext
Retrieves the absolute file path to the named resource. This can be used, for example, to locate configuration or authority files. The resource should be declared in the <externalResourceDependencies> section of the descriptor.This only works if the resource is a local file. If the resource is not a local file (for example, it could be an
http
URL, then an exception will be thrown.URL decoding will be done on the file path, so it is safe to use this method for file paths that contain spaces.
For backwards compatibility, if the key is not declared as a resource dependency, it is looked up directly in the
data path
and the class path. However, this usage is deprecated and support may be dropped in future versions. ALL external resource dependencies should be declared in the descriptor.This version of this method takes an array of parameters used to further identify the resource. This can be used, for example, with resources that vary depending on the language of the document being analyzed, such as when the <fileLanguageResourceSpecifier> element is used in the component descriptor.
- Specified by:
getResourceFilePath
in interfaceAnnotatorContext
- Parameters:
aKey
- the key by which the resource is identified. This key should be declared in the <externalResourceDependencies> section of the descriptor.aParams
- The parameters used to further specify the resource- Returns:
- the absolute file path at which the named resource is located,
null
if the named resource could not be found. - Throws:
AnnotatorContextException
- if an error occurs- See Also:
UimaContext.getResourceFilePath(String,String[])
-
getDataPath
public java.lang.String getDataPath()
Description copied from interface:AnnotatorContext
Gets the data path used to locate resources. This path may contain more than one directory, separated by the Systempath.separator
character (; on windows, : on UNIX).This method is intended to be used only for integration of legacy or third-party components that have their own resource management facility. If possible, it is recommended that you use the
getResoureXXX
methods instead.- Specified by:
getDataPath
in interfaceAnnotatorContext
- Returns:
- the data path
- See Also:
AnnotatorContext.getDataPath()
-
setProcessTrace
public void setProcessTrace(ProcessTrace aProcessTrace)
Sets the current ProcessTrace object, which will receive trace events generated by the InstrumentationFacility.This method is to be called from the Analysis Engine, not the Annotator, so it is not part of the AnnotatorContext interface.
- Parameters:
aProcessTrace
- -
-
mapToSofaID
@Deprecated public SofaID mapToSofaID(java.lang.String aSofaName)
Deprecated.Description copied from interface:AnnotatorContext
Retrieve actual sofa ID given a symbolic name- Specified by:
mapToSofaID
in interfaceAnnotatorContext
- Parameters:
aSofaName
- this component's name for a SofA- Returns:
- absolute SofA ID
-
getSofaMappings
@Deprecated public SofaID[] getSofaMappings()
Deprecated.- Specified by:
getSofaMappings
in interfaceAnnotatorContext
- Returns:
- array of SofaID objects containing mapping of component sofa name to absolute sofa id
-
-