Author: schor Date: Thu Jul 19 19:31:38 2018 New Revision: 1836296 URL: http://svn.apache.org/viewvc?rev=1836296&view=rev Log: [UIMA-5841]
Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/Subiterator.java Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/Subiterator.java URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/Subiterator.java?rev=1836296&r1=1836295&r2=1836296&view=diff ============================================================================== --- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/Subiterator.java (original) +++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/Subiterator.java Thu Jul 19 19:31:38 2018 @@ -19,6 +19,7 @@ package org.apache.uima.cas.impl; +import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -1255,6 +1256,7 @@ public class Subiterator<T extends Annot @Override public int size() { FSIterator<T> it2 = copy(); + it2.moveToFirst(); int sz = 0; while (it2.hasNext()) { sz++; @@ -1264,13 +1266,15 @@ public class Subiterator<T extends Annot } @Override - public FeatureStructure[] getArray() { + public T[] getArray(Class<? super T> clazz) { FSIterator<T> it2 = copy(); + it2.moveToFirst(); ArrayList<FeatureStructure> a = new ArrayList<>(); while (it2.hasNext()) { a.add(it2.nextNvc()); } - return a.toArray(new FeatureStructure[a.size()]); + T[] r = (T[]) Array.newInstance(clazz, a.size()); + return a.toArray(r); } // /**