org.apache.uima.fsvars
Interface FsVariables

All Known Implementing Classes:
FsVariablesImpl

public interface FsVariables

Implements cross-annotator named feature structure variables.

To use, a certain type and index must be declared in the processing pipeline. Use the type system and index declaration that come with this package. There's also an annotator descriptor that shows you how to import the type system and index specification into your own descriptor.

Use FsVariableFactory.newInstance() to create a FsVariables object. On every process call to your annotator (or whenever there's a new CAS; you can use this in other places than just annotators), you need to call init(CAS) to re-initialize the object to the next CAS.


Field Summary
static java.lang.String INDEX_NAME
           
static java.lang.String NAME_FEATURE_NAME
           
static java.lang.String TYPE_FEATURE_NAME
           
static java.lang.String TYPE_NAME
           
static java.lang.String VALUE_FEATURE_NAME
           
 
Method Summary
 boolean checkCas(org.apache.uima.cas.CAS cas)
          Check a CAS for FsVariable type system and index definition.
 void declareFsVariable(java.lang.String name, org.apache.uima.cas.Type type)
          Declare a new FsVariable.
 org.apache.uima.cas.Type getFsVariableType(java.lang.String name)
          Get the type of an FsVariable.
 org.apache.uima.cas.FeatureStructure getVariableValue(java.lang.String name)
          Get the FeatureStructure value of a variable.
 void init(org.apache.uima.cas.CAS cas)
          Initialize this with current CAS.
 boolean isFsVariable(java.lang.String name)
          Check if a variable of that name exists.
 java.util.List listFsVariables()
          Return a list of all variable names that are currently declared.
 java.util.List listFsVariables(org.apache.uima.cas.Type type)
          Return a list of all variable names of those variables whose type is a subtype of the type parameter.
 void setVariable(java.lang.String name, org.apache.uima.cas.FeatureStructure fs)
          Set the value of an existing variable.
 

Field Detail

INDEX_NAME

static final java.lang.String INDEX_NAME
See Also:
Constant Field Values

TYPE_NAME

static final java.lang.String TYPE_NAME
See Also:
Constant Field Values

NAME_FEATURE_NAME

static final java.lang.String NAME_FEATURE_NAME
See Also:
Constant Field Values

TYPE_FEATURE_NAME

static final java.lang.String TYPE_FEATURE_NAME
See Also:
Constant Field Values

VALUE_FEATURE_NAME

static final java.lang.String VALUE_FEATURE_NAME
See Also:
Constant Field Values
Method Detail

checkCas

boolean checkCas(org.apache.uima.cas.CAS cas)
Check a CAS for FsVariable type system and index definition. If this return true, init(CAS) will not throw an exception.

Parameters:
cas - The CAS to check.
Returns:
true iff CAS contains required type and index.

init

void init(org.apache.uima.cas.CAS cas)
          throws FsVariablesException
Initialize this with current CAS. This needs to be called on every process, before any other APIs are called!

Parameters:
cas - The current CAS.
Throws:
FsVariablesException - When the CAS does not contain FsVariable type or index.

declareFsVariable

void declareFsVariable(java.lang.String name,
                       org.apache.uima.cas.Type type)
                       throws FsVariablesException
Declare a new FsVariable. The variable must not yet exist, or an exception is thrown. Use isFsVariable(String) to check if a variable with the same name already exists.

Parameters:
name - The name of the variable.
type - The type of the variable.
Throws:
FsVariablesException - When FsVariable name already exists.

isFsVariable

boolean isFsVariable(java.lang.String name)
Check if a variable of that name exists.

Parameters:
name - The name of the variable.
Returns:
true iff a FsVariable of that name exists.

getFsVariableType

org.apache.uima.cas.Type getFsVariableType(java.lang.String name)
                                           throws FsVariablesException
Get the type of an FsVariable.

Parameters:
name - The name of the variable.
Returns:
The type of the variable, if it exists.
Throws:
FsVariablesException - If no variable of that name exists, or somehow the name of the variable's type does not resolve to a type in the type system.

listFsVariables

java.util.List listFsVariables()
Return a list of all variable names that are currently declared.

Returns:
A (sorted) list of strings of all variable names.

listFsVariables

java.util.List listFsVariables(org.apache.uima.cas.Type type)
Return a list of all variable names of those variables whose type is a subtype of the type parameter.

Parameters:
type - The type of variables we want to see.
Returns:
A (sorted) list of strings of variable names.

getVariableValue

org.apache.uima.cas.FeatureStructure getVariableValue(java.lang.String name)
                                                      throws FsVariablesException
Get the FeatureStructure value of a variable.

Parameters:
name - The name of the variable.
Returns:
The FS value of the variable.
Throws:
FsVariablesException - When no variable of name exists.

setVariable

void setVariable(java.lang.String name,
                 org.apache.uima.cas.FeatureStructure fs)
                 throws FsVariablesException
Set the value of an existing variable.

Parameters:
name - The name of the variable.
fs - The value to set.
Throws:
FsVariablesException - When no variable of name exists.


Copyright © 2011. All Rights Reserved.