org.apache.uima.analysis_engine.impl
Class ResultSpecification_impl

java.lang.Object
  extended by org.apache.uima.resource.metadata.impl.MetaDataObject_impl
      extended by org.apache.uima.analysis_engine.impl.ResultSpecification_impl
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ResultSpecification, MetaDataObject, XMLizable

public final class ResultSpecification_impl
extends MetaDataObject_impl
implements ResultSpecification

Reference implementaion of ResultSpecification. Notes on the implementation There are two ways this data is used: with and without "compiling" Compiling means: adding subtypes of types and adding all features of a type Uncompiled form is called ORIGINAL. Compiling is deferred - until the first reference to containsType or Feature. Many instances of this class are made, sometimes via cloning. Sometimes types and features are deleted - the intent is to do this operation on the uncompiled form, and then "recompile" it. Types and Features are kept on a per-language basis. Language can include a special value, x-unspecified, which "matches" any other language. Language specifications are simplified to eliminate the country part. All refs to test if a type or feature is in the result spec for a language uses the simplified language. Set operations are done to combine, for a particular type or feature, the languages for which it is valid. This is a Union operation Set operations are done to union the input types/features with the output types/features when computing the default result-spec for an aggregate. Set operations are done to intersect the result spec with the output capabilities of a component. Languages are represented as integers; there is a hash table from the string to the integer, and an array to go from integer to lang string. A result set of ORIGINALs consists of types/features with associated language sets.

See Also:
Serialized Form

Constructor Summary
ResultSpecification_impl()
          constructor: init the default languge set with the language x-unspecified
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.
 
Method Summary
 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(java.lang.String aFullFeatureName)
          Adds a Feature to this ResultSpecification for the language x-unspecified.
 void addResultFeature(java.lang.String aFullFeatureName, java.lang.String[] aLanguageIDs)
          Adds a Feature to this ResultSpecification for the specified languages.
 void addResultType(java.lang.String aTypeName, boolean aAllAnnotatorFeatures)
          Adds an Type to this ResultSpecification for the language x-unspecified.
 void addResultType(java.lang.String aTypeName, boolean aAllAnnotatorFeatures, java.lang.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 aTypeOrFeature, java.lang.String[] aLanguageIDs)
          Adds a Result Type or Feature to this ResultSpecification for the specified languages.
 java.lang.Object clone()
          returns a clone of the ResultSpecification object.
 void compile(TypeSystem aTypeSystem)
          Compiles this ResultSpecification using a specific TypeSystem.
 boolean containsFeature(java.lang.String aFullFeatureName)
          Determines whether this ResultSpecification contains the specified Feature for the language x-unspecified.
 boolean containsFeature(java.lang.String aFullFeatureName, java.lang.String language)
          Determines whether this ResultSpecification contains the specified Feature for the specified language.
 boolean containsType(java.lang.String aTypeName)
          Determines whether this ResultSpecification contains the specified Type for the language x-unspecified.
 boolean containsType(java.lang.String aTypeName, java.lang.String language)
          Determines whether this ResultSpecification contains the specified Type for the specified language.
 TypeOrFeature[] getResultTypesAndFeatures()
          Retrieves the Types and Features that the AnalysisEngine or Annotator is requested to produce for the default language x-unspecified (that is, regardless any language specification).
 TypeOrFeature[] getResultTypesAndFeatures(java.lang.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.
 void removeTypeOrFeature(TypeOrFeature aTypeOrFeature)
          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, java.lang.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.
 java.lang.String toString()
          Dump this metadata object's attributes and values to a String.
 
Methods inherited from class org.apache.uima.resource.metadata.impl.MetaDataObject_impl
buildFromXMLElement, buildFromXMLElement, equals, getAttributeClass, getAttributeValue, getPropertyDescriptors, getPropertyXmlInfo, getRelativePathBase, getSourceUrl, getSourceUrlString, getWrapperClass, getXMLAttributes, hashCode, isModifiable, listAttributes, readArrayPropertyValueFromXMLElement, readMapPropertyFromXml, readPropertyValueFromXMLElement, readUnknownPropertyValueFromXMLElement, setAttributeValue, setSourceUrl, setSourceUrlIfNull, toXML, toXML, toXML, toXML, writeArrayPropertyAsElement, writeMapPropertyToXml, writePropertyAsElement
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.uima.util.XMLizable
buildFromXMLElement, buildFromXMLElement, toXML, toXML, toXML, toXML
 

Constructor Detail

ResultSpecification_impl

public ResultSpecification_impl()
constructor: init the default languge set with the language x-unspecified


ResultSpecification_impl

public 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. Otherwise, the type system *must* be set via a method call prior to querying the result spec, with the one exception of the method getResultTypesAndFeaturesWithoutCompiling

Parameters:
aTypeSystem -
Method Detail

getResultTypesAndFeatures

public TypeOrFeature[] getResultTypesAndFeatures()
Description copied from interface: ResultSpecification
Retrieves the Types and Features that the AnalysisEngine or Annotator is requested to produce for the default language x-unspecified (that is, regardless any language specification).

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.

Specified by:
getResultTypesAndFeatures in interface ResultSpecification
Returns:
an array of TypeOrFeature objects that define the result types and features for the language x-unspecified.
See Also:
ResultSpecification.getResultTypesAndFeatures()

getResultTypesAndFeatures

public TypeOrFeature[] getResultTypesAndFeatures(java.lang.String language)
Description copied from interface: ResultSpecification
Retrieves the Types and Features that the AnalysisEngine or Annotator is requested to produce for the specified language. See the class comment for how languages are compared.

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.

Specified by:
getResultTypesAndFeatures in interface ResultSpecification
Returns:
an array of TypeOrFeature objects that define the result types and features for the specified language.
See Also:
ResultSpecification.getResultTypesAndFeatures(java.lang.String)

setResultTypesAndFeatures

public void setResultTypesAndFeatures(TypeOrFeature[] aTypesAndFeatures)
Description copied from interface: ResultSpecification
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)

