You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2017/07/20 13:59:59 UTC
svn commit: r1802486 -
/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java
Author: schor
Date: Thu Jul 20 13:59:58 2017
New Revision: 1802486
URL: http://svn.apache.org/viewvc?rev=1802486&view=rev
Log:
[UIMA-5505] support class argument getAnnotationIndex
Modified:
uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java
Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java?rev=1802486&r1=1802485&r2=1802486&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java Thu Jul 20 13:59:58 2017
@@ -29,6 +29,8 @@ import org.apache.uima.cas.impl.SelectFS
import org.apache.uima.cas.text.AnnotationFS;
import org.apache.uima.cas.text.AnnotationIndex;
import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.impl.JCasImpl;
+import org.apache.uima.jcas.tcas.Annotation;
/**
* Object-oriented CAS (Common Analysis System) API.
@@ -603,6 +605,12 @@ public interface CAS extends AbstractCas
JCas getJCas() throws CASException;
/**
+ * Get the JCasImpl for this CAS
+ * @return the JCasImpl for this CAS
+ */
+ JCasImpl getJCasImpl();
+
+ /**
* Get the Cas view that the current component should use. This
* should only be used by single-view components.
*
@@ -759,6 +767,20 @@ public interface CAS extends AbstractCas
<T extends AnnotationFS> AnnotationIndex<T> getAnnotationIndex(Type type) throws CASRuntimeException;
/**
+ * Get the standard annotation index restricted to a specific annotation type.
+ *
+ * @param type
+ * The annotation type the index is restricted to, specified as a JCas class
+ * @param <T> the topmost Java class corresponding to the type
+ * @return The standard annotation index, restricted to <code>type</code>.
+ * @exception CASRuntimeException When <code>type</code> is not an annotation type.
+ */
+ default <T extends AnnotationFS> AnnotationIndex<T> getAnnotationIndex(Class<T> clazz)
+ throws CASRuntimeException {
+ return getAnnotationIndex(this.getJCasImpl().getCasType(clazz));
+ }
+
+ /**
* Create a new annotation. Note that you still need to insert the annotation into the index
* repository yourself.
*