org.apache.uima.fit.util

## Class CasUtil

- java.lang.Object
- - org.apache.uima.fit.util.CasUtil

-     public final class CasUtil
      extends Object

  Utility methods for convenient access to the `CAS`.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `UIMA_BUILTIN_JCAS_PREFIX` Package name of JCas wrapper classes built into UIMA.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T extends org.apache.uima.jcas.cas.TOP> boolean` | `exists(org.apache.uima.cas.CAS aCas, org.apache.uima.cas.Type aType)` Test if a CAS contains an annotation of the given type.
    `static org.apache.uima.cas.Type` | `getAnnotationType(org.apache.uima.cas.CAS aCas, Class<?> aJCasClass)` Get the CAS type for the given JCas wrapper class making sure it is or inherits from `Annotation`.
    `static org.apache.uima.cas.Type` | `getAnnotationType(org.apache.uima.cas.CAS aCas, String aTypeName)` Get the CAS type for the given name making sure it is or inherits from Annotation.
    `static org.apache.uima.cas.Type` | `getType(org.apache.uima.cas.CAS cas, Class<?> type)` Get the CAS type for the given JCas wrapper class.
    `static org.apache.uima.cas.Type` | `getType(org.apache.uima.cas.CAS aCas, String aTypename)` Get the CAS type for the given name.
    `static org.apache.uima.cas.CAS` | `getView(org.apache.uima.cas.CAS cas, String viewName, boolean create)` Convenience method to get the specified view or create a new view if the requested view does not exist.
    `static org.apache.uima.cas.CAS` | `getView(org.apache.uima.cas.CAS cas, String viewName, org.apache.uima.cas.CAS fallback)` Convenience method to get the specified view or a default view if the requested view does not exist.
    `static Map<org.apache.uima.cas.text.AnnotationFS,Collection<org.apache.uima.cas.text.AnnotationFS>>` | `indexCovered(org.apache.uima.cas.CAS cas, org.apache.uima.cas.Type type, org.apache.uima.cas.Type coveredType)` Create an index for quickly lookup up the annotations covered by a particular annotation.
    `static Map<org.apache.uima.cas.text.AnnotationFS,Collection<org.apache.uima.cas.text.AnnotationFS>>` | `indexCovering(org.apache.uima.cas.CAS cas, org.apache.uima.cas.Type type, org.apache.uima.cas.Type coveringType)` Create an index for quickly lookup up the annotations covering a particular annotation.
    `static <T extends org.apache.uima.cas.text.AnnotationFS> Iterator<T>` | `iterator(org.apache.uima.cas.CAS cas, org.apache.uima.cas.Type type)` Get an iterator over the given annotation type.
    `static <T extends org.apache.uima.cas.FeatureStructure> Iterator<T>` | `iteratorFS(org.apache.uima.cas.CAS cas, org.apache.uima.cas.Type type)` Get an iterator over the given feature structures type.
    `static Collection<org.apache.uima.cas.text.AnnotationFS>` | `select(org.apache.uima.cas.ArrayFS array, org.apache.uima.cas.Type type)` Convenience method to iterator over all annotations of a given type.
    `static Collection<org.apache.uima.cas.text.AnnotationFS>` | `select(org.apache.uima.cas.CAS cas, org.apache.uima.cas.Type type)` Convenience method to iterator over all annotations of a given type.
    `static Collection<org.apache.uima.cas.text.AnnotationFS>` | `selectAll(org.apache.uima.cas.CAS aCas)` Convenience method to iterator over all annotations.
    `static Collection<org.apache.uima.cas.FeatureStructure>` | `selectAllFS(org.apache.uima.cas.CAS aCas)` Convenience method to iterator over all features structures.
    `static List<org.apache.uima.cas.text.AnnotationFS>` | `selectAt(org.apache.uima.cas.CAS aCas, org.apache.uima.cas.Type aType, int aBegin, int aEnd)` Get all annotations of the given type at the specified offsets.
    `static List<org.apache.uima.cas.text.AnnotationFS>` | `selectBetween(org.apache.uima.cas.CAS cas, org.apache.uima.cas.Type type, org.apache.uima.cas.text.AnnotationFS ann1, org.apache.uima.cas.text.AnnotationFS ann2)` Get a list of annotations of the given annotation type located between two annotations.
    `static List<org.apache.uima.cas.text.AnnotationFS>` | `selectBetween(org.apache.uima.cas.Type type, org.apache.uima.cas.text.AnnotationFS ann1, org.apache.uima.cas.text.AnnotationFS ann2)` Get a list of annotations of the given annotation type located between two annotations.
    `static org.apache.uima.cas.text.AnnotationFS` | `selectByIndex(org.apache.uima.cas.CAS cas, org.apache.uima.cas.Type type, int index)` This method exists simply as a convenience method for unit testing.
    `static List<org.apache.uima.cas.text.AnnotationFS>` | `selectCovered(org.apache.uima.cas.CAS cas, org.apache.uima.cas.Type type, org.apache.uima.cas.text.AnnotationFS coveringAnnotation)` Get a list of annotations of the given annotation type constraint by a certain annotation.
    `static List<org.apache.uima.cas.text.AnnotationFS>` | `selectCovered(org.apache.uima.cas.CAS cas, org.apache.uima.cas.Type type, int begin, int end)` Get a list of annotations of the given annotation type constraint by a certain annotation.
    `static List<org.apache.uima.cas.text.AnnotationFS>` | `selectCovered(org.apache.uima.cas.Type type, org.apache.uima.cas.text.AnnotationFS coveringAnnotation)` Get a list of annotations of the given annotation type constraint by a certain annotation.
    `static List<org.apache.uima.cas.text.AnnotationFS>` | `selectCovering(org.apache.uima.cas.CAS cas, org.apache.uima.cas.Type type, org.apache.uima.cas.text.AnnotationFS coveredAnnotation)` Get a list of annotations of the given annotation type constraint by a certain annotation.
    `static List<org.apache.uima.cas.text.AnnotationFS>` | `selectCovering(org.apache.uima.cas.CAS cas, org.apache.uima.cas.Type type, int begin, int end)` Get a list of annotations of the given annotation type constraint by a certain annotation.
    `static List<org.apache.uima.cas.text.AnnotationFS>` | `selectCovering(org.apache.uima.cas.Type type, org.apache.uima.cas.text.AnnotationFS coveredAnnotation)` Get a list of annotations of the given annotation type constraint by a certain annotation.
    `static List<org.apache.uima.cas.text.AnnotationFS>` | `selectFollowing(org.apache.uima.cas.CAS cas, org.apache.uima.cas.Type type, org.apache.uima.cas.text.AnnotationFS annotation, int count)` Returns the n annotations following the given annotation
    `static Collection<org.apache.uima.cas.FeatureStructure>` | `selectFS(org.apache.uima.cas.ArrayFS array, org.apache.uima.cas.Type type)` Convenience method to iterator over all feature structures of a given type.
    `static Collection<org.apache.uima.cas.FeatureStructure>` | `selectFS(org.apache.uima.cas.CAS cas, org.apache.uima.cas.Type type)` Convenience method to iterator over all feature structures of a given type.
    `static List<org.apache.uima.cas.text.AnnotationFS>` | `selectPreceding(org.apache.uima.cas.CAS cas, org.apache.uima.cas.Type type, org.apache.uima.cas.text.AnnotationFS annotation, int count)` Returns the n annotations preceding the given annotation
    `static org.apache.uima.cas.FeatureStructure` | `selectSingle(org.apache.uima.cas.CAS cas, org.apache.uima.cas.Type type)` Get the single instance of the specified type from the JCas.
    `static org.apache.uima.cas.text.AnnotationFS` | `selectSingleAt(org.apache.uima.cas.CAS aCas, org.apache.uima.cas.Type aType, int aBegin, int aEnd)` Get the single instance of the specified type from the CAS at the given offsets.
    `static org.apache.uima.cas.text.AnnotationFS` | `selectSingleRelative(org.apache.uima.cas.CAS cas, org.apache.uima.cas.Type type, org.apache.uima.cas.text.AnnotationFS aAnchor, int aPosition)` Return an annotation preceding or following of a given reference annotation.
    `static org.apache.uima.cas.text.AnnotationFS` | `selectSingleRelative(org.apache.uima.cas.Type type, org.apache.uima.cas.text.AnnotationFS annotation, int index)` Return an annotation preceding or following of a given reference annotation.
    `static <T extends org.apache.uima.cas.text.AnnotationFS> List<String>` | `toText(Iterable<T> iterable)` Fetch the text covered by the specified annotations and return it as a list of strings.
    `static <T extends org.apache.uima.cas.text.AnnotationFS> List<String>` | `toText(Iterator<T> iterator)` Fetch the text covered by the specified annotations and return it as a list of strings.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### UIMA_BUILTIN_JCAS_PREFIX

          public static final String UIMA_BUILTIN_JCAS_PREFIX

      Package name of JCas wrapper classes built into UIMA.
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### iteratorFS

          public static <T extends org.apache.uima.cas.FeatureStructure> Iterator<T> iteratorFS(org.apache.uima.cas.CAS cas,
                                                                                                org.apache.uima.cas.Type type)

      Get an iterator over the given feature structures type.
      Type Parameters:
        `T` - the JCas type.
      Parameters:
        `cas` - a CAS.
        `type` - a type.
      Returns:
        a return value.
      See Also:
        Order of selected feature structures

    - #### iterator

          public static <T extends org.apache.uima.cas.text.AnnotationFS> Iterator<T> iterator(org.apache.uima.cas.CAS cas,
                                                                                               org.apache.uima.cas.Type type)

      Get an iterator over the given annotation type.
      Type Parameters:
        `T` - the JCas type.
      Parameters:
        `cas` - a CAS.
        `type` - a type.
      Returns:
        a return value.
      See Also:
        Order of selected feature structures

    - #### getType

          public static org.apache.uima.cas.Type getType(org.apache.uima.cas.CAS cas,
                                                         Class<?> type)

      Get the CAS type for the given JCas wrapper class.
      Parameters:
        `cas` - the CAS hosting the type system.
        `type` - the JCas wrapper class.
      Returns:
        the CAS type.

    - #### getType

          public static org.apache.uima.cas.Type getType(org.apache.uima.cas.CAS aCas,
                                                         String aTypename)

      Get the CAS type for the given name.
      Parameters:
        `aCas` - the CAS hosting the type system.
        `aTypename` - the fully qualified type name.
      Returns:
        the CAS type.

    - #### getAnnotationType

          public static org.apache.uima.cas.Type getAnnotationType(org.apache.uima.cas.CAS aCas,
                                                                   Class<?> aJCasClass)

      Get the CAS type for the given JCas wrapper class making sure it is or inherits from `Annotation`.
      Parameters:
        `aCas` - the CAS hosting the type system.
        `aJCasClass` - the JCas wrapper class.
      Returns:
        the CAS type.

    - #### getAnnotationType

          public static org.apache.uima.cas.Type getAnnotationType(org.apache.uima.cas.CAS aCas,
                                                                   String aTypeName)

      Get the CAS type for the given name making sure it is or inherits from Annotation.
      Parameters:
        `aCas` - the CAS hosting the type system.
        `aTypeName` - the fully qualified type name.
      Returns:
        the CAS type.

    - #### selectFS

          public static Collection<org.apache.uima.cas.FeatureStructure> selectFS(org.apache.uima.cas.ArrayFS array,
                                                                                  org.apache.uima.cas.Type type)

      Convenience method to iterator over all feature structures of a given type.
      Parameters:
        `array` - features structure array.
        `type` - the type.
      Returns:
        A collection of the selected type.
      See Also:
        Order of selected feature structures

    - #### select

          public static Collection<org.apache.uima.cas.text.AnnotationFS> select(org.apache.uima.cas.ArrayFS array,
                                                                                 org.apache.uima.cas.Type type)

      Convenience method to iterator over all annotations of a given type.
      Parameters:
        `array` - features structure array.
        `type` - the type.
      Returns:
        A collection of the selected type.
      See Also:
        Order of selected feature structures

    - #### selectAllFS

          public static Collection<org.apache.uima.cas.FeatureStructure> selectAllFS(org.apache.uima.cas.CAS aCas)

      Convenience method to iterator over all features structures.
      Parameters:
        `aCas` - the CAS hosting the type system.
      Returns:
        A collection of the selected type.
      See Also:
        Order of selected feature structures

    - #### selectFS

          public static Collection<org.apache.uima.cas.FeatureStructure> selectFS(org.apache.uima.cas.CAS cas,
                                                                                  org.apache.uima.cas.Type type)

      Convenience method to iterator over all feature structures of a given type.
      Parameters:
        `cas` - the CAS containing the type system.
        `type` - the type.
      Returns:
        A collection of the selected type.
      See Also:
        Order of selected feature structures

    - #### selectAll

          public static Collection<org.apache.uima.cas.text.AnnotationFS> selectAll(org.apache.uima.cas.CAS aCas)

      Convenience method to iterator over all annotations.
      Parameters:
        `aCas` - the CAS hosting the type system.
      Returns:
        A collection of the selected type.
      See Also:
        Order of selected feature structures

    - #### select

          public static Collection<org.apache.uima.cas.text.AnnotationFS> select(org.apache.uima.cas.CAS cas,
                                                                                 org.apache.uima.cas.Type type)

      Convenience method to iterator over all annotations of a given type.
      Parameters:
        `cas` - the CAS containing the type system.
        `type` - the type.
      Returns:
        A collection of the selected type.
      See Also:
        Order of selected feature structures

    - #### selectAt

          public static List<org.apache.uima.cas.text.AnnotationFS> selectAt(org.apache.uima.cas.CAS aCas,
                                                                             org.apache.uima.cas.Type aType,
                                                                             int aBegin,
                                                                             int aEnd)

      Get all annotations of the given type at the specified offsets.
      Parameters:
        `aCas` - the CAS containing the annotations.
        `aType` - the type of annotations to fetch.
        `aBegin` - the begin offset.
        `aEnd` - the end offset.
      Returns:
        the annotations at the specified offsets.

    - #### selectSingleAt

          public static org.apache.uima.cas.text.AnnotationFS selectSingleAt(org.apache.uima.cas.CAS aCas,
                                                                             org.apache.uima.cas.Type aType,
                                                                             int aBegin,
                                                                             int aEnd)

      Get the single instance of the specified type from the CAS at the given offsets.
      Parameters:
        `aCas` - the CAS containing the annotations.
        `aType` - the type of annotations to fetch.
        `aBegin` - the begin offset.
        `aEnd` - the end offset.
      Returns:
        the single annotation at the specified offsets.

    - #### selectBetween

          public static List<org.apache.uima.cas.text.AnnotationFS> selectBetween(org.apache.uima.cas.Type type,
                                                                                  org.apache.uima.cas.text.AnnotationFS ann1,
                                                                                  org.apache.uima.cas.text.AnnotationFS ann2)

      Get a list of annotations of the given annotation type located between two annotations. Does not use subiterators and does not respect type priorities. Zero-width annotations what lie on the borders are included in the result, e.g. if the boundary annotations are [1..2] and [2..3] then an annotation [2..2] is returned. If there is a non-zero overlap between the boundary annotations, the result is empty. The method properly handles cases where the second boundary annotations occurs before the first boundary annotation by switching their roles.
      Parameters:
        `type` - a UIMA type.
        `ann1` - the first boundary annotation.
        `ann2` - the second boundary annotation.
      Returns:
        a return value.
      See Also:
        `Subiterator`, Order of selected feature structures

    - #### selectBetween

          public static List<org.apache.uima.cas.text.AnnotationFS> selectBetween(org.apache.uima.cas.CAS cas,
                                                                                  org.apache.uima.cas.Type type,
                                                                                  org.apache.uima.cas.text.AnnotationFS ann1,
                                                                                  org.apache.uima.cas.text.AnnotationFS ann2)

      Get a list of annotations of the given annotation type located between two annotations. Does not use subiterators and does not respect type priorities. Zero-width annotations what lie on the borders are included in the result, e.g. if the boundary annotations are [1..2] and [2..3] then an annotation [2..2] is returned. If there is a non-zero overlap between the boundary annotations, the result is empty. The method properly handles cases where the second boundary annotations occurs before the first boundary annotation by switching their roles.
      Parameters:
        `cas` - a CAS.
        `type` - a UIMA type.
        `ann1` - the first boundary annotation.
        `ann2` - the second boundary annotation.
      Returns:
        a return value.
      See Also:
        `Subiterator`, Order of selected feature structures

    - #### selectCovered

          public static List<org.apache.uima.cas.text.AnnotationFS> selectCovered(org.apache.uima.cas.Type type,
                                                                                  org.apache.uima.cas.text.AnnotationFS coveringAnnotation)

      Get a list of annotations of the given annotation type constraint by a certain annotation. Iterates over all annotations of the given type to find the covered annotations. Does not use subiterators and does not respect type prioritites. Was adapted from `Subiterator`. Uses the same approach except that type priorities are ignored.

      The covering annotation is never returned itself, even if it is of the queried-for type or a subtype of that type.

      The method only returns properly covered annotations, that is annotations where the begin/end offsets are equal to the 'covering' annotation or where both the begin/end are included in the span of the 'covering' annotation. Partially overlapping annotations are not returned.

      Parameters:
        `type` - a UIMA type.
        `coveringAnnotation` - the covering annotation.
      Returns:
        a return value.
      See Also:
        `Subiterator`, Order of selected feature structures

    - #### selectCovered

          public static List<org.apache.uima.cas.text.AnnotationFS> selectCovered(org.apache.uima.cas.CAS cas,
                                                                                  org.apache.uima.cas.Type type,
                                                                                  org.apache.uima.cas.text.AnnotationFS coveringAnnotation)

      Get a list of annotations of the given annotation type constraint by a certain annotation. Iterates over all annotations of the given type to find the covered annotations. Does not use subiterators and does not respect type prioritites. Was adapted from `Subiterator`. Uses the same approach except that type priorities are ignored.

      The covering annotation is never returned itself, even if it is of the queried-for type or a subtype of that type.

      The method only returns properly covered annotations, that is annotations where the begin/end offsets are equal to the 'covering' annotation or where both the begin/end are included in the span of the 'covering' annotation. Partially overlapping annotations are not returned.

      Parameters:
        `cas` - a CAS.
        `type` - a UIMA type.
        `coveringAnnotation` - the covering annotation.
      Returns:
        a return value.
      See Also:
        `Subiterator`, Order of selected feature structures

    - #### selectCovered

          public static List<org.apache.uima.cas.text.AnnotationFS> selectCovered(org.apache.uima.cas.CAS cas,
                                                                                  org.apache.uima.cas.Type type,
                                                                                  int begin,
                                                                                  int end)

      Get a list of annotations of the given annotation type constraint by a certain annotation. Iterates over all annotations of the given type to find the covered annotations. Does not use subiterators and does not respect type prioritites. Was adapted from `Subiterator`. Uses the same approach except that type priorities are ignored.

      Note: this is significantly slower than using `selectCovered(CAS, Type, AnnotationFS)`. It is possible to use `selectCovered(cas, type, new Annotation(jCas, int, int))`, but that will allocate memory in the jCas for the new annotation. If you do that repeatedly many times, memory may fill up.

      The method only returns properly covered annotations, that is annotations where the begin/end offsets are equal to the given begin/end or where both the begin/end are included in the span of the given span. Partially overlapping annotations are not returned.

      Parameters:
        `cas` - a CAS.
        `type` - a UIMA type.
        `begin` - begin offset.
        `end` - end offset.
      Returns:
        a return value.
      See Also:
        `Subiterator`, Order of selected feature structures

    - #### selectCovering

          public static List<org.apache.uima.cas.text.AnnotationFS> selectCovering(org.apache.uima.cas.Type type,
                                                                                   org.apache.uima.cas.text.AnnotationFS coveredAnnotation)

      Get a list of annotations of the given annotation type constraint by a certain annotation. Iterates over all annotations to find the covering annotations.

      The method only returns properly covering annotations, that is annotations where the begin/end offsets are equal to the begin/end of the given annotation or where given 'covered' annotation is properly contained within the span of the 'covering' annotation. Partially overlapping annotations are not returned.

      Note: this is REALLY SLOW! You don't want to use this. Instead, consider using `indexCovering(CAS, Type, Type)` or a `ContainmentIndex`.

      Parameters:
        `type` - a UIMA type.
        `coveredAnnotation` - the covered annotation.
      Returns:
        a return value.
      See Also:
        Order of selected feature structures

    - #### selectCovering

          public static List<org.apache.uima.cas.text.AnnotationFS> selectCovering(org.apache.uima.cas.CAS cas,
                                                                                   org.apache.uima.cas.Type type,
                                                                                   org.apache.uima.cas.text.AnnotationFS coveredAnnotation)

      Get a list of annotations of the given annotation type constraint by a certain annotation. Iterates over all annotations to find the covering annotations.

      The method only returns properly covering annotations, that is annotations where the begin/end offsets are equal to the begin/end of the given annotation or where given 'covered' annotation is properly contained within the span of the 'covering' annotation. Partially overlapping annotations are not returned.

      Note: this is REALLY SLOW! You don't want to use this. Instead, consider using `indexCovering(CAS, Type, Type)` or a `ContainmentIndex`.

      Parameters:
        `cas` - a CAS.
        `type` - a UIMA type.
        `coveredAnnotation` - the covered annotation.
      Returns:
        a return value.
      See Also:
        Order of selected feature structures

    - #### selectCovering

          public static List<org.apache.uima.cas.text.AnnotationFS> selectCovering(org.apache.uima.cas.CAS cas,
                                                                                   org.apache.uima.cas.Type type,
                                                                                   int begin,
                                                                                   int end)

      Get a list of annotations of the given annotation type constraint by a certain annotation. Iterates over all annotations to find the covering annotations.

      The method only returns properly covering annotations, that is annotations where the begin/end offsets are equal to the given begin/end to or where given span is properly contained within the span of the 'covering' annotation. Partially overlapping annotations are not returned.

      Note: this is REALLY SLOW! You don't want to use this. Instead, consider using `indexCovering(CAS, Type, Type)` or a `ContainmentIndex`.

      Parameters:
        `cas` - a CAS.
        `type` - a UIMA type.
        `begin` - begin offset.
        `end` - end offset.
      Returns:
        a return value.
      See Also:
        Order of selected feature structures

    - #### indexCovering

          public static Map<org.apache.uima.cas.text.AnnotationFS,Collection<org.apache.uima.cas.text.AnnotationFS>> indexCovering(org.apache.uima.cas.CAS cas,
                                                                                                                                   org.apache.uima.cas.Type type,
                                                                                                                                   org.apache.uima.cas.Type coveringType)

      Create an index for quickly lookup up the annotations covering a particular annotation. This is preferable to using `selectCovering(CAS, Type, int, int)` because the overhead of scanning the CAS occurs only when the index is build. Subsequent lookups to the index are fast.

      The method only returns properly covering annotations, that is annotations where the begin/end offsets are equal to the begin/end of the given annotation or where given 'covered' annotation is properly contained within the span of the 'covering' annotation. Partially overlapping annotations are not returned.

      When querying for the annotations covering a given annotation, the given annotation itself is never returned, even if it is of the queried type.

      Parameters:
        `cas` - a CAS.
        `type` - type to create the index for - this is used in lookups.
        `coveringType` - type of covering annotations.
      Returns:
        the index.
      See Also:
        Order of selected feature structures

    - #### indexCovered

          public static Map<org.apache.uima.cas.text.AnnotationFS,Collection<org.apache.uima.cas.text.AnnotationFS>> indexCovered(org.apache.uima.cas.CAS cas,
                                                                                                                                  org.apache.uima.cas.Type type,
                                                                                                                                  org.apache.uima.cas.Type coveredType)

      Create an index for quickly lookup up the annotations covered by a particular annotation. This is preferable to using `selectCovered(CAS, Type, int, int)` because the overhead of scanning the CAS occurs only when the index is build. Subsequent lookups to the index are fast. The order of entries in the map is not defined. However, lists of covered annotations in the map are guaranteed to be in the same order as in the UIMA default annotation index.

      The method only returns properly covered annotations, that is annotations where the begin/end offsets are equal to the 'covering' annotation or where both the begin/end are included in the span of the 'covering' annotation. Partially overlapping annotations are not returned.

      When querying for the annotations covered by a given annotation, the given annotation itself is never returned, even if it is of the queried type. *

      Parameters:
        `cas` - a CAS.
        `type` - type to create the index for - this is used in lookups.
        `coveredType` - type of covering annotations.
      Returns:
        the index.
      See Also:
        Order of selected feature structures

    - #### selectByIndex

          public static org.apache.uima.cas.text.AnnotationFS selectByIndex(org.apache.uima.cas.CAS cas,
                                                                            org.apache.uima.cas.Type type,
                                                                            int index)

      This method exists simply as a convenience method for unit testing. It is not very efficient and should not, in general be used outside the context of unit testing.
      Parameters:
        `cas` - a CAS containing the annotation.
        `type` - a UIMA type.
        `index` - this can be either positive (0 corresponds to the first annotation of a type) or negative (-1 corresponds to the last annotation of a type.)
      Returns:
        an annotation of the given type
      See Also:
        Order of selected feature structures

    - #### selectSingle

          public static org.apache.uima.cas.FeatureStructure selectSingle(org.apache.uima.cas.CAS cas,
                                                                          org.apache.uima.cas.Type type)

      Get the single instance of the specified type from the JCas.
      Parameters:
        `cas` - a CAS containing the annotation.
        `type` - a UIMA type.
      Returns:
        the single instance of the given type. throws IllegalArgumentException if not exactly one instance if the given type is present.

    - #### selectSingleRelative

          public static org.apache.uima.cas.text.AnnotationFS selectSingleRelative(org.apache.uima.cas.Type type,
                                                                                   org.apache.uima.cas.text.AnnotationFS annotation,
                                                                                   int index)

      Return an annotation preceding or following of a given reference annotation.
      Parameters:
        `type` - a type.
        `annotation` - anchor annotation
        `index` - relative position to access. A negative value selects a preceding annotation while a positive number selects a following annotation.
      Returns:
        the addressed annotation.
      See Also:
        Order of selected feature structures

    - #### selectSingleRelative

          public static org.apache.uima.cas.text.AnnotationFS selectSingleRelative(org.apache.uima.cas.CAS cas,
                                                                                   org.apache.uima.cas.Type type,
                                                                                   org.apache.uima.cas.text.AnnotationFS aAnchor,
                                                                                   int aPosition)

      Return an annotation preceding or following of a given reference annotation. If the type parameter corresponds to the type or a subtype of the anchor annotation and the relative position is 0, then the anchor annotation is returned.
      Parameters:
        `cas` - a CAS containing the annotation.
        `type` - a type.
        `aAnchor` - anchor annotation
        `aPosition` - relative position to access. A negative value selects a preceding annotation while a positive number selects a following annotation.
      Returns:
        the addressed annotation.
      Throws:
        `IndexOutOfBoundsException` - if the relative position points beyond the type index bounds.
        `IllegalArgumentException` - if the relative position is `0` and the anchor type does not subsume the selected type.
      See Also:
        Order of selected feature structures

    - #### selectPreceding

          public static List<org.apache.uima.cas.text.AnnotationFS> selectPreceding(org.apache.uima.cas.CAS cas,
                                                                                    org.apache.uima.cas.Type type,
                                                                                    org.apache.uima.cas.text.AnnotationFS annotation,
                                                                                    int count)

      Returns the n annotations preceding the given annotation
      Parameters:
        `cas` - a CAS.
        `type` - a UIMA type.
        `annotation` - anchor annotation
        `count` - number of annotations to collect
      Returns:
        List of aType annotations preceding anchor annotation
      See Also:
        Order of selected feature structures

    - #### selectFollowing

          public static List<org.apache.uima.cas.text.AnnotationFS> selectFollowing(org.apache.uima.cas.CAS cas,
                                                                                    org.apache.uima.cas.Type type,
                                                                                    org.apache.uima.cas.text.AnnotationFS annotation,
                                                                                    int count)

      Returns the n annotations following the given annotation
      Parameters:
        `cas` - a CAS.
        `type` - a UIMA type.
        `annotation` - anchor annotation
        `count` - number of annotations to collect
      Returns:
        List of aType annotations following anchor annotation
      See Also:
        Order of selected feature structures

    - #### exists

          public static <T extends org.apache.uima.jcas.cas.TOP> boolean exists(org.apache.uima.cas.CAS aCas,
                                                                                org.apache.uima.cas.Type aType)

      Test if a CAS contains an annotation of the given type.
      Type Parameters:
        `T` - the annotation type.
      Parameters:
        `aCas` - a CAS.
        `aType` - a annotation type.
      Returns:
        `true` if there is at least one annotation of the given type in the CAS.

    - #### getView

          public static org.apache.uima.cas.CAS getView(org.apache.uima.cas.CAS cas,
                                                        String viewName,
                                                        org.apache.uima.cas.CAS fallback)

      Convenience method to get the specified view or a default view if the requested view does not exist. The default can also be `null`.
      Parameters:
        `cas` - a CAS
        `viewName` - the requested view.
        `fallback` - the default view if the requested view does not exist.
      Returns:
        the requested view or the default if the requested view does not exist.

    - #### getView

          public static org.apache.uima.cas.CAS getView(org.apache.uima.cas.CAS cas,
                                                        String viewName,
                                                        boolean create)

      Convenience method to get the specified view or create a new view if the requested view does not exist.
      Parameters:
        `cas` - a CAS
        `viewName` - the requested view.
        `create` - the view is created if it does not exist.
      Returns:
        the requested view
      Throws:
        `IllegalArgumentException` - if the view does not exist and is not to be created.

    - #### toText

          public static <T extends org.apache.uima.cas.text.AnnotationFS> List<String> toText(Iterable<T> iterable)

      Fetch the text covered by the specified annotations and return it as a list of strings.
      Type Parameters:
        `T` - UIMA JCas type.
      Parameters:
        `iterable` - annotation container.
      Returns:
        list of covered strings.

    - #### toText

          public static <T extends org.apache.uima.cas.text.AnnotationFS> List<String> toText(Iterator<T> iterator)

      Fetch the text covered by the specified annotations and return it as a list of strings.
      Type Parameters:
        `T` - UIMA JCas type.
      Parameters:
        `iterator` - annotation iterator.
      Returns:
        list of covered strings.

Copyright © 2012–2020 The Apache Software Foundation. All rights reserved.