Specified by:
setResultTypesAndFeatures in interface ResultSpecification
Parameters:
aTypesAndFeatures - an array of TypeOrFeature objects that define the result types and features for the language x-unspecified.
See Also:
ResultSpecification.setResultTypesAndFeatures(org.apache.uima.analysis_engine.TypeOrFeature[])

setResultTypesAndFeatures

public void setResultTypesAndFeatures(TypeOrFeature[] aTypesAndFeatures,
                                      java.lang.String[] aLanguageIDs)
Description copied from interface: ResultSpecification
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).

Specified by:
setResultTypesAndFeatures in interface ResultSpecification
Parameters:
aTypesAndFeatures - an array of TypeOrFeature objects that define the result types and features for the specified languages.
aLanguageIDs - an array of ISO language identifiers.
See Also:
ResultSpecification.setResultTypesAndFeatures(org.apache.uima.analysis_engine.TypeOrFeature[], java.lang.String[])

addResultTypeOrFeature

public void addResultTypeOrFeature(TypeOrFeature aTypeOrFeature)
Description copied from interface: ResultSpecification
Adds a Result Type or Feature to this 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.

Specified by:
addResultTypeOrFeature in interface ResultSpecification
Parameters:
aTypeOrFeature - the Type or Feature to add for the language x-unspecified
See Also:
ResultSpecification.addResultTypeOrFeature(org.apache.uima.analysis_engine.TypeOrFeature)

addResultTypeOrFeature

public void addResultTypeOrFeature(TypeOrFeature aTypeOrFeature,
                                   java.lang.String[] aLanguageIDs)
Description copied from interface: ResultSpecification
Adds a Result Type or Feature to this 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.

Specified by:
addResultTypeOrFeature in interface ResultSpecification
Parameters:
aTypeOrFeature - the Type or Feature to add for the specified languages
aLanguageIDs - an array of ISO language identifiers.
See Also:
ResultSpecification.addResultTypeOrFeature(org.apache.uima.analysis_engine.TypeOrFeature, java.lang.String[])

addResultType

public void addResultType(java.lang.String aTypeName,
                          boolean aAllAnnotatorFeatures)
Description copied from interface: ResultSpecification
Adds an Type to this 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.

Specified by:
addResultType in interface ResultSpecification
Parameters:
aTypeName - the name of the Type to add for the language x-unspecified
aAllAnnotatorFeatures - whether all features of this type should also be produced
See Also:
ResultSpecification.addResultType(java.lang.String, boolean)

addResultType

public void addResultType(java.lang.String aTypeName,
                          boolean aAllAnnotatorFeatures,
                          java.lang.String[] aLanguageIDs)
Description copied from interface: ResultSpecification
Adds an Type to this 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.

Specified by:
addResultType in interface ResultSpecification
Parameters:
aTypeName - the name of the Type to add for the specified languages
aAllAnnotatorFeatures - whether all features of this type should also be produced
aLanguageIDs - an array of ISO language identifiers.
See Also:
ResultSpecification.addResultType(java.lang.String, boolean, java.lang.String[])

addResultFeature

public void addResultFeature(java.lang.String aFullFeatureName)
Description copied from interface: ResultSpecification
Adds a Feature to this 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.

Specified by:
addResultFeature in interface ResultSpecification
Parameters:
aFullFeatureName - the fully-qualified name of the Feature to add for the language x-unspecified
See Also:
ResultSpecification.addResultFeature(java.lang.String)

addResultFeature

public void addResultFeature(java.lang.String aFullFeatureName,
                             java.lang.String[] aLanguageIDs)
Description copied from interface: ResultSpecification
Adds a Feature to this 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.

Specified by:
addResultFeature in interface ResultSpecification
Parameters:
aFullFeatureName - the fully-qualified name of the Feature to add for the specified languages
aLanguageIDs - an array of ISO language identifiers.
See Also:
ResultSpecification.addResultFeature(java.lang.String, java.lang.String[])

compile

public void compile(TypeSystem aTypeSystem)
Description copied from interface: ResultSpecification
Compiles this 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.

