public final class ResultSpecification_impl extends MetaDataObject_impl implements ResultSpecification
ResultSpecification
.
Notes on the implementation
Result Specifications (result specs, rs) are closely tied to capability specifications.
They consist of instances of
TypeOrFeatures and associated languages for which they are set.
This impl supports removing previously added types and features
for particular languages.
There are two forms of the data kept:
The data as it was provided to set the items in the result spec
This form is used when removing previously added things
The data after a type system has been provided, expanded to cover
the various implied settings, due to either
all Features flag on a type or
the type/subtype hierarchy in the type system
TypesOrFeatures are:
typeXXX:FeatureYYY - specifying a particular feature of a type
(Corner case: typeXXX:FeatureYYY doesn't imply there's a
typeXXX allFeat nor a
typeXXX w/o allFeat.
typeXXX with allFeatures - a shorthand for specifying
typeXXX and
typeXXX:FeatureYYY for all features YYY defined for typeXXX
(Corner case: excludes features ZZZ defined only in subtype of typeXXX)
typeXXX without allFeatures (w/o allFeat) - specifies a type, but says nothing about the features
This is specifiable in the XML. It means:
The type is produced/needed but there's no information about the features that
are to be produced or used
containsType typeXXX
returns true if typeXXX is in the RS, with or without the allFeats flag
returns false if only features involving typeXXX are specified
Intersection is done on fully expanded representations.
There are two kinds of inheritance used
Assuming there's a type system (which must be present when intersection is used), there's type/subtype
This means that if a resultSpec is set for typeXXX, then the containsType(typeYYY)
returns true if typeYYY is a subtype of typeXXX.
This also needs to work for typeXXX:featZZZ; containsFeature(typeYYY:featZZZ)
returns true if type YYY is a subtype of typeXXX.
Languages have a 3 level hierarchy:
x-unspecified - the same as no language being specified.
If the resultSpec contains typeXXX for language x-unspecified,
containsType(typeXXX, languageLLL) returns true, for any languageLLL
a "base" language, without a '-', e.g. "en"
a sub-language, with one or more '-', e.g., "en-us"
The rules for matching languages only handle these three levels of inheritance.
(Corner case: 3 or more level language hierarchy are treated as 3 level hierarchies
eg. zh-Hant-HK (Traditional Chinese as used in Hong Kong)
See http://www.w3.org/International/articles/language-tags/Overview.en.php )
Design considerations and assumptions
Many instances of this class are made, sometimes via cloning.
Most uses only use types, not type:features
Most don't use languages
A small subset of the possible types and type:features is specified explicitly
Sometimes types and/or features are deleted. (language capability flow deletes types and/or features)
Types and Features are kept on a per-language basis. Language can include a special value,
x-unspecified, which "matches" any other language.
Set operations among different result specs:
Union: done in aggregates over result-specs derived from input capabilities of delegates
Intersection: done for primitive components, over result-spec derived from output capability of the primitive
remove: one type or feature (used by language capability flow)
(Corner cases
removing typeXXX doesn't remove typeXXX:featureYYY
removing typeXXX allFeat doesn't remove typeXXX w/o allFeat (may have different languages)
removing typeXXX w/o allFeat doesn't remove typeXXX allFeat
The compiled version is used in containsType, containsFeature testing, and is used when
computing intersection.MetaDataObject_impl.MetaDataAttr, MetaDataObject_impl.SerialContext, MetaDataObject_impl.Serializer
Modifier and Type | Field and Description |
---|---|
static List<Type> |
EMPTY_TYPE_LIST
used for empty type subsumption lists in subtype iterator
|
serialContext
Constructor and Description |
---|
ResultSpecification_impl() |
ResultSpecification_impl(TypeSystem aTypeSystem)
Constructor specifying the type system
this should always be used in preference to the 0 argument version
if the type system is available.
|
Modifier and Type | Method and Description |
---|---|
void |
addCapabilities(Capability[] capabilities)
Adds the output types and features from the specified capabilities to this
ResultSpecification . |
void |
addCapabilities(Capability[] capabilities,
boolean outputs)
Adds either outputs or inputs from the specified capabilities to this
ResultSpecification . |
void |
addResultFeature(String aFullFeatureName)
Adds a Feature to this
ResultSpecification for the language x-unspecified. |
void |
addResultFeature(String aFullFeatureName,
String[] aLanguageIDs)
Adds a Feature to this
ResultSpecification for the specified languages. |
void |
addResultType(String aTypeName,
boolean aAllAnnotatorFeatures)
Adds an Type to this
ResultSpecification for the language x-unspecified. |
void |
addResultType(String aTypeName,
boolean aAllAnnotatorFeatures,
String[] aLanguageIDs)
Adds an Type to this
ResultSpecification for the specified languages. |
void |
addResultTypeOrFeature(TypeOrFeature aTypeOrFeature)
Adds a Result Type or Feature to this
ResultSpecification for the language
x-unspecified. |
void |
addResultTypeOrFeature(TypeOrFeature tof,
String[] languages)
Adds a Result Type or Feature to this
ResultSpecification for the specified
languages. |
Object |
clone()
returns a clone of the
ResultSpecification object. |
void |
compile(TypeSystem aTypeSystem)
Deprecated.
no longer needed, remove call to this
|
boolean |
containsFeature(String aFullFeatureName)
Determines whether this
ResultSpecification contains the specified Feature for
the language x-unspecified. |
boolean |
containsFeature(String aFullFeatureName,
String aLanguage)
Determines whether this
ResultSpecification contains the specified Feature for
the specified language. |
boolean |
containsType(String aTypeName)
Determines whether this
ResultSpecification contains the specified Type for the
language x-unspecified. |
boolean |
containsType(String aTypeName,
String aLanguage)
Determines whether this
ResultSpecification contains the specified Type for the
specified language. |
boolean |
equals(Object aObj)
Determines if this object is equal to another.
|
TypeOrFeature[] |
getResultTypesAndFeatures()
Retrieves the Types and Features that the AnalysisEngine or Annotator is requested to produce,
for all languages.
|
TypeOrFeature[] |
getResultTypesAndFeatures(String language)
Retrieves the Types and Features that the AnalysisEngine or Annotator is requested to produce
for the specified language.
|
TypeSystem |
getTypeSystem()
get the type system associated with this result specification.
|
protected XmlizationInfo |
getXmlizationInfo()
To be implemented by subclasses to return information describing how to represent this object
in XML.
|
int |
hashCode()
Gets the hash code for this object.
|
void |
removeTypeOrFeature(TypeOrFeature tof)
removes the specified TypeOrFeature from this
ResultSpecification . |
void |
setResultTypesAndFeatures(TypeOrFeature[] aTypesAndFeatures)
Sets the Types and Features that the AnalysisEngine or Annotator is requested to produce for
the language x-unspecified, and removes all other type or feature information, that may be
previously present (e.g., for other languages)
|
void |
setResultTypesAndFeatures(TypeOrFeature[] aTypesAndFeatures,
String[] aLanguageIDs)
Sets the Types and Features that the AnalysisEngine or Annotator is requested to produce for
the specified languages, and removes all other type or feature information, that may be
previously present (e.g., for other languages).
|
void |
setTypeSystem(TypeSystem ts)
set the type system associated with this result specification.
|
String |
toString()
Dump this metadata object's attributes and values to a String.
|
buildFromXMLElement, buildFromXMLElement, getAdditionalAttributes, getAttributeClass, getAttributeValue, getInfoset, getMatchingNode, getPropertyDescriptors, getPropertyXmlInfo, getRelativePathBase, getSerialContext, getSourceUrl, getSourceUrlString, getWrapperClass, getXMLAttributes, isModifiable, listAttributes, readArrayPropertyValueFromXMLElement, readMapPropertyFromXml, readPropertyValueFromXMLElement, readUnknownPropertyValueFromXMLElement, resolveSettings, setAttributeValue, setInfoset, setSourceUrl, setSourceUrlIfNull, toXML, toXML, toXML, toXML, valueIsNullOrEmptyArray, writeArrayPropertyAsElement, writeMapPropertyToXml, writePropertyAsElement
finalize, getClass, notify, notifyAll, wait, wait, wait
buildFromXMLElement, buildFromXMLElement, toXML, toXML, toXML, toXML
public ResultSpecification_impl()
public ResultSpecification_impl(TypeSystem aTypeSystem)
aTypeSystem
- -public TypeOrFeature[] getResultTypesAndFeatures()
ResultSpecification
The set of types and features returned are just the ones that have been explicitly set or added to the ResultSpecification, and doesn't include any derived subtypes, even if this ResultSpecification has been compiled.
getResultTypesAndFeatures
in interface ResultSpecification
TypeOrFeature
objects that define the result types and features for
all languages.ResultSpecification.getResultTypesAndFeatures()
public TypeOrFeature[] getResultTypesAndFeatures(String language)
ResultSpecification
The set of types and features returned are just the ones that have been explicitly set or added to the ResultSpecification, and doesn't include any derived subtypes, even if this ResultSpecification has been compiled.
getResultTypesAndFeatures
in interface ResultSpecification
language
- the language specifierTypeOrFeature
objects that define the result types and features for
the specified language.May contain near-duplicates - same type, but with different settings of allannotatorfeatures
(only if they have different languages)
public void setResultTypesAndFeatures(TypeOrFeature[] aTypesAndFeatures)
ResultSpecification
setResultTypesAndFeatures
in interface ResultSpecification
aTypesAndFeatures
- an array of TypeOrFeature
objects that define the result types and features
for the language x-unspecified.ResultSpecification.setResultTypesAndFeatures(org.apache.uima.analysis_engine.TypeOrFeature[])
public void setResultTypesAndFeatures(TypeOrFeature[] aTypesAndFeatures, String[] aLanguageIDs)
ResultSpecification
setResultTypesAndFeatures
in interface ResultSpecification
aTypesAndFeatures
- an array of TypeOrFeature
objects that define the result types and features
for the specified languages.aLanguageIDs
- an array of ISO language identifiers.ResultSpecification.setResultTypesAndFeatures(org.apache.uima.analysis_engine.TypeOrFeature[],
java.lang.String[])
public void addResultTypeOrFeature(TypeOrFeature aTypeOrFeature)
ResultSpecification
ResultSpecification
for the language
x-unspecified. If there is already a same-named TypeOrFeature object contained in the
result spec, its language specification for this ToF will be replaced with x-unspecified,
and its allAnnotatorFeatures flag will be replaced with the parameter's.addResultTypeOrFeature
in interface ResultSpecification
aTypeOrFeature
- the Type or Feature to add for the language x-unspecifiedResultSpecification.addResultTypeOrFeature(org.apache.uima.analysis_engine.TypeOrFeature)
public void addResultTypeOrFeature(TypeOrFeature tof, String[] languages)
ResultSpecification
ResultSpecification
for the specified
languages. If there is already a same-named TypeOrFeature object contained in the
result spec, the language
specification for this ToF will be replaced with the specified languages,
and its allAnnotatorFeatures flag will be replaced with the parameter's. If null is passed in for
the aLanguageIDs, this is treated as if one language, x-unspecified, was given.addResultTypeOrFeature
in interface ResultSpecification
tof
- the Type or Feature to add for the specified languageslanguages
- an array of ISO language identifiers.Note: Javadoc makes assumption that there's one tof per type, but this design allows 2 (one with allAnnotatorFeatures set or not).
public void addResultType(String aTypeName, boolean aAllAnnotatorFeatures)
ResultSpecification
ResultSpecification
for the language x-unspecified.
If the current Type is already contained in the result spec, the language specification for
this Type will be replaced with x-unspecified,
and its allAnnotatorFeatures flag will be replaced with the parameter's.addResultType
in interface ResultSpecification
aTypeName
- the name of the Type to add for the language x-unspecifiedaAllAnnotatorFeatures
- whether all features of this type should also be producedResultSpecification.addResultType(java.lang.String,
boolean)
public void addResultType(String aTypeName, boolean aAllAnnotatorFeatures, String[] aLanguageIDs)
ResultSpecification
ResultSpecification
for the specified languages.
If the given Type is already contained in the result spec, the languages specified will be
added to those already associated with the Type in this ResultSpec.
The given type's allAnnotatorFeatures is logically "or"ed with any existing value.
If null is passed in for
the aLanguageIDs, this is treated as if one language, x-unspecified, was given.addResultType
in interface ResultSpecification
aTypeName
- the name of the Type to add for the specified languagesaAllAnnotatorFeatures
- whether all features of this type should also be producedaLanguageIDs
- an array of ISO language identifiers.ResultSpecification.addResultType(java.lang.String,
boolean, java.lang.String[])
public void addResultFeature(String aFullFeatureName)
ResultSpecification
ResultSpecification
for the language x-unspecified.
If the given Type is already contained in the result spec, the languages associated with that type will be
replaced by x-unspecified.addResultFeature
in interface ResultSpecification
aFullFeatureName
- the fully-qualified name of the Feature to add for the language x-unspecifiedResultSpecification.addResultFeature(java.lang.String)
public void addResultFeature(String aFullFeatureName, String[] aLanguageIDs)
ResultSpecification
ResultSpecification
for the specified languages.
If the current Feature is already contained in the result spec, the language specification for
this Feature will be augmented (added to) with the specified languages.
If null is passed in for
the aLanguageIDs, this is treated as if one language, x-unspecified, was given.addResultFeature
in interface ResultSpecification
aFullFeatureName
- the fully-qualified name of the Feature to add for the specified languagesaLanguageIDs
- an array of ISO language identifiers.ResultSpecification.addResultFeature(java.lang.String,
java.lang.String[])
@Deprecated public void compile(TypeSystem aTypeSystem)
ResultSpecification
ResultSpecification
using a specific TypeSystem
. The
result is cached and used by the ResultSpecification.containsType(String)
and ResultSpecification.containsFeature(String)
methods to
properly consider the inheritance of types and to restrict allAnnotatorFeatures
to just those features defined in the type system when this
ResultSpecification
contains Types with allAnnotatorFeatures
set
to true.
This method is called automatically internally when needed. Framework code, Annotators and Applications do not need to call it.
compile
in interface ResultSpecification
aTypeSystem
- the Type System used to determine which features belong to each TypeResultSpecification.compile(org.apache.uima.cas.TypeSystem)
public boolean containsType(String aTypeName)
ResultSpecification
ResultSpecification
contains the specified Type for the
language x-unspecified. If a type system is available to the result specification,
a type will be considered to be contained in the result spec, also, if it
is a subtype of the types originally specified to be in the result specification.containsType
in interface ResultSpecification
aTypeName
- the name of the typeResultSpecification
contains the type with name
aTypeName
.ResultSpecification.containsType(java.lang.String)
public boolean containsType(String aTypeName, String aLanguage)
ResultSpecification
ResultSpecification
contains the specified Type for the
specified language. A type is considered to be contained in the result spec, also, if it
is a subtype of the types originally specified to be in the result specification for this language.containsType
in interface ResultSpecification
aTypeName
- the name of the typeaLanguage
- the language to search for.
A null value or the value x-unspecified for this argument only
matches ResultSpecifications having x-unspecified as their type.
A language value that is contained within a language in the ResultSpecification
is considered to match. In particular:
Language ResultSpecification Result
x-unspecified x-unspecified match
x-unspecified en no match
en x-unspecified match
en en-us no match
en-us en matchResultSpecification
contains the type with name
aTypeName
for a matching language.method:
for each type (with all-feat, without all-feat):
for each type, and supertypes
check if one of the resultSpec languages subsumes the given language.
if so, return true
return false;
But: cache this: key = int[2]: type#, langi#, value = true/false
public boolean containsFeature(String aFullFeatureName)
ResultSpecification
ResultSpecification
contains the specified Feature for
the language x-unspecified. Feature names are fully qualified, consisting of the
type name plus the feature-of-that-type name. A feature ttt:fff is contained in the result spec if
that fff is specified for type ttt or any supertype of ttt in the result spec.
A feature can be specified in the result spec explicitly or by specifying a type or supertype
of the feature's type having the allAnnotatorFeatures flag set.containsFeature
in interface ResultSpecification
aFullFeatureName
- the fully-qualified name of the feature, in the form MyTypeName:MyFeatureName.ResultSpecification
contains the feature with
name aFullFeatureName
.ResultSpecification.containsFeature(java.lang.String)
public boolean containsFeature(String aFullFeatureName, String aLanguage)
ResultSpecification
ResultSpecification
contains the specified Feature for
the specified language. Feature names are fully qualified, consisting of the
type name plus the feature-of-that-type name. A feature ttt:fff is contained in the result spec if
that fff is specified for type ttt or any supertype of ttt in the result spec.
A feature can be specified in the result spec explicitly or by specifying a type or supertype
of the feature's type having the allAnnotatorFeatures flag set.containsFeature
in interface ResultSpecification
aFullFeatureName
- the fully-qualified name of the feature, in the form MyTypeName:MyFeatureName.aLanguage
- the language to search for.
A null value or the value x-unspecified for this argument only
matches ResultSpecifications having x-unspecified as their type.
A language value that is contained within a language in the ResultSpecification
is considered to match. In particular:
Language ResultSpecification Result
x-unspecified x-unspecified match
x-unspecified en no match
en x-unspecified match
en en-us no match
en-us en matchResultSpecification
contains the feature with
name aFullFeatureName
for a matching language.ResultSpecification.containsFeature(java.lang.String,java.lang.String)
protected XmlizationInfo getXmlizationInfo()
MetaDataObject_impl
getXmlizationInfo
in class MetaDataObject_impl
MetaDataObject_impl.getXmlizationInfo()
public void addCapabilities(Capability[] capabilities)
ResultSpecification
ResultSpecification
.
If a Type being added is already contained in the ResultSpecification, the languages from the Capabilities entry for this type will be added to those already associated with the Type in this ResultSpec. The given capability instance's allAnnotatorFeatures is logically "or"ed with any existing value.
addCapabilities
in interface ResultSpecification
capabilities
- capabilities to addResultSpecification.addCapabilities(org.apache.uima.resource.metadata.Capability[])
public void addCapabilities(Capability[] capabilities, boolean outputs)
ResultSpecification
ResultSpecification
.
If a Type being added is already contained in the ResultSpecification, the languages from the Capabilities entry for this type will be added to those already associated with the Type in this ResultSpec. The given capability instance's allAnnotatorFeatures is logically "or"ed with any existing value.
addCapabilities
in interface ResultSpecification
capabilities
- capabilities to addoutputs
- true to add the output types/features to this ResultSpecification, false to add the
input types/features to this ResultSpecification.ResultSpecification.addCapabilities(org.apache.uima.resource.metadata.Capability[],
boolean)
public void removeTypeOrFeature(TypeOrFeature tof)
ResultSpecification
ResultSpecification
.removeTypeOrFeature
in interface ResultSpecification
tof
- the Type or Feature to removeThis removes the type or feature for all languages.
Beware: there are two possible ToFs one with allFeatures set or not (if they have different languages).
public Object clone()
ResultSpecification
object.clone
in interface ResultSpecification
clone
in interface MetaDataObject
clone
in class MetaDataObject_impl
multi-core: could be cloning while another thread is modifying?
public void setTypeSystem(TypeSystem ts)
ResultSpecification
setTypeSystem
in interface ResultSpecification
ts
- the CAS Type Systempublic TypeSystem getTypeSystem()
ResultSpecification
getTypeSystem
in interface ResultSpecification
public String toString()
MetaDataObject_impl
toString
in class MetaDataObject_impl
public boolean equals(Object aObj)
MetaDataObject_impl
equals
in interface MetaDataObject
equals
in class MetaDataObject_impl
aObj
- object with which to compare this objectaObj
public int hashCode()
MetaDataObject_impl
x
and
y
must be equal if x.equals(y)
returns true;hashCode
in class MetaDataObject_impl
Copyright © 2006–2021 The Apache Software Foundation. All rights reserved.