org.apache.uima.resource.metadata
Interface SimplePrecondition

All Superinterfaces:
Cloneable, MetaDataObject, Precondition, Serializable, XMLizable
All Known Subinterfaces:
LanguagePrecondition, MimeTypePrecondition

public interface SimplePrecondition
extends Precondition

SimplePrecondition defines a few simple conditions that can be evaluted against a CAS.

A value in the CAS (see below) will be compared against the precondition's comparisonValue property using the speicified predicate.

The value in the CAS is specified by providing values for indexName, fsMatchConstraint, and featureName. If any FeatureStructure in the specified index matches the FS match constraint and has a feature value that satisfies this precondition's precicate, the precondition will be considered satisfied. If the index name is ommitted, the default Annotation index (if present) will be used.

The possible predicates are defined by constants on this interface. The currently avaialble predicates are:

As with all MetaDataObjects, a SimplePrecondition may or may not be modifiable. An application can find out by calling the MetaDataObject.isModifiable() method.


Field Summary
static String ELEMENT_OF
          Identifies the ELEMENT_OF predicate.
static String EQUAL
          Identifies the EQUAL predicate.
static String LANGUAGE_SUBSUMED
          Identifies the LANGUAGE_SUBSUMED predicate.
static String PRECONDITION_TYPE
          The type identifier for this class of precondition.
 
Method Summary
 Object getComparisonValue()
          Retrieves the literal value to which features' values will be compared.
 boolean getDefault()
          Retrieves the deafult value for this precondition.
 String getFeatureName()
          Gets the name of the feature to be tested.
 String getFsIndexName()
          Retrieves the name of the FeatureStructure index containing FeatureStructures to be tested by this precondition.
 FSMatchConstraint getFsMatchConstraint()
          Retrieves the FSMatchConstraint that determines which CAS feature structures will be tested by this precondition.
 String getPreconditionType()
          Gets the type of this precondition.
 String getPredicate()
          Retrieves the predicate used to compare the test value to the comparison value.
 void setComparisonValue(Object aValue)
          Sets the literal value to which features' values will be compared.
 void setDefault(boolean aDefault)
          Sets the deafult value for this precondition.
 void setFeatureName(String aFeatureName)
          Sets the name of the feature to be tested.
 void setFsIndexName(String aIndexName)
          Sets the name of the FeatureStructure index containing FeatureStructures to be tested by this precondition.
 void setFsMatchConstraint(FSMatchConstraint aConstraint)
          Sets the FSMatchConstraint that determines which CAS feature structures will be tested by this precondition.
 void setPredicate(String aPredicate)
          Sets the predicate used to compare the test value to the comparison value.
 
Methods inherited from interface org.apache.uima.resource.metadata.Precondition
evaluate
 
Methods inherited from interface org.apache.uima.resource.metadata.MetaDataObject
clone, equals, getAttributeValue, getSourceUrl, getSourceUrlString, isModifiable, listAttributes, setAttributeValue, setSourceUrl
 
Methods inherited from interface org.apache.uima.util.XMLizable
buildFromXMLElement, buildFromXMLElement, toXML, toXML, toXML, toXML
 

Field Detail

PRECONDITION_TYPE

static final String PRECONDITION_TYPE
The type identifier for this class of precondition. This is the return value of getPreconditionType().

See Also:
Constant Field Values

EQUAL

static final String EQUAL
Identifies the EQUAL predicate. This predicate evaluates to true if and only if the test value and the comparison value are of the same data type and are equal, according to the equality rules of that data type.

See Also:
Constant Field Values

ELEMENT_OF

static final String ELEMENT_OF
Identifies the ELEMENT_OF predicate. For this predicate, the comparison value must be an array. ELEMENT_OF evaluates to true if and only if the test value is equal to one of the elements of the array. (If the comparison value is not an array, ELEMENT_OF always evaluates to false.)

See Also:
Constant Field Values

LANGUAGE_SUBSUMED

static final String LANGUAGE_SUBSUMED
Identifies the LANGUAGE_SUBSUMED predicate. For this predicate, the comparison value must be an array of ISO language identifiers. LANGUAGE_SUBSUMED evaluates to true if and only if the test value is an ISO language identifier that is subsumed by one of the values of the comparison array. (For example, "en_US" is subsumed by "en.")

See Also:
Constant Field Values
Method Detail

getPreconditionType

String getPreconditionType()
Gets the type of this precondition. Each sub-interface of Precondition has its own standard type identifier String. These identifier Strings are used instead of Java class names in order to ease portability of metadata to other languages.

Specified by:
getPreconditionType in interface Precondition
Returns:
PRECONDITION_TYPE

getFsIndexName

String getFsIndexName()
Retrieves the name of the FeatureStructure index containing FeatureStructures to be tested by this precondition.

Returns:
the name of the FS index, null if the default annotation index should be used

setFsIndexName

void setFsIndexName(String aIndexName)
Sets the name of the FeatureStructure index containing FeatureStructures to be tested by this precondition.

Parameters:
aIndexName - the name of the FS index, null if the default annotation index should be used
Throws:
UIMA_UnsupportedOperationException - if this MetaDataObject is not modifiable.

getFsMatchConstraint

FSMatchConstraint getFsMatchConstraint()
Retrieves the FSMatchConstraint that determines which CAS feature structures will be tested by this precondition.

Returns:
the FS match constraint, null if none

setFsMatchConstraint

void setFsMatchConstraint(FSMatchConstraint aConstraint)
Sets the FSMatchConstraint that determines which CAS feature structures will be tested by this precondition.

Parameters:
aConstraint - the FS match constraint, null if none
Throws:
UIMA_UnsupportedOperationException - if this MetaDataObject is not modifiable.

getFeatureName

String getFeatureName()
Gets the name of the feature to be tested.

Returns:
the feature name, null if none

setFeatureName

void setFeatureName(String aFeatureName)
Sets the name of the feature to be tested.

Parameters:
aFeatureName - the feature name, null if none
Throws:
UIMA_UnsupportedOperationException - if this MetaDataObject is not modifiable.

getComparisonValue

Object getComparisonValue()
Retrieves the literal value to which features' values will be compared.

Returns:
the value, which must be a String, Integer, Float, Boolean or an array of one of those four types.

setComparisonValue

void setComparisonValue(Object aValue)
Sets the literal value to which features' values will be compared.

Parameters:
aValue - the comparison value, which must be a String, Integer, Float, Boolean, or an array of one of those four types.
Throws:
UIMA_UnsupportedOperationException - if this MetaDataObject is not modifiable.

getPredicate

String getPredicate()
Retrieves the predicate used to compare the test value to the comparison value.

Returns:
a String that identifies the predicate used. This will always match one of the constants defined on this interface.

setPredicate

void setPredicate(String aPredicate)
Sets the predicate used to compare the test value to the comparison value.

Parameters:
aPredicate - a String that identifies the predicate used. This must match one of the constants defined on this interface.
Throws:
UIMA_UnsupportedOperationException - if this MetaDataObject is not modifiable.
UIMA_IllegalArgumentException - if the given value is not appropriate for the given attribute.

getDefault

boolean getDefault()
Retrieves the deafult value for this precondition. This is the value returned if there is no applicable test value in the CAS.

Returns:
the default value

setDefault

void setDefault(boolean aDefault)
Sets the deafult value for this precondition. This is the value returned if there is no applicable test value in the CAS.

Parameters:
aDefault - the default value
Throws:
UIMA_UnsupportedOperationException - if this MetaDataObject is not modifiable.


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