Merge pull request #133 from apache/feature/UIMA-6270-Add-selectOverlapping-to-JCasUtil
[UIMA-6270] Add selectOverlapping to (J)CasUtil
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java b/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java
index 1aaca7c..b3a77c6 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/util/CasUtil.java
@@ -900,6 +900,23 @@
return unmodifiableMap(index);
}
+
+ /**
+ * Get a list of annotations of the given annotation type overlapping the given annotation. Does
+ * not use subiterators and does not respect type prioritites.
+ *
+ * @param aType
+ * a UIMA type.
+ * @param aBoundaryAnnotation
+ * the covering annotation.
+ * @return a list of overlapping annotations.
+ * @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a>
+ */
+ public static List<AnnotationFS> selectOverlapping(Type aType,
+ AnnotationFS aBoundaryAnnotation) {
+ return selectOverlapping(aBoundaryAnnotation.getCAS(), aType, aBoundaryAnnotation.getBegin(),
+ aBoundaryAnnotation.getEnd());
+ }
/**
* Get a list of annotations of the given annotation type overlapping the given annotation. Does
diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/util/JCasUtil.java b/uimafit-core/src/main/java/org/apache/uima/fit/util/JCasUtil.java
index 7d8695a..2c1cf32 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/util/JCasUtil.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/util/JCasUtil.java
@@ -544,6 +544,23 @@
* Get a list of annotations of the given annotation type overlapping the given annotation. Does
* not use subiterators and does not respect type prioritites.
*
+ * @param aType
+ * a UIMA type.
+ * @param aBoundaryAnnotation
+ * the covering annotation.
+ * @return a list of overlapping annotations.
+ * @see <a href="package-summary.html#SortOrder">Order of selected feature structures</a>
+ */
+ public static <T extends Annotation> List<T> selectOverlapping(Class<T> aType,
+ AnnotationFS aBoundaryAnnotation) {
+ return cast(CasUtil.selectOverlapping(getType(aBoundaryAnnotation.getJCas(), aType),
+ aBoundaryAnnotation));
+ }
+
+ /**
+ * Get a list of annotations of the given annotation type overlapping the given annotation. Does
+ * not use subiterators and does not respect type prioritites.
+ *
* @param aJCas
* a CAS.
* @param aType
@@ -557,7 +574,7 @@
AnnotationFS aBoundaryAnnotation) {
return cast(
CasUtil.selectOverlapping(aJCas.getCas(), getType(aJCas, aType), aBoundaryAnnotation));
- }
+ }
/**
* Get a list of annotations of the given annotation type overlapping the given span. Does not use