org.apache.uima.fit.util

## Class ContainmentIndex<S extends org.apache.uima.cas.text.AnnotationFS,U extends org.apache.uima.cas.text.AnnotationFS>

- java.lang.Object
- - org.apache.uima.fit.util.ContainmentIndex<S,U>

- Type Parameters:
    `S` - covering type.
    `U` - covered type.

      public class ContainmentIndex<S extends org.apache.uima.cas.text.AnnotationFS,U extends org.apache.uima.cas.text.AnnotationFS>
      extends Object

  Create a fast way of repeatedly checking whether instances of one type are contained within the boundaries on another type.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ContainmentIndex.Type`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `ContainmentIndex(org.apache.uima.cas.CAS cas, org.apache.uima.cas.Type aSuper, org.apache.uima.cas.Type aUnder, ContainmentIndex.Type aType)` Create a new index on the given JCas using the specified two types.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Collection<U>` | `containedIn(S aSuper)` Get all instances of the covered type contained within the boundaries of the specified instance of the covering type.
    `Collection<S>` | `containing(U aUnder)` Get all instances of the covering type containing the the specified instance of the covered type.
    `static ContainmentIndex<org.apache.uima.cas.text.AnnotationFS,org.apache.uima.cas.text.AnnotationFS>` | `create(org.apache.uima.cas.CAS cas, org.apache.uima.cas.Type aSuper, org.apache.uima.cas.Type aUnder, ContainmentIndex.Type aType)` Factory method to create an index instead of using the constructor.
    `static <A extends org.apache.uima.cas.text.AnnotationFS,B extends org.apache.uima.cas.text.AnnotationFS> ContainmentIndex<A,B>` | `create(org.apache.uima.jcas.JCas aJcas, Class<A> aSuper, Class<B> aUnder, ContainmentIndex.Type aType)` Factory method to create an index instead of using the constructor.
    `boolean` | `isContainedIn(S aSuper, U aUnder)` Checks if the given covered type is contained in the specified covering type.
    `boolean` | `isContainedInAny(U aUnder)` Checks if the given covered type is contained in any instance of the covering type.

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

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

- - ### Constructor Detail

    - #### ContainmentIndex

          protected ContainmentIndex(org.apache.uima.cas.CAS cas,
                                     org.apache.uima.cas.Type aSuper,
                                     org.apache.uima.cas.Type aUnder,
                                     ContainmentIndex.Type aType)

      Create a new index on the given JCas using the specified two types. The last argument indicates in which directions lookups to the index will be made.
      Parameters:
        `cas` - the working JCas.
        `aSuper` - the covering type.
        `aUnder` - the covered type.
        `aType` - the indexing strategy.

  - ### Method Detail

    - #### containedIn

          public Collection<U> containedIn(S aSuper)

      Get all instances of the covered type contained within the boundaries of the specified instance of the covering type.
      Parameters:
        `aSuper` - a covering type instance.
      Returns:
        a collection of covered type instances.

    - #### containing

          public Collection<S> containing(U aUnder)

      Get all instances of the covering type containing the the specified instance of the covered type.
      Parameters:
        `aUnder` - a covered type instance.
      Returns:
        a collection of covering type instances.

    - #### isContainedIn

          public boolean isContainedIn(S aSuper,
                                       U aUnder)

      Checks if the given covered type is contained in the specified covering type.
      Parameters:
        `aSuper` - the covering type instance.
        `aUnder` - the covered type instance.
      Returns:
        whether the covered instance is contained in the covering instance.

    - #### isContainedInAny

          public boolean isContainedInAny(U aUnder)

      Checks if the given covered type is contained in any instance of the covering type.
      Parameters:
        `aUnder` - the covered type instance.
      Returns:
        whether the covered instance is contained in any instance of the covering type.

    - #### create

          public static <A extends org.apache.uima.cas.text.AnnotationFS,B extends org.apache.uima.cas.text.AnnotationFS> ContainmentIndex<A,B> create(org.apache.uima.jcas.JCas aJcas,
                                                                                                                                                       Class<A> aSuper,
                                                                                                                                                       Class<B> aUnder,
                                                                                                                                                       ContainmentIndex.Type aType)

      Factory method to create an index instead of using the constructor. This makes used of Java's type inference capabilities and results in less verbose code.
      Type Parameters:
        `A` - covering type.
        `B` - covered type.
      Parameters:
        `aJcas` - the working JCas.
        `aSuper` - the covering type.
        `aUnder` - the covered type.
        `aType` - the indexing strategy.
      Returns:
        the index instance.

    - #### create

          public static ContainmentIndex<org.apache.uima.cas.text.AnnotationFS,org.apache.uima.cas.text.AnnotationFS> create(org.apache.uima.cas.CAS cas,
                                                                                                                             org.apache.uima.cas.Type aSuper,
                                                                                                                             org.apache.uima.cas.Type aUnder,
                                                                                                                             ContainmentIndex.Type aType)

      Factory method to create an index instead of using the constructor. This makes used of Java's type inference capabilities and results in less verbose code.
      Parameters:
        `cas` - the working JCas.
        `aSuper` - the covering type.
        `aUnder` - the covered type.
        `aType` - the indexing strategy.
      Returns:
        the index instance.

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