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/12/29 16:56:00 UTC

svn commit: r1722167 - /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/

Author: schor
Date: Tue Dec 29 15:56:00 2015
New Revision: 1722167

URL: http://svn.apache.org/viewvc?rev=1722167&view=rev
Log:
[UIMA-4669] undo some changes to more specific types, to achieve better backwards compatibility

Modified:
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_annotation.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_bag.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_flat.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_iicp.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_set_sorted.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_singletype.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_snapshot.java

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_annotation.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_annotation.java?rev=1722167&r1=1722166&r2=1722167&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_annotation.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_annotation.java Tue Dec 29 15:56:00 2015
@@ -31,7 +31,7 @@ import org.apache.uima.jcas.tcas.Annotat
  * Implements AnnotationIndex
  * replaces AnnotationIndexImpl in v2
  */
-public class FsIndex_annotation <T extends Annotation> 
+public class FsIndex_annotation <T extends AnnotationFS> 
                  extends FsIndex_iicp<T> 
                  implements AnnotationIndex<T> {
   
@@ -146,7 +146,7 @@ public class FsIndex_annotation <T exten
 
   @Override
   public FSIndex<T> withSnapshotIterators() {
-    return new FsIndex_snapshot(this);
+    return new FsIndex_snapshot<>(this);
   }
 //  public FSIndex<T> withSnapshotIterators() {
 //    return (FSIndex<T>) Proxy.newProxyInstance(

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_bag.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_bag.java?rev=1722167&r1=1722166&r2=1722167&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_bag.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_bag.java Tue Dec 29 15:56:00 2015
@@ -19,6 +19,7 @@
 
 package org.apache.uima.cas.impl;
 
+import java.util.Collection;
 import java.util.List;
 
 import org.apache.uima.cas.FSIterator;
@@ -34,7 +35,7 @@ import org.apache.uima.jcas.cas.TOP;
  * @param <T> the Java cover class type for this index, passed along to (wrapped) iterators producing Java cover classes
  * NOTE: V3 doesn't support ALLOW_DUP_ADD_TO_INDEXES
  */
-public class FsIndex_bag<T extends TOP> extends FsIndex_singletype<T> {
+public class FsIndex_bag<T extends FeatureStructure> extends FsIndex_singletype<T> {
   
 //  // package private
 //  final static boolean USE_POSITIVE_INT_SET = !FSIndexRepositoryImpl.IS_ALLOW_DUP_ADD_2_INDEXES;
@@ -83,7 +84,7 @@ public class FsIndex_bag<T extends TOP>
    * For bag indexes, compare equal only if identical addresses
    */
   @Override
-  public int compare(TOP fs1, TOP fs2) {
+  public int compare(FeatureStructure fs1, FeatureStructure fs2) {
     return (fs1 == fs2) ? 0 : (fs1.id() < fs2.id()) ? -1 : 1;
   }
 
@@ -179,8 +180,8 @@ public class FsIndex_bag<T extends TOP>
   }
 
   @Override
-  protected void bulkAddTo(List<TOP> fss) {
-    fss.addAll(this.index);
+  protected void bulkAddTo(List<T> fss) {
+    fss.addAll((Collection<? extends T>) this.index);
   }
   
   /* (non-Javadoc)

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_flat.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_flat.java?rev=1722167&r1=1722166&r2=1722167&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_flat.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_flat.java Tue Dec 29 15:56:00 2015
@@ -21,6 +21,7 @@ package org.apache.uima.cas.impl;
 
 import java.lang.reflect.Array;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Comparator;
 import java.util.ConcurrentModificationException;
 import java.util.List;
@@ -28,7 +29,6 @@ import java.util.List;
 import org.apache.uima.cas.FSIterator;
 import org.apache.uima.cas.FeatureStructure;
 import org.apache.uima.internal.util.IntVector;
-import org.apache.uima.jcas.cas.TOP;
 
 /**
  * Common part of flattened indexes, used for both snapshot iterators and 
@@ -36,14 +36,14 @@ import org.apache.uima.jcas.cas.TOP;
  *  
  * @param <T> the Java class type for this index
  */
-public class FsIndex_flat<T extends TOP> extends FsIndex_singletype<T> {
+public class FsIndex_flat<T extends FeatureStructure> extends FsIndex_singletype<T> {
 
   // The index, an array.
-  final private TOP[] indexedFSs;
+  final private FeatureStructure[] indexedFSs;
   
   final private FsIndex_iicp<T> iicp;
   
-  final private Comparator<TOP> comparator;
+  final private Comparator<FeatureStructure> comparator;
     
   FsIndex_flat(FsIndex_iicp<T> iicp) {
     super(iicp.getCASImpl(), iicp.fsIndex_singletype.getType(), iicp.fsIndex_singletype.getIndexingStrategy(),
@@ -57,9 +57,9 @@ public class FsIndex_flat<T extends TOP>
    * Flat array filled, ordered
    * @param flatArray the array to fill
    */
-  private TOP[] fillFlatArray() {
+  private FeatureStructure[] fillFlatArray() {
     
-    TOP[] a =  (TOP[]) Array.newInstance(TOP.class, iicp.size());
+    FeatureStructure[] a =  (FeatureStructure[]) Array.newInstance(FeatureStructure.class, iicp.size());
     
     FSIterator<T> it = iicp.iterator();
     int i = 0;
@@ -74,7 +74,7 @@ public class FsIndex_flat<T extends TOP>
     return a;
   }
   
-  FeatureStructureImplC[] getFlatArray() {
+  FeatureStructure[] getFlatArray() {
     return indexedFSs;
   }
 
@@ -113,8 +113,8 @@ public class FsIndex_flat<T extends TOP>
   @Override
   public T find(FeatureStructure fs) {
     if (isSorted()) {
-      for (TOP item : indexedFSs) {
-        if (comparator.compare(item,  (TOP)fs) == 0) {
+      for (FeatureStructure item : indexedFSs) {
+        if (comparator.compare(item, fs) == 0) {
           return (T) item;
         }
       }
@@ -123,7 +123,7 @@ public class FsIndex_flat<T extends TOP>
 
     // ordered case
     // r is index if found, otherwise, (-(insertion point) - 1). 
-    int r = Arrays.binarySearch(indexedFSs,  (TOP)fs, comparator);
+    int r = Arrays.binarySearch(indexedFSs, fs, comparator);
     return (r >= 0) ? (T) indexedFSs[r] : null;
   }
 
@@ -132,7 +132,7 @@ public class FsIndex_flat<T extends TOP>
     if (isSorted()) {
       Arrays.binarySearch((T[]) indexedFSs, 0, indexedFSs.length, fs, (T fs1, T fs2) -> fs1 == fs2 ? 0 : -1);
     } else {
-      for (FeatureStructureImplC item : indexedFSs) {
+      for (FeatureStructure item : indexedFSs) {
         if (fs == item) {
           return (T) item;
         }
@@ -142,7 +142,7 @@ public class FsIndex_flat<T extends TOP>
 
     // ordered case
     // r is index if found, otherwise, (-(insertion point) - 1). 
-    int r = Arrays.binarySearch(indexedFSs, (FeatureStructureImplC) fs, (FeatureStructureImplC f1, FeatureStructureImplC f2) -> Integer.compare(f1.id(), f2.id()));
+    int r = Arrays.binarySearch(indexedFSs, fs, (f1, f2) -> Integer.compare(f1.id(), f2.id()));
     return (r == 0) ? fs : null;    
   }
 
@@ -164,13 +164,13 @@ public class FsIndex_flat<T extends TOP>
    * @see org.apache.uima.cas.impl.FsIndex_singletype#bulkAddTo(java.util.List)
    */
   @Override
-  protected void bulkAddTo(List<TOP> v) {
-    v.addAll(Arrays.asList(indexedFSs));
+  protected void bulkAddTo(List<T> v) {
+    v.addAll((Collection<? extends T>) Arrays.asList(indexedFSs));
   }
   
   // maybe needed for backwards compatibility for now
   protected void bulkAddTo(IntVector v) {
-    Arrays.stream(indexedFSs).mapToInt(FeatureStructureImplC::id).forEach(v::add);
+    Arrays.stream(indexedFSs).mapToInt(FeatureStructure::id).forEach(v::add);
   }
   
   /**
@@ -178,13 +178,7 @@ public class FsIndex_flat<T extends TOP>
    */    
   @Override
   public int compare(FeatureStructure fs1, FeatureStructure fs2) {
-    return comparator.compare((TOP)fs1,  (TOP)fs2);
+    return comparator.compare(fs1,  fs2);
   }
-  
-  @Override
-  public int compare(TOP fs1, TOP fs2) {
-    return comparator.compare(fs1, fs2);
-  }
-
 
 }

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_iicp.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_iicp.java?rev=1722167&r1=1722166&r2=1722167&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_iicp.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_iicp.java Tue Dec 29 15:56:00 2015
@@ -28,9 +28,9 @@ import org.apache.uima.jcas.cas.TOP;
  * This class is package private to share with FSIndexFlat
  * For Internal Use
  */  
-class FsIndex_iicp<T extends TOP> 
-          implements Comparable<FsIndex_iicp<? extends TOP>>,
-                     Comparator<T>,
+class FsIndex_iicp<T extends FeatureStructure> 
+          implements Comparable<FsIndex_iicp<? extends FeatureStructure>>,
+                     Comparator<FeatureStructure>,
                      LowLevelIndex<T> {
 
 //  private final static boolean DEBUG = false;
@@ -49,7 +49,7 @@ class FsIndex_iicp<T extends TOP>
    * 
    * This is set up lazily on first need, to avoid extra work when won't be accessed
    */
-  ArrayList<FsIndex_singletype<TOP>> cachedSubFsLeafIndexes = null;
+  ArrayList<FsIndex_singletype<FeatureStructure>> cachedSubFsLeafIndexes = null;
   
   // VOLATILE to permit double-checked locking technique
   private volatile boolean isIteratorCacheSetup = false;
@@ -74,7 +74,7 @@ class FsIndex_iicp<T extends TOP>
     } else {  
       int len = Math.min(3,  cachedSubFsLeafIndexes.size());
       for (int i = 0; i < len; i++) {
-        FsIndex_singletype<TOP> lii = cachedSubFsLeafIndexes.get(i); 
+        FsIndex_singletype<FeatureStructure> lii = cachedSubFsLeafIndexes.get(i); 
         sb.append("  cache ").append(i++);
         sb.append("  ").append(lii).append('\n');
       }
@@ -136,7 +136,7 @@ class FsIndex_iicp<T extends TOP>
       final int indexKind = this.getIndexingStrategy();
       int size = (indexKind == FSIndex.DEFAULT_BAG_INDEX) ? 1 : 1 + (int) rootType.getAllSubtypes().count();
 
-      final ArrayList<FsIndex_singletype<TOP>> tempSubIndexCache = new ArrayList<FsIndex_singletype<TOP>>();
+      final ArrayList<FsIndex_singletype<FeatureStructure>> tempSubIndexCache = new ArrayList<FsIndex_singletype<FeatureStructure>>();
       sortedTypeCodes = (indexKind == FSIndex.SORTED_INDEX) ? new int[size] : null;
 
       initOneType(rootType, tempSubIndexCache, indexKind);
@@ -170,11 +170,11 @@ class FsIndex_iicp<T extends TOP>
     }  // end of synchronized block
   }
   
-  private void initOneType(TypeImpl ti, ArrayList<FsIndex_singletype<TOP>> cache, int indexKind) {
-    ArrayList<FsIndex_iicp<TOP>> ift = 
+  private void initOneType(TypeImpl ti, ArrayList<FsIndex_singletype<FeatureStructure>> cache, int indexKind) {
+    ArrayList<FsIndex_iicp<FeatureStructure>> ift = 
         fsIndexRepositoryImpl.getIndexesForType(ti.getCode()).indexesForType;
     
-    FsIndex_singletype<TOP> singleIndex = ift.get(ift.indexOf(this)).fsIndex_singletype;
+    FsIndex_singletype<FeatureStructure> singleIndex = ift.get(ift.indexOf(this)).fsIndex_singletype;
     
     if (indexKind == FSIndex.SORTED_INDEX) {
       sortedTypeCodes[cache.size()] = singleIndex.getTypeCode();
@@ -198,7 +198,7 @@ class FsIndex_iicp<T extends TOP>
    * @see java.lang.Comparable#compareTo(Object)
    * 
    */
-  public int compareTo(FsIndex_iicp<? extends TOP> cp) {
+  public int compareTo(FsIndex_iicp<? extends FeatureStructure> cp) {
     final int typeCode1 = ((TypeImpl) this.fsIndex_singletype.getType()).getCode();
     final int typeCode2 = ((TypeImpl) cp.fsIndex_singletype.getType()).getCode();
     if (typeCode1 < typeCode2) {
@@ -222,7 +222,7 @@ class FsIndex_iicp<T extends TOP>
   
   public boolean isEmpty() {
     createIndexIteratorCache();  
-    for (FsIndex_singletype<TOP> index : cachedSubFsLeafIndexes) {
+    for (FsIndex_singletype<FeatureStructure> index : cachedSubFsLeafIndexes) {
       if (index.size() > 0) {
         return false;
       }
@@ -232,7 +232,7 @@ class FsIndex_iicp<T extends TOP>
   
   boolean has1OrMoreEntries() {
     createIndexIteratorCache();  // does nothing if already created
-    final ArrayList<FsIndex_singletype<TOP>> localIc = this.cachedSubFsLeafIndexes;
+    final ArrayList<FsIndex_singletype<FeatureStructure>> localIc = this.cachedSubFsLeafIndexes;
     final int len = localIc.size();
     for (int i = 0; i < len; i++) {
       if (localIc.get(i).size() > 0) {
@@ -252,7 +252,7 @@ class FsIndex_iicp<T extends TOP>
    * @return a guess at the size, done quickly
    */
   int guessedSize() {
-    final ArrayList<FsIndex_singletype<TOP>> localIc = this.cachedSubFsLeafIndexes;
+    final ArrayList<FsIndex_singletype<FeatureStructure>> localIc = this.cachedSubFsLeafIndexes;
     final int len = localIc.size();
     final int lim = Math.min(3, len);
     int size = 0;
@@ -320,11 +320,11 @@ class FsIndex_iicp<T extends TOP>
 //      }
 //    }
   
-  FsIndex_singletype<TOP> getNoSubtypeIndexForType(Type type) {
+  <T extends FeatureStructure> FsIndex_singletype<T> getNoSubtypeIndexForType(Type type) {
     createIndexIteratorCache();
-    for (FsIndex_singletype<TOP> noSubtypeIndex : cachedSubFsLeafIndexes) {
+    for (FsIndex_singletype<FeatureStructure> noSubtypeIndex : cachedSubFsLeafIndexes) {
       if (noSubtypeIndex.getType() == type) {
-        return noSubtypeIndex;
+        return (FsIndex_singletype<T>) noSubtypeIndex;
       }
     }
     return null;
@@ -365,12 +365,7 @@ class FsIndex_iicp<T extends TOP>
   public int compare(FeatureStructure fs1, FeatureStructure fs2) {
     return fsIndex_singletype.compare(fs1,  fs2);
   }
-  
-  @Override
-  public int compare(TOP fs1, TOP fs2) {
-    return fsIndex_singletype.compare(fs1,  fs2);
-  }
-  
+    
   @Override
   public boolean contains(FeatureStructure fs) {
     return find(fs) != null;
@@ -380,7 +375,7 @@ class FsIndex_iicp<T extends TOP>
   public T find(FeatureStructure fs) {
     createIndexIteratorCache();  // does nothing if already created
     
-    for (FsIndex_singletype<TOP> idx : cachedSubFsLeafIndexes) {
+    for (FsIndex_singletype<FeatureStructure> idx : cachedSubFsLeafIndexes) {
      FeatureStructure result = idx.find(fs);
       if (result != null) {
         return (T) result;
@@ -403,7 +398,7 @@ class FsIndex_iicp<T extends TOP>
     createIndexIteratorCache();  // may not be needed here   
    
     return (cachedSubFsLeafIndexes.size() == 1)
-           ? fsIndex_singletype.iterator()
+           ? (FSIterator<T>) fsIndex_singletype.iterator()
            : fsIndex_singletype.isSorted()
              ? new FsIterator_subtypes_ordered<T>(this)
              : new FsIterator_aggregation_common<T>(new FsIterator_subtypes_unordered<T>(this).iterators, fsIndex_singletype);

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_set_sorted.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_set_sorted.java?rev=1722167&r1=1722166&r2=1722167&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_set_sorted.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_set_sorted.java Tue Dec 29 15:56:00 2015
@@ -52,9 +52,13 @@ import org.apache.uima.jcas.cas.TOP;
  * 
  * @param <T> the Java class type for this index
  */
-public class FsIndex_set_sorted<T extends TOP> extends FsIndex_singletype<T> {
+public class FsIndex_set_sorted<T extends FeatureStructure> extends FsIndex_singletype<T> {
   
-  final private SortedSet<TOP> ss = new SortedSet<TOP>() {
+  /**
+   * This impl of sorted set interface allows using the bulk add operation implemented in Java's 
+   * TreeSet - that tests if the argument being passed in is an instance of SortedSet and does a fast insert.
+   */
+  final private SortedSet<T> ss = new SortedSet<T>() {
     
     @Override
     public int size() { return itemsToBeAdded.size(); }
@@ -63,19 +67,19 @@ public class FsIndex_set_sorted<T extend
     @Override
     public boolean contains(Object o) { throw new UnsupportedOperationException(); }
     @Override
-    public Iterator<TOP> iterator() { return itemsToBeAdded.iterator(); }
+    public Iterator<T> iterator() { return itemsToBeAdded.iterator(); }
     @Override
     public Object[] toArray() { throw new UnsupportedOperationException(); }
     @Override
     public <U> U[] toArray(U[] a) { throw new UnsupportedOperationException(); }
     @Override
-    public boolean add(TOP e) { throw new UnsupportedOperationException(); }
+    public boolean add(T e) { throw new UnsupportedOperationException(); }
     @Override
     public boolean remove(Object o) { throw new UnsupportedOperationException(); }
     @Override
     public boolean containsAll(Collection<?> c) { throw new UnsupportedOperationException(); }
     @Override
-    public boolean addAll(Collection<? extends TOP> c) { throw new UnsupportedOperationException(); }
+    public boolean addAll(Collection<? extends T> c) { throw new UnsupportedOperationException(); }
     @Override
     public boolean retainAll(Collection<?> c) { throw new UnsupportedOperationException(); }
     @Override
@@ -83,28 +87,30 @@ public class FsIndex_set_sorted<T extend
     @Override
     public void clear() { throw new UnsupportedOperationException(); }
     @Override
-    public Comparator<TOP> comparator() { return comparator; }
+    public Comparator<? super T> comparator() { return comparator; }
     @Override
-    public SortedSet<TOP> subSet(TOP fromElement, TOP toElement) { throw new UnsupportedOperationException(); }
+    public SortedSet<T> subSet(FeatureStructure fromElement, FeatureStructure toElement) { throw new UnsupportedOperationException(); }
     @Override
-    public SortedSet<TOP> headSet(TOP toElement) { throw new UnsupportedOperationException(); }
+    public SortedSet<T> headSet(FeatureStructure toElement) { throw new UnsupportedOperationException(); }
     @Override
-    public SortedSet<TOP> tailSet(TOP fromElement) { throw new UnsupportedOperationException(); }
+    public SortedSet<T> tailSet(FeatureStructure fromElement) { throw new UnsupportedOperationException(); }
     @Override
-    public TOP first() { throw new UnsupportedOperationException(); }
+    public T first() { throw new UnsupportedOperationException(); }
     @Override
-    public TOP last() { throw new UnsupportedOperationException(); }     
+    public T last() { throw new UnsupportedOperationException(); }  
+    
+    
   };
 
 
   // The index, a NavigableSet. 
-  final private TreeSet<TOP> indexedFSs;
+  final private TreeSet<FeatureStructure> indexedFSs;
   
-  final private Comparator<TOP> comparator;
+  final private Comparator<FeatureStructure> comparator;
   
-  final private ArrayList<TOP> itemsToBeAdded = new ArrayList<>();  // to batch the adds
+  final private ArrayList<T> itemsToBeAdded = new ArrayList<>();  // to batch the adds
   
-  private TOP largestItem = null;
+  private T largestItem = null;
    
   FsIndex_set_sorted(CASImpl cas, Type type, int indexType, FSIndexComparator comparatorForIndexSpecs, boolean useSorted) {
     super(cas, type, indexType, comparatorForIndexSpecs);
@@ -120,7 +126,7 @@ public class FsIndex_set_sorted<T extend
               return (c == 0) ? (Integer.compare(o1.id(), o2.id())) : c;} 
           : (o1, o2) -> compare(o1,  o2);
     }          
-    this.indexedFSs = new TreeSet<TOP>(comparator);
+    this.indexedFSs = new TreeSet<FeatureStructure>(comparator);
   }
 
   @Override
@@ -178,7 +184,7 @@ public class FsIndex_set_sorted<T extend
       }
       
       maybeProcessBulkAdds(); // we do this so the return value from add is accurate
-      return this.indexedFSs.add((TOP)fs);
+      return this.indexedFSs.add(fs);
     }
   }
 
@@ -201,14 +207,13 @@ public class FsIndex_set_sorted<T extend
    * @return an arbitrary fs that matches 
    */
   @Override
-  public T find(FeatureStructure templateKeyIn) {
+  public T find(FeatureStructure templateKey) {
     maybeProcessBulkAdds();
-    TOP templateKey = (TOP) templateKeyIn;
     if (null == templateKey || this.indexedFSs.size() == 0) {
       return null;
     }
     T found;
-    TOP fs1GEfs = this.indexedFSs.ceiling(templateKey);
+    FeatureStructure fs1GEfs = this.indexedFSs.ceiling(templateKey);
     
     if (fs1GEfs == null) {  // then all elements are less-that the templateKey
       found = (T) indexedFSs.lower(templateKey);  //highest of elements less-than the template key
@@ -271,9 +276,9 @@ public class FsIndex_set_sorted<T extend
   }
   
   @Override
-  protected void bulkAddTo(List<TOP> v) {
+  protected void bulkAddTo(List<T> v) {
     maybeProcessBulkAdds();
-    v.addAll(indexedFSs);
+    v.addAll((Collection<? extends T>) indexedFSs);
   }
   
 //  @Override
@@ -281,9 +286,9 @@ public class FsIndex_set_sorted<T extend
 //    this.indexedFSs.stream().mapToInt(fs -> ((FeatureStructureImplC)fs).id()).forEach(v::add);
 //  }
   
-  NavigableSet<TOP> getNavigableSet() { //used by FsIterator_sorted to compute various derivitive nav sets
+  NavigableSet<T> getNavigableSet() { //used by FsIterator_sorted to compute various derivitive nav sets
     maybeProcessBulkAdds();
-    return indexedFSs;
+    return (NavigableSet<T>) indexedFSs;
   }
    
   @Override

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_singletype.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_singletype.java?rev=1722167&r1=1722166&r2=1722167&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_singletype.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_singletype.java Tue Dec 29 15:56:00 2015
@@ -28,7 +28,6 @@ import org.apache.uima.cas.FeatureStruct
 import org.apache.uima.cas.Type;
 import org.apache.uima.cas.admin.FSIndexComparator;
 import org.apache.uima.cas.admin.LinearTypeOrder;
-import org.apache.uima.jcas.cas.TOP;
 
 /**
  * The common (among all index kinds - set, sorted, bag) info for an index over 1 type (excluding subtypes)
@@ -37,7 +36,7 @@ import org.apache.uima.jcas.cas.TOP;
  * 
  * @param <T> the Java cover class type for this index, passed along to (wrapped) iterators producing Java cover classes
  */
-public abstract class FsIndex_singletype<T extends TOP> implements Comparator<TOP>, LowLevelIndex<T> {
+public abstract class FsIndex_singletype<T extends FeatureStructure> implements Comparator<FeatureStructure>, LowLevelIndex<T> {
 
   private final static String[] indexTypes = new String[] {"Sorted", "Set", "Bag", "DefaultBag"}; 
 
@@ -151,7 +150,7 @@ public abstract class FsIndex_singletype
   
   @Override
   public FSIterator<T> iterator(FeatureStructure initialPositionFs) {
-    FSIterator<T> fsIt = iterator();
+    FSIterator<T> fsIt = (FSIterator<T>) iterator();
     fsIt.moveTo(initialPositionFs);
     return fsIt;
   }
@@ -188,17 +187,12 @@ public abstract class FsIndex_singletype
   public int compare(int fs1, int fs2) {
     return compare(casImpl.getFsFromId_checked(fs1), casImpl.getFsFromId_checked(fs2));
   }
-  
-  @Override
-  public int compare(FeatureStructure fs1, FeatureStructure fs2) {
-    return compare((TOP) fs1, (TOP) fs2);
-  }
-  
+    
   /**
    * @see org.apache.uima.cas.FSIndex#compare(T, T)
    */    
   @Override
-  public int compare(TOP fs1, TOP fs2) {
+  public int compare(FeatureStructure fs1, FeatureStructure fs2) {
   
     if (fs1 == fs2) {
       return 0;
@@ -319,7 +313,7 @@ public abstract class FsIndex_singletype
    * For serialization: get all the items in this index and bulk add to an List<T>
    * @param v the set of items to add
    */
-  protected abstract void bulkAddTo(List<TOP> v);
+  protected abstract void bulkAddTo(List<T> v);
   
   @Override
   public LowLevelIterator<T> ll_iterator(boolean ambiguous) {

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_snapshot.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_snapshot.java?rev=1722167&r1=1722166&r2=1722167&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_snapshot.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FsIndex_snapshot.java Tue Dec 29 15:56:00 2015
@@ -29,7 +29,7 @@ import org.apache.uima.jcas.cas.TOP;
  * Implementation of light-weight wrapper of normal indexes, which support special kinds of iterators
  *   base on the setting of IteratorExtraFunction
  */
-public class FsIndex_snapshot <T extends TOP> implements FSIndex<T> {
+public class FsIndex_snapshot <T extends FeatureStructure> implements FSIndex<T> {
   
   static final boolean ORDERED = false;
   static final boolean UNORDERED = true;