Specified by:
compile in interface ResultSpecification
Parameters:
aTypeSystem - the Type System used to determine which features belong to each Type
See Also:
ResultSpecification.compile(org.apache.uima.cas.TypeSystem)

containsType

public boolean containsType(java.lang.String aTypeName)
Description copied from interface: ResultSpecification
Determines whether this 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.

Specified by:
containsType in interface ResultSpecification
Parameters:
aTypeName - the name of the type
Returns:
true if and only if this ResultSpecification contains the type with name aTypeName.
See Also:
ResultSpecification.containsType(java.lang.String)

containsType

public boolean containsType(java.lang.String aTypeName,
                            java.lang.String language)
Description copied from interface: ResultSpecification
Determines whether this 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.

Specified by:
containsType in interface ResultSpecification
Parameters:
aTypeName - the name of the type
language - the language to search for. A null value or the value x-unspecified for this argument disables the language test - any language will match. The language is matched after excluding any country code, if present.
Returns:
true if and only if this ResultSpecification contains the type with name aTypeName for the specified language.
See Also:
ResultSpecification.containsType(java.lang.String,java.lang.String)

containsFeature

public boolean containsFeature(java.lang.String aFullFeatureName)
Description copied from interface: ResultSpecification
Determines whether this 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.

Specified by:
containsFeature in interface ResultSpecification
Parameters:
aFullFeatureName - the fully-qualified name of the feature, in the form MyTypeName:MyFeatureName.
Returns:
true if and only if this ResultSpecification contains the feature with name aFullFeatureName.
See Also:
ResultSpecification.containsFeature(java.lang.String)

containsFeature

public boolean containsFeature(java.lang.String aFullFeatureName,
                               java.lang.String language)
Description copied from interface: ResultSpecification
Determines whether this 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.

Specified by:
containsFeature in interface ResultSpecification
Parameters:
aFullFeatureName - the fully-qualified name of the feature, in the form MyTypeName:MyFeatureName.
language - the language to search for. A null value or the value x-unspecified for this argument disables the language test - any language will match. A value with a country code in addition to a language will match a result-spec without the country code.
Returns:
true if and only if this ResultSpecification contains the feature with name aFullFeatureName for the specified language.
See Also:
ResultSpecification.containsFeature(java.lang.String,java.lang.String)

getXmlizationInfo

protected XmlizationInfo getXmlizationInfo()
Description copied from class: MetaDataObject_impl
To be implemented by subclasses to return information describing how to represent this object in XML.

Specified by:
getXmlizationInfo in class MetaDataObject_impl
Returns:
information defining this object's XML representation
See Also:
org.apache.uima.resource.impl.MetaDataObject_impl#getXmlizationInfo()

addCapabilities

public void addCapabilities(Capability[] capabilities)
Description copied from interface: ResultSpecification
Adds the output types and features from the specified capabilities to this 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.

Specified by:
addCapabilities in interface ResultSpecification
Parameters:
capabilities - capabilities to add
See Also:
ResultSpecification.addCapabilities(org.apache.uima.resource.metadata.Capability[])

addCapabilities

public void addCapabilities(Capability[] capabilities,
                            boolean outputs)
Description copied from interface: ResultSpecification
Adds either outputs or inputs from the specified capabilities to this 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.

Specified by:
addCapabilities in interface ResultSpecification
Parameters:
capabilities - capabilities to add
outputs - true to add the output types/features to this ResultSpecification, false to add the input types/features to this ResultSpecification.
See Also:
ResultSpecification.addCapabilities(org.apache.uima.resource.metadata.Capability[], boolean)

removeTypeOrFeature

public void removeTypeOrFeature(TypeOrFeature aTypeOrFeature)
Description copied from interface: ResultSpecification
removes the specified TypeOrFeature from this ResultSpecification.

Specified by:
removeTypeOrFeature in interface ResultSpecification
Parameters:
aTypeOrFeature - the Type or Feature to remove
See Also:
ResultSpecification.removeTypeOrFeature(org.apache.uima.analysis_engine.TypeOrFeature)

clone

public java.lang.Object clone()
returns a clone of the ResultSpecification object.

Specified by:
clone in interface ResultSpecification
Specified by:
clone in interface MetaDataObject
Overrides:
clone in class MetaDataObject_impl
Returns:
Object copy of the current object
See Also:
org.apache.uima.resource.MetaDataObject#clone()

setTypeSystem

public void setTypeSystem(TypeSystem ts)
Description copied from interface: ResultSpecification
set the type system associated with this result specification. It is used to augment any types with their subtypes

Specified by:
setTypeSystem in interface ResultSpecification
Parameters:
ts - the CAS Type System

getTypeSystem

public TypeSystem getTypeSystem()
Description copied from interface: ResultSpecification
get the type system associated with this result specification.

Specified by:
getTypeSystem in interface ResultSpecification

toString

public java.lang.String toString()
Description copied from class: MetaDataObject_impl
Dump this metadata object's attributes and values to a String. This is useful for debugging.

Overrides:
toString in class MetaDataObject_impl


Copyright © 2010 The Apache Software Foundation. All Rights Reserved.