You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by tw...@apache.org on 2008/06/06 18:09:10 UTC

svn commit: r664007 - /incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/impl/JCasImpl.java

Author: twgoetz
Date: Fri Jun  6 09:09:10 2008
New Revision: 664007

URL: http://svn.apache.org/viewvc?rev=664007&view=rev
Log:
No Jira: remove tabs.

Modified:
    incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/impl/JCasImpl.java

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/impl/JCasImpl.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/impl/JCasImpl.java?rev=664007&r1=664006&r2=664007&view=diff
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/impl/JCasImpl.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/jcas/impl/JCasImpl.java Fri Jun  6 09:09:10 2008
@@ -23,7 +23,6 @@
 // *
 // * Compatibility removes at some point: TypeSystemInit and it's caller
 
-
 import java.io.InputStream;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
@@ -91,9 +90,7 @@
  * 
  * JCas and Foo_Type style classes have one instantiation per CAS View
  * 
- * Integrated with Framework Design 
- * -------------------------------- 
- * Assume: Framework collects for
+ * Integrated with Framework Design -------------------------------- Assume: Framework collects for
  * each CAS creation all the types that will be defined for this CAS. Note: can create multiple
  * instances of CASs (and JCases) each TAE/App.
  * 
@@ -114,38 +111,29 @@
  * 
  * If the CAS has its contents reset, call jcas.clearData() to reset the corresponding JCas content.
  * 
- * Implementation Notes: 
- * At loadtime, Foo and Foo_Type classes are assigned static
- * integer indexes, using the JCasRegistry.  
- * These indexes are used in arrays in the jcas instance to go from Foo class (not
- * instances) to Foo_Type instances (one per CAS). 
- * Things which require "types" at runtime reference the Foo_Type instances.
+ * Implementation Notes: At loadtime, Foo and Foo_Type classes are assigned static integer indexes,
+ * using the JCasRegistry. These indexes are used in arrays in the jcas instance to go from Foo
+ * class (not instances) to Foo_Type instances (one per CAS). Things which require "types" at
+ * runtime reference the Foo_Type instances.
  * 
  * Maps: Note: per CAS means per shared JCas instance assoc w/ CAS
  * 
- * (universal) 
- * (static field in class) 
- * go from Foo class to index unique ID used with next map to
- * locate Foo_Type instance associated with this class 
- * If universal - becomes an index for all
- * FooStyle classes loaded (per CAS) 
+ * (universal) (static field in class) go from Foo class to index unique ID used with next map to
+ * locate Foo_Type instance associated with this class If universal - becomes an index for all
+ * FooStyle classes loaded (per CAS)
  * 
