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 2015/10/29 18:24:55 UTC
svn commit: r1711308 -
/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/FSIterator.java
Author: schor
Date: Thu Oct 29 17:24:54 2015
New Revision: 1711308
URL: http://svn.apache.org/viewvc?rev=1711308&view=rev
Log:
[UIMA-4671] default methods supporting hasNext and Next in terms of FSIterator primitives isValid and get + moveToNext operations.
Modified:
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/FSIterator.java
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/FSIterator.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/FSIterator.java?rev=1711308&r1=1711307&r2=1711308&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/FSIterator.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/FSIterator.java Thu Oct 29 17:24:54 2015
@@ -124,10 +124,25 @@ public interface FSIterator<T extends Fe
*
* @param fs
* The feature structure the iterator that supplies the
- * comparison information. It must be of type T or a subtype of T.
+ * comparison information. It can be a supertype of T as long as it can supply the keys needed.
+ * A typical example is a subtype of Annotation, and using an annotation instance to specify
+ * the begin / end.
* @exception ConcurrentModificationException if the underlying indexes being iterated over were modified
*/
- void moveTo(FeatureStructure fs);
+ void moveTo(FeatureStructure fs);
+
+ /**
+ * A special version of moveTo for subtypes of AnnotationFS, which moves to a particular begin/end
+ * (no type priority).
+ *
+ * NOTE: This is not yet supported - it is intended for an additional kind of subiterator which doesn't use type priority
+ *
+ * @param begin the starting point (inclusive)
+ * @param end the ending point (inclusive)
+ */
+ default void moveTo(int begin, int end) {
+ throw new UnsupportedOperationException();
+ }
/**
* Copy this iterator.
@@ -136,4 +151,37 @@ public interface FSIterator<T extends Fe
*/
FSIterator<T> copy();
+ /*****************************************************
+ * DEFAULT implementations of Iterator interface
+ * in terms of FSIterator methods
+ *****************************************************/
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.Iterator#hasNext()
+ */
+ default boolean hasNext() {
+ return isValid();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.Iterator#next()
+ */
+ default T next() {
+ T result = get();
+ moveToNext();
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.Iterator#remove()
+ */
+ default void remove() {
+ throw new UnsupportedOperationException();
+ }
+
}