Class ContainmentIndex<S extends AnnotationFS,U extends 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 AnnotationFS,U extends AnnotationFS> extends Object
Create a fast way of repeatedly checking whether instances of one type are contained within the boundaries on another type.
  • Constructor Details

    • ContainmentIndex

      protected ContainmentIndex(CAS cas, Type aSuper, 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 Details

    • 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 AnnotationFS, B extends AnnotationFS> ContainmentIndex<A,B> create(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<AnnotationFS,AnnotationFS> create(CAS cas, Type aSuper, 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.