- * (ArrayList) map index from Foo (static) to Foo_Type instance
- *   used in creating new instances. 
- *   Needs to be one per CAS because a particular "xyz" feature in
- *     CAS1 != "xyz" feature in CAS2 
- *     If above universal, then can become large array with mostly unused
- *     slots. 
- *     Possibility: reuse no-longer-used slots. Identify no-longer-used slots at CAS Type unload
- *     event?
+ * (ArrayList) map index from Foo (static) to Foo_Type instance used in creating new instances.
+ * Needs to be one per CAS because a particular "xyz" feature in CAS1 != "xyz" feature in CAS2 If
+ * above universal, then can become large array with mostly unused slots. Possibility: reuse
+ * no-longer-used slots. Identify no-longer-used slots at CAS Type unload event?
  */
 
 /**
- * implements the supporting infrastructure for JCas model linked with a Cas. 
- * There is one logical instance of this instantiated per Cas or CasView. 
- * If you hold a reference to a CAS, to get a reference to
- * the corresponding JCas, use the method getJCas(). Likewise, if you hold a reference to this
- * object, you can get a reference to the corresponding CAS object using the method getCas().
+ * implements the supporting infrastructure for JCas model linked with a Cas. There is one logical
+ * instance of this instantiated per Cas or CasView. If you hold a reference to a CAS, to get a
+ * reference to the corresponding JCas, use the method getJCas(). Likewise, if you hold a reference
+ * to this object, you can get a reference to the corresponding CAS object using the method
+ * getCas().
  * <p>
  * There are variables here that hold references to constant, frequently needed Cas values, such as
  * 0-length FSArrays, 0-length Strings, etc. These can be used to improve efficiency, since the same
@@ -154,16 +142,18 @@
  */
 
 public class JCasImpl extends AbstractCas_ImplBase implements AbstractCas, JCas {
-	// * FSIndexRepository - the get method returns the java type *
-	// * so FSIndexRepository can't be in the implements clause *
+  // * FSIndexRepository - the get method returns the java type *
+  // * so FSIndexRepository can't be in the implements clause *
 
   private static class LoadedJCasType {
-    final String typeName; 
-    
+    final String typeName;
+
     final int index;
+
     final boolean isSubtypeOfAnnotationBase;
-    
+
     final Constructor constructorFor_Type;
+
     final Constructor constructorForType;
 
     LoadedJCasType(String typeName, Class _TypeClass, ClassLoader cl) {
@@ -171,12 +161,12 @@
       int tempindex = 0;
       boolean tempisSubtypeOfAnnotationBase = false;
       Constructor tempconstructorFor_Type = null;
-      Constructor tempconstructorForType = null;     
+      Constructor tempconstructorForType = null;
 
       String name = _TypeClass.getName();
       try {
         Class typeClass = Class.forName(name.substring(0, name.length() - 5), true, cl); // drop
-                                                                                          // _Type
+        // _Type
 
         Field typeIndexField = null;
         try {
@@ -207,200 +197,198 @@
         index = tempindex;
         constructorFor_Type = tempconstructorFor_Type;
         constructorForType = tempconstructorForType;
-        isSubtypeOfAnnotationBase = tempisSubtypeOfAnnotationBase; 
+        isSubtypeOfAnnotationBase = tempisSubtypeOfAnnotationBase;
       }
     }
-    
+
     private void logAndThrow(Exception e) {
       CASRuntimeException casEx = new CASRuntimeException(CASRuntimeException.JCAS_CAS_MISMATCH);
       casEx.initCause(e);
-      throw casEx;      
+      throw casEx;
     }
   }
 
-	// *************************************************
-	// * Static Data shared with all instances of JCas *
-	// *************************************************
-	private final static int INITIAL_HASHMAP_SIZE = 256;
+  // *************************************************
+  // * Static Data shared with all instances of JCas *
+  // *************************************************
+  private final static int INITIAL_HASHMAP_SIZE = 256;
 
-  // keys = class loader, 
+  // keys = class loader,
   // values = Maps: keys = string = fully qualified java type names of _Type classes
-  //                values = instances of LoadedJCasType 
-  
-  // Note: cannot use treemap here because keys (class loaders) are not comparable (have no sort order)
+  // values = instances of LoadedJCasType
+
+  // Note: cannot use treemap here because keys (class loaders) are not comparable (have no sort
+  // order)
   // To use: first look up with key = typeSystemImpl instance (uses == test)
-  //   Then use value and look up using class loader (uses == test)
-  //   These are Weak maps so that they don't hold onto their keys (class loader or type system) if these 
-  //     are no longer in use
+  // Then use value and look up using class loader (uses == test)
+  // These are Weak maps so that they don't hold onto their keys (class loader or type system) if
+  // these
+  // are no longer in use
   //
-  //  This is a static map - effectively indexed by all loaded type systems and all classloaders
-  
-  //  Access to this must be synch'd
+  // This is a static map - effectively indexed by all loaded type systems and all classloaders
+
+  // Access to this must be synch'd
   private static Map typeSystemToLoadedJCasTypesByClassLoader = new WeakHashMap(4);
-  
-	// **********************************************
-	// * Data shared among views of a single CAS *
-	// * We keep one copy per view set *
-	// **********************************************/
+
+  // **********************************************
+  // * Data shared among views of a single CAS *
+  // * We keep one copy per view set *
+  // **********************************************/
   private static class JCasSharedView {
-		// ********************************************************
-		// * Data shared among all views in a (J)CAS View group *
-		// * Access to this data is assumed to be single threaded *
-		// ********************************************************
+    // ********************************************************
+    // * Data shared among all views in a (J)CAS View group *
+    // * Access to this data is assumed to be single threaded *
+    // ********************************************************
 
     /**
-     *   key = CAS addr, 
-     *   value = corresponding Java instance
-     *  This impl was changed in May 2007 to a design of one cover object
-     *  per CAS object, when dealing with multiple views.
-     *  This implements better semantics for co-located components sharing 
-     *  these objects - they all get to share the same object, independent of
-     *  which view(s) the object may be indexed in.  For cases where the user has
-     *  augmented the definition of the JCas object to have native Java fields, this
-     *  design is closer to the user's expectation.
+     * key = CAS addr, value = corresponding Java instance This impl was changed in May 2007 to a
+     * design of one cover object per CAS object, when dealing with multiple views. This implements
+     * better semantics for co-located components sharing these objects - they all get to share the
+     * same object, independent of which view(s) the object may be indexed in. For cases where the
+     * user has augmented the definition of the JCas object to have native Java fields, this design
+     * is closer to the user's expectation.
      * 
-     * The only use for multiple objects, previously, was to implement the 0-argument
-     * version of addToIndexes and removeFromIndexes.  The new implementation will come close
-     * (but not be perfectly the same) as the old implementation, by doing the following:
+     * The only use for multiple objects, previously, was to implement the 0-argument version of
+     * addToIndexes and removeFromIndexes. The new implementation will come close (but not be
+     * perfectly the same) as the old implementation, by doing the following:
+     * 
+     * Changing the "new" and get/next from iterator methods to set the _Type field of the retrieved
+     * cover class object (or new object) to the correct view.
+     * 
+     * Deref objects follow many paths. They all have a default view they create the object with
+     * respect to. A simple deref uses the same cas ref the original object had.
      * 
-     *    Changing the "new" and get/next from iterator methods to set the _Type field of the
-     *    retrieved cover class object (or new object) to the correct view.
-     *    
-     *    Deref objects follow many paths.  They all have a default view they create the object
-     *    with respect to.  A simple deref uses the same cas ref the original object had.
-     *      
      */
     private int prevCaddr2JfsSize = INITIAL_HASHMAP_SIZE;
-    
+
     private JCasHashMap cAddr2Jfs = new JCasHashMap(INITIAL_HASHMAP_SIZE);
-    
-    private final Map   cAddr2JfsByClassLoader = new HashMap();
+
+    private final Map cAddr2JfsByClassLoader = new HashMap();
 
     /* convenience holders of CAS constants that may be useful */
     /* initialization done lazily - on first call to getter */
 
-    public StringArray  stringArray0L          = null;
+    public StringArray stringArray0L = null;
 
-    public IntegerArray integerArray0L         = null;
+    public IntegerArray integerArray0L = null;
 
-    public FloatArray   floatArray0L           = null;
+    public FloatArray floatArray0L = null;
 
-    public FSArray      fsArray0L              = null;
+    public FSArray fsArray0L = null;
 
     // * collection of errors that occur during initialization
-    public Collection   errorSet               = new ArrayList();
-    
-    public ClassLoader  currentClassLoader     = null;
+    public Collection errorSet = new ArrayList();
+
+    public ClassLoader currentClassLoader = null;
 
     private JCasSharedView(CASImpl aCAS) {
       cAddr2JfsByClassLoader.put(aCAS.getJCasClassLoader(), cAddr2Jfs);
       currentClassLoader = aCAS.getJCasClassLoader();
     }
   }
-  
-	// *******************
-	// * Data per (J)CAS *
-	// * There may be multiples of these for one base CAS - one per "view"
-	// * Access to this data is assumed to be single threaded
-	// *******************
-
-	private final JCasSharedView sharedView;
-
-  //not public to protect it from accidents
-	private final CASImpl casImpl; 
-
-	private final LowLevelIndexRepository ll_IndexRepository;
-
-	private final JFSIndexRepository jfsIndexRepository;
-
-	/*
-   * typeArray is one per CAS because holds pointers to instances of _Type objects, per CAS
-   * Not in shared view, because the typeArray points to instances that go with the view. This is
-   * used when making instances - it allows each instance to be associated with a view, for purposes
-   * of making addtoIndexes() and removeFromIndexes() work.
-   * Not final, because it may need to be "extended" if alternate versions of types are loaded from
-   * different class loaders, at some point in the execution.  The alternate versions are given
-   * their own slots in this array.
-   */
-	private TOP_Type[] typeArray = new TOP_Type[0]; // contents are subtypes of TOP_Type
-
-	// *********************************
-	// * Getters for read-only objects *
-	// *********************************
-	/*
+
+  // *******************
+  // * Data per (J)CAS *
+  // * There may be multiples of these for one base CAS - one per "view"
+  // * Access to this data is assumed to be single threaded
+  // *******************
+
+  private final JCasSharedView sharedView;
+
+  // not public to protect it from accidents
+  private final CASImpl casImpl;
+
+  private final LowLevelIndexRepository ll_IndexRepository;
+
+  private final JFSIndexRepository jfsIndexRepository;
+
+  /*
+   * typeArray is one per CAS because holds pointers to instances of _Type objects, per CAS Not in
+   * shared view, because the typeArray points to instances that go with the view. This is used when
+   * making instances - it allows each instance to be associated with a view, for purposes of making
+   * addtoIndexes() and removeFromIndexes() work. Not final, because it may need to be "extended" if
+   * alternate versions of types are loaded from different class loaders, at some point in the
+   * execution. The alternate versions are given their own slots in this array.
+   */
+  private TOP_Type[] typeArray = new TOP_Type[0]; // contents are subtypes of TOP_Type
+
+  // *********************************
+  // * Getters for read-only objects *
+  // *********************************
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getFSIndexRepository()
    */
-	public FSIndexRepository getFSIndexRepository() {
-		return casImpl.getIndexRepository();
-	}
+  public FSIndexRepository getFSIndexRepository() {
+    return casImpl.getIndexRepository();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getLowLevelIndexRepository()
    */
-	public LowLevelIndexRepository getLowLevelIndexRepository() {
-		return ll_IndexRepository;
-	}
+  public LowLevelIndexRepository getLowLevelIndexRepository() {
+    return ll_IndexRepository;
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getCas()
    */
-	public CAS getCas() {
-		return casImpl;
-	}
+  public CAS getCas() {
+    return casImpl;
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getCasImpl()
    */
-	public CASImpl getCasImpl() {
-		return casImpl;
-	}
+  public CASImpl getCasImpl() {
+    return casImpl;
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getLowLevelCas()
    */
-	public LowLevelCAS getLowLevelCas() {
-		return casImpl;
-	}
+  public LowLevelCAS getLowLevelCas() {
+    return casImpl;
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getTypeSystem()
    */
-	public TypeSystem getTypeSystem() {
-		return casImpl.getTypeSystem();
-	}
+  public TypeSystem getTypeSystem() {
+    return casImpl.getTypeSystem();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getType(int)
    */
   public TOP_Type getType(int i) {
     if (i >= typeArray.length || null == typeArray[i]) {
-      // unknown ID.  This may be due to a need to update the typeArray
-      //   due to switching class loaders.  This updating is done
-      //   partially lazily - when needed, beyond the particular CAS instance and
-      //   view that was being passed to a process method when the
-      //   class loader switch was done.
-      
-      //   In order for this to work, all access to the typeArray must be
-      //   via this getter.
-      
-      //   Try instantiating the entries in typeArray for this class loader
+      // unknown ID. This may be due to a need to update the typeArray
+      // due to switching class loaders. This updating is done
+      // partially lazily - when needed, beyond the particular CAS instance and
+      // view that was being passed to a process method when the
+      // class loader switch was done.
+
+      // In order for this to work, all access to the typeArray must be
+      // via this getter.
+
+      // Try instantiating the entries in typeArray for this class loader
       instantiateJCas_Types(this.sharedView.currentClassLoader);
       if (i >= typeArray.length || null == typeArray[i]) {
-        
+
         // unknown ID. Attempt to get offending class.
         Class cls = JCasRegistry.getClassForIndex(i);
         if (cls != null) {
@@ -427,41 +415,40 @@
     return typeArray[i];
   }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getCasType(int)
    */
-	public Type getCasType(int i) {
-		return getType(i).casType;
-	}
+  public Type getCasType(int i) {
+    return getType(i).casType;
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getType(org.apache.uima.jcas.cas.TOP)
    */
-	public TOP_Type getType(TOP instance) {
-		return getType(instance.getTypeIndexID());
-	}
-
-	/** throws (an unchecked) CASRuntimeException */
-	private void logAndThrow(Exception e) {
-		CASRuntimeException casEx = new CASRuntimeException(CASRuntimeException.JCAS_CAS_MISMATCH);
-		casEx.initCause(e);
-		throw casEx;
-	}
-
-
-	// never called, but have to set values to null because they're final
-	private JCasImpl() {
-		sharedView = null;
-		casImpl = null;
-		ll_IndexRepository = null;
-		throw new RuntimeException("JCas constructor with no args called, should never be called.");
-	}
+  public TOP_Type getType(TOP instance) {
+    return getType(instance.getTypeIndexID());
+  }
 
-	/*
+  /** throws (an unchecked) CASRuntimeException */
+  private void logAndThrow(Exception e) {
+    CASRuntimeException casEx = new CASRuntimeException(CASRuntimeException.JCAS_CAS_MISMATCH);
+    casEx.initCause(e);
+    throw casEx;
+  }
+
+  // never called, but have to set values to null because they're final
+  private JCasImpl() {
+    sharedView = null;
+    casImpl = null;
+    ll_IndexRepository = null;
+    throw new RuntimeException("JCas constructor with no args called, should never be called.");
+  }
+
+  /*
    * Private constructor, called when new instance (either for new cas, or for old cas but new
    * Annotator/Application class, needed
    * 
@@ -470,48 +457,50 @@
    * The CAS must be initialized when this is called.
    * 
    */
-	private JCasImpl(CASImpl cas) throws CASException {
+  private JCasImpl(CASImpl cas) throws CASException {
+
+    // * A new instance of JCas exists for each CAS
+    // * At this point, some but not necessarily all of the Types have been
+    // loaded
+
+    // * the typeArray needs to be big enough to hold all the types
+    // * that will be loaded.
+
+    this.casImpl = cas;
+    if (casImpl != casImpl.getBaseCAS()) {
+      sharedView = ((JCasImpl) casImpl.getBaseCAS().getJCas()).sharedView;
+      sharedView.errorSet.clear();
+    } else {
+      sharedView = new JCasSharedView(cas);
+    }
 
-		// * A new instance of JCas exists for each CAS
-		// * At this point, some but not necessarily all of the Types have been
-		// loaded
-
-		// * the typeArray needs to be big enough to hold all the types
-		// * that will be loaded.
-
-		this.casImpl = cas;
-		if (casImpl != casImpl.getBaseCAS()) {
-			sharedView = ((JCasImpl) casImpl.getBaseCAS().getJCas()).sharedView;
-			sharedView.errorSet.clear();
-		} else {
-			sharedView = new JCasSharedView(cas);
-		}
-
-		this.ll_IndexRepository = casImpl.ll_getIndexRepository();
-		this.jfsIndexRepository = new JFSIndexRepositoryImpl(this, cas.getIndexRepository());
-
-		// * acquire the lock for this thread that is the same lock
-		// * used in the getNextIndexIncr operation. This will block
-		// * any other (meaning on another thread)
-		// * loading of the JCas Type classes until this thread's loading
-		// * completes.
+    this.ll_IndexRepository = casImpl.ll_getIndexRepository();
+    this.jfsIndexRepository = new JFSIndexRepositoryImpl(this, cas.getIndexRepository());
 
- 		synchronized (JCasImpl.class) {
+    // * acquire the lock for this thread that is the same lock
+    // * used in the getNextIndexIncr operation. This will block
+    // * any other (meaning on another thread)
+    // * loading of the JCas Type classes until this thread's loading
+    // * completes.
+
+    synchronized (JCasImpl.class) {
       ClassLoader cl = cas.getJCasClassLoader();
       instantiateJCas_Types(cl);
-		} // end of synchronized block
-	}
+    } // end of synchronized block
+  }
 
   /**
    * This is only called when the JCas is already set up
-   * @param cl class loader to switch to
-   * @throws CASException 
+   * 
+   * @param cl
+   *                class loader to switch to
+   * @throws CASException
    */
-  public void switchClassLoader(ClassLoader cl)  {
-    
+  public void switchClassLoader(ClassLoader cl) {
+
     // first try a fast switch - works if we've switched before to this class loader
     if (!casImpl.getFSClassRegistry().swapInGeneratorsForClassLoader(cl, casImpl)) {
-      instantiateJCas_Types(cl);      
+      instantiateJCas_Types(cl);
     }
     final JCasSharedView sv = this.sharedView;
     sv.cAddr2Jfs = (JCasHashMap) sv.cAddr2JfsByClassLoader.get(cl);
@@ -521,11 +510,12 @@
     }
     sv.currentClassLoader = cl;
   }
-  
+
   /**
-   * There may be several type systems with different defined types loaded and operating at the same time
-   * (in different CASes)
-   *   There is an instance of the loaded JCas Classes for each Type System for each class loader.
+   * There may be several type systems with different defined types loaded and operating at the same
+   * time (in different CASes) There is an instance of the loaded JCas Classes for each Type System
+   * for each class loader.
+   * 
    * @param cl
    * @return
    */
@@ -555,7 +545,8 @@
         try {
           String nameBase = "org.apache.uima.jcas." + casName.substring(5);
           name_Type = nameBase + "_Type";
-          jcasTypes.put(nameBase, new LoadedJCasType(t.getName(), Class.forName(name_Type, true, cl), cl));
+          jcasTypes.put(nameBase, new LoadedJCasType(t.getName(), Class
+              .forName(name_Type, true, cl), cl));
         } catch (ClassNotFoundException e1) {
           // OK for DocumentAnnotation, which may not have a cover class.
           // Otherwise, not OK.
@@ -570,7 +561,8 @@
       // as well as other JCas model types
       try {
         name_Type = casName + "_Type";
-        jcasTypes.put(casName, new LoadedJCasType(t.getName(), Class.forName(name_Type, true, cl), cl));
+        jcasTypes.put(casName, new LoadedJCasType(t.getName(), Class.forName(name_Type, true, cl),
+            cl));
         // also force the load the plain name without _Type for
         // old-style - that's where
         // the index is incremented
@@ -594,17 +586,17 @@
     expandTypeArrayIfNeeded();
     return jcasTypes;
   }
-  
+
   // note: callers are not synchronized because the typeArray has a
-  //  separate instance per CAS (actually per CAS view)
+  // separate instance per CAS (actually per CAS view)
   private void expandTypeArrayIfNeeded() {
     if (typeArray.length < JCasRegistry.getNumberOfRegisteredClasses()) {
-      TOP_Type [] newTypeArray = new TOP_Type[JCasRegistry.getNumberOfRegisteredClasses()];
+      TOP_Type[] newTypeArray = new TOP_Type[JCasRegistry.getNumberOfRegisteredClasses()];
       System.arraycopy(typeArray, 0, newTypeArray, 0, typeArray.length);
       typeArray = newTypeArray;
-    }  
+    }
   }
-  
+
   public void instantiateJCas_Types(ClassLoader cl) {
     Map loadedJCasTypes = null;
     FSClassRegistry fscr = casImpl.getFSClassRegistry();
@@ -630,7 +622,7 @@
       if (!alreadyLoaded) {
         copyDownSuperGenerators(loadedJCasTypes, newFSGeneratorSet);
         if (casImpl.usingBaseClassLoader()) {
-          fscr.setBaseGenerators(newFSGeneratorSet);  // should be under sync lock
+          fscr.setBaseGenerators(newFSGeneratorSet); // should be under sync lock
         }
         fscr.saveGeneratorsForClassLoader(cl, newFSGeneratorSet);
       }
@@ -641,9 +633,9 @@
       casImpl.setLocalFsGenerators(newFSGeneratorSet);
     }
   }
-  
+
   // note all callers are synchronized
-  private void copyDownSuperGenerators(Map jcasTypes, FSGenerator [] fsGenerators) { 
+  private void copyDownSuperGenerators(Map jcasTypes, FSGenerator[] fsGenerators) {
     final TypeSystem ts = casImpl.getTypeSystem();
     Iterator typeIt = ts.getTypeIterator(); // reset iterator to start
     Type topType = ts.getTopType();
@@ -673,136 +665,139 @@
         }
       } while ((null == jcasTypes.get(superTypeName) && !superType.equals(topType)));
       // copy down its generator
-      fsGenerators[((TypeImpl)t).getCode()] = fsGenerators[((TypeImpl)superType).getCode()];
+      fsGenerators[((TypeImpl) t).getCode()] = fsGenerators[((TypeImpl) superType).getCode()];
     }
   }
 
-	/**
+  /**
    * creates a new JCas instance that corresponds to a CAS instance. Will be called once by the UIMA
    * framework when it creates the CAS.
    * 
    * @param cas
-   *          a CAS instance
+   *                a CAS instance
    * @return newly created and initialized JCas
    */
-	public static JCas getJCas(CASImpl cas) throws CASException {
-		JCasImpl jcas = new JCasImpl(cas);
+  public static JCas getJCas(CASImpl cas) throws CASException {
+    JCasImpl jcas = new JCasImpl(cas);
     JCasSharedView sv = jcas.sharedView;
-		if (sv.errorSet.size() > 0) {
-			StringBuffer msg = new StringBuffer(100);
-			Iterator iter = sv.errorSet.iterator();
-			while (iter.hasNext()) {
-				Exception f = (Exception) iter.next();
-				msg.append(f.getMessage());
-				msg.append("\n");
-			}
-			CASException e = new CASException(CASException.JCAS_INIT_ERROR,
-					new String[] { msg.toString() });
-			throw e;
-		}
-		return jcas;
-	}
+    if (sv.errorSet.size() > 0) {
+      StringBuffer msg = new StringBuffer(100);
+      Iterator iter = sv.errorSet.iterator();
+      while (iter.hasNext()) {
+        Exception f = (Exception) iter.next();
+        msg.append(f.getMessage());
+        msg.append("\n");
+      }
+      CASException e = new CASException(CASException.JCAS_INIT_ERROR,
+          new String[] { msg.toString() });
+      throw e;
+    }
+    return jcas;
+  }
 
-	/**
+  /**
    * built-in types which have alternate names It really isn't necessary to skip these - they're
    * never instantiated. But it is a very slight performance boost, and it may be safer given
    * possible future changes to these types' implementations.
    */
-	private static final Collection builtInsWithNoJCas = new ArrayList();
-	static {
-			builtInsWithNoJCas.add(CAS.TYPE_NAME_BOOLEAN);
-			builtInsWithNoJCas.add(CAS.TYPE_NAME_BYTE);
-			builtInsWithNoJCas.add(CAS.TYPE_NAME_SHORT);
-			builtInsWithNoJCas.add(CAS.TYPE_NAME_INTEGER);
-			builtInsWithNoJCas.add(CAS.TYPE_NAME_LONG);
-			builtInsWithNoJCas.add(CAS.TYPE_NAME_FLOAT);
-			builtInsWithNoJCas.add(CAS.TYPE_NAME_DOUBLE);
-			builtInsWithNoJCas.add(CAS.TYPE_NAME_STRING);
-			builtInsWithNoJCas.add(CAS.TYPE_NAME_ARRAY_BASE);
-			builtInsWithNoJCas.add(CAS.TYPE_NAME_LIST_BASE);
-	}
-
-	private static final Collection builtInsWithAltNames = new ArrayList();
-	static { // initialization code
-			builtInsWithAltNames.add(CAS.TYPE_NAME_TOP);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_STRING_ARRAY);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_BOOLEAN_ARRAY);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_BYTE_ARRAY);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_SHORT_ARRAY);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_INTEGER_ARRAY);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_LONG_ARRAY);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_FS_ARRAY);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_FLOAT_ARRAY);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_DOUBLE_ARRAY);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_EMPTY_FLOAT_LIST);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_EMPTY_FS_LIST);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_EMPTY_INTEGER_LIST);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_EMPTY_STRING_LIST);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_FLOAT_LIST);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_FS_LIST);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_INTEGER_LIST);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_STRING_LIST);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_NON_EMPTY_FLOAT_LIST);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_NON_EMPTY_FS_LIST);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_NON_EMPTY_INTEGER_LIST);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_NON_EMPTY_STRING_LIST);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_SOFA);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_ANNOTATION_BASE);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_ANNOTATION);
-			builtInsWithAltNames.add(CAS.TYPE_NAME_DOCUMENT_ANNOTATION);
-	}
-
- 
-    // This generator class is used in place of the generator that is in each of the
-	// older JCasGen'd classes
-	
-	// It makes use of the passed-in CAS view so one generator works for all Cas Views.
-	// It references the xxx_Type instance using the getType call, which will 
-	//  (lazily) instantiate the xxx_Type object if needed (due to switching class loaders: 
-	//  see comment under getType(int))
-	
+  private static final Collection builtInsWithNoJCas = new ArrayList();
+  static {
+    builtInsWithNoJCas.add(CAS.TYPE_NAME_BOOLEAN);
+    builtInsWithNoJCas.add(CAS.TYPE_NAME_BYTE);
+    builtInsWithNoJCas.add(CAS.TYPE_NAME_SHORT);
+    builtInsWithNoJCas.add(CAS.TYPE_NAME_INTEGER);
+    builtInsWithNoJCas.add(CAS.TYPE_NAME_LONG);
+    builtInsWithNoJCas.add(CAS.TYPE_NAME_FLOAT);
+    builtInsWithNoJCas.add(CAS.TYPE_NAME_DOUBLE);
+    builtInsWithNoJCas.add(CAS.TYPE_NAME_STRING);
+    builtInsWithNoJCas.add(CAS.TYPE_NAME_ARRAY_BASE);
+    builtInsWithNoJCas.add(CAS.TYPE_NAME_LIST_BASE);
+  }
+
+  private static final Collection builtInsWithAltNames = new ArrayList();
+  static { // initialization code
+    builtInsWithAltNames.add(CAS.TYPE_NAME_TOP);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_STRING_ARRAY);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_BOOLEAN_ARRAY);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_BYTE_ARRAY);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_SHORT_ARRAY);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_INTEGER_ARRAY);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_LONG_ARRAY);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_FS_ARRAY);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_FLOAT_ARRAY);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_DOUBLE_ARRAY);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_EMPTY_FLOAT_LIST);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_EMPTY_FS_LIST);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_EMPTY_INTEGER_LIST);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_EMPTY_STRING_LIST);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_FLOAT_LIST);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_FS_LIST);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_INTEGER_LIST);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_STRING_LIST);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_NON_EMPTY_FLOAT_LIST);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_NON_EMPTY_FS_LIST);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_NON_EMPTY_INTEGER_LIST);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_NON_EMPTY_STRING_LIST);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_SOFA);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_ANNOTATION_BASE);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_ANNOTATION);
+    builtInsWithAltNames.add(CAS.TYPE_NAME_DOCUMENT_ANNOTATION);
+  }
+
+  // This generator class is used in place of the generator that is in each of the
+  // older JCasGen'd classes
+
+  // It makes use of the passed-in CAS view so one generator works for all Cas Views.
+  // It references the xxx_Type instance using the getType call, which will
+  // (lazily) instantiate the xxx_Type object if needed (due to switching class loaders:
+  // see comment under getType(int))
+
   static private class JCasFsGenerator implements FSGenerator {
     private final int type;
+
     private final Constructor c;
 
     private final boolean isSubtypeOfAnnotationBase;
+
     private final int sofaNbrFeatCode;
+
     private final int annotSofaFeatCode;
 
-    JCasFsGenerator(int type, Constructor c, boolean isSubtypeOfAnnotationBase, int sofaNbrFeatCode, int annotSofaFeatCode) {
-      this.type = type;  
+    JCasFsGenerator(int type, Constructor c, boolean isSubtypeOfAnnotationBase,
+        int sofaNbrFeatCode, int annotSofaFeatCode) {
+      this.type = type;
       this.c = c;
       this.isSubtypeOfAnnotationBase = isSubtypeOfAnnotationBase;
       this.sofaNbrFeatCode = sofaNbrFeatCode;
       this.annotSofaFeatCode = annotSofaFeatCode;
     }
-    
+
     // Called in 3 cases
-    //   1) a non-JCas call to create a new FS
-    //   2) a dereference of an existing FS
-    //   3) an iterator
+    // 1) a non-JCas call to create a new FS
+    // 2) a dereference of an existing FS
+    // 3) an iterator
     public FeatureStructure createFS(int addr, CASImpl casView) {
-      Object [] initargs = new Object[2];
+      Object[] initargs = new Object[2];
       JCasImpl jcasView = null;
       // this funny logic is because although the annotationView should always be set if
-      //  a type is a subtype of annotation, it isn't always set if an application uses low-level 
-      //  api's.  Rather than blow up, we limp along.
-      CASImpl maybeAnnotationView = null;  
+      // a type is a subtype of annotation, it isn't always set if an application uses low-level
+      // api's. Rather than blow up, we limp along.
+      CASImpl maybeAnnotationView = null;
       if (isSubtypeOfAnnotationBase) {
         final int sofaNbr = getSofaNbr(addr, casView);
         if (sofaNbr > 0) {
-          maybeAnnotationView = (CASImpl)casView.getView(sofaNbr);
+          maybeAnnotationView = (CASImpl) casView.getView(sofaNbr);
         }
       }
       final CASImpl view = (null != maybeAnnotationView) ? maybeAnnotationView : casView;
 
       try {
-        jcasView = (JCasImpl)view.getJCas();
+        jcasView = (JCasImpl) view.getJCas();
       } catch (CASException e1) {
-       logAndThrow(e1, jcasView);
+        logAndThrow(e1, jcasView);
       }
-     
-     // Return eq fs instance if already created
+
+      // Return eq fs instance if already created
       TOP fs = jcasView.getJfsFromCaddr(addr);
       if (null != fs) {
         fs.jcasType = jcasView.getType(type);
@@ -819,19 +814,20 @@
           logAndThrow(e, jcasView);
         } catch (InvocationTargetException e) {
           logAndThrow(e, jcasView);
-        } 
+        }
         jcasView.putJfsFromCaddr(addr, fs);
       }
       return fs;
     }
