public class AnnotatorContext_impl extends Object implements AnnotatorContext
AnnotatorContext
.Constructor and Description |
---|
AnnotatorContext_impl(UimaContextAdmin aUimaContext)
Creates a new AnnotatorContext_impl.
|
Modifier and Type | Method and Description |
---|---|
String[] |
getConfigParameterNames()
Gets the names of all configuration parameters that are not declared in a group.
|
String[] |
getConfigParameterNames(String aGroup)
Gets the names of all configuration parameters in the specified group.
|
Object |
getConfigParameterValue(String aName)
Retrieves the value for a configuration parameter that is not defined in any group or is
defined in the default group.
|
Object |
getConfigParameterValue(String aGroupName,
String aParamName)
Retrieves the value for a configuration parameter in a particular group.
|
String[] |
getConfigurationGroupNames()
Gets the names of all configuration parameter groups.
|
String |
getDataPath()
Gets the data path used to locate resources.
|
InstrumentationFacility |
getInstrumentationFacility()
Gets the InstrumentationFacility to be used within this AnalysisEngine.
|
Logger |
getLogger()
Gets the
Logger to which this annotator should send its log output. |
InputStream |
getResourceAsStream(String aKey)
Acquires Resource InputStreams using the ResourceManager, or, if that fails, the ClassLoader.
|
InputStream |
getResourceAsStream(String aKey,
String[] aParams)
Retrieves an InputStream for reading from the named resource.
|
String |
getResourceFilePath(String aKey)
Retrieves the absolute file path to the named resource.
|
String |
getResourceFilePath(String aKey,
String[] aParams)
Retrieves the absolute file path to the named resource.
|
Object |
getResourceObject(String aKey)
Acquires a Resource object using the ResourceManager.
|
Object |
getResourceObject(String aKey,
String[] aParams)
Retrieves the named resource object.
|
URI |
getResourceURI(String aKey)
Retrieves the URI to the named resource.
|
URI |
getResourceURI(String aKey,
String[] aParams)
Retrieves the URI to the named resource.
|
URL |
getResourceURL(String aKey)
Locates Resource URL's using the ResourceManager, or, if that fails, the ClassLoader.
|
URL |
getResourceURL(String aKey,
String[] aParams)
Retrieves the URL to the named resource.
|
SofaID[] |
getSofaMappings()
Deprecated.
|
SofaID |
mapToSofaID(String aSofaName)
Deprecated.
|
void |
setProcessTrace(ProcessTrace aProcessTrace)
Sets the current ProcessTrace object, which will receive trace events generated by the
InstrumentationFacility.
|
public AnnotatorContext_impl(UimaContextAdmin aUimaContext)
aUimaContext
- the UIMA Context that this AnnotatorContext wraps.public Object getConfigParameterValue(String aName)
AnnotatorContext
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 returns null
if there is no declared
configuration parameter with the specified name.
getConfigParameterValue
in interface AnnotatorContext
aName
- the name of the parameter to look upnull
if the parameter does not
exist or has not been assigned a value.AnnotatorContext.getConfigParameterValue(String)
public Object getConfigParameterValue(String aGroupName, String aParamName)
AnnotatorContext
ConfigurationParameterDeclarations.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 returns null
if there is no declared
configuration parameter with the specified name.
getConfigParameterValue
in interface AnnotatorContext
aGroupName
- the name of the group containing the parameteraParamName
- the name of the parameter to look upnull
if the parameter does not
exist or has not been assigned a value.AnnotatorContext.getConfigParameterValue(java.lang.String,
java.lang.String)
public Logger getLogger()
AnnotatorContext
Logger
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).getLogger
in interface AnnotatorContext
AnnotatorContext.getLogger()
public InstrumentationFacility getInstrumentationFacility()
getInstrumentationFacility
in interface AnnotatorContext
public String[] getConfigurationGroupNames()
AnnotatorContext
getConfigurationGroupNames
in interface AnnotatorContext
public String[] getConfigParameterNames()
AnnotatorContext
getConfigParameterNames
in interface AnnotatorContext
public String[] getConfigParameterNames(String aGroup)
AnnotatorContext
getConfigParameterNames
in interface AnnotatorContext
aGroup
- the group nameaGroup
.
Note that this does include parameters with null values. Returns an empty array if
there are none (including if the group does not exist).public URL getResourceURL(String aKey) throws AnnotatorContextException
getResourceURL
in interface AnnotatorContext
aKey
- the key by which the resource is identified. This key should be declared in the
<externalResourceDependencies> section of the descriptor.URL
at which the named resource is located, null
if
the named resource could not be found.AnnotatorContextException
- if there's a problemAnnotatorContext.getResourceURL(String)
public URI getResourceURI(String aKey) throws AnnotatorContextException
AnnotatorContext
This method is safer than AnnotatorContext.getResourceURL(String)
in its treatment of file paths
containing spaces. This is because the URI.getPath()
does perform URL decoding of that
path (decoding %20 sequences to spaces) whereas URL.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.
getResourceURI
in interface AnnotatorContext
aKey
- the key by which the resource is identified. This key should be declared in the
<externalResourceDependencies> section of the descriptor.URI
at which the named resource is located, null
if
the named resource could not be found.AnnotatorContextException
- if there's an exceptionUimaContext.getResourceURI(String)
public String getResourceFilePath(String aKey) throws AnnotatorContextException
AnnotatorContext
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.
getResourceFilePath
in interface AnnotatorContext
aKey
- the key by which the resource is identified. This key should be declared in the
<externalResourceDependencies> section of the descriptor.null
if
the named resource could not be found.AnnotatorContextException
- if there's an exceptionUimaContext.getResourceFilePath(String)
public InputStream getResourceAsStream(String aKey) throws AnnotatorContextException
getResourceAsStream
in interface AnnotatorContext
aKey
- the key by which the resource is identified. This key should be declared in the
<externalResourceDependencies> section of the descriptor.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.AnnotatorContextException
- if an error occursAnnotatorContext.getResourceAsStream(String)
public Object getResourceObject(String aKey) throws AnnotatorContextException
getResourceObject
in interface AnnotatorContext
aKey
- the key by which the resource is identified. This key should be declared in the
<externalResourceDependencies> section of the descriptor.aName
, null
if none.AnnotatorContextException
- if an error occursAnnotatorContext.getResourceObject(String)
public InputStream getResourceAsStream(String aKey, String[] aParams) throws AnnotatorContextException
AnnotatorContext
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.
getResourceAsStream
in interface AnnotatorContext
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").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.AnnotatorContextException
- if an error occursAnnotatorContext.getResourceAsStream(java.lang.String,
java.lang.String[])
public Object getResourceObject(String aKey, String[] aParams) throws AnnotatorContextException
AnnotatorContext
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.
getResourceObject
in interface AnnotatorContext
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").aName
, null
if none.AnnotatorContextException
- if an error occursAnnotatorContext.getResourceObject(java.lang.String,
java.lang.String[])
public URL getResourceURL(String aKey, String[] aParams) throws AnnotatorContextException
AnnotatorContext
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 call
getResourceURL().getPath()
and attempt to use the result as a file path.
Instead, you may use AnnotatorContext.getResourceURI(String)
or AnnotatorContext.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.
getResourceURL
in interface AnnotatorContext
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").URL
at which the named resource is located, null
if
the named resource could not be found.AnnotatorContextException
- if an error occursAnnotatorContext.getResourceURL(java.lang.String,
java.lang.String[])
public URI getResourceURI(String aKey, String[] aParams) throws AnnotatorContextException
AnnotatorContext
This method is safer than AnnotatorContext.getResourceURL(String)
in its treatment of file paths
containing spaces. This is because the URI.getPath()
does perform URL decoding of that
path (decoding %20 sequences to spaces) whereas URL.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.
getResourceURI
in interface AnnotatorContext
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 resourceURI
at which the named resource is located, null
if
the named resource could not be found.AnnotatorContextException
- if an error occursUimaContext.getResourceURI(String,String[])
public String getResourceFilePath(String aKey, String[] aParams) throws AnnotatorContextException
AnnotatorContext
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.
getResourceFilePath
in interface AnnotatorContext
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 resourcenull
if
the named resource could not be found.AnnotatorContextException
- if an error occursUimaContext.getResourceFilePath(String,String[])
public String getDataPath()
AnnotatorContext
path.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.
getDataPath
in interface AnnotatorContext
AnnotatorContext.getDataPath()
public void setProcessTrace(ProcessTrace aProcessTrace)
This method is to be called from the Analysis Engine, not the Annotator, so it is not part of the AnnotatorContext interface.
aProcessTrace
- -@Deprecated public SofaID mapToSofaID(String aSofaName)
AnnotatorContext.mapToSofaID(java.lang.String)
AnnotatorContext
mapToSofaID
in interface AnnotatorContext
aSofaName
- this component's name for a SofA@Deprecated public SofaID[] getSofaMappings()
AnnotatorContext.getSofaMappings()
getSofaMappings
in interface AnnotatorContext
Copyright © 2006–2021 The Apache Software Foundation. All rights reserved.