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/01/22 04:14:07 UTC

svn commit: r1779769 [1/2] - in /uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src: main/java/org/apache/uima/ main/java/org/apache/uima/cas/ main/java/org/apache/uima/cas/impl/ main/java/org/apache/uima/jcas/cas/ main/resources/org/apache/uima/ te...

Author: schor
Date: Sun Jan 22 04:14:07 2017
New Revision: 1779769

URL: http://svn.apache.org/viewvc?rev=1779769&view=rev
Log:
[UIMA-5272] convert 3 new built-in types to semi-built-in for better backward compatibility.  Remove special case accomodation code.

Added:
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/resources/org/apache/uima/semibuiltins.xml
Modified:
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/UimaSerializable.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/BuiltinTypeKinds.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemConstants.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/FSArrayList.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/FSHashSet.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/IntegerArrayList.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/test/java/org/apache/uima/jcas/test/CASTestSetup.java

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/UimaSerializable.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/UimaSerializable.java?rev=1779769&r1=1779768&r2=1779769&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/UimaSerializable.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/UimaSerializable.java Sun Jan 22 04:14:07 2017
@@ -20,7 +20,6 @@
 package org.apache.uima;
 
 import org.apache.uima.cas.impl.FeatureStructureImplC;
-import org.apache.uima.jcas.cas.FSArrayList;
 
 /**
  * This interface is implemented by JCas classes that need to be called by the 

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/BuiltinTypeKinds.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/BuiltinTypeKinds.java?rev=1779769&r1=1779768&r2=1779769&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/BuiltinTypeKinds.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/BuiltinTypeKinds.java Sun Jan 22 04:14:07 2017
@@ -67,8 +67,8 @@ public class BuiltinTypeKinds {
         CAS.TYPE_NAME_LONG,
         CAS.TYPE_NAME_FLOAT,
         CAS.TYPE_NAME_DOUBLE,
-        CAS.TYPE_NAME_STRING,
-        CAS.TYPE_NAME_JAVA_OBJECT
+        CAS.TYPE_NAME_STRING
+//        CAS.TYPE_NAME_JAVA_OBJECT
         );
     
     Misc.addAll(creatableArrays,  
@@ -95,10 +95,10 @@ public class BuiltinTypeKinds {
         CAS.TYPE_NAME_NON_EMPTY_STRING_LIST,
         CAS.TYPE_NAME_TOP,
         CAS.TYPE_NAME_ANNOTATION_BASE,
-        CAS.TYPE_NAME_ANNOTATION,
-        CAS.TYPE_NAME_FS_ARRAY_LIST,
-        CAS.TYPE_NAME_INT_ARRAY_LIST,
-        CAS.TYPE_NAME_FS_HASH_SET
+        CAS.TYPE_NAME_ANNOTATION
+//        CAS.TYPE_NAME_FS_ARRAY_LIST,
+//        CAS.TYPE_NAME_INT_ARRAY_LIST,
+//        CAS.TYPE_NAME_FS_HASH_SET
     );    
     creatableBuiltinJCas.addAll(creatableArrays);
  

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java?rev=1779769&r1=1779768&r2=1779769&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/CAS.java Sun Jan 22 04:14:07 2017
@@ -126,20 +126,20 @@ public interface CAS extends AbstractCas
    */
   static final String TYPE_NAME_DOUBLE = UIMA_CAS_PREFIX + "Double";
 
-  /**
-   * Java Object type
-   */
-  static final String TYPE_NAME_JAVA_OBJECT = UIMA_CAS_PREFIX + "JavaObject";
-  
-  /**
-   * FS Array List
-   */
-  static final String TYPE_NAME_FS_ARRAY_LIST = UIMA_CAS_PREFIX + "FSArrayList";
-
-  /**
-   * int Array List
-   */
-  static final String TYPE_NAME_INT_ARRAY_LIST = UIMA_CAS_PREFIX + "IntegerArrayList";
+//  /**
+//   * Java Object type
+//   */
+//  static final String TYPE_NAME_JAVA_OBJECT = UIMA_CAS_PREFIX + "JavaObject";
+//  
+//  /**
+//   * FS Array List
+//   */
+//  static final String TYPE_NAME_FS_ARRAY_LIST = UIMA_CAS_PREFIX + "FSArrayList";
+//
+//  /**
+//   * int Array List
+//   */
+//  static final String TYPE_NAME_INT_ARRAY_LIST = UIMA_CAS_PREFIX + "IntegerArrayList";
 
   /**
    * ArrayBase type.
@@ -191,10 +191,10 @@ public interface CAS extends AbstractCas
    */
   static final String TYPE_NAME_DOUBLE_ARRAY = UIMA_CAS_PREFIX + "DoubleArray";
 
-  /**
-   * FSHashSet type
-   */
-  static final String TYPE_NAME_FS_HASH_SET = UIMA_CAS_PREFIX +  "FSHashSet"; 
+//  /**
+//   * FSHashSet type
+//   */
+//  static final String TYPE_NAME_FS_HASH_SET = UIMA_CAS_PREFIX +  "FSHashSet"; 
   /**
    * Sofa type.
    */

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java?rev=1779769&r1=1779768&r2=1779769&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes.java Sun Jan 22 04:14:07 2017
@@ -1585,9 +1585,9 @@ public class BinaryCasSerDes {
 
     for (int heapIndex = startPos; heapIndex < heapsz; heapIndex += getFsSpaceReq(fs, type)) {
       int typecode = heap.heap[heapIndex];
-      if (isBeforeV3 && typecode > TypeSystemConstants.lastBuiltinV2TypeCode) {
-        typecode = typecode + TypeSystemConstants.numberOfNewBuiltInsSinceV2;
-      }
+//      if (isBeforeV3 && typecode > TypeSystemConstants.lastBuiltinV2TypeCode) {
+//        typecode = typecode + TypeSystemConstants.numberOfNewBuiltInsSinceV2;
+//      }
       type = tsi.getTypeForCode(heap.heap[heapIndex]);
       if (type == null) {
         throw new CASRuntimeException(CASRuntimeException.deserialized_type_not_found, Integer.valueOf(heap.heap[heapIndex]));

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java?rev=1779769&r1=1779768&r2=1779769&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes4.java Sun Jan 22 04:14:07 2017
@@ -1785,12 +1785,12 @@ public class BinaryCasSerDes4 implements
       if (TRACE_DES) System.out.println("Form4Deser heapStart: " + heapStart + "  heapEnd: " + heapEnd);
       for (int iHeap = heapStart; iHeap < heapEnd; iHeap += type.getFsSpaceReq(arraySize)) {
         final int typeCode = readVnumber(typeCode_dis);
-        final int adjTypeCode = typeCode + ((this.bcsd.isBeforeV3 && typeCode > TypeSystemConstants.lastBuiltinV2TypeCode) 
-            ? TypeSystemConstants.numberOfNewBuiltInsSinceV2
-            : 0);
-         type = ts.getTypeForCode(adjTypeCode);
+//        final int adjTypeCode = typeCode + ((this.bcsd.isBeforeV3 && typeCode > TypeSystemConstants.lastBuiltinV2TypeCode) 
+//            ? TypeSystemConstants.numberOfNewBuiltInsSinceV2
+//            : 0);
+         type = ts.getTypeForCode(typeCode);
         
-        prevFs = prevFsByType[adjTypeCode]; // could be null;
+        prevFs = prevFsByType[typeCode]; // could be null;
         prevFsRefs = getPrevFsRef(type); // null or int[], only for things having fsrefs (array or not)
         
         if (type.isArray()) {
@@ -1869,7 +1869,7 @@ public class BinaryCasSerDes4 implements
 //        fs2seq.put(currentFs, s2);  // 1 origin to match v2
         seq2fs.put(s2, currentFs);
         
-        prevFsByType[adjTypeCode] = currentFs;
+        prevFsByType[typeCode] = currentFs;
       }
       
       csds.setHeapEnd(heapEnd);

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java?rev=1779769&r1=1779768&r2=1779769&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java Sun Jan 22 04:14:07 2017
@@ -1808,11 +1808,11 @@ public class BinaryCasSerDes6 implements
                          ? tgtType.getFsSpaceReq(lastArrayLength)
                          : 0) {
       final int tgtTypeCode = readVnumber(typeCode_dis); // get type code
-      final int adjTgtTypeCode = tgtTypeCode + ((this.bcsd.isBeforeV3 && tgtTypeCode > TypeSystemConstants.lastBuiltinV2TypeCode) 
-          ? TypeSystemConstants.numberOfNewBuiltInsSinceV2
-          : 0);
-      tgtType = (isTypeMapping ? tgtTs : srcTs).getTypeForCode(adjTgtTypeCode); 
-      final TypeImpl srcType = isTypeMapping ? typeMapper.mapTypeCodeTgt2Src(adjTgtTypeCode) : tgtType;
+//      final int adjTgtTypeCode = tgtTypeCode + ((this.bcsd.isBeforeV3 && tgtTypeCode > TypeSystemConstants.lastBuiltinV2TypeCode) 
+//          ? TypeSystemConstants.numberOfNewBuiltInsSinceV2
+//          : 0);
+      tgtType = (isTypeMapping ? tgtTs : srcTs).getTypeForCode(tgtTypeCode); 
+      final TypeImpl srcType = isTypeMapping ? typeMapper.mapTypeCodeTgt2Src(tgtTypeCode) : tgtType;
       
       final boolean storeIt = (srcType != null);
       // A receiving client from a service always
@@ -1839,7 +1839,7 @@ public class BinaryCasSerDes6 implements
  
       if (TRACE_DES) {
         System.out.format("Des: fsnbr %,4d fsid %,4d adjTgtTypeCode: %,3d %13s srcTypeCode: %s%n", 
-            nbrFSs, cas.getLastUsedFsId() + 1, adjTgtTypeCode, tgtType.getShortName(),  (null == srcType) ? "<null>" : Integer.toString(srcType.getCode()));
+            nbrFSs, cas.getLastUsedFsId() + 1, tgtTypeCode, tgtType.getShortName(),  (null == srcType) ? "<null>" : Integer.toString(srcType.getCode()));
       }
 
       if (tgtType.isArray()) {

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemConstants.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemConstants.java?rev=1779769&r1=1779768&r2=1779769&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemConstants.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemConstants.java Sun Jan 22 04:14:07 2017
@@ -71,14 +71,14 @@ public interface TypeSystemConstants {
   static final int annotTypeCode = 35;
   static final int docTypeCode = 36;  // DocumentAnnotation
 
-  static final int lastBuiltinV2TypeCode = 36;
+//  static final int lastBuiltinV2TypeCode = 36;
 
   // new v3 type codes.. Above codes match v2
-  static final int fsArrayListTypeCode = 37;
-  static final int intArrayListTypeCode = 38;
-  static final int fsHashSetTypeCode = 39;
+//  static final int fsArrayListTypeCode = 37;
+//  static final int intArrayListTypeCode = 38;
+//  static final int fsHashSetTypeCode = 39;
 
-  static final int numberOfNewBuiltInsSinceV2 = 3;
+//  static final int numberOfNewBuiltInsSinceV2 = 3;
 
 //  static final int javaObjectTypeCode = 37;
 //  static final int javaObjectArrayTypeCode = 38;

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java?rev=1779769&r1=1779768&r2=1779769&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java Sun Jan 22 04:14:07 2017
@@ -310,9 +310,10 @@ public class TypeSystemImpl implements T
   public final TypeImpl_list stringNeListType;
   public final TypeImpl_list fsNeListType;
 
-  public final TypeImpl      fsArrayListType;
-  public final TypeImpl      intArrayListType;
-  public final TypeImpl      fsHashSetType;
+  // no longer built-in for better backwards compatibility
+//  public final TypeImpl      fsArrayListType;
+//  public final TypeImpl      intArrayListType;
+//  public final TypeImpl      fsHashSetType;
             
 //  /**
 //   * List indexed by typecode
@@ -515,14 +516,14 @@ public class TypeSystemImpl implements T
     docType = new TypeImpl_annot(CAS.TYPE_NAME_DOCUMENT_ANNOTATION, this, annotType, Annotation.class);
     langFeat = (FeatureImpl) addFeature(CAS.FEATURE_BASE_NAME_LANGUAGE, docType, stringType, false);
     
-    fsArrayListType = new TypeImpl(CAS.TYPE_NAME_FS_ARRAY_LIST, this, topType);
-    addFeature(CAS.FEATURE_BASE_NAME_FS_ARRAY, fsArrayListType, fsArrayType);
-    
-    intArrayListType = new TypeImpl(CAS.TYPE_NAME_INT_ARRAY_LIST, this, topType);
-    addFeature(CAS.FEATURE_BASE_NAME_INT_ARRAY, intArrayListType, intArrayType);
-    
-    fsHashSetType = new TypeImpl(CAS.TYPE_NAME_FS_HASH_SET, this, topType);
-    addFeature(CAS.FEATURE_BASE_NAME_FS_ARRAY, fsHashSetType, fsArrayType);
+//    fsArrayListType = new TypeImpl(CAS.TYPE_NAME_FS_ARRAY_LIST, this, topType);
+//    addFeature(CAS.FEATURE_BASE_NAME_FS_ARRAY, fsArrayListType, fsArrayType);
+//    
+//    intArrayListType = new TypeImpl(CAS.TYPE_NAME_INT_ARRAY_LIST, this, topType);
+//    addFeature(CAS.FEATURE_BASE_NAME_INT_ARRAY, intArrayListType, intArrayType);
+//    
+//    fsHashSetType = new TypeImpl(CAS.TYPE_NAME_FS_HASH_SET, this, topType);
+//    addFeature(CAS.FEATURE_BASE_NAME_FS_ARRAY, fsHashSetType, fsArrayType);
 
 //    javaObjectType = new TypeImpl_javaObject(CAS.TYPE_NAME_JAVA_OBJECT, this, topType, Object.class);
 //    javaObjectArrayType = addArrayType(javaObjectType, null, HEAP_STORED_ARRAY, JavaObjectArray.class);
@@ -619,9 +620,9 @@ public class TypeSystemImpl implements T
     setTypeFinal(stringNeListType);
     setTypeFinal(intNeListType);
     
-    setTypeFinal(fsArrayListType);
-    setTypeFinal(intArrayListType);
-    setTypeFinal(fsHashSetType);
+//    setTypeFinal(fsArrayListType);
+//    setTypeFinal(intArrayListType);
+//    setTypeFinal(fsHashSetType);
 
     listBaseType.setFeatureFinal();
     fsListType.setFeatureFinal();
@@ -639,9 +640,9 @@ public class TypeSystemImpl implements T
     annotType.setFeatureFinal();
     annotBaseType.setFeatureFinal();
     
-    fsArrayListType.setFeatureFinal();
-    intListType.setFeatureFinal();
-    fsHashSetType.setFeatureFinal();
+//    fsArrayListType.setFeatureFinal();
+//    intListType.setFeatureFinal();
+//    fsHashSetType.setFeatureFinal();
 
 //    allTypesForByteCodeGen = new TypeImpl[] {
 //        booleanType, 
@@ -2023,7 +2024,7 @@ public class TypeSystemImpl implements T
     case CAS.TYPE_NAME_FLOAT:
     case CAS.TYPE_NAME_DOUBLE:
     case CAS.TYPE_NAME_STRING:
-    case CAS.TYPE_NAME_JAVA_OBJECT:
+//    case CAS.TYPE_NAME_JAVA_OBJECT:
 //    case CAS.TYPE_NAME_MAP:
 //    case CAS.TYPE_NAME_LIST:
       return false;

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/FSArrayList.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/FSArrayList.java?rev=1779769&r1=1779768&r2=1779769&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/FSArrayList.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/FSArrayList.java Sun Jan 22 04:14:07 2017
@@ -1,824 +1,831 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.uima.jcas.cas;
-
-import java.util.AbstractList;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.RandomAccess;
-import java.util.Spliterator;
-import java.util.function.Consumer;
-import java.util.function.Predicate;
-import java.util.function.UnaryOperator;
-import java.util.stream.Stream;
-
-import org.apache.uima.UimaSerializableFSs;
-import org.apache.uima.cas.CASRuntimeException;
-import org.apache.uima.cas.CommonArrayFS;
-import org.apache.uima.cas.FeatureStructure;
-import org.apache.uima.cas.impl.CASImpl;
-import org.apache.uima.cas.impl.FeatureStructureImplC;
-import org.apache.uima.cas.impl.TypeImpl;
-import org.apache.uima.cas.impl.TypeSystemImpl;
-import org.apache.uima.jcas.JCas;
-import org.apache.uima.jcas.JCasRegistry;
-import org.apache.uima.util.impl.Constants;
-
-
-/**
- * An ArrayList type containing Feature Structures, for UIMA
- *   - Has all the methods of List
- *   - Implements the select(...) APIs 
- *   
- * Implementation notes:
- *   - Uses UimaSerializable APIs
- *   - two implementations of the array list:
- *     -- one uses the original FSArray, via an asList wrapper
- *     -- This is used until an add or remove operation;
- *       --- switches to ArrayList, resetting the original FSArray to null
- *       
- *   - This enables operation without creating the Java Object in use cases of deserializing and
- *     referencing when updating is not being used.
- *
- * @param <T> the generic type
- */
-public final class FSArrayList <T extends TOP> extends TOP implements 
-                                 UimaSerializableFSs, CommonArrayFS, SelectViaCopyToArray, 
-                                 List<T>, RandomAccess, Cloneable {
-
-  /** The Constant EMPTY_LIST. */
-  private final static List<? extends TOP> EMPTY_LIST = Arrays.asList(Constants.EMPTY_TOP_ARRAY);
-  /**
-   * each cover class when loaded sets an index. used in the JCas typeArray to go from the cover
-   * class or class instance to the corresponding instance of the _Type class
-   */
-  public final static int typeIndexID = JCasRegistry.register(FSArrayList.class);
-
-  /** The Constant type. */
-  public final static int type = typeIndexID;
-
-  /**
-   * used to obtain reference to the _Type instance.
-   *
-   * @return the type array index
-   */
-  // can't be factored - refs locally defined field
-  @Override
-  public int getTypeIndexID() {
-    return typeIndexID;
-  }
-
-  /** lifecycle   - starts as empty array list   - becomes non-empty when updated (add)       -- used from that point on. */
-  private final List<T> fsArrayList;
-  
-  /** lifecycle   - starts as the empty list   - set when _init_from_cas_data()   - set to null when update (add/remove) happens. */
-  private List<T> fsArrayAsList = (List<T>) EMPTY_LIST;
-  
-  /** The Constant _FI_fsArray. */
-  public static final int _FI_fsArray = TypeSystemImpl.getAdjustedFeatureOffset("fsArray");
-  
-  /**
-   * Instantiates a new FS array list.
-   */
-  // never called. Here to disable default constructor
-  @SuppressWarnings("unused")
-  private FSArrayList() {
-    fsArrayList = null;
-  }
-
-  /**
-   * Make a new ArrayList .
-   *
-   * @param jcas The JCas
-   */
-  public FSArrayList(JCas jcas) {
-    super(jcas);
-    fsArrayList = new ArrayList<>();
-
-    if (CASImpl.traceFSs) { // tracing done after array setting, skipped in super class
-      _casView.traceFSCreate(this);
-    }
-  }
-
-  /**
-   * Make a new ArrayList with an initial size .
-   *
-   * @param jcas The JCas
-   * @param length initial size
-   */
-  public FSArrayList(JCas jcas, int length) {
-    super(jcas);
-    _casView.validateArraySize(length);
-    fsArrayList = new ArrayList<>(length);
-
-    if (CASImpl.traceFSs) { // tracing done after array setting, skipped in super class
-      _casView.traceFSCreate(this);
-    }
-  }
-  
-  /**
-   * used by generator
-   * Make a new FSArrayList.
-   *
-   * @param t -
-   * @param c -
-   */
-  public FSArrayList(TypeImpl t, CASImpl c) {
-    super(t, c);  
-    
-    if (CASImpl.traceFSs) { // tracing done after array setting, skipped in super class
-      _casView.traceFSCreate(this);
-    }
-    fsArrayList = new ArrayList<>();
-  }
-
-  // *------------------*
-  // * Feature: fsArray
-  /**
-   * Gets the fs array.
-   *
-   * @return the fs array
-   */
-  /* getter for fsArray */
-  private FSArray getFsArray() { return (FSArray) _getFeatureValueNc(_FI_fsArray); }
-
-  /**
-   * Sets the fs array.
-   *
-   * @param v the new fs array
-   */
-  /* setter for fsArray */
-  private void setFsArray(FSArray v) {
-    _setFeatureValueNcWj(_FI_fsArray, v); }
-
-  /**
-   * Maybe start using array list.
-   */
-  private void maybeStartUsingArrayList() {
-    if (fsArrayAsList != null) {
-      fsArrayList.clear();
-      fsArrayList.addAll(fsArrayAsList);
-      fsArrayAsList = null;  // stop using this one
-    }
-  }
-  
-  /**
-   * Gta.
-   *
-   * @return the TO p[]
-   */
-  private TOP[] gta() {
-    FSArray fsa = getFsArray();
-    if (null == fsa) {
-      return Constants.EMPTY_TOP_ARRAY;
-    }
-    return fsa._getTheArray();
-  }
-  
-  /* (non-Javadoc)
-   * @see org.apache.uima.UimaSerializable#_init_from_cas_data()
-   */
-  @Override
-  public void _init_from_cas_data() {
-    // special handling to have getter and setter honor pear trampolines
-//    fsArrayAsList = (List<T>) Arrays.asList(gta());
-    final FSArray fsa = getFsArray();
-    if (null == fsa) {
-      fsArrayAsList = Collections.emptyList();
-    } else {
-    
-      fsArrayAsList = new AbstractList<T>() {
-        int i = 0;
-        @Override
-        public T get(int index) {
-          return (T) fsa.get(i);
-        }
-  
-        @Override
-        public int size() {
-          return fsa.size();
-        }      
-      };
-    }
-  }
-  
-  /* (non-Javadoc)
-   * @see org.apache.uima.UimaSerializable#_save_to_cas_data()
-   */
-  @Override
-  public void _save_to_cas_data() {
-    // if fsArraysAsList is not null, then the cas data form is still valid, do nothing
-    if (null != fsArrayAsList) {
-      return;
-    }
-    
-    // reallocate fsArray if wrong size
-    final int sz = size();
-    FSArray fsa = getFsArray();
-    if (fsa == null || fsa.size() != sz) {
-      setFsArray(fsa = new FSArray(_casView.getJCasImpl(), sz));
-    }
-    
-    // using element by element instead of bulk operations to
-    //   pick up any pear trampoline conversion and 
-    //   in case fsa was preallocated and right size, may need journaling
-    int i = 0;
-    for (TOP fs : fsArrayList) {
-      TOP currentValue = fsa.get(i);
-      if (currentValue != fs) {
-        fsa.set(i, fs); // done this way to record for journaling for delta CAS
-      }
-      i++;
-    }
-  }
-  
-  /**
-   * Gl.
-   *
-   * @return the list
-   */
-  private List<T> gl () {
-    return (null == fsArrayAsList) 
-      ? fsArrayList
-      : fsArrayAsList;
-  }
-  
-  /* (non-Javadoc)
-   * @see java.util.List#get(int)
-   */
-  @Override
-  public T get(int i) {
-    return gl().get(i);
-  }
-
-  /**
-   * updates the i-th value of the FSArrayList.
-   *
-   * @param i the i
-   * @param v the v
-   * @return the t
-   */
-  @Override
-  public T set(int i, T v) {
-    
-    if (v != null && _casView.getBaseCAS() != v._casView.getBaseCAS()) {
-      /** Feature Structure {0} belongs to CAS {1}, may not be set as the value of an array or list element in a different CAS {2}.*/
-      throw new CASRuntimeException(CASRuntimeException.FS_NOT_MEMBER_OF_CAS, v, v._casView, _casView);
-    }
-    return gl().set(i, v);
-  }
-  
-  /**
-   *  return the size of the array.
-   *
-   * @return the int
-   */
-  @Override
-  public int size() {
-    return gl().size();
-  }
-
-  /**
-   * Copy from array.
-   *
-   * @param src -
-   * @param srcPos -
-   * @param destPos -
-   * @param length -
-   * @see org.apache.uima.cas.ArrayFS#copyFromArray(FeatureStructure[], int, int, int)
-   */
-  public void copyFromArray(T[] src, int srcPos, int destPos, int length) {
-    int srcEnd = srcPos + length;
-    int destEnd = destPos + length;
-    if (srcPos < 0 ||
-        srcEnd > src.length ||
-        destEnd > size()) {
-      throw new ArrayIndexOutOfBoundsException(
-          String.format("FSArrayList.copyFromArray, srcPos: %,d destPos: %,d length: %,d",  srcPos, destPos, length));
-    }
-    for (;srcPos < srcEnd && destPos < destEnd;) {
-      set(destPos++, src[srcPos++]);
-    }
-  }
-
-  /**
-   * Copy to array.
-   *
-   * @param srcPos -
-   * @param dest -
-   * @param destPos -
-   * @param length -
-   * @see org.apache.uima.cas.ArrayFS#copyToArray(int, FeatureStructure[], int, int)
-   */
-  public void copyToArray(int srcPos, FeatureStructure[] dest, int destPos, int length) {
-    int srcEnd = srcPos + length;
-    int destEnd = destPos + length;
-    if (srcPos < 0 ||
-        srcEnd > size() ||
-        destEnd > dest.length) {
-      throw new ArrayIndexOutOfBoundsException(
-          String.format("FSArrayList.copyToArray, srcPos: %,d destPos: %,d length: %,d",  srcPos, destPos, length));
-    }
-    for (;srcPos < srcEnd && destPos < destEnd;) {
-      dest[destPos++] = get(srcPos++);
-    }
-  }
-
-  /**
-   * Note: doesn't convert to pear trampolines!.
-   *
-   * @return the feature structure[]
-   * @see org.apache.uima.cas.ArrayFS#toArray()
-   */
-  @Override
-  public T[] toArray() {
-    T[] r = (T[]) new TOP[size()];
-    copyToArray(0, r, 0, size());
-    return r;
-  }
-
-  /* (non-Javadoc)
-   * @see org.apache.uima.jcas.cas.SelectViaCopyToArray#_toArrayForSelect()
-   */
-  @Override
-  public FeatureStructure[] _toArrayForSelect() { return toArray(); }
-
-  /**
-   * Not supported, will throw UnsupportedOperationException.
-   *
-   * @param src the src
-   * @param srcPos the src pos
-   * @param destPos the dest pos
-   * @param length the length
-   */
-  @Override
-  public void copyFromArray(String[] src, int srcPos, int destPos, int length) {
-    throw new UnsupportedOperationException();
-  }
-    
-  /**
-   * Copies an array of Feature Structures to an Array of Strings.
-   * The strings are the "toString()" representation of the feature structures, 
-   * 
-   * @param srcPos
-   *                The index of the first element to copy.
-   * @param dest
-   *                The array to copy to.
-   * @param destPos
-   *                Where to start copying into <code>dest</code>.
-   * @param length
-   *                The number of elements to copy.
-   * @exception ArrayIndexOutOfBoundsException
-   *                    If <code>srcPos &lt; 0</code> or
-   *                    <code>length &gt; size()</code> or
-   *                    <code>destPos + length &gt; destArray.length</code>.
-   */
-  @Override
-  public void copyToArray(int srcPos, String[] dest, int destPos, int length) {
-    _casView.checkArrayBounds(size(), srcPos, length);
-    int i = 0;
-    for (T fs : this) {
-      dest[i + destPos] = (fs == null) ? null : fs.toString();
-      i++;
-    }
-  }
-  
-  /* 
-   * 
-   * (non-Javadoc)
-   * @see org.apache.uima.jcas.cas.CommonArray#copyValuesFrom(org.apache.uima.jcas.cas.CommonArray)
-   * no conversion to Pear trampolines done
-   */
-  @Override
-  public void copyValuesFrom(CommonArrayFS v) {
-    clear();
-    Spliterator<T> si;
-    if (v instanceof FSArrayList) {
-      si = ((FSArrayList<T>) v).spliterator();
-    } else if (v instanceof FSArray) {
-      si = (Spliterator<T>) ((FSArray)v).spliterator();
-    } else {
-      throw new ClassCastException("argument must be of class FSArray or FSArrayList");
-    } 
-    
-    si.forEachRemaining(fs -> add(fs));
-  }
-  
-  /**
-   * Convenience - create a FSArrayList from an existing FeatureStructure[].
-   *
-   * @param <N> generic type of returned FS
-   * @param jcas -
-   * @param a -
-   * @return -
-   */
-  public static <N extends TOP> FSArrayList<N> create(JCas jcas, N[] a) {
-    FSArrayList<N> fsa = new FSArrayList<>(jcas, a.length);
-    fsa.copyFromArray(a, 0, 0, a.length);  // does pear and journaling actions as needed
-    return fsa;
-  }
-  
-  /* (non-Javadoc)
-   * @see org.apache.uima.UimaSerializable#_superClone()
-   */
-  @Override
-  public FeatureStructureImplC _superClone() {return clone();}  // enable common clone
-  
-  /**
-   * Contains all.
-   *
-   * @param c -
-   * @return -
-   * @see java.util.AbstractCollection#containsAll(java.util.Collection)
-   */
-  @Override
-  public boolean containsAll(Collection<?> c) {
-    return gl().containsAll(c);
-  }
-
-  /**
-   * Checks if is empty.
-   *
-   * @return -
-   * @see java.util.ArrayList#isEmpty()
-   */
-  @Override
-  public boolean isEmpty() {
-    return gl().isEmpty();
-  }
-
-  /**
-   * Contains.
-   *
-   * @param o -
-   * @return -
-   * @see java.util.ArrayList#contains(java.lang.Object)
-   */
-  @Override
-  public boolean contains(Object o) {
-    if (!(o instanceof TOP)) return false;
-    TOP fs = (TOP) o;    
-    return gl().contains(fs);
-  }
-
-  /**
-   * Index of.
-   *
-   * @param o -
-   * @return -
-   * @see java.util.ArrayList#indexOf(java.lang.Object)
-   */
-  @Override
-  public int indexOf(Object o) {
-    if (!(o instanceof TOP)) return -1;
-    TOP fs = (TOP) o;    
-    return gl().indexOf(fs);
-  }
-
-  /**
-   * Last index of.
-   *
-   * @param o -
-   * @return -
-   * @see java.util.ArrayList#lastIndexOf(java.lang.Object)
-   */
-  @Override
-  public int lastIndexOf(Object o) {
-    if (!(o instanceof TOP)) return -1;
-    TOP fs = (TOP) o;    
-    return gl().lastIndexOf(fs);
-  }
-
-  /**
-   * To array.
-   *
-   * @param <T> the generic type
-   * @param a -
-   * @return -
-   * @see java.util.ArrayList#toArray(java.lang.Object[])
-   */
-  @Override
-  public <T> T[] toArray(T[] a) {
-    return gl().toArray(a);
-  }
-
-
-  /* (non-Javadoc)
-   * @see java.lang.Object#toString()
-   */
-  @Override
-  public String toString() {
-    final int maxLen = 10;
-    return "FSArrayList [size="
-        + size()
-        + ", fsArrayList="
-        + (fsArrayList != null ? fsArrayList.subList(0, Math.min(fsArrayList.size(), maxLen))
-            : null)
-        + ", fsArrayAsList=" + (fsArrayAsList != null
-            ? fsArrayAsList.subList(0, Math.min(fsArrayAsList.size(), maxLen)) : null)
-        + "]";
-  }
-
-  /**
-   * Adds the.
-   *
-   * @param e -
-   * @return -
-   * @see java.util.ArrayList#add(java.lang.Object)
-   */
-  @Override
-  public boolean add(T e) {
-    maybeStartUsingArrayList();
-    return fsArrayList.add(e);
-  }
-
-  /**
-   * equals means equal items, same order.
-   *
-   * @param o -
-   * @return -
-   * @see java.util.AbstractList#equals(java.lang.Object)
-   */
-  @Override
-  public boolean equals(Object o) {
-    if (!(o instanceof FSArrayList)) return false;
-    FSArrayList<T> other = (FSArrayList<T>) o;
-    if (size() != other.size()) return false;
-    
-    Iterator<T> it_other = other.iterator();
-    for (T item : this) {
-      if (!item.equals(it_other.next())) return false;
-    }
-    return true;
-  }
-
-  /**
-   * Adds the.
-   *
-   * @param index -
-   * @param element -
-   * @see java.util.ArrayList#add(int, java.lang.Object)
-   */
-  @Override
-  public void add(int index, T element) {
-    maybeStartUsingArrayList();
-    fsArrayList.add(index, element);
-  }
-
-  /**
-   * Removes the.
-   *
-   * @param index -
-   * @return -
-   * @see java.util.ArrayList#remove(int)
-   */
-  @Override
-  public T remove(int index) {
-    maybeStartUsingArrayList();
-    return fsArrayList.remove(index);
-  }
-
-  /**
-   * Removes the.
-   *
-   * @param o -
-   * @return -
-   * @see java.util.ArrayList#remove(java.lang.Object)
-   */
-  @Override
-  public boolean remove(Object o) {
-    maybeStartUsingArrayList();
-    return fsArrayList.remove(o);
-  }
-
-  /**
-   * want hashcode to depend only on equal items, regardless of what format.
-   *
-   * @return -
-   * @see java.util.AbstractList#hashCode()
-   */
-  @Override
-  public int hashCode() {
-    int hc = 1;
-    final int prime = 31;
-    for (T item : this) {
-      hc = hc * prime + item.hashCode();
-    }
-    return hc;
-  }
-
-  /**
-   * Clear.
-   *
-   * @see java.util.ArrayList#clear()
-   */
-  @Override
-  public void clear() {
-    maybeStartUsingArrayList();
-    fsArrayList.clear();
-  }
-
-  /**
-   * Adds the all.
-   *
-   * @param c -
-   * @return -
-   * @see java.util.ArrayList#addAll(java.util.Collection)
-   */
-  @Override
-  public boolean addAll(Collection<? extends T> c) {
-    maybeStartUsingArrayList();
-    return fsArrayList.addAll(c);
-  }
-
-  /**
-   * Adds the all.
-   *
-   * @param index -
-   * @param c -
-   * @return -
-   * @see java.util.ArrayList#addAll(int, java.util.Collection)
-   */
-  @Override
-  public boolean addAll(int index, Collection<? extends T> c) {
-    maybeStartUsingArrayList();
-    return fsArrayList.addAll(index, c);
-  }
-
-  /**
-   * Removes the all.
-   *
-   * @param c -
-   * @return -
-   * @see java.util.ArrayList#removeAll(java.util.Collection)
-   */
-  @Override
-  public boolean removeAll(Collection<?> c) {
-    maybeStartUsingArrayList();
-    return fsArrayList.removeAll(c);
-  }
-
-  /**
-   * Retain all.
-   *
-   * @param c -
-   * @return -
-   * @see java.util.ArrayList#retainAll(java.util.Collection)
-   */
-  @Override
-  public boolean retainAll(Collection<?> c) {
-    maybeStartUsingArrayList();
-    return fsArrayList.retainAll(c);
-  }
-
-  /**
-   * Stream.
-   *
-   * @return -
-   * @see java.util.Collection#stream()
-   */
-  @Override
-  public Stream<T> stream() {
-    return gl().stream();
-  }
-
-  /**
-   * Parallel stream.
-   *
-   * @return -
-   * @see java.util.Collection#parallelStream()
-   */
-  @Override
-  public Stream<T> parallelStream() {
-    return gl().parallelStream();
-  }
-
-  /**
-   * List iterator.
-   *
-   * @param index -
-   * @return -
-   * @see java.util.ArrayList#listIterator(int)
-   */
-  @Override
-  public ListIterator<T> listIterator(int index) {
-    return gl().listIterator(index);
-  }
-
-  /**
-   * List iterator.
-   *
-   * @return -
-   * @see java.util.ArrayList#listIterator()
-   */
-  @Override
-  public ListIterator<T> listIterator() {
-    return gl().listIterator();
-  }
-
-  /**
-   * Iterator.
-   *
-   * @return -
-   * @see java.util.ArrayList#iterator()
-   */
-  @Override
-  public Iterator<T> iterator() {
-    return gl().iterator();
-  }
-
-  /**
-   * Sub list.
-   *
-   * @param fromIndex -
-   * @param toIndex -
-   * @return -
-   * @see java.util.ArrayList#subList(int, int)
-   */
-  @Override
-  public List<T> subList(int fromIndex, int toIndex) {
-    return gl().subList(fromIndex, toIndex);
-  }
-
-  /**
-   * For each.
-   *
-   * @param action -
-   * @see java.util.ArrayList#forEach(java.util.function.Consumer)
-   */
-  @Override
-  public void forEach(Consumer<? super T> action) {
-    gl().forEach(action);
-  }
-
-  /**
-   * Spliterator.
-   *
-   * @return -
-   * @see java.util.ArrayList#spliterator()
-   */
-  @Override
-  public Spliterator<T> spliterator() {
-    return gl().spliterator();
-  }
-
-  /**
-   * Removes the if.
-   *
-   * @param filter -
-   * @return -
-   * @see java.util.ArrayList#removeIf(java.util.function.Predicate)
-   */
-  @Override
-  public boolean removeIf(Predicate<? super T> filter) {
-    maybeStartUsingArrayList();
-    return fsArrayList.removeIf(filter);
-  }
-
-  /**
-   * Replace all.
-   *
-   * @param operator -
-   * @see java.util.ArrayList#replaceAll(java.util.function.UnaryOperator)
-   */
-  @Override
-  public void replaceAll(UnaryOperator<T> operator) {
-    maybeStartUsingArrayList();
-    fsArrayList.replaceAll(operator);
-  }
-
-  /**
-   * Sort.
-   *
-   * @param c -
-   * @see java.util.ArrayList#sort(java.util.Comparator)
-   */
-  @Override
-  public void sort(Comparator<? super T> c) {
-    gl().sort(c);
-  }
-     
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+   
+/* Apache UIMA v3 - First created by JCasGen Fri Jan 20 11:55:59 EST 2017 */
+
+package org.apache.uima.jcas.cas;
+
+import java.util.AbstractList;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.RandomAccess;
+import java.util.Spliterator;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+import java.util.function.UnaryOperator;
+import java.util.stream.Stream;
+
+import org.apache.uima.UimaSerializableFSs;
+import org.apache.uima.cas.CASRuntimeException;
+import org.apache.uima.cas.CommonArrayFS;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.impl.CASImpl;
+import org.apache.uima.cas.impl.FeatureStructureImplC;
+import org.apache.uima.cas.impl.TypeImpl;
+import org.apache.uima.cas.impl.TypeSystemImpl;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.JCasRegistry;
+import org.apache.uima.jcas.cas.FSArray;
+import org.apache.uima.jcas.cas.SelectViaCopyToArray;
+import org.apache.uima.jcas.cas.TOP;
+import org.apache.uima.util.impl.Constants;
+
+
+/** An expandable array of Feature Structures, implementing the ArrayList API.
+ * Updated by JCasGen Fri Jan 20 11:55:59 EST 2017
+ * XML source: C:/au/svnCheckouts/branches/uimaj/v3-alpha/uimaj-types/src/main/descriptors/java_object_type_descriptors.xml
+ * @generated */
+
+/**
+ * <p>An ArrayList type containing Feature Structures, for UIMA
+ *   <ul><li>Has all the methods of List
+ *       <li>Implements the select(...) APIs 
+ *   </ul>
+ *   
+ * <p>Implementation notes:
+ *   <ul>
+ *     <li>Uses UimaSerializable APIs
+ *     <li>two implementations of the array list:
+ *     <ul><li>one uses the original FSArray, via an asList wrapper
+ *         <li>This is used until an add or remove operation;
+ *         <li>switches to ArrayList, resetting the original FSArray to null
+ *     </ul>
+ *       
+ *     <li>This enables operation without creating the Java Object in use cases of deserializing and
+ *     referencing when updating is not being used.
+ *   </ul>
+ *
+ * @param <T> the generic type
+ */
+
+public class FSArrayList <T extends TOP> extends TOP implements 
+                         UimaSerializableFSs, CommonArrayFS, SelectViaCopyToArray, 
+                         List<T>, RandomAccess, Cloneable {
+ 
+  /** The Constant EMPTY_LIST. */
+  private final static List<? extends TOP> EMPTY_LIST = Arrays.asList(Constants.EMPTY_TOP_ARRAY);
+
+  /** @generated
+   * @ordered 
+   */
+  @SuppressWarnings ("hiding")
+  public final static String _TypeName = "org.apache.uima.jcas.type.FSArrayList";
+  
+  /** @generated
+   * @ordered 
+   */
+  @SuppressWarnings ("hiding")
+  public final static int typeIndexID = JCasRegistry.register(FSArrayList.class);
+  /** @generated
+   * @ordered 
+   */
+  @SuppressWarnings ("hiding")
+  public final static int type = typeIndexID;
+  /** @generated
+   * @return index of the type  
+   */
+  @Override
+  public              int getTypeIndexID() {return typeIndexID;}
+ 
+  /** lifecycle   - starts as empty array list   - becomes non-empty when updated (add)       -- used from that point on. */
+  private final List<T> fsArrayList;
+  
+  /** lifecycle   - starts as the empty list   - set when _init_from_cas_data()   - set to null when update (add/remove) happens. */
+  @SuppressWarnings("unchecked")
+  private List<T> fsArrayAsList = (List<T>) EMPTY_LIST;
+
+  /* *******************
+   *   Feature Offsets *
+   * *******************/ 
+   
+  public final static String _FeatName_fsArray = "fsArray";
+
+
+  /* Feature Adjusted Offsets */
+  public final static int _FI_fsArray = TypeSystemImpl.getAdjustedFeatureOffset("fsArray");
+
+   
+  /** Never called.  Disable default constructor
+   * @generated */
+  protected FSArrayList() {
+    fsArrayList = null;
+  }
+    
+  /** Internal - constructor used by generator 
+   * @generated
+   * @param casImpl the CAS this Feature Structure belongs to
+   * @param type the type of this Feature Structure 
+   */
+  public FSArrayList(TypeImpl type, CASImpl casImpl) {
+    super(type, casImpl);
+    if (CASImpl.traceFSs) { // tracing done after array setting, skipped in super class
+      _casView.traceFSCreate(this);
+    }
+    fsArrayList = new ArrayList<>();
+  }
+  
+  /** @generated
+   * @param jcas JCas to which this Feature Structure belongs 
+   */
+  public FSArrayList(JCas jcas) {
+    super(jcas);
+    fsArrayList = new ArrayList<>();
+
+    if (CASImpl.traceFSs) { // tracing done after array setting, skipped in super class
+                            // because this impls CommonArrayFS
+      _casView.traceFSCreate(this);
+    }   
+  } 
+
+  /**
+   * Make a new ArrayList with an initial size .
+   *
+   * @param jcas The JCas
+   * @param length initial size
+   */
+  public FSArrayList(JCas jcas, int length) {
+    super(jcas);
+    _casView.validateArraySize(length);
+    fsArrayList = new ArrayList<>(length);
+
+    if (CASImpl.traceFSs) { // tracing done after array setting, skipped in super class
+      _casView.traceFSCreate(this);
+    }
+  }     
+ 
+    
+  //*--------------*
+  //* Feature: fsArray
+
+  /** getter for fsArray - gets internal use - holds the contents
+   * @generated
+   * @return value of the feature 
+   */
+  private FSArray getFsArray() { return (FSArray)(_getFeatureValueNc(_FI_fsArray));}
+    
+  /** setter for fsArray - sets internal use - holds the contents 
+   * @generated
+   * @param v value to set into the feature 
+   */
+  private void setFsArray(FSArray v) {
+    _setFeatureValueNcWj(_FI_fsArray, v);
+  }    
+    
+  /**
+   * Maybe start using array list.
+   */
+  private void maybeStartUsingArrayList() {
+    if (fsArrayAsList != null) {
+      fsArrayList.clear();
+      fsArrayList.addAll(fsArrayAsList);
+      fsArrayAsList = null;  // stop using this one
+    }
+  }
+    
+  /* (non-Javadoc)
+   * @see org.apache.uima.UimaSerializable#_init_from_cas_data()
+   */
+  @Override
+  public void _init_from_cas_data() {
+    // special handling to have getter and setter honor pear trampolines
+    final FSArray fsa = getFsArray();
+    if (null == fsa) {
+      fsArrayAsList = Collections.emptyList();
+    } else {
+    
+      fsArrayAsList = new AbstractList<T>() {
+        int i = 0;
+        @Override
+        public T get(int index) {
+          return (T) fsa.get(i);
+        }
+  
+        @Override
+        public int size() {
+          return fsa.size();
+        }      
+      };
+    }
+  }
+  
+  /* (non-Javadoc)
+   * @see org.apache.uima.UimaSerializable#_save_to_cas_data()
+   */
+  @Override
+  public void _save_to_cas_data() {
+    // if fsArraysAsList is not null, then the cas data form is still valid, do nothing
+    if (null != fsArrayAsList) {
+      return;
+    }
+    
+    // reallocate fsArray if wrong size
+    final int sz = size();
+    FSArray fsa = getFsArray();
+    if (fsa == null || fsa.size() != sz) {
+      setFsArray(fsa = new FSArray(_casView.getJCasImpl(), sz));
+    }
+    
+    // using element by element instead of bulk operations to
+    //   pick up any pear trampoline conversion and 
+    //   in case fsa was preallocated and right size, may need journaling
+    int i = 0;
+    for (TOP fs : fsArrayList) {
+      TOP currentValue = fsa.get(i);
+      if (currentValue != fs) {
+        fsa.set(i, fs); // done this way to record for journaling for delta CAS
+      }
+      i++;
+    }
+  }
+  
+  /**
+   * Gl.
+   *
+   * @return the list
+   */
+  private List<T> gl () {
+    return (null == fsArrayAsList) 
+      ? fsArrayList
+      : fsArrayAsList;
+  }
+  
+  /* (non-Javadoc)
+   * @see java.util.List#get(int)
+   */
+  @Override
+  public T get(int i) {
+    return gl().get(i);
+  }
+
+  /**
+   * updates the i-th value of the FSArrayList.
+   *
+   * @param i the i
+   * @param v the v
+   * @return the t
+   */
+  @Override
+  public T set(int i, T v) {
+    
+    if (v != null && _casView.getBaseCAS() != v._casView.getBaseCAS()) {
+      /** Feature Structure {0} belongs to CAS {1}, may not be set as the value of an array or list element in a different CAS {2}.*/
+      throw new CASRuntimeException(CASRuntimeException.FS_NOT_MEMBER_OF_CAS, v, v._casView, _casView);
+    }
+    return gl().set(i, v);
+  }
+  
+  /**
+   *  return the size of the array.
+   *
+   * @return the int
+   */
+  @Override
+  public int size() {
+    return gl().size();
+  }
+
+  /**
+   * Copy from array.
+   *
+   * @param src -
+   * @param srcPos -
+   * @param destPos -
+   * @param length -
+   * @see org.apache.uima.cas.ArrayFS#copyFromArray(FeatureStructure[], int, int, int)
+   */
+  public void copyFromArray(T[] src, int srcPos, int destPos, int length) {
+    int srcEnd = srcPos + length;
+    int destEnd = destPos + length;
+    if (srcPos < 0 ||
+        srcEnd > src.length ||
+        destEnd > size()) {
+      throw new ArrayIndexOutOfBoundsException(
+          String.format("FSArrayList.copyFromArray, srcPos: %,d destPos: %,d length: %,d",  srcPos, destPos, length));
+    }
+    for (;srcPos < srcEnd && destPos < destEnd;) {
+      set(destPos++, src[srcPos++]);
+    }
+  }
+
+  /**
+   * Copy to array.
+   *
+   * @param srcPos -
+   * @param dest -
+   * @param destPos -
+   * @param length -
+   * @see org.apache.uima.cas.ArrayFS#copyToArray(int, FeatureStructure[], int, int)
+   */
+  public void copyToArray(int srcPos, FeatureStructure[] dest, int destPos, int length) {
+    int srcEnd = srcPos + length;
+    int destEnd = destPos + length;
+    if (srcPos < 0 ||
+        srcEnd > size() ||
+        destEnd > dest.length) {
+      throw new ArrayIndexOutOfBoundsException(
+          String.format("FSArrayList.copyToArray, srcPos: %,d destPos: %,d length: %,d",  srcPos, destPos, length));
+    }
+    for (;srcPos < srcEnd && destPos < destEnd;) {
+      dest[destPos++] = get(srcPos++);
+    }
+  }
+
+  /**
+   * Note: doesn't convert to pear trampolines!.
+   *
+   * @return the feature structure[]
+   * @see org.apache.uima.cas.ArrayFS#toArray()
+   */
+  @Override
+  public T[] toArray() {
+    T[] r = (T[]) new TOP[size()];
+    copyToArray(0, r, 0, size());
+    return r;
+  }
+
+  /* (non-Javadoc)
+   * @see org.apache.uima.jcas.cas.SelectViaCopyToArray#_toArrayForSelect()
+   */
+  @Override
+  public FeatureStructure[] _toArrayForSelect() { return toArray(); }
+
+  /**
+   * Not supported, will throw UnsupportedOperationException.
+   *
+   * @param src the src
+   * @param srcPos the src pos
+   * @param destPos the dest pos
+   * @param length the length
+   */
+  @Override
+  public void copyFromArray(String[] src, int srcPos, int destPos, int length) {
+    throw new UnsupportedOperationException();
+  }
+    
+  /**
+   * Copies an array of Feature Structures to an Array of Strings.
+   * The strings are the "toString()" representation of the feature structures, 
+   * 
+   * @param srcPos
+   *                The index of the first element to copy.
+   * @param dest
+   *                The array to copy to.
+   * @param destPos
+   *                Where to start copying into <code>dest</code>.
+   * @param length
+   *                The number of elements to copy.
+   * @exception ArrayIndexOutOfBoundsException
+   *                    If <code>srcPos &lt; 0</code> or
+   *                    <code>length &gt; size()</code> or
+   *                    <code>destPos + length &gt; destArray.length</code>.
+   */
+  @Override
+  public void copyToArray(int srcPos, String[] dest, int destPos, int length) {
+    _casView.checkArrayBounds(size(), srcPos, length);
+    int i = 0;
+    for (T fs : this) {
+      dest[i + destPos] = (fs == null) ? null : fs.toString();
+      i++;
+    }
+  }
+  
+  /* 
+   * 
+   * (non-Javadoc)
+   * @see org.apache.uima.jcas.cas.CommonArray#copyValuesFrom(org.apache.uima.jcas.cas.CommonArray)
+   * no conversion to Pear trampolines done
+   */
+  @Override
+  public void copyValuesFrom(CommonArrayFS v) {
+    clear();
+    Spliterator<T> si;
+    if (v instanceof FSArrayList) {
+      si = ((FSArrayList<T>) v).spliterator();
+    } else if (v instanceof FSArray) {
+      si = (Spliterator<T>) ((FSArray)v).spliterator();
+    } else {
+      throw new ClassCastException("argument must be of class FSArray or FSArrayList");
+    } 
+    
+    si.forEachRemaining(fs -> add(fs));
+  }
+  
+  /**
+   * Convenience - create a FSArrayList from an existing FeatureStructure[].
+   *
+   * @param <N> generic type of returned FS
+   * @param jcas -
+   * @param a -
+   * @return -
+   */
+  public static <N extends TOP> FSArrayList<N> create(JCas jcas, N[] a) {
+    FSArrayList<N> fsa = new FSArrayList<>(jcas, a.length);
+    fsa.copyFromArray(a, 0, 0, a.length);  // does pear and journaling actions as needed
+    return fsa;
+  }
+  
+  /* (non-Javadoc)
+   * @see org.apache.uima.UimaSerializable#_superClone()
+   */
+  @Override
+  public FeatureStructureImplC _superClone() {return clone();}  // enable common clone
+  
+  /**
+   * Contains all.
+   *
+   * @param c -
+   * @return -
+   * @see java.util.AbstractCollection#containsAll(java.util.Collection)
+   */
+  @Override
+  public boolean containsAll(Collection<?> c) {
+    return gl().containsAll(c);
+  }
+
+  /**
+   * Checks if is empty.
+   *
+   * @return -
+   * @see java.util.ArrayList#isEmpty()
+   */
+  @Override
+  public boolean isEmpty() {
+    return gl().isEmpty();
+  }
+
+  /**
+   * Contains.
+   *
+   * @param o -
+   * @return -
+   * @see java.util.ArrayList#contains(java.lang.Object)
+   */
+  @Override
+  public boolean contains(Object o) {
+    if (!(o instanceof TOP)) return false;
+    TOP fs = (TOP) o;    
+    return gl().contains(fs);
+  }
+
+  /**
+   * Index of.
+   *
+   * @param o -
+   * @return -
+   * @see java.util.ArrayList#indexOf(java.lang.Object)
+   */
+  @Override
+  public int indexOf(Object o) {
+    if (!(o instanceof TOP)) return -1;
+    TOP fs = (TOP) o;    
+    return gl().indexOf(fs);
+  }
+
+  /**
+   * Last index of.
+   *
+   * @param o -
+   * @return -
+   * @see java.util.ArrayList#lastIndexOf(java.lang.Object)
+   */
+  @Override
+  public int lastIndexOf(Object o) {
+    if (!(o instanceof TOP)) return -1;
+    TOP fs = (TOP) o;    
+    return gl().lastIndexOf(fs);
+  }
+
+  /**
+   * To array.
+   *
+   * @param <T> the generic type
+   * @param a -
+   * @return -
+   * @see java.util.ArrayList#toArray(java.lang.Object[])
+   */
+  @Override
+  public <U> U[] toArray(U[] a) {
+    return gl().toArray(a);
+  }
+
+
+  /* (non-Javadoc)
+   * @see java.lang.Object#toString()
+   */
+  @Override
+  public String toString() {
+    final int maxLen = 10;
+    return "FSArrayList [size="
+        + size()
+        + ", fsArrayList="
+        + (fsArrayList != null ? fsArrayList.subList(0, Math.min(fsArrayList.size(), maxLen))
+            : null)
+        + ", fsArrayAsList=" + (fsArrayAsList != null
+            ? fsArrayAsList.subList(0, Math.min(fsArrayAsList.size(), maxLen)) : null)
+        + "]";
+  }
+
+  /**
+   * Adds the.
+   *
+   * @param e -
+   * @return -
+   * @see java.util.ArrayList#add(java.lang.Object)
+   */
+  @Override
+  public boolean add(T e) {
+    maybeStartUsingArrayList();
+    return fsArrayList.add(e);
+  }
+
+  /**
+   * equals means equal items, same order.
+   *
+   * @param o -
+   * @return -
+   * @see java.util.AbstractList#equals(java.lang.Object)
+   */
+  @Override
+  public boolean equals(Object o) {
+    if (!(o instanceof FSArrayList)) return false;
+    FSArrayList<T> other = (FSArrayList<T>) o;
+    if (size() != other.size()) return false;
+    
+    Iterator<T> it_other = other.iterator();
+    for (T item : this) {
+      if (!item.equals(it_other.next())) return false;
+    }
+    return true;
+  }
+
+  /**
+   * Adds the.
+   *
+   * @param index -
+   * @param element -
+   * @see java.util.ArrayList#add(int, java.lang.Object)
+   */
+  @Override
+  public void add(int index, T element) {
+    maybeStartUsingArrayList();
+    fsArrayList.add(index, element);
+  }
+
+  /**
+   * Removes the.
+   *
+   * @param index -
+   * @return -
+   * @see java.util.ArrayList#remove(int)
+   */
+  @Override
+  public T remove(int index) {
+    maybeStartUsingArrayList();
+    return fsArrayList.remove(index);
+  }
+
+  /**
+   * Removes the.
+   *
+   * @param o -
+   * @return -
+   * @see java.util.ArrayList#remove(java.lang.Object)
+   */
+  @Override
+  public boolean remove(Object o) {
+    maybeStartUsingArrayList();
+    return fsArrayList.remove(o);
+  }
+
+  /**
+   * want hashcode to depend only on equal items, regardless of what format.
+   *
+   * @return -
+   * @see java.util.AbstractList#hashCode()
+   */
+  @Override
+  public int hashCode() {
+    int hc = 1;
+    final int prime = 31;
+    for (T item : this) {
+      hc = hc * prime + item.hashCode();
+    }
+    return hc;
+  }
+
+  /**
+   * Clear.
+   *
+   * @see java.util.ArrayList#clear()
+   */
+  @Override
+  public void clear() {
+    maybeStartUsingArrayList();
+    fsArrayList.clear();
+  }
+
+  /**
+   * Adds the all.
+   *
+   * @param c -
+   * @return -
+   * @see java.util.ArrayList#addAll(java.util.Collection)
+   */
+  @Override
+  public boolean addAll(Collection<? extends T> c) {
+    maybeStartUsingArrayList();
+    return fsArrayList.addAll(c);
+  }
+
+  /**
+   * Adds the all.
+   *
+   * @param index -
+   * @param c -
+   * @return -
+   * @see java.util.ArrayList#addAll(int, java.util.Collection)
+   */
+  @Override
+  public boolean addAll(int index, Collection<? extends T> c) {
+    maybeStartUsingArrayList();
+    return fsArrayList.addAll(index, c);
+  }
+
+  /**
+   * Removes the all.
+   *
+   * @param c -
+   * @return -
+   * @see java.util.ArrayList#removeAll(java.util.Collection)
+   */
+  @Override
+  public boolean removeAll(Collection<?> c) {
+    maybeStartUsingArrayList();
+    return fsArrayList.removeAll(c);
+  }
+
+  /**
+   * Retain all.
+   *
+   * @param c -
+   * @return -
+   * @see java.util.ArrayList#retainAll(java.util.Collection)
+   */
+  @Override
+  public boolean retainAll(Collection<?> c) {
+    maybeStartUsingArrayList();
+    return fsArrayList.retainAll(c);
+  }
+
+  /**
+   * Stream.
+   *
+   * @return -
+   * @see java.util.Collection#stream()
+   */
+  @Override
+  public Stream<T> stream() {
+    return gl().stream();
+  }
+
+  /**
+   * Parallel stream.
+   *
+   * @return -
+   * @see java.util.Collection#parallelStream()
+   */
+  @Override
+  public Stream<T> parallelStream() {
+    return gl().parallelStream();
+  }
+
+  /**
+   * List iterator.
+   *
+   * @param index -
+   * @return -
+   * @see java.util.ArrayList#listIterator(int)
+   */
+  @Override
+  public ListIterator<T> listIterator(int index) {
+    return gl().listIterator(index);
+  }
+
+  /**
+   * List iterator.
+   *
+   * @return -
+   * @see java.util.ArrayList#listIterator()
+   */
+  @Override
+  public ListIterator<T> listIterator() {
+    return gl().listIterator();
+  }
+
+  /**
+   * Iterator.
+   *
+   * @return -
+   * @see java.util.ArrayList#iterator()
+   */
+  @Override
+  public Iterator<T> iterator() {
+    return gl().iterator();
+  }
+
+  /**
+   * Sub list.
+   *
+   * @param fromIndex -
+   * @param toIndex -
+   * @return -
+   * @see java.util.ArrayList#subList(int, int)
+   */
+  @Override
+  public List<T> subList(int fromIndex, int toIndex) {
+    return gl().subList(fromIndex, toIndex);
+  }
+
+  /**
+   * For each.
+   *
+   * @param action -
+   * @see java.util.ArrayList#forEach(java.util.function.Consumer)
+   */
+  @Override
+  public void forEach(Consumer<? super T> action) {
+    gl().forEach(action);
+  }
+
+  /**
+   * Spliterator.
+   *
+   * @return -
+   * @see java.util.ArrayList#spliterator()
+   */
+  @Override
+  public Spliterator<T> spliterator() {
+    return gl().spliterator();
+  }
+
+  /**
+   * Removes the if.
+   *
+   * @param filter -
+   * @return -
+   * @see java.util.ArrayList#removeIf(java.util.function.Predicate)
+   */
+  @Override
+  public boolean removeIf(Predicate<? super T> filter) {
+    maybeStartUsingArrayList();
+    return fsArrayList.removeIf(filter);
+  }
+
+  /**
+   * Replace all.
+   *
+   * @param operator -
+   * @see java.util.ArrayList#replaceAll(java.util.function.UnaryOperator)
+   */
+  @Override
+  public void replaceAll(UnaryOperator<T> operator) {
+    maybeStartUsingArrayList();
+    fsArrayList.replaceAll(operator);
+  }
+
+  /**
+   * Sort.
+   *
+   * @param c -
+   * @see java.util.ArrayList#sort(java.util.Comparator)
+   */
+  @Override
+  public void sort(Comparator<? super T> c) {
+    gl().sort(c);
+  }
+    
+}
+
+    
\ No newline at end of file

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/FSHashSet.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/FSHashSet.java?rev=1779769&r1=1779768&r2=1779769&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/FSHashSet.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/jcas/cas/FSHashSet.java Sun Jan 22 04:14:07 2017
@@ -1,522 +1,530 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.uima.jcas.cas;
-
-import java.lang.reflect.Array;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.RandomAccess;
-import java.util.Set;
-import java.util.Spliterator;
-
-import javax.xml.crypto.NoSuchMechanismException;
-
-import org.apache.uima.UimaSerializableFSs;
-import org.apache.uima.cas.FeatureStructure;
-import org.apache.uima.cas.impl.CASImpl;
-import org.apache.uima.cas.impl.FeatureStructureImplC;
-import org.apache.uima.cas.impl.TypeImpl;
-import org.apache.uima.cas.impl.TypeSystemImpl;
-import org.apache.uima.jcas.JCas;
-import org.apache.uima.jcas.JCasRegistry;
-import org.apache.uima.util.impl.Constants;
-
-/**
- * A HashSet type containing Feature Structures,
- *   - Has all the methods of HashSet
- *   - Implements the select(...) APIs 
- *   
- * Implementation notes:
- *   - Uses UimaSerializable APIs 
- *
- * No PEAR trampoline conversions are done
- * 
- * @param <T> the generic type
- */
-public final class FSHashSet <T extends TOP> extends TOP implements 
-                                 UimaSerializableFSs, SelectViaCopyToArray, 
-                                 Set<T>, RandomAccess, Cloneable {
-
-  /* public static string for use where constants are needed, e.g. in some Java Annotations */
-  public final static String _TypeName = "org.apache.uima.cas.jcas.FSHashSet";
-
-  /**
-   * each cover class when loaded sets an index. used in the JCas typeArray to go from the cover
-   * class or class instance to the corresponding instance of the _Type class
-   */
-  public final static int typeIndexID = JCasRegistry.register(FSHashSet.class);
-
-  /** The Constant type. */
-  public final static int type = typeIndexID;
-
-  /**
-   * used to obtain reference to the _Type instance.
-   *
-   * @return the type array index
-   */
-  // can't be factored - refs locally defined field
-  @Override
-  public int getTypeIndexID() {
-    return typeIndexID;
-  }
-    
-  /** lifecycle   
-   *   - starts as empty array list   
-   *   - becomes non-empty when updated (add)       
-   *   -- used from that point on. */
-  
-  private boolean isPendingInit = false;
-  private boolean isSaveNeeded = false;
-  
-  private final HashSet<T> fsHashSet; // not set here to allow initial size version
-   
-  /** The Constant _FI_fsArray. */
-  public static final int _FI_fsArray = TypeSystemImpl.getAdjustedFeatureOffset("fsArray");
-  
-  /**
-   * Instantiates a new FS hash set.
-   */
-  // never called. Here to disable default constructor
-  @SuppressWarnings("unused")
-  private FSHashSet() {
-    fsHashSet = null;
-  }
-
-  /**
-   * Make a new ArrayList .
-   *
-   * @param jcas The JCas
-   */
-  public FSHashSet(JCas jcas) {
-    super(jcas);
-    fsHashSet = new HashSet<>();
-
-    if (CASImpl.traceFSs) { // tracing done after array setting, skipped in super class
-      _casView.traceFSCreate(this);
-    }
-  }
-
-  /**
-   * Make a new ArrayList with an initial size .
-   *
-   * @param jcas The JCas
-   * @param length initial size
-   */
-  public FSHashSet(JCas jcas, int length) {
-    super(jcas);
-    _casView.validateArraySize(length);
-    fsHashSet = new HashSet<>(length);
-
-    if (CASImpl.traceFSs) { // tracing done after array setting, skipped in super class
-      _casView.traceFSCreate(this);
-    }
-  }
-  
-  /**
-   * used by generator
-   * Make a new FSArrayList.
-   *
-   * @param t -
-   * @param c -
-   */
-  public FSHashSet(TypeImpl t, CASImpl c) {
-    super(t, c);  
-    
-    if (CASImpl.traceFSs) { // tracing done after array setting, skipped in super class
-      _casView.traceFSCreate(this);
-    }
-    fsHashSet = new HashSet<>();
-  }
-
-  // *------------------*
-  // * Feature: fsArray
-  /**
-   * Gets the fs array.
-   *
-   * @return the fs array
-   */
-  /* getter for fsArray */
-  private FSArray getFsArray() { return (FSArray) _getFeatureValueNc(_FI_fsArray); }
-
-  /**
-   * Sets the fs array.
-   *
-   * @param v the new fs array
-   */
-  /* setter for fsArray */
-  private void setFsArray(FSArray v) {
-    _setFeatureValueNcWj(_FI_fsArray, v); }
-  
-  /* (non-Javadoc)
-   * @see org.apache.uima.UimaSerializable#_init_from_cas_data()
-   */
-  @Override
-  public void _init_from_cas_data() {
-    isPendingInit = true;
-  }
-
-  private void maybeLazyInit() {
-    if (isPendingInit) {
-      lazyInit();
-    }
-  }
-  
-  private void lazyInit() {  
-    isPendingInit = false;
-    fsHashSet.clear();
-    FSArray a = getFsArray();
-    if (a != null) {
-      // do element by element to pick up pear trampoline conversion
-      for (TOP fs : a) {
-        fsHashSet.add((T) fs);
-      }
-    }
-  }
-    
-  /* (non-Javadoc)
-   * @see org.apache.uima.UimaSerializable#_save_to_cas_data()
-   */
-  @Override
-  public void _save_to_cas_data() {
-    if (isSaveNeeded) {
-      isSaveNeeded = false;
-      FSArray fsa = getFsArray();
-      if (fsa == null || fsa.size() != fsHashSet.size()) {
-        fsa = new FSArray(_casView.getJCasImpl(), fsHashSet.size());
-        setFsArray(fsa);
-      }
- 
-      // using element by element instead of bulk operations to
-      //   pick up any pear trampoline conversion and
-      //   in case fsa was preallocated and right size, may need journaling
-      
-      int i = 0;
-      for (TOP fs : fsHashSet) {
-        TOP currentValue = fsa.get(i);
-        if (currentValue != fs) {
-          fsa.set(i, fs); // done this way to record for journaling for delta CAS
-        }
-        i++;
-      }
-    }
-  }
-
-  /* (non-Javadoc)
-   * @see org.apache.uima.jcas.cas.SelectViaCopyToArray#_toArrayForSelect()
-   */
-  @Override
-  public T[] _toArrayForSelect() {
-    return toArray(); 
-  }
-
-  /* (non-Javadoc)
-   * @see org.apache.uima.UimaSerializable#_superClone()
-   */
-  @Override
-  public FeatureStructureImplC _superClone() { return clone();}  // enable common clone
-  
-  private TOP[] gta() {
-    FSArray fsa = getFsArray();
-    if (null == fsa) {
-      return Constants.EMPTY_TOP_ARRAY;
-    }
-    return fsa._getTheArray();
-  }
-  
-  /**
-   * Equals.
-   *
-   * @param o the o
-   * @return true, if successful
-   * @see java.util.AbstractSet#equals(java.lang.Object)
-   */
-  @Override
-  public boolean equals(Object o) {
-    if (!(o instanceof FSHashSet)) return false;
-    FSHashSet other = (FSHashSet) o;
-    if (size() != other.size()) return false;
-    if (size() == 0) return true;
-    
-    for (T item : this) {
-      if (!other.contains(item)) return false;
-    }
-    
-    return true;
-  }
-
-  /**
-   * Hash code.
-   *
-   * @return the int
-   * @see java.util.AbstractSet#hashCode()
-   */
-  @Override
-  public int hashCode() {
-    return isSaveNeeded
-        ? fsHashSet.hashCode()
-        : Arrays.hashCode(gta());
-  }
-
-  /**
-   * To array.
-   *
-   * @return the feature structure[]
-   * @see java.util.AbstractCollection#toArray()
-   */
-  @Override
-  public T[] toArray() {
-    if (isSaveNeeded) {
-      T[] r = (T[]) new TOP[size()];
-      fsHashSet.toArray(r);
-      return r;
-    }
-    return (T[]) gta().clone();
-  }
-
-  /**
-   * Removes all elements matching c.
-   *
-   * @param c the elements to remove
-   * @return true, if set changed
-   * @see java.util.AbstractSet#removeAll(java.util.Collection)
-   */
-  @Override
-  public boolean removeAll(Collection<?> c) {
-    maybeLazyInit();
-    boolean r = fsHashSet.removeAll(c); 
-    if (r) isSaveNeeded = true;
-    return r;
-  }
-
-  /**
-   * To array.
-   *
-   * @param <N> the generic type
-   * @param a the a
-   * @return the N[]
-   * @see java.util.AbstractCollection#toArray(Object[])
-   */
-  @Override
-  public <N> N[] toArray(N[] a) {
-    if (isSaveNeeded) {
-      return fsHashSet.toArray(a);
-    }
-    final int sz = size();
-    if (a.length < sz) {
-      a = (N[]) Array.newInstance(a.getClass().getComponentType(), sz);
-    }
-    
-    TOP[] d = gta();
-    System.arraycopy(d, 0, a, 0, d.length);
-    return a;
-  }
-
-  /**
-   * Iterator.
-   *
-   * @return the iterator
-   * @see java.util.HashSet#iterator()
-   */
-  @Override
-  public Iterator<T> iterator() {
-    if (size() == 0) {
-      return Collections.emptyIterator();
-    }
-    
-    return isSaveNeeded 
-        ? fsHashSet.iterator()
-        : gtaIterator();
-  }
-  
-  private Iterator<T> gtaIterator() {
-    return (Iterator<T>) getFsArray().iterator(); 
-  }
-
-  /**
-   * Size.
-   *
-   * @return the int
-   * @see java.util.HashSet#size()
-   */
-  @Override
-  public int size() {
-    return isSaveNeeded 
-        ? fsHashSet.size()
-        : gta().length;
-  }
-
-  /**
-   * Checks if is empty.
-   *
-   * @return true, if is empty
-   * @see java.util.HashSet#isEmpty()
-   */
-  @Override
-  public boolean isEmpty() {
-    return size() == 0;
-  }
-
-  /**
-   * Contains.
-   *
-   * @param o the o
-   * @return true, if successful
-   * @see java.util.HashSet#contains(java.lang.Object)
-   */
-  @Override
-  public boolean contains(Object o) {
-    maybeLazyInit();
-    return fsHashSet.contains(o);
-  }
-
-  /**
-   * Adds the element to the set.
-   *
-   * @param e the element to add
-   * @return true, if the set didn't already contain this element
-   * @see java.util.HashSet#add(java.lang.Object)
-   */
-  @Override
-  public boolean add(T e) {
-    maybeLazyInit();
-    boolean r = fsHashSet.add(e); 
-    if (r) isSaveNeeded = true;
-    return r;
-  }
-
-  /**
-   * Removes the element.
-   *
-   * @param o the o
-   * @return true, if the set contained the element
-   * @see java.util.HashSet#remove(java.lang.Object)
-   */
-  @Override
-  public boolean remove(Object o) {
-    maybeLazyInit();
-    boolean r = fsHashSet.remove(o);
-    if (r) isSaveNeeded = true;
-    return r;
-  }
-
-  /**
-   * Clear.
-   *
-   * @see java.util.HashSet#clear()
-   */
-  @Override
-  public void clear() {
-    if (size() == 0) return;
-    maybeLazyInit();
-    isSaveNeeded = true;
-    fsHashSet.clear();
-  }
-
-  /**
-   * Contains all.
-   *
-   * @param c the c
-   * @return true, if set contains all of the elements in c
-   * @see java.util.AbstractCollection#containsAll(java.util.Collection)
-   */
-  @Override
-  public boolean containsAll(Collection<?> c) {
-    maybeLazyInit();
-    return fsHashSet.containsAll(c);
-  }
-
-  /**
-   * Adds all the elements .
-   *
-   * @param c the c
-   * @return true, if set changed
-   * @see java.util.AbstractCollection#addAll(java.util.Collection)
-   */
-  @Override
-  public boolean addAll(Collection<? extends T> c) {
-    maybeLazyInit();
-    boolean r = fsHashSet.addAll(c);
-    if (r) isSaveNeeded = true;
-    return r;
-  }
-
-  /**
-   * Spliterator.
-   *
-   * @return the spliterator
-   * @see java.util.HashSet#spliterator()
-   */
-  @Override
-  public Spliterator<T> spliterator() {
-    return isSaveNeeded
-        ? fsHashSet.spliterator()
-        : (Spliterator<T>) Arrays.asList(gta()).spliterator();
-  }
-
-  /**
-   * Retain all.
-   *
-   * @param c the c
-   * @return true, if collection changed
-   * @see java.util.AbstractCollection#retainAll(java.util.Collection)
-   */
-  @Override
-  public boolean retainAll(Collection<?> c) {
-    maybeLazyInit();
-    boolean r = fsHashSet.retainAll(c);
-    if (r) isSaveNeeded = true;
-    return r;
-  }
-
-  /* (non-Javadoc)
-   * @see java.lang.Object#toString()
-   */
-  @Override
-  public String toString() {
-    final int maxLen = 10;
-    return "FSHashSet [isPendingInit=" + isPendingInit + ", isSaveNeeded=" + isSaveNeeded
-        + ", fsHashSet=" + (fsHashSet != null ? toString(fsHashSet, maxLen) : null) + "]";
-  }
-
-  /**
-   * To string.
-   *
-   * @param collection the collection
-   * @param maxLen the max len
-   * @return the string
-   */
-  private String toString(Collection<?> collection, int maxLen) {
-    StringBuilder builder = new StringBuilder();
-    builder.append("[");
-    int i = 0;
-    for (Iterator<?> iterator = collection.iterator(); iterator.hasNext() && i < maxLen; i++) {
-      if (i > 0)
-        builder.append(", ");
-      builder.append(iterator.next());
-    }
-    builder.append("]");
-    return builder.toString();
-  }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+   
+/* Apache UIMA v3 - First created by JCasGen Fri Jan 20 11:55:59 EST 2017 */
+
+package org.apache.uima.jcas.cas;
+
+import java.lang.reflect.Array;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.RandomAccess;
+import java.util.Set;
+import java.util.Spliterator;
+
+import org.apache.uima.UimaSerializableFSs;
+import org.apache.uima.cas.impl.CASImpl;
+import org.apache.uima.cas.impl.FeatureStructureImplC;
+import org.apache.uima.cas.impl.TypeImpl;
+import org.apache.uima.cas.impl.TypeSystemImpl;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.JCasRegistry;
+import org.apache.uima.jcas.cas.FSArray;
+import org.apache.uima.jcas.cas.SelectViaCopyToArray;
+import org.apache.uima.jcas.cas.TOP;
+import org.apache.uima.util.impl.Constants;
+
+
+/** a hash set of Feature Structures
+ * Updated by JCasGen Fri Jan 20 11:55:59 EST 2017
+ * XML source: C:/au/svnCheckouts/branches/uimaj/v3-alpha/uimaj-types/src/main/descriptors/java_object_type_descriptors.xml
+ * @generated */
+public class FSHashSet <T extends TOP> extends TOP implements 
+                            UimaSerializableFSs, SelectViaCopyToArray, 
+                            Set<T>, RandomAccess, Cloneable {
+  
+  /** @generated
+   * @ordered 
+   */
+  @SuppressWarnings ("hiding")
+  public final static String _TypeName = "org.apache.uima.jcas.type.FSHashSet";
+  
+  /** @generated
+   * @ordered 
+   */
+  @SuppressWarnings ("hiding")
+  public final static int typeIndexID = JCasRegistry.register(FSHashSet.class);
+  /** @generated
+   * @ordered 
+   */
+  @SuppressWarnings ("hiding")
+  public final static int type = typeIndexID;
+  /** @generated
+   * @return index of the type  
+   */
+  @Override
+  public              int getTypeIndexID() {return typeIndexID;}
+ 
+  /** lifecycle   
+   *   - starts as empty array list   
+   *   - becomes non-empty when updated (add)       
+   *   -- used from that point on. */
+  
+  private boolean isPendingInit = false;
+  private boolean isSaveNeeded = false;
+  
+  private final HashSet<T> fsHashSet; // not set here to allow initial size version
+
+  /* *******************
+   *   Feature Offsets *
+   * *******************/ 
+   
+  public final static String _FeatName_fsArray = "fsArray";
+
+
+  /* Feature Adjusted Offsets */
+  public final static int _FI_fsArray = TypeSystemImpl.getAdjustedFeatureOffset("fsArray");
+
+   
+  /** Never called.  Disable default constructor
+   * @generated */
+  protected FSHashSet() {
+    fsHashSet = null;
+  }
+    
+  /** Internal - constructor used by generator 
+   * @generated
+   * @param casImpl the CAS this Feature Structure belongs to
+   * @param type the type of this Feature Structure 
+   */
+  public FSHashSet(TypeImpl type, CASImpl casImpl) {
+    super(type, casImpl);
+    fsHashSet = new HashSet<>();
+
+    if (CASImpl.traceFSs) { // tracing done after array setting, skipped in super class
+      _casView.traceFSCreate(this);
+    }
+  }
+  
+  /** @generated
+   * @param jcas JCas to which this Feature Structure belongs 
+   */
+  public FSHashSet(JCas jcas) {
+    super(jcas);
+    fsHashSet = new HashSet<>();
+
+    if (CASImpl.traceFSs) { // tracing done after array setting, skipped in super class
+      _casView.traceFSCreate(this);
+    }   
+  } 
+
+  /**
+   * Make a new ArrayList with an initial size .
+   *
+   * @param jcas The JCas
+   * @param length initial size
+   */
+  public FSHashSet(JCas jcas, int length) {
+    super(jcas);
+    _casView.validateArraySize(length);
+    fsHashSet = new HashSet<>(length);
+
+    if (CASImpl.traceFSs) { // tracing done after array setting, skipped in super class
+      _casView.traceFSCreate(this);
+    }
+  }
+    
+  //*--------------*
+  //* Feature: fsArray
+
+  /** getter for fsArray - gets internal use - holds the set of Feature Structures
+   * @generated
+   * @return value of the feature 
+   */
+  private FSArray getFsArray() { return (FSArray)(_getFeatureValueNc(_FI_fsArray));}
+    
+  /** setter for fsArray - sets internal use - holds the set of Feature Structures 
+   * @generated
+   * @param v value to set into the feature 
+   */
+  private void setFsArray(FSArray v) {
+    _setFeatureValueNcWj(_FI_fsArray, v);
+  }    
+    
+  /* (non-Javadoc)
+   * @see org.apache.uima.UimaSerializable#_init_from_cas_data()
+   */
+  @Override
+  public void _init_from_cas_data() {
+    isPendingInit = true;
+  }
+
+  private void maybeLazyInit() {
+    if (isPendingInit) {
+      lazyInit();
+    }
+  }
+  
+  private void lazyInit() {  
+    isPendingInit = false;
+    fsHashSet.clear();
+    FSArray a = getFsArray();
+    if (a != null) {
+      // do element by element to pick up pear trampoline conversion
+      for (TOP fs : a) {
+        fsHashSet.add((T) fs);
+      }
+    }
+  }
+    
+  /* (non-Javadoc)
+   * @see org.apache.uima.UimaSerializable#_save_to_cas_data()
+   */
+  @Override
+  public void _save_to_cas_data() {
+    if (isSaveNeeded) {
+      isSaveNeeded = false;
+      FSArray fsa = getFsArray();
+      if (fsa == null || fsa.size() != fsHashSet.size()) {
+        fsa = new FSArray(_casView.getJCasImpl(), fsHashSet.size());
+        setFsArray(fsa);
+      }
+ 
+      // using element by element instead of bulk operations to
+      //   pick up any pear trampoline conversion and
+      //   in case fsa was preallocated and right size, may need journaling
+      
+      int i = 0;
+      for (TOP fs : fsHashSet) {
+        TOP currentValue = fsa.get(i);
+        if (currentValue != fs) {
+          fsa.set(i, fs); // done this way to record for journaling for delta CAS
+        }
+        i++;
+      }
+    }
+  }
+
+  /* (non-Javadoc)
+   * @see org.apache.uima.jcas.cas.SelectViaCopyToArray#_toArrayForSelect()
+   */
+  @Override
+  public T[] _toArrayForSelect() {
+    return toArray(); 
+  }
+
+  /* (non-Javadoc)
+   * @see org.apache.uima.UimaSerializable#_superClone()
+   */
+  @Override
+  public FeatureStructureImplC _superClone() { return clone();}  // enable common clone
+  
+  private TOP[] gta() {
+    FSArray fsa = getFsArray();
+    if (null == fsa) {
+      return Constants.EMPTY_TOP_ARRAY;
+    }
+    return fsa._getTheArray();
+  }
+  
+  /**
+   * Equals.
+   *
+   * @param o the o
+   * @return true, if successful
+   * @see java.util.AbstractSet#equals(java.lang.Object)
+   */
+  @Override
+  public boolean equals(Object o) {
+    if (!(o instanceof FSHashSet)) return false;
+    FSHashSet<?> other = (FSHashSet<?>) o;
+    if (size() != other.size()) return false;
+    if (size() == 0) return true;
+    
+    for (T item : this) {
+      if (!other.contains(item)) return false;
+    }
+    
+    return true;
+  }
+
+  /**
+   * Hash code.
+   *
+   * @return the int
+   * @see java.util.AbstractSet#hashCode()
+   */
+  @Override
+  public int hashCode() {
+    // hash code needs to be the same for both styles
+    // fsHashSet adds element hashcodes, Arrays combines using 31*.
+    
+//    return isSaveNeeded
+//        ? fsHashSet.hashCode()    // no good - hash codes different
+//        : Arrays.hashCode(gta());
+    if (isSaveNeeded) {
+      return fsHashSet.hashCode();
+    }
+    int hc = 0;
+    for (TOP fs : gta()) {
+      if (fs == null) {
+        continue;
+      }
+      hc += fs.hashCode();
+    }
+    return hc;
+  }
+
+  /**
+   * To array.
+   *
+   * @return the feature structure[]
+   * @see java.util.AbstractCollection#toArray()
+   */
+  @Override
+  public T[] toArray() {
+    if (isSaveNeeded) {
+      T[] r = (T[]) new TOP[size()];
+      fsHashSet.toArray(r);
+      return r;
+    }
+    return (T[]) gta().clone();
+  }
+
+  /**
+   * Removes all elements matching c.
+   *
+   * @param c the elements to remove
+   * @return true, if set changed
+   * @see java.util.AbstractSet#removeAll(java.util.Collection)
+   */
+  @Override
+  public boolean removeAll(Collection<?> c) {
+    maybeLazyInit();
+    boolean r = fsHashSet.removeAll(c); 
+    if (r) isSaveNeeded = true;
+    return r;
+  }
+
+  /**
+   * To array.
+   *
+   * @param <N> the generic type
+   * @param a the a
+   * @return the N[]
+   * @see java.util.AbstractCollection#toArray(Object[])
+   */
+  @Override
+  public <N> N[] toArray(N[] a) {
+    if (isSaveNeeded) {
+      return fsHashSet.toArray(a);
+    }
+    final int sz = size();
+    if (a.length < sz) {
+      a = (N[]) Array.newInstance(a.getClass().getComponentType(), sz);
+    }
+    
+    TOP[] d = gta();
+    System.arraycopy(d, 0, a, 0, d.length);
+    return a;
+  }
+
+  /**
+   * Iterator.
+   *
+   * @return the iterator
+   * @see java.util.HashSet#iterator()
+   */
+  @Override
+  public Iterator<T> iterator() {
+    if (size() == 0) {
+      return Collections.emptyIterator();
+    }
+    
+    return isSaveNeeded 
+        ? fsHashSet.iterator()
+        : gtaIterator();
+  }
+  
+  private Iterator<T> gtaIterator() {
+    return (Iterator<T>) getFsArray().iterator(); 
+  }
+
+  /**
+   * Size.
+   *
+   * @return the int
+   * @see java.util.HashSet#size()
+   */
+  @Override
+  public int size() {
+    return isSaveNeeded 
+        ? fsHashSet.size()
+        : gta().length;
+  }
+
+  /**
+   * Checks if is empty.
+   *
+   * @return true, if is empty
+   * @see java.util.HashSet#isEmpty()
+   */
+  @Override
+  public boolean isEmpty() {
+    return size() == 0;
+  }
+
+  /**
+   * Contains.
+   *
+   * @param o the o
+   * @return true, if successful
+   * @see java.util.HashSet#contains(java.lang.Object)
+   */
+  @Override
+  public boolean contains(Object o) {
+    maybeLazyInit();
+    return fsHashSet.contains(o);
+  }
+
+  /**
+   * Adds the element to the set.
+   *
+   * @param e the element to add
+   * @return true, if the set didn't already contain this element
+   * @see java.util.HashSet#add(java.lang.Object)
+   */
+  @Override
+  public boolean add(T e) {
+    maybeLazyInit();
+    boolean r = fsHashSet.add(e); 
+    if (r) isSaveNeeded = true;
+    return r;
+  }
+
+  /**
+   * Removes the element.
+   *
+   * @param o the o
+   * @return true, if the set contained the element
+   * @see java.util.HashSet#remove(java.lang.Object)
+   */
+  @Override
+  public boolean remove(Object o) {
+    maybeLazyInit();
+    boolean r = fsHashSet.remove(o);
+    if (r) isSaveNeeded = true;
+    return r;
+  }
+
+  /**
+   * Clear.
+   *
+   * @see java.util.HashSet#clear()
+   */
+  @Override
+  public void clear() {
+    if (size() == 0) return;
+    maybeLazyInit();
+    isSaveNeeded = true;
+    fsHashSet.clear();
+  }
+
+  /**
+   * Contains all.
+   *
+   * @param c the c
+   * @return true, if set contains all of the elements in c
+   * @see java.util.AbstractCollection#containsAll(java.util.Collection)
+   */
+  @Override
+  public boolean containsAll(Collection<?> c) {
+    maybeLazyInit();
+    return fsHashSet.containsAll(c);
+  }
+
+  /**
+   * Adds all the elements .
+   *
+   * @param c the c
+   * @return true, if set changed
+   * @see java.util.AbstractCollection#addAll(java.util.Collection)
+   */
+  @Override
+  public boolean addAll(Collection<? extends T> c) {
+    maybeLazyInit();
+    boolean r = fsHashSet.addAll(c);
+    if (r) isSaveNeeded = true;
+    return r;
+  }
+
+  /**
+   * Spliterator.
+   *
+   * @return the spliterator
+   * @see java.util.HashSet#spliterator()
+   */
+  @Override
+  public Spliterator<T> spliterator() {
+    return isSaveNeeded
+        ? fsHashSet.spliterator()
+        : (Spliterator<T>) Arrays.asList(gta()).spliterator();
+  }
+
+  /**
+   * Retain all.
+   *
+   * @param c the c
+   * @return true, if collection changed
+   * @see java.util.AbstractCollection#retainAll(java.util.Collection)
+   */
+  @Override
+  public boolean retainAll(Collection<?> c) {
+    maybeLazyInit();
+    boolean r = fsHashSet.retainAll(c);
+    if (r) isSaveNeeded = true;
+    return r;
+  }
+
+  /* (non-Javadoc)
+   * @see java.lang.Object#toString()
+   */
+  @Override
+  public String toString() {
+    final int maxLen = 10;
+    return "FSHashSet [isPendingInit=" + isPendingInit + ", isSaveNeeded=" + isSaveNeeded
+        + ", fsHashSet=" + (fsHashSet != null ? toString(fsHashSet, maxLen) : null) + "]";
+  }
+
+  /**
+   * To string.
+   *
+   * @param collection the collection
+   * @param maxLen the max len
+   * @return the string
+   */
+  private String toString(Collection<?> collection, int maxLen) {
+    StringBuilder builder = new StringBuilder();
+    builder.append("[");
+    int i = 0;
+    for (Iterator<?> iterator = collection.iterator(); iterator.hasNext() && i < maxLen; i++) {
+      if (i > 0)
+        builder.append(", ");
+      builder.append(iterator.next());
+    }
+    builder.append("]");
+    return builder.toString();
+  }
+
+}
+
+    
\ No newline at end of file