- 
+
     private void logAndThrow(Exception e, JCasImpl jcasView) {
-      CASRuntimeException casEx = new CASRuntimeException(CASRuntimeException.JCAS_CAS_MISMATCH,
-              new String[] { (null == jcasView)? "-- ignore outer msg, error is can''t get value of jcas from cas"
-                        : (jcasView.getType(type).casType.getName() + "; exception= " 
-                                + e.getClass().getName() + "; msg= " + e.getLocalizedMessage())});
+      CASRuntimeException casEx = new CASRuntimeException(
+          CASRuntimeException.JCAS_CAS_MISMATCH,
+          new String[] { (null == jcasView) ? "-- ignore outer msg, error is can''t get value of jcas from cas"
+              : (jcasView.getType(type).casType.getName() + "; exception= "
+                  + e.getClass().getName() + "; msg= " + e.getLocalizedMessage()) });
       casEx.initCause(e);
-      throw casEx;      
+      throw casEx;
     }
 
     private int getSofaNbr(int addr, CASImpl casView) {
@@ -841,20 +837,20 @@
     }
   }
 
-  
   // per JCas instance - so don't need to synch.
   private final Object[] constructorArgsFor_Type = new Object[2];
-  
+
   /**
    * Make the instance of the JCas xxx_Type class for this CAS. Note: not all types will have
    * xxx_Type. Instance creation does the typeSystemInit kind of function, as well.
    */
 
-  private void makeInstanceOf_Type(LoadedJCasType jcasTypeInfo, boolean alreadyLoaded, FSGenerator[] fsGenerators) {
+  private void makeInstanceOf_Type(LoadedJCasType jcasTypeInfo, boolean alreadyLoaded,
+      FSGenerator[] fsGenerators) {
     Constructor c_Type = jcasTypeInfo.constructorFor_Type;
-    Constructor cType  = jcasTypeInfo.constructorForType;
+    Constructor cType = jcasTypeInfo.constructorForType;
     int typeIndex = jcasTypeInfo.index;
-    TypeImpl casType = (TypeImpl)casImpl.getTypeSystem().getType(jcasTypeInfo.typeName);
+    TypeImpl casType = (TypeImpl) casImpl.getTypeSystem().getType(jcasTypeInfo.typeName);
 
     try {
       constructorArgsFor_Type[0] = this;
@@ -862,13 +858,14 @@
       TOP_Type x_Type_instance = (TOP_Type) c_Type.newInstance(constructorArgsFor_Type);
       typeArray[typeIndex] = x_Type_instance;
       // install the standard generator
-      //   this is sharable by all views, since the CAS is passed to the generator
-      //   Also sharable by all in a CasPool, except for "swapping" due to PEARs/Classloaders.
-      if (! alreadyLoaded) {
+      // this is sharable by all views, since the CAS is passed to the generator
+      // Also sharable by all in a CasPool, except for "swapping" due to PEARs/Classloaders.
+      if (!alreadyLoaded) {
         final TypeSystemImpl ts = casImpl.getTypeSystemImpl();
-        fsGenerators[casType.getCode()] = new JCasFsGenerator(typeIndex, cType, jcasTypeInfo.isSubtypeOfAnnotationBase, 
-                ts.sofaNumFeatCode, ts.annotSofaFeatCode);
-//        this.casImpl.getFSClassRegistry().loadJCasGeneratorForType(typeIndex, cType, casType, jcasTypeInfo.isSubtypeOfAnnotationBase);
+        fsGenerators[casType.getCode()] = new JCasFsGenerator(typeIndex, cType,
+            jcasTypeInfo.isSubtypeOfAnnotationBase, ts.sofaNumFeatCode, ts.annotSofaFeatCode);
+        // this.casImpl.getFSClassRegistry().loadJCasGeneratorForType(typeIndex, cType, casType,
+        // jcasTypeInfo.isSubtypeOfAnnotationBase);
       }
     } catch (SecurityException e) {
       logAndThrow(e);
@@ -883,161 +880,136 @@
     }
   }
 
-	/**
+  /**
    * Make the instance of the JCas xxx_Type class for this CAS. Note: not all types will have
    * xxx_Type. Instance creation does the typeSystemInit kind of function, as well.
    */
-/*
-	private void makeInstanceOf_Type(Type casType, Class clas, CASImpl cas) {
-		Constructor c;
-		Field typeIndexField = null;
-		int typeIndex;
-		try {
-			c = clas.getDeclaredConstructor(jcasBaseAndType);
-			try {
-
-				typeIndexField = clas.getDeclaredField("typeIndexID");
-			} catch (NoSuchFieldException e) {
-				try {
-					// old version has the index in the base type
-					String name = clas.getName();
-					Class clas2 = Class.forName(name.substring(0, name.length() - 5), true, cas
-							.getJCasClassLoader()); // drop _Type
-					typeIndexField = clas2.getDeclaredField("typeIndexID");
-				} catch (NoSuchFieldException e2) {
-					logAndThrow(e2);
-				} catch (ClassNotFoundException e3) {
-					logAndThrow(e3);
-				}
-			}
-			typeIndex = typeIndexField.getInt(null); // null - static instance var
-			TOP_Type x_Type_instance = (TOP_Type) c.newInstance(new Object[] { this, casType });
-			typeArray[typeIndex] = x_Type_instance;
-		} catch (SecurityException e) {
-			logAndThrow(e);
-		} catch (NoSuchMethodException e) {
-			logAndThrow(e);
-		} catch (InstantiationException e) {
-			logAndThrow(e);
-		} catch (IllegalAccessException e) {
-			logAndThrow(e);
-		} catch (InvocationTargetException e) {
-			logAndThrow(e);
-		} catch (ArrayIndexOutOfBoundsException e) {
-			logAndThrow(e);
-		}
-	}
-*/
-   
+  /*
+   * private void makeInstanceOf_Type(Type casType, Class clas, CASImpl cas) { Constructor c; Field
+   * typeIndexField = null; int typeIndex; try { c = clas.getDeclaredConstructor(jcasBaseAndType);
+   * try {
+   * 
+   * typeIndexField = clas.getDeclaredField("typeIndexID"); } catch (NoSuchFieldException e) { try { //
+   * old version has the index in the base type String name = clas.getName(); Class clas2 =
+   * Class.forName(name.substring(0, name.length() - 5), true, cas .getJCasClassLoader()); // drop
+   * _Type typeIndexField = clas2.getDeclaredField("typeIndexID"); } catch (NoSuchFieldException e2) {
+   * logAndThrow(e2); } catch (ClassNotFoundException e3) { logAndThrow(e3); } } typeIndex =
+   * typeIndexField.getInt(null); // null - static instance var TOP_Type x_Type_instance =
+   * (TOP_Type) c.newInstance(new Object[] { this, casType }); typeArray[typeIndex] =
+   * x_Type_instance; } catch (SecurityException e) { logAndThrow(e); } catch (NoSuchMethodException
+   * e) { logAndThrow(e); } catch (InstantiationException e) { logAndThrow(e); } catch
+   * (IllegalAccessException e) { logAndThrow(e); } catch (InvocationTargetException e) {
+   * logAndThrow(e); } catch (ArrayIndexOutOfBoundsException e) { logAndThrow(e); } }
+   */
 
-  
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getRequiredType(java.lang.String)
    */
-	public Type getRequiredType(String s) throws CASException {
-		Type t = getTypeSystem().getType(s);
-		if (null == t) {
-			CASException casEx = new CASException(CASException.JCAS_TYPENOTFOUND_ERROR,
-					new String[] { s });
-			throw casEx;
-		}
-		return t;
-	}
+  public Type getRequiredType(String s) throws CASException {
+    Type t = getTypeSystem().getType(s);
+    if (null == t) {
+      CASException casEx = new CASException(CASException.JCAS_TYPENOTFOUND_ERROR,
+          new String[] { s });
+      throw casEx;
+    }
+    return t;
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getRequiredFeature(org.apache.uima.cas.Type, java.lang.String)
    */
-	public Feature getRequiredFeature(Type t, String s) throws CASException {
-		Feature f = t.getFeatureByBaseName(s);
-		if (null == f) {
-			CASException casEx = new CASException(CASException.JCAS_FEATURENOTFOUND_ERROR, new String[] {
-					t.getName(), s });
-			throw casEx;
-		}
-		return f;
-	}
+  public Feature getRequiredFeature(Type t, String s) throws CASException {
+    Feature f = t.getFeatureByBaseName(s);
+    if (null == f) {
+      CASException casEx = new CASException(CASException.JCAS_FEATURENOTFOUND_ERROR, new String[] {
+          t.getName(), s });
+      throw casEx;
+    }
+    return f;
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getRequiredFeatureDE(org.apache.uima.cas.Type, java.lang.String,
    *      java.lang.String, boolean)
    */
 
-	public Feature getRequiredFeatureDE(Type t, String s, String rangeName, boolean featOkTst) {
-		Feature f = t.getFeatureByBaseName(s);
-		Type rangeType = this.getTypeSystem().getType(rangeName);
-		if (null == f && !featOkTst) {
-			CASException casEx = new CASException(CASException.JCAS_FEATURENOTFOUND_ERROR, new String[] {
-					t.getName(), s });
-			sharedView.errorSet.add(casEx);
-		}
-		if (null != f)
-			try {
-				casImpl.checkTypingConditions(t, rangeType, f);
-			} catch (LowLevelException e) {
-				CASException casEx = new CASException(CASException.JCAS_FEATURE_WRONG_TYPE, new String[] {
-						t.getName(), s, rangeName, f.getRange().toString() });
-				sharedView.errorSet.add(casEx);
-			}
-		return f;
-	}
+  public Feature getRequiredFeatureDE(Type t, String s, String rangeName, boolean featOkTst) {
+    Feature f = t.getFeatureByBaseName(s);
+    Type rangeType = this.getTypeSystem().getType(rangeName);
+    if (null == f && !featOkTst) {
+      CASException casEx = new CASException(CASException.JCAS_FEATURENOTFOUND_ERROR, new String[] {
+          t.getName(), s });
+      sharedView.errorSet.add(casEx);
+    }
+    if (null != f)
+      try {
+        casImpl.checkTypingConditions(t, rangeType, f);
+      } catch (LowLevelException e) {
+        CASException casEx = new CASException(CASException.JCAS_FEATURE_WRONG_TYPE, new String[] {
+            t.getName(), s, rangeName, f.getRange().toString() });
+        sharedView.errorSet.add(casEx);
+      }
+    return f;
+  }
 
-	/**
+  /**
    * Internal - throw missing feature exception at runtime
    * 
    * @param feat
    * @param type
    */
-	public void throwFeatMissing(String feat, String type) {
-		CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INAPPROP_FEAT,
-				new String[] { feat, type });
-		throw e;
-	}
-
-	// constant used in the following function
-	/** internal use - constant used in getting constructors */
-	final static private Class[] jcasBaseAndType = new Class[] { JCas.class, Type.class };
-  final static private Class[] intAnd_Type     = new Class[] { int.class, TOP_Type.class };
+  public void throwFeatMissing(String feat, String type) {
+    CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INAPPROP_FEAT,
+        new String[] { feat, type });
+    throw e;
+  }
 
-	/*
+  // constant used in the following function
+  /** internal use - constant used in getting constructors */
+  final static private Class[] jcasBaseAndType = new Class[] { JCas.class, Type.class };
+
+  final static private Class[] intAnd_Type = new Class[] { int.class, TOP_Type.class };
+
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#putJfsFromCaddr(int, org.apache.uima.cas.FeatureStructure)
    */
-	public void putJfsFromCaddr(int casAddr, FeatureStructure fs) {
-		sharedView.cAddr2Jfs.put((FeatureStructureImpl)fs);
-	}
+  public void putJfsFromCaddr(int casAddr, FeatureStructure fs) {
+    sharedView.cAddr2Jfs.put((FeatureStructureImpl) fs);
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getJfsFromCaddr(int)
    */
-	public TOP getJfsFromCaddr(int casAddr) {
-		return (TOP) sharedView.cAddr2Jfs.get(casAddr);
-	}
-  
+  public TOP getJfsFromCaddr(int casAddr) {
+    return (TOP) sharedView.cAddr2Jfs.get(casAddr);
+  }
+
   public void showJfsFromCaddrHistogram() {
     sharedView.cAddr2Jfs.showHistogram();
   }
 
-	// * Implementation of part of the Cas interface as part of JCas*
+  // * Implementation of part of the Cas interface as part of JCas*
 
-	/**
+  /**
    * (Internal Use only) called by the CAS reset function - clears the hashtable holding the
    * associations.
    */
-	public static void clearData(CAS cas) {
-		JCasImpl jcas = (JCasImpl) ((CASImpl)cas).getExistingJCas();
+  public static void clearData(CAS cas) {
+    JCasImpl jcas = (JCasImpl) ((CASImpl) cas).getExistingJCas();
     final JCasSharedView sv = jcas.sharedView;
     for (Iterator it = sv.cAddr2JfsByClassLoader.entrySet().iterator(); it.hasNext();) {
-      Map.Entry e = (Map.Entry)it.next();
-      sv.cAddr2Jfs = (JCasHashMap)e.getValue();
+      Map.Entry e = (Map.Entry) it.next();
+      sv.cAddr2Jfs = (JCasHashMap) e.getValue();
       int hashSize = Math.max(sv.cAddr2Jfs.size(), 32); // not worth dropping
       // below 32
       // System.out.println("\n***JCas Resizing Hashtable: size is: " +
@@ -1061,468 +1033,473 @@
       sv.fsArray0L = null;
       sv.integerArray0L = null;
     }
-    sv.cAddr2Jfs = (JCasHashMap)sv.cAddr2JfsByClassLoader.get(((CASImpl)cas).getJCasClassLoader());
-	}
+    sv.cAddr2Jfs = (JCasHashMap) sv.cAddr2JfsByClassLoader
+        .get(((CASImpl) cas).getJCasClassLoader());
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#reset()
    */
-	public void reset() {
-		casImpl.reset();
-	}
+  public void reset() {
+    casImpl.reset();
+  }
 
-	private final static int NULL = 0;
+  private final static int NULL = 0;
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#checkArrayBounds(int, int)
    */
-	public final void checkArrayBounds(int fsRef, int pos) {
-		if (NULL == fsRef) {
-			LowLevelException e = new LowLevelException(LowLevelException.NULL_ARRAY_ACCESS);
-			// note - need to add this to ll_runtimeException
-			e.addArgument(Integer.toString(pos));
-			throw e;
-		}
-		final int arrayLength = casImpl.ll_getArraySize(fsRef);
-		if (pos < 0 || pos >= arrayLength) {
-			LowLevelException e = new LowLevelException(LowLevelException.ARRAY_INDEX_OUT_OF_RANGE);
-			e.addArgument(Integer.toString(pos));
-			throw e;
-		}
-	}
-
-	// *****************
-	// * Sofa support *
-	// *****************
+  public final void checkArrayBounds(int fsRef, int pos) {
+    if (NULL == fsRef) {
+      LowLevelException e = new LowLevelException(LowLevelException.NULL_ARRAY_ACCESS);
+      // note - need to add this to ll_runtimeException
+      e.addArgument(Integer.toString(pos));
+      throw e;
+    }
+    final int arrayLength = casImpl.ll_getArraySize(fsRef);
+    if (pos < 0 || pos >= arrayLength) {
+      LowLevelException e = new LowLevelException(LowLevelException.ARRAY_INDEX_OUT_OF_RANGE);
+      e.addArgument(Integer.toString(pos));
+      throw e;
+    }
+  }
+
+  // *****************
+  // * Sofa support *
+  // *****************
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getSofa(org.apache.uima.cas.SofaID)
    */
-	public Sofa getSofa(SofaID sofaID) {
-		return (Sofa) casImpl.getSofa(sofaID);
-	}
+  public Sofa getSofa(SofaID sofaID) {
+    return (Sofa) casImpl.getSofa(sofaID);
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getSofa()
    */
-	public Sofa getSofa() {
-		return (Sofa) casImpl.getSofa();
-	}
+  public Sofa getSofa() {
+    return (Sofa) casImpl.getSofa();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#createView(java.lang.String)
    */
-	public JCas createView(String sofaID) throws CASException {
-		return casImpl.createView(sofaID).getJCas();
-	}
+  public JCas createView(String sofaID) throws CASException {
+    return casImpl.createView(sofaID).getJCas();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getJCas(org.apache.uima.jcas.cas.Sofa)
    */
-	public JCas getJCas(Sofa sofa) throws CASException {
-		return casImpl.getView(sofa).getJCas();
-	}
+  public JCas getJCas(Sofa sofa) throws CASException {
+    return casImpl.getView(sofa).getJCas();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getSofaIterator()
    */
-	public FSIterator getSofaIterator() {
-		return casImpl.getSofaIterator();
-	}
-
-	// *****************
-	// * Index support *
-	// *****************
+  public FSIterator getSofaIterator() {
+    return casImpl.getSofaIterator();
+  }
+
+  // *****************
+  // * Index support *
+  // *****************
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getJFSIndexRepository()
    */
-	public JFSIndexRepository getJFSIndexRepository() {
-		return jfsIndexRepository;
-	}
-
-	// ****************
-	// * TCas support *
-	// ****************
+  public JFSIndexRepository getJFSIndexRepository() {
+    return jfsIndexRepository;
+  }
+
+  // ****************
+  // * TCas support *
+  // ****************
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getDocumentAnnotationFs()
    */
-	public TOP getDocumentAnnotationFs() {
-		return (TOP) casImpl.getDocumentAnnotation();
-	}
+  public TOP getDocumentAnnotationFs() {
+    return (TOP) casImpl.getDocumentAnnotation();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getDocumentText()
    */
-	public String getDocumentText() {
-		return casImpl.getDocumentText();
-	}
+  public String getDocumentText() {
+    return casImpl.getDocumentText();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getSofaDataString()
    */
-	public String getSofaDataString() {
-		return casImpl.getSofaDataString();
-	}
+  public String getSofaDataString() {
+    return casImpl.getSofaDataString();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getSofaDataArray()
    */
-	public FeatureStructure getSofaDataArray() {
-		return casImpl.getSofaDataArray();
-	}
+  public FeatureStructure getSofaDataArray() {
+    return casImpl.getSofaDataArray();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getSofaDataURI()
    */
-	public String getSofaDataURI() {
-		return casImpl.getSofaDataURI();
-	}
+  public String getSofaDataURI() {
+    return casImpl.getSofaDataURI();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getSofaMimeType()
    */
-	public String getSofaMimeType() {
-		return casImpl.getSofaMimeType();
-	}
+  public String getSofaMimeType() {
+    return casImpl.getSofaMimeType();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#setDocumentText(java.lang.String)
    */
-	public void setDocumentText(String text) throws CASRuntimeException {
-		casImpl.setDocumentText(text);
-	}
+  public void setDocumentText(String text) throws CASRuntimeException {
+    casImpl.setDocumentText(text);
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#setSofaDataString(java.lang.String, java.lang.String)
    */
-	public void setSofaDataString(String text, String mime) throws CASRuntimeException {
-		casImpl.setSofaDataString(text, mime);
-	}
+  public void setSofaDataString(String text, String mime) throws CASRuntimeException {
+    casImpl.setSofaDataString(text, mime);
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#setSofaDataArray(org.apache.uima.jcas.cas.TOP, java.lang.String)
    */
-	public void setSofaDataArray(FeatureStructure array, String mime) throws CASRuntimeException {
-		casImpl.setSofaDataArray(array, mime);
-	}
+  public void setSofaDataArray(FeatureStructure array, String mime) throws CASRuntimeException {
+    casImpl.setSofaDataArray(array, mime);
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#setSofaDataURI(java.lang.String, java.lang.String)
    */
-	public void setSofaDataURI(String uri, String mime) throws CASRuntimeException {
-		casImpl.setSofaDataURI(uri, mime);
-	}
+  public void setSofaDataURI(String uri, String mime) throws CASRuntimeException {
+    casImpl.setSofaDataURI(uri, mime);
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getDocumentLanguage()
    */
-	public String getDocumentLanguage() {
-		return casImpl.getDocumentLanguage();
-	}
+  public String getDocumentLanguage() {
+    return casImpl.getDocumentLanguage();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#setDocumentLanguage(java.lang.String)
    */
-	public void setDocumentLanguage(String language) throws CASRuntimeException {
-		casImpl.setDocumentLanguage(language);
-	}
+  public void setDocumentLanguage(String language) throws CASRuntimeException {
+    casImpl.setDocumentLanguage(language);
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getSofaDataStream()
    */
-	public InputStream getSofaDataStream() {
-		return casImpl.getSofaDataStream();
-	}
+  public InputStream getSofaDataStream() {
+    return casImpl.getSofaDataStream();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getConstraintFactory()
    */
-	public ConstraintFactory getConstraintFactory() {
-		return casImpl.getConstraintFactory();
-	}
+  public ConstraintFactory getConstraintFactory() {
+    return casImpl.getConstraintFactory();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#createFeaturePath()
    */
-	public FeaturePath createFeaturePath() {
-		return casImpl.createFeaturePath();
-	}
+  public FeaturePath createFeaturePath() {
+    return casImpl.createFeaturePath();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#createFilteredIterator(org.apache.uima.cas.FSIterator,
    *      org.apache.uima.cas.FSMatchConstraint)
    */
-	public FSIterator createFilteredIterator(FSIterator it, FSMatchConstraint constraint) {
-		return casImpl.createFilteredIterator(it, constraint);
-	}
+  public FSIterator createFilteredIterator(FSIterator it, FSMatchConstraint constraint) {
+    return casImpl.createFilteredIterator(it, constraint);
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getStringArray0L()
    */
 
-	public StringArray getStringArray0L() {
-		if (null == sharedView.stringArray0L)
-			sharedView.stringArray0L = new StringArray(this, 0);
-		return sharedView.stringArray0L;
-	}
+  public StringArray getStringArray0L() {
+    if (null == sharedView.stringArray0L)
+      sharedView.stringArray0L = new StringArray(this, 0);
+    return sharedView.stringArray0L;
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getIntegerArray0L()
    */
-	public IntegerArray getIntegerArray0L() {
-		if (null == sharedView.integerArray0L)
-			sharedView.integerArray0L = new IntegerArray(this, 0);
-		return sharedView.integerArray0L;
-	}
+  public IntegerArray getIntegerArray0L() {
+    if (null == sharedView.integerArray0L)
+      sharedView.integerArray0L = new IntegerArray(this, 0);
+    return sharedView.integerArray0L;
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getFloatArray0L()
    */
-	public FloatArray getFloatArray0L() {
-		if (null == sharedView.floatArray0L)
-			sharedView.floatArray0L = new FloatArray(this, 0);
-		return sharedView.floatArray0L;
-	}
+  public FloatArray getFloatArray0L() {
+    if (null == sharedView.floatArray0L)
+      sharedView.floatArray0L = new FloatArray(this, 0);
+    return sharedView.floatArray0L;
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getFSArray0L()
    */
-	public FSArray getFSArray0L() {
-		if (null == sharedView.fsArray0L)
-			sharedView.fsArray0L = new FSArray(this, 0);
-		return sharedView.fsArray0L;
-	}
+  public FSArray getFSArray0L() {
+    if (null == sharedView.fsArray0L)
+      sharedView.fsArray0L = new FSArray(this, 0);
+    return sharedView.fsArray0L;
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#processInit()
    */
-	public void processInit() {
-		// unused
-	}
+  public void processInit() {
+    // unused
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.cas.AbstractCas_ImplBase#setOwn
    */
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#setOwner(org.apache.uima.cas.CasOwner)
    */
-	public void setOwner(CasOwner aCasOwner) {
-		casImpl.setOwner(aCasOwner);
-	}
+  public void setOwner(CasOwner aCasOwner) {
+    casImpl.setOwner(aCasOwner);
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#release()
    */
-	public void release() {
-		casImpl.release();
-	}
+  public void release() {
+    casImpl.release();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getView(java.lang.String)
    */
-	public JCas getView(String localViewName) throws CASException {
-		return casImpl.getView(localViewName).getJCas();
-	}
+  public JCas getView(String localViewName) throws CASException {
+    return casImpl.getView(localViewName).getJCas();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getView(org.apache.uima.cas.SofaFS)
    */
-	public JCas getView(SofaFS aSofa) throws CASException {
-		return casImpl.getView(aSofa).getJCas();
-	}
+  public JCas getView(SofaFS aSofa) throws CASException {
+    return casImpl.getView(aSofa).getJCas();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#addFsToIndexes(org.apache.uima.cas.FeatureStructure)
    */
-	public void addFsToIndexes(FeatureStructure instance) {
-		casImpl.addFsToIndexes(instance);
-	}
+  public void addFsToIndexes(FeatureStructure instance) {
+    casImpl.addFsToIndexes(instance);
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#removeFsFromIndexes(org.apache.uima.cas.FeatureStructure)
    */
-	public void removeFsFromIndexes(FeatureStructure instance) {
-		casImpl.removeFsFromIndexes(instance);
-	}
+  public void removeFsFromIndexes(FeatureStructure instance) {
+    casImpl.removeFsFromIndexes(instance);
+  }
 
-	/**
+  /**
    * @see org.apache.uima.cas.CAS#fs2listIterator(FSIterator)
    */
-	public ListIterator fs2listIterator(FSIterator it) {
-		return casImpl.fs2listIterator(it);
-	}
+  public ListIterator fs2listIterator(FSIterator it) {
+    return casImpl.fs2listIterator(it);
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.cas.BaseCas#createFeatureValuePath(java.lang.String)
    */
-	public FeatureValuePath createFeatureValuePath(String featureValuePath)
-			throws CASRuntimeException {
-		return casImpl.createFeatureValuePath(featureValuePath);
-	}
+  public FeatureValuePath createFeatureValuePath(String featureValuePath)
+      throws CASRuntimeException {
+    return casImpl.createFeatureValuePath(featureValuePath);
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.cas.BaseCas#createSofa(org.apache.uima.cas.SofaID, java.lang.String)
    * @deprecated
    */
-	public SofaFS createSofa(SofaID sofaID, String mimeType) {
-		// extract absolute SofaName string from the ID
-		return casImpl.createSofa(sofaID, mimeType);
-	}
+  public SofaFS createSofa(SofaID sofaID, String mimeType) {
+    // extract absolute SofaName string from the ID
+    return casImpl.createSofa(sofaID, mimeType);
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.cas.BaseCas#getIndexRepository()
    */
-	public FSIndexRepository getIndexRepository() {
-		return casImpl.getIndexRepository();
-	}
+  public FSIndexRepository getIndexRepository() {
+    return casImpl.getIndexRepository();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.cas.BaseCas#getViewName()
    */
-	public String getViewName() {
-		return casImpl.getViewName();
-	}
+  public String getViewName() {
+    return casImpl.getViewName();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.cas.BaseCas#size()
    */
-	public int size() {
-		// TODO improve this to account for JCas
-		// structure sizes
-		return casImpl.size();
-	}
+  public int size() {
+    // TODO improve this to account for JCas
+    // structure sizes
+    return casImpl.size();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getAnnotationIndex()
    */
-	public AnnotationIndex getAnnotationIndex() {
-		return casImpl.getAnnotationIndex();
-	}
+  public AnnotationIndex getAnnotationIndex() {
+    return casImpl.getAnnotationIndex();
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getAnnotationIndex(org.apache.uima.cas.Type)
    */
-	public AnnotationIndex getAnnotationIndex(Type type) throws CASRuntimeException {
-		return casImpl.getAnnotationIndex(type);
-	}
+  public AnnotationIndex getAnnotationIndex(Type type) throws CASRuntimeException {
+    return casImpl.getAnnotationIndex(type);
+  }
 
-	/*
+  /*
    * (non-Javadoc)
    * 
    * @see org.apache.uima.jcas.JCas#getAnnotationIndex(int)
    */
-	public AnnotationIndex getAnnotationIndex(int type) throws CASRuntimeException {
-		return casImpl.getAnnotationIndex(this.getCasType(type));
-	}
+  public AnnotationIndex getAnnotationIndex(int type) throws CASRuntimeException {
+    return casImpl.getAnnotationIndex(this.getCasType(type));
+  }
 
-  /* (non-Javadoc)
+  /*
+   * (non-Javadoc)
+   * 
    * @see org.apache.uima.jcas.JCas#getViewIterator()
    */
   public Iterator getViewIterator() throws CASException {
     List viewList = new ArrayList();
     Iterator casViewIter = casImpl.getViewIterator();
-    while(casViewIter.hasNext()) {
-      viewList.add(((CAS)casViewIter.next()).getJCas());
+    while (casViewIter.hasNext()) {
+      viewList.add(((CAS) casViewIter.next()).getJCas());
     }
     return viewList.iterator();
   }
 
-  /* (non-Javadoc)
+  /*
+   * (non-Javadoc)
+   * 
    * @see org.apache.uima.jcas.JCas#getViewIterator(java.lang.String)
    */
   public Iterator getViewIterator(String localViewNamePrefix) throws CASException {
     List viewList = new ArrayList();
     Iterator casViewIter = casImpl.getViewIterator(localViewNamePrefix);
-    while(casViewIter.hasNext()) {
-      viewList.add(((CAS)casViewIter.next()).getJCas());
+    while (casViewIter.hasNext()) {
+      viewList.add(((CAS) casViewIter.next()).getJCas());
     }
     return viewList.iterator();
   }