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/10/31 21:06:29 UTC
svn commit: r1813935 - in
/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas:
ArrayFS.java CAS.java FSIndex.java SelectFSs.java
Author: schor
Date: Tue Oct 31 21:06:29 2017
New Revision: 1813935
URL: http://svn.apache.org/viewvc?rev=1813935&view=rev
Log:
[UIMA-5633][UIMA-5632] clean up generics, add missing javadocs
Modified:
uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/ArrayFS.java
uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java
uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/FSIndex.java
uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/SelectFSs.java
Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/ArrayFS.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/ArrayFS.java?rev=1813935&r1=1813934&r2=1813935&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/ArrayFS.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/ArrayFS.java Tue Oct 31 21:06:29 2017
@@ -85,7 +85,7 @@ public interface ArrayFS<E extends Featu
* If <code>srcOffset < 0</code> or <code>length > size()</code> or
* <code>destOffset + length > destArray.length</code>.
*/
- <T extends E> void copyFromArray(T[] src, int srcOffset, int destOffset, int length)
+ <T extends FeatureStructure> void copyFromArray(T[] src, int srcOffset, int destOffset, int length)
throws ArrayIndexOutOfBoundsException;
/**
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=1813935&r1=1813934&r2=1813935&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 Tue Oct 31 21:06:29 2017
@@ -80,9 +80,6 @@ import org.apache.uima.jcas.impl.JCasImp
* {@link TypeSystem TypeSystem} object, you can access the {@link Type Type} and
* {@link Feature Feature} objects for the CAS built-in types. Note that this interface also
* provides constants for the names of the built-in types and features.
- *
- *
- *
*/
public interface CAS extends AbstractCas {
@@ -1169,31 +1166,59 @@ public interface CAS extends AbstractCas
*/
void protectIndexes(Runnable runnable);
- default <T extends FeatureStructure> SelectFSs<T> select() {
+ /**
+ * @param <T> the Type of the elements being accessed
+ * @return a newly created selection object for accessing feature structures
+ */
+ default <T extends TOP> SelectFSs<T> select() {
return new SelectFSs_impl<>(this);
}
- default <T extends FeatureStructure> SelectFSs<T> select(Type type) {
+ /**
+ * @param type specifies the type (and subtypes of that type) to access
+ * @param <T> the Type of the elements being accessed
+ * @return a newly created selection object for accessing feature structures of that type and its subtypes
+ */
+ default <T extends TOP> SelectFSs<T> select(Type type) {
return new SelectFSs_impl<>(this).type(type);
}
- default <T extends FeatureStructure> SelectFSs<T> select(Class<T> clazz) {
+ /**
+ * @param clazz a JCas class corresponding to the type (and subtypes of that type) to access
+ * @param <T> the Type of the elements being accessed
+ * @return a newly created selection object for accessing feature structures of that type and its subtypes
+ */
+ default <T extends TOP> SelectFSs<T> select(Class<T> clazz) {
return new SelectFSs_impl<>(this).type(clazz);
}
- default <T extends FeatureStructure> SelectFSs<T> select(int jcasType) {
+ /**
+ * @param jcasType the "type" field from the JCas class corresponding to the type (and subtypes of that type) to access
+ * @param <T> the Type of the elements being accessed
+ * @return a newly created selection object for accessing feature structures of that type and its subtypes
+ */
+ default <T extends TOP> SelectFSs<T> select(int jcasType) {
return new SelectFSs_impl<>(this).type(jcasType);
}
- default <T extends FeatureStructure> SelectFSs<T> select(String fullyQualifiedTypeName) {
+ /**
+ * @param fullyQualifiedTypeName the string name of the type to access
+ * @param <T> the Type of the elements being accessed
+ * @return a newly created selection object for accessing feature structures of that type and its subtypes
+ */
+ default <T extends TOP> SelectFSs<T> select(String fullyQualifiedTypeName) {
return new SelectFSs_impl<>(this).type(fullyQualifiedTypeName);
}
+ /**
+ * @param <T> the type of the element of the list
+ * @param clazz a JCas class corresponding to the type (and subtypes of that type) to access
+ * @return a lazily created shared (for this CAS) empty list
+ */
default <T extends TOP> EmptyList emptyList(Class<T> clazz) {
return ((CASImpl)this.getLowLevelCAS()).emptyListFromTypeCode(((TypeImpl)getCasType(clazz)).getCode());
}
-
/**
* @return a lazily created shared (for this CAS) empty list
*/
@@ -1204,7 +1229,7 @@ public interface CAS extends AbstractCas
/**
* @return a lazily created shared (for this CAS) empty list
*/
- default EmptyFSList emptyFSList() {
+ default <T extends TOP> EmptyFSList<T> emptyFSList() {
return ((CASImpl)getLowLevelCAS()).emptyFSList();
};
@@ -1221,7 +1246,12 @@ public interface CAS extends AbstractCas
default EmptyStringList emptyStringList() {
return ((CASImpl)getLowLevelCAS()).emptyStringList();
};
-
+
+ /**
+ * @param <T> the class of the elements of the array
+ * @param clazz the class of the elements of the array
+ * @return a lazily created shared (for this CAS) 0-length array
+ */
default <T extends TOP> CommonArrayFS<T> emptyArray(Class<T> clazz) {
return ((CASImpl)getLowLevelCAS()).emptyArray(getCasType(clazz));
}
@@ -1236,7 +1266,7 @@ public interface CAS extends AbstractCas
/**
* @return a lazily created shared (for this CAS) 0-length array
*/
- default FSArray emptyFSArray() {
+ default <T extends FeatureStructure> FSArray<T> emptyFSArray() {
return ((CASImpl)getLowLevelCAS()).emptyFSArray();
};
Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/FSIndex.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/FSIndex.java?rev=1813935&r1=1813934&r2=1813935&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/FSIndex.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/FSIndex.java Tue Oct 31 21:06:29 2017
@@ -22,6 +22,10 @@ package org.apache.uima.cas;
import java.util.Collection;
import java.util.stream.Stream;
+import org.apache.uima.cas.impl.LowLevelIndex;
+import org.apache.uima.cas.impl.TypeImpl;
+import org.apache.uima.jcas.cas.TOP;
+
/**
* Feature structure index access interface.
*
@@ -209,17 +213,64 @@ public interface FSIndex<T extends Featu
*/
FSIndex<T> withSnapshotIterators();
- <N extends FeatureStructure> SelectFSs<N> select();
-
- <N extends FeatureStructure> SelectFSs<N> select(Type type);
+ /**
+ * @param <N> the Type of the elements being accessed
+ * @return a newly created selection object for accessing feature structures
+ */
+ SelectFSs<T> select();
+
+ /**
+ * @param type specifies the type (and subtypes of that type) to access
+ * @param <N> the Type of the elements being accessed
+ * @return a newly created selection object for accessing feature structures of that type and its subtypes
+ */
+ <N extends T> SelectFSs<N> select(Type type);
- <N extends FeatureStructure> SelectFSs<N> select(Class<N> clazz);
+ /**
+ * @param clazz a JCas class corresponding to the type (and subtypes of that type) to access
+ * @param <N> the Type of the elements being accessed
+ * @return a newly created selection object for accessing feature structures of that type and its subtypes
+ */
+ <N extends T> SelectFSs<N> select(Class<N> clazz);
- <N extends FeatureStructure> SelectFSs<N> select(int jcasType);
+ /**
+ * @param jcasType the "type" field from the JCas class corresponding to the type (and subtypes of that type) to access
+ * @param <N> the Type of the elements being accessed
+ * @return a newly created selection object for accessing feature structures of that type and its subtypes
+ */
+ <N extends T> SelectFSs<N> select(int jcasType);
- <N extends FeatureStructure> SelectFSs<N> select(String fullyQualifiedTypeName);
+ /**
+ * @param fullyQualifiedTypeName the string name of the type to access
+ * @param <N> the Type of the elements being accessed
+ * @return a newly created selection object for accessing feature structures of that type and its subtypes
+ */
+ <N extends T> SelectFSs<N> select(String fullyQualifiedTypeName);
+ /**
+ * @param <T> the Type of the elements being accessed
+ * @return a Stream over all the elements in the index (including subtypes)
+ */
default Stream<T> stream() {
return this.select();
}
+
+ /**
+ * @param clazz - the subtype
+ * @param <U> the subtype
+ * @return an instance of this index specialized to a subtype
+ */
+ default <U extends T> FSIndex<U> subType(Class<? extends TOP> clazz) {
+ return ((LowLevelIndex<T>)this).getSubIndex(clazz);
+ }
+
+ /**
+ * @param type - the subtype
+ * @param <U> the subtype
+ * @return an instance of this index specialized to a subtype
+ */
+ default <U extends T> FSIndex<U> subType(Type type) {
+ return ((LowLevelIndex<T>)this).getSubIndex(type);
+ }
+
}
Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/SelectFSs.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/SelectFSs.java?rev=1813935&r1=1813934&r2=1813935&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/SelectFSs.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/SelectFSs.java Tue Oct 31 21:06:29 2017
@@ -668,11 +668,10 @@ public interface SelectFSs<T extends Fea
* Use this static method to capture the generic argument
* @param index - the index to select over as a source
* @param <U> generic type of index
- * @param <V> generic type of returned select
* @return - a SelectFSs instance
*/
- static <U extends FeatureStructure, V extends U> SelectFSs<V> select(FSIndex<U> index) {
+ static <U extends FeatureStructure> SelectFSs<U> select(FSIndex<U> index) {
return index.select();
}