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 2007/05/21 23:49:17 UTC

svn commit: r540312 [3/4] - in /incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima: cas/admin/ cas/impl/ jcas/impl/

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASMgrSerializer.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASMgrSerializer.java?view=diff&rev=540312&r1=540311&r2=540312
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASMgrSerializer.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASMgrSerializer.java Mon May 21 14:49:16 2007
@@ -424,7 +424,7 @@
   public TypeSystemImpl getTypeSystem() {
     final TypeSystemImpl ts = new TypeSystemImpl();
     // First, add the top type.
-    ts.addTopType(CAS.TYPE_NAME_TOP);
+//    ts.addTopType(CAS.TYPE_NAME_TOP);  // does nothing, top type already there
     // HashMap nameMap = null;
     // Temporary. The name map will go away completely.
     HashMap nameMap = new HashMap();

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java?view=diff&rev=540312&r1=540311&r2=540312
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASSerializer.java Mon May 21 14:49:16 2007
@@ -99,25 +99,25 @@
    */
 	public void addCAS(CASImpl cas, boolean addMetaData) {
 		this.fsIndex = cas.getIndexedFSs();
-		final int heapSize = cas.heap.getCurrentTempSize();
+		final int heapSize = cas.getHeap().getCurrentTempSize();
 		this.heapArray = new int[heapSize];
-		System.arraycopy(cas.heap.heap, 0, this.heapArray, 0, heapSize);
+		System.arraycopy(cas.getHeap().heap, 0, this.heapArray, 0, heapSize);
 		if (addMetaData) {
-			this.heapMetaData = cas.heap.getMetaData();
+			this.heapMetaData = cas.getHeap().getMetaData();
 		}
 		this.stringTable = stringArrayListToArray(cas.getStringTable());
 
-		final int byteHeapSize = cas.byteHeap.getSize();
+		final int byteHeapSize = cas.getByteHeap().getSize();
 		this.byteHeapArray = new byte[byteHeapSize];
-		System.arraycopy(cas.byteHeap.heap, 0, this.byteHeapArray, 0, byteHeapSize);
+		System.arraycopy(cas.getByteHeap().heap, 0, this.byteHeapArray, 0, byteHeapSize);
 
-		final int shortHeapSize = cas.shortHeap.getSize();
+		final int shortHeapSize = cas.getShortHeap().getSize();
 		this.shortHeapArray = new short[shortHeapSize];
-		System.arraycopy(cas.shortHeap.heap, 0, this.shortHeapArray, 0, shortHeapSize);
+		System.arraycopy(cas.getShortHeap().heap, 0, this.shortHeapArray, 0, shortHeapSize);
 
-		final int longHeapSize = cas.longHeap.getSize();
+		final int longHeapSize = cas.getLongHeap().getSize();
 		this.longHeapArray = new long[longHeapSize];
-		System.arraycopy(cas.longHeap.heap, 0, this.longHeapArray, 0, longHeapSize);
+		System.arraycopy(cas.getLongHeap().heap, 0, this.longHeapArray, 0, longHeapSize);
 	}
 
 	/**
@@ -181,10 +181,10 @@
 			dos.writeInt(version);
 
 			// output the FS heap
-			final int heapSize = cas.heap.getCurrentTempSize();
+			final int heapSize = cas.getHeap().getCurrentTempSize();
 			dos.writeInt(heapSize);
 			for (int i = 0; i < heapSize; i++) {
-				dos.writeInt(cas.heap.heap[i]);
+				dos.writeInt(cas.getHeap().heap[i]);
 			}
 
 			// output the strings
@@ -193,14 +193,14 @@
 
 			// local array to hold ref heap to be serialized
 			// String list reference in this local ref heap will be updated to be string heap references.
-			int[] refheap = new int[cas.stringHeap.refHeapPos];
+			int[] refheap = new int[cas.getStringHeap().refHeapPos];
 			for (int i = 0; i < refheap.length; i++) {
-				refheap[i] = cas.stringHeap.refHeap[i];
+				refheap[i] = cas.getStringHeap().refHeap[i];
 			}
 
 			// compute the number of total size of data in stringHeap
 			// total size = char buffer length + length of strings in the string list;
-			int stringHeapLength = cas.stringHeap.charHeapPos;
+			int stringHeapLength = cas.getStringHeap().charHeapPos;
             int stringListLength = 0;
 			for (int i = 0; i < refheap.length; i += 3) {
 				int ref = refheap[i + StringHeap.STRING_LIST_ADDR_OFFSET];
@@ -208,7 +208,7 @@
 				// get length and add to total string heap length
 				if (ref != 0) {
                     // terminate each string with a null
-					stringListLength += 1 + ((String) cas.stringHeap.stringList.get(ref)).length();
+					stringListLength += 1 + ((String) cas.getStringHeap().stringList.get(ref)).length();
 				}
 			}
 			
@@ -218,12 +218,12 @@
                // add 1 for the null at the beginning
                stringTotalLength += 1;
             }
-            dos.writeInt(stringTotalLength);
+				dos.writeInt(stringTotalLength);
 
             //write the data in the stringheap, if there is any
             if (stringTotalLength > 0) {
-                if (cas.stringHeap.charHeapPos > 0) {
-                    dos.writeChars( String.valueOf(cas.stringHeap.stringHeap, 0, cas.stringHeap.charHeapPos) );
+                if (cas.getStringHeap().charHeapPos > 0) {
+                    dos.writeChars( String.valueOf(cas.getStringHeap().stringHeap, 0, cas.getStringHeap().charHeapPos) );
                 }
                 else {
                     // no stringheap data
@@ -236,7 +236,7 @@
                 //write out the data in the StringList and update the 
                 //reference in the local ref heap.
                 if ( stringListLength > 0 ) {
-                    int pos = cas.stringHeap.charHeapPos > 0 ? cas.stringHeap.charHeapPos : 1;
+                    int pos = cas.getStringHeap().charHeapPos > 0 ? cas.getStringHeap().charHeapPos : 1;
                     for (int i=0; i < refheap.length; i+=3) {
                         int ref = refheap[i+StringHeap.STRING_LIST_ADDR_OFFSET];
                         //this is a string in the string list
@@ -244,10 +244,10 @@
                             //update the ref					
                             refheap[i+StringHeap.CHAR_HEAP_POINTER_OFFSET] = pos;
                             //write out the chars in the string
-                            dos.writeChars((String)cas.stringHeap.stringList.get(ref));
+                            dos.writeChars((String)cas.getStringHeap().stringList.get(ref));
                             dos.writeChar(0); // null terminate each string
                             //update pos
-                            pos += 1 + ((String) cas.stringHeap.stringList.get(ref)).length(); 
+                            pos += 1 + ((String) cas.getStringHeap().stringList.get(ref)).length(); 
                         }				
                     }
                 }
@@ -276,11 +276,12 @@
 			}
 
 			// 8bit heap
-			int byteheapsz = cas.byteHeap.getSize();
+			int byteheapsz = cas.getByteHeap().getSize();
 			dos.writeInt(byteheapsz);
-			for (int i = 0; i < cas.byteHeap.getSize(); i++) {
-				dos.writeByte(cas.byteHeap.heap[i]);
+			for (int i = 0; i < cas.getByteHeap().getSize(); i++) {
+				dos.writeByte(cas.getByteHeap().heap[i]);
 			}
+
 			// word alignment
       int align = (4 - (byteheapsz % 4)) % 4;
 			for (int i = 0; i < align; i++) {
@@ -288,21 +289,22 @@
 			}
 
 			// 16bit heap
-      int shortheapsz = cas.shortHeap.getSize();
+			int shortheapsz = cas.getShortHeap().getSize();
 			dos.writeInt(shortheapsz);
-			for (int i = 0; i < cas.shortHeap.getSize(); i++) {
-				dos.writeShort(cas.shortHeap.heap[i]);
+			for (int i = 0; i < cas.getShortHeap().getSize(); i++) {
+				dos.writeShort(cas.getShortHeap().heap[i]);
 			}
+
 			// word alignment
       if (shortheapsz % 2 != 0) {
         dos.writeShort(0);
-      }
+			}
 
 			// 64bit heap
-			int longheapsz = cas.longHeap.getSize();
+			int longheapsz = cas.getLongHeap().getSize();
 			dos.writeInt(longheapsz);
-			for (int i = 0; i < cas.longHeap.getSize(); i++) {
-				dos.writeLong(cas.longHeap.heap[i]);
+			for (int i = 0; i < cas.getLongHeap().getSize(); i++) {
+				dos.writeLong(cas.getLongHeap().heap[i]);
 			}
 		} catch (IOException e) {
 			CASRuntimeException exception = new CASRuntimeException(

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSClassRegistry.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSClassRegistry.java?view=diff&rev=540312&r1=540311&r2=540312
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSClassRegistry.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSClassRegistry.java Mon May 21 14:49:16 2007
@@ -19,31 +19,29 @@
 
 package org.apache.uima.cas.impl;
 
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.TreeMap;
 
+import org.apache.uima.cas.CASException;
+import org.apache.uima.cas.CASRuntimeException;
 import org.apache.uima.cas.FeatureStructure;
 import org.apache.uima.cas.Type;
+import org.apache.uima.jcas.cas.TOP;
+import org.apache.uima.jcas.impl.JCasImpl;
 
 /*
- * For JCas there is one instance of this class per view.
- * 
- * To have all views share the same instance of this would require
- * that JCasGen generate different "generator" classes which used the
- * CASImpl parameter to locate at generate time the corresponding 
- * JCas impl and the corresponding xxx_Type instance.  While this could
- * reasonably be done, it would break all existing applications until they
- * "regenerated" their JCas cover classes.  So we won't go there ... 5/2007
- * 
+ * There is one instance of this class per type system.
+ * It is shared by multiple CASes (in a CAS pool, for instance,
+ * when these CASes are sharing the same type system), and
+ * it is shared by all views of that CAS.
  */
 
 public class FSClassRegistry {
 
-  private final boolean useFSCache;
-
   private static class DefaultFSGenerator implements FSGenerator {
     private DefaultFSGenerator() {
       super();
@@ -54,9 +52,76 @@
     }
   }
 
+  static private class JCasFsGenerator implements FSGenerator {
+    private final int type;
+    private final Constructor c;
+    private final Object[] initargs;
+    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;  
+      this.c = c;
+      initargs = new Object[] {null, null};
+      this.isSubtypeOfAnnotationBase = isSubtypeOfAnnotationBase;
+      this.sofaNbrFeatCode = sofaNbrFeatCode;
+      this.annotSofaFeatCode = annotSofaFeatCode;
+    }
+    
+    public FeatureStructure createFS(int addr, CASImpl casView) {
+      JCasImpl jcasView = null;
+      final CASImpl view = (isSubtypeOfAnnotationBase) ?
+              (CASImpl)casView.getView(getSofaNbr(addr, casView)) :
+              casView;
+      if (null == view) 
+        System.out.println("null");
+      try {
+        jcasView = (JCasImpl)view.getJCas();
+      } catch (CASException e1) {
+       logAndThrow(e1);
+      }
+     
+     // Return eq fs instance if already created
+      TOP fs = jcasView.getJfsFromCaddr(addr);
+      if (null != fs) {
+        fs.jcasType = jcasView.getType(type);
+      } else {
+        initargs[0] = new Integer(addr);
+        initargs[1] = jcasView.getType(type);
+        try {
+          fs = (TOP) c.newInstance(initargs);
+        } catch (IllegalArgumentException e) {
+          logAndThrow(e);
+        } catch (InstantiationException e) {
+          logAndThrow(e);
+        } catch (IllegalAccessException e) {
+          logAndThrow(e);
+        } catch (InvocationTargetException e) {
+          logAndThrow(e);
+        } 
+        jcasView.putJfsFromCaddr(addr, fs);
+      }
+      return fs;
+    }
+ 
+    private void logAndThrow(Exception e) {
+      CASRuntimeException casEx = new CASRuntimeException(CASRuntimeException.JCAS_CAS_MISMATCH);
+      casEx.initCause(e);
+      throw casEx;      
+    }
+
+    private int getSofaNbr(int addr, CASImpl casView) {
+      final LowLevelCAS llCas = casView.getLowLevelCAS();
+      int sofa = llCas.ll_getIntValue(addr, annotSofaFeatCode, false);
+      return casView.getLowLevelCAS().ll_getIntValue(sofa, sofaNbrFeatCode);
+    }
+  }
   private TypeSystemImpl ts;
 
-  private FSGenerator[] generators;
+  private FSGenerator[] generators; 
+  
+  private static final FSGenerator defaultGenerator = new DefaultFSGenerator();
  
   /*
    * Generators sometimes need to be changed while running
@@ -81,24 +146,17 @@
   // private final TreeMap map;
   private FeatureStructure[] fsArray;
 
-  private static final int initialArraySize = 1000;
-
-  FSClassRegistry(TypeSystemImpl ts, boolean useFSCache) {
-    super();
-    this.useFSCache = useFSCache;
+  FSClassRegistry(TypeSystemImpl ts) {
     this.ts = ts;
+  }
+  
+  void initGeneratorArray() {
     this.generators = new FSGenerator[ts.getTypeArraySize()];
-    DefaultFSGenerator fsg = new DefaultFSGenerator();
     for (int i = ts.getSmallestType(); i < this.generators.length; i++) {
-      this.generators[i] = fsg;
-    }
-    // rbt = new RedBlackTree();
-    // this.map = new TreeMap();
-    if (useFSCache) {
-      this.fsArray = new FeatureStructure[initialArraySize];
+      this.generators[i] = defaultGenerator;
     }
   }
-
+  
   /**
    * adds generator for type and all its subtypes. Because of this, call this on supertypes first,
    * then subtypes (otherwise subtypes will be overwritten by generators for the supertypes).
@@ -163,38 +221,22 @@
     return false;
   }
 
-  FeatureStructure createFS(int addr, CASImpl cas) {
-    // Get the type of the structure from the heap and invoke the
-    // corresponding
-    // generator.
-    if (addr == 0) {
-      return null;
-    }
-    // FS object cache code.
-    FeatureStructure fs = null;
-    if (this.useFSCache) {
-      try {
-        fs = this.fsArray[addr];
-      } catch (ArrayIndexOutOfBoundsException e) {
-        // Do nothing.
-      }
-      if (fs == null) {
-        fs = this.generators[cas.heap.heap[addr]].createFS(addr, cas);
-        if (addr >= this.fsArray.length) {
-          int newLen = this.fsArray.length * 2;
-          while (newLen <= addr) {
-            newLen *= 2;
-          }
-          FeatureStructure[] newArray = new FeatureStructure[newLen];
-          System.arraycopy(this.fsArray, 0, newArray, 0, this.fsArray.length);
-          this.fsArray = newArray;
-        }
-        this.fsArray[addr] = fs;
-      }
-    } else {
-      fs = this.generators[cas.heap.heap[addr]].createFS(addr, cas);
-    }
-    return fs;
+  // assume addr is never 0 - caller must insure this
+  FeatureStructure createFSusingGenerator(int addr, CASImpl cas) {
+    return this.generators[cas.getHeap().heap[addr]].createFS(addr, cas);    
+  }
+  
+  /*
+   * Generators used are created with as much info as can be looked up once, ahead of time.
+   * Things variable at run time include the cas instance, and the view.
+   * 
+   * In this design, generators are shared with all views for a particular CAS, but are different for 
+   * different CASes (distinct from shared-views of the same CAS)
+   * 
+   * Internal use only - public only to give access to JCas routines in another package
+   */
+  public void loadJCasGeneratorForType (int type, Constructor c, TypeImpl casType, boolean isSubtypeOfAnnotationBase) {
+    FSGenerator fsGenerator = new JCasFsGenerator(type, c, isSubtypeOfAnnotationBase, ts.sofaNumFeatCode, ts.annotSofaFeatCode);
+    addGeneratorForType(casType, fsGenerator);
   }
-
 }

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSLeafIndexImpl.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSLeafIndexImpl.java?view=diff&rev=540312&r1=540311&r2=540312
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSLeafIndexImpl.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSLeafIndexImpl.java Mon May 21 14:49:16 2007
@@ -283,8 +283,8 @@
           return -1;
         }
         case LONG_CODE: {
-          long long1 = this.lowLevelCAS.longHeap.getHeapValue(val1);
-          long long2 = this.lowLevelCAS.longHeap.getHeapValue(val2);
+          long long1 = this.lowLevelCAS.getLongHeap().getHeapValue(val1);
+          long long2 = this.lowLevelCAS.getLongHeap().getHeapValue(val2);
           if (long1 < long2) {
             if (this.keyComp[i] == FSIndexComparator.STANDARD_COMPARE) {
               return -1;
@@ -299,8 +299,8 @@
           break;
         }
         case DOUBLE_CODE: {
-          double double1 = Double.longBitsToDouble(this.lowLevelCAS.longHeap.getHeapValue(val1));
-          double double2 = Double.longBitsToDouble(this.lowLevelCAS.longHeap.getHeapValue(val2));
+          double double1 = Double.longBitsToDouble(this.lowLevelCAS.getLongHeap().getHeapValue(val1));
+          double double2 = Double.longBitsToDouble(this.lowLevelCAS.getLongHeap().getHeapValue(val2));
           if (double1 < double2) {
             if (this.keyComp[i] == FSIndexComparator.STANDARD_COMPARE) {
               return -1;

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/ShortArrayFSImpl.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/ShortArrayFSImpl.java?view=diff&rev=540312&r1=540311&r2=540312
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/ShortArrayFSImpl.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/ShortArrayFSImpl.java Mon May 21 14:49:16 2007
@@ -69,21 +69,21 @@
    * @see org.apache.uima.cas.ShortArrayFS#copyFromArray(short[], int, int, int)
    */
   public void copyFromArray(short[] src, int srcOffset, int destOffset, int length) {
-    copyFromJavaArray(src, srcOffset, casImpl.shortHeap.heap, destOffset, length);
+    copyFromJavaArray(src, srcOffset, casImpl.getShortHeap().heap, destOffset, length);
   }
 
   /**
    * @see org.apache.uima.cas.ShortArrayFS#copyToArray(int, short[], int, int)
    */
   public void copyToArray(int srcOffset, short[] dest, int destOffset, int length) {
-    copyToJavaArray(this.casImpl.shortHeap.heap, srcOffset, dest, destOffset, length);
+    copyToJavaArray(this.casImpl.getShortHeap().heap, srcOffset, dest, destOffset, length);
   }
 
   /**
    * @see org.apache.uima.cas.ShortArrayFS#toArray()
    */
   public short[] toArray() {
-    return (short[]) toArray(this.casImpl.shortHeap.heap);
+    return (short[]) toArray(this.casImpl.getShortHeap().heap);
   }
 
   /**
@@ -91,8 +91,8 @@
    */
   public void copyToArray(int srcOffset, String[] dest, int destOffset, int length) {
     casImpl.checkArrayBounds(addr, srcOffset, length);
-    srcOffset += casImpl.heap.heap[casImpl.getArrayStartAddress(addr)];
-    final short[] heap = this.casImpl.shortHeap.heap;
+    srcOffset += casImpl.getHeap().heap[casImpl.getArrayStartAddress(addr)];
+    final short[] heap = this.casImpl.getShortHeap().heap;
     for (int i = 0; i < length; i++) {
       dest[i + destOffset] = Short.toString(heap[i + srcOffset]);
     }

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java?view=diff&rev=540312&r1=540311&r2=540312
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java Mon May 21 14:49:16 2007
@@ -130,9 +130,9 @@
   // feature is declared on).
   private StringToIntMap featureMap;
 
-  private ArrayList tree; // Vector of IntVectors encoding type tree
+  private ArrayList tree; // Collection of IntVectors encoding type tree
 
-  private ArrayList subsumes; // Vector of BitSets for subsumption relation
+  private ArrayList subsumes; // Collection of BitSets for subsumption relation
 
   private IntVector intro;
 
@@ -146,10 +146,10 @@
   // Code of root of hierarchy (will be 1 with current implementation)
   private int top;
 
-  // A vector of TypeImpl objects.
+  // An ArrayList (unsynchronized) of TypeImpl objects.
   private ArrayList types;
 
-  // A vector of FeatureImpl objects.
+  // An ArrayList (unsynchronized) of FeatureImpl objects.
   private ArrayList features;
 
   // List of parent types.
@@ -158,12 +158,11 @@
   // String sets for string subtypes.
   private final ArrayList stringSets;
 
-  
   // This map contains an entry for every subtype of the string type.  The value is a pointer into
   // the stringSets array list.
   private final IntRedBlackTree stringSetMap;
 
-  // For each type, remember of an array of this component type has already
+  // For each type, remember if an array of this component type has already
   // been created.
   private final IntRedBlackTree componentToArrayTypeMap;
 
@@ -176,55 +175,129 @@
   // Is the type system locked?
   private boolean locked = false;
 
-  // Must be able to lock type system info in the CAS, so need a handle to
-  // embedding CAS.
-  // Deleted (MIS 6/06) - Type Systems shared by many CASes, can't point to
-  // one.
-  // private CASImpl cas;
-
   private static final int LEAST_TYPE_CODE = 1;
 
   // private static final int INVALID_TYPE_CODE = 0;
-  private static final int LEAST_FEATUE_CODE = 1;
+  private static final int LEAST_FEATURE_CODE = 1;
+
+  private int numCommittedTypes = 0;
+  
+  final CASMetadata casMetadata;  // needs to be visible in package
+  
+  boolean areBuiltInTypesSetup = false;
 
-  // private int topTypeCode;
-  private int booleanTypeCode = UNKNOWN_TYPE_CODE;
+  TypeImpl intType;
 
-  private int byteTypeCode = UNKNOWN_TYPE_CODE;
+  TypeImpl stringType;
 
-  private int shortTypeCode = UNKNOWN_TYPE_CODE;
+  TypeImpl floatType;
 
-  private int intTypeCode = UNKNOWN_TYPE_CODE;
+  TypeImpl arrayBaseType;
 
-  private int floatTypeCode = UNKNOWN_TYPE_CODE;
+  TypeImpl intArrayType;
 
-  private int longTypeCode = UNKNOWN_TYPE_CODE;
+  TypeImpl floatArrayType;
 
-  private int doubleTypeCode = UNKNOWN_TYPE_CODE;
+  TypeImpl stringArrayType;
 
-  private int stringTypeCode = UNKNOWN_TYPE_CODE;
+  TypeImpl fsArrayType;
 
-  private int arrayBaseTypeCode = UNKNOWN_TYPE_CODE;
+  TypeImpl sofaType;
 
-  private int booleanArrayTypeCode = UNKNOWN_TYPE_CODE;
+  TypeImpl annotType;
 
-  private int byteArrayTypeCode = UNKNOWN_TYPE_CODE;
+  TypeImpl annotBaseType;
 
-  private int shortArrayTypeCode = UNKNOWN_TYPE_CODE;
+  TypeImpl docType;
 
-  private int intArrayTypeCode = UNKNOWN_TYPE_CODE;
+  FeatureImpl startFeat;
 
-  private int floatArrayTypeCode = UNKNOWN_TYPE_CODE;
+  FeatureImpl endFeat;
 
-  private int longArrayTypeCode = UNKNOWN_TYPE_CODE;
+  FeatureImpl langFeat;
+  
+  FeatureImpl sofaNum;
 
-  private int doubleArrayTypeCode = UNKNOWN_TYPE_CODE;
+  TypeImpl byteType;
 
-  private int stringArrayTypeCode = UNKNOWN_TYPE_CODE;
+  TypeImpl byteArrayType;
 
-  private int fsArrayTypeCode = UNKNOWN_TYPE_CODE;
+  TypeImpl booleanType;
 
-  private int numCommittedTypes = 0;
+  TypeImpl booleanArrayType;
+
+  TypeImpl shortType;
+
+  TypeImpl shortArrayType;
+
+  TypeImpl longType;
+
+  TypeImpl longArrayType;
+
+  TypeImpl doubleType;
+
+  TypeImpl doubleArrayType;
+
+ //  int topTypeCode;
+  int intTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int stringTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int floatTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int arrayBaseTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int intArrayTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int floatArrayTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int stringArrayTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int fsArrayTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int sofaTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int annotTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int annotBaseTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int byteTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int booleanTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int shortTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int longTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int doubleTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int byteArrayTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int booleanArrayTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int shortArrayTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int longArrayTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int doubleArrayTypeCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int sofaNumFeatCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int sofaIdFeatCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int sofaMimeFeatCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int sofaUriFeatCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int sofaArrayFeatCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int annotSofaFeatCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int startFeatCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int endFeatCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
+
+  int langFeatCode = LowLevelTypeSystem.UNKNOWN_TYPE_CODE;
 
   /**
    * Default constructor.
@@ -237,7 +310,6 @@
   }
 
   public TypeSystemImpl() {
-    super();
     // Changed numbering to start at 1. Hope this doesn't break
     // anything. If it does, I know who's fault it is...
     this.typeNameST = new SymbolTable(1);
@@ -266,6 +338,97 @@
     this.arrayCodeToTypeMap = new RedBlackTree();
     this.parents = new IntVector();
     this.parents.add(0);
+    
+    this.casMetadata = new CASMetadata(this);
+    // load in built-in types
+    CASImpl.setupTSDefault(this);
+    initTypeVariables();
+  }
+  
+  // only built-in types here; can be called before 
+  // type system is committed, as long as the built-in ones
+  // are defined.
+  final void initTypeVariables() {
+    // Type objects.
+//    this.ts.topType = (TypeImpl) this.ts.getTopType();  // never used
+    this.intType = (TypeImpl) getType(CAS.TYPE_NAME_INTEGER);
+    this.stringType = (TypeImpl) getType(CAS.TYPE_NAME_STRING);
+    this.floatType = (TypeImpl) getType(CAS.TYPE_NAME_FLOAT);
+    this.arrayBaseType = (TypeImpl) getType(CAS.TYPE_NAME_ARRAY_BASE);
+    this.intArrayType = (TypeImpl) getType(CAS.TYPE_NAME_INTEGER_ARRAY);
+    this.floatArrayType = (TypeImpl) getType(CAS.TYPE_NAME_FLOAT_ARRAY);
+    this.stringArrayType = (TypeImpl) getType(CAS.TYPE_NAME_STRING_ARRAY);
+    this.fsArrayType = (TypeImpl) getType(CAS.TYPE_NAME_FS_ARRAY);
+    this.sofaType = (TypeImpl) getType(CAS.TYPE_NAME_SOFA);
+    this.annotType = (TypeImpl) getType(CAS.TYPE_NAME_ANNOTATION);
+    this.sofaNum = (FeatureImpl) getFeatureByFullName(CAS.FEATURE_FULL_NAME_SOFANUM);
+    this.annotBaseType = (TypeImpl) getType(CAS.TYPE_NAME_ANNOTATION_BASE);
+    this.startFeat = (FeatureImpl) getFeatureByFullName(CAS.FEATURE_FULL_NAME_BEGIN);
+    this.endFeat = (FeatureImpl) getFeatureByFullName(CAS.FEATURE_FULL_NAME_END);
+    this.langFeat = (FeatureImpl) getFeatureByFullName(CAS.FEATURE_FULL_NAME_LANGUAGE);
+    this.docType = (TypeImpl) getType(CAS.TYPE_NAME_DOCUMENT_ANNOTATION);
+
+    this.byteType = (TypeImpl) getType(CAS.TYPE_NAME_BYTE);
+    this.byteArrayType = (TypeImpl) getType(CAS.TYPE_NAME_BYTE_ARRAY);
+    this.booleanType = (TypeImpl) getType(CAS.TYPE_NAME_BOOLEAN);
+    this.booleanArrayType = (TypeImpl) getType(CAS.TYPE_NAME_BOOLEAN_ARRAY);
+    this.shortType = (TypeImpl) getType(CAS.TYPE_NAME_SHORT);
+    this.shortArrayType = (TypeImpl) getType(CAS.TYPE_NAME_SHORT_ARRAY);
+    this.longType = (TypeImpl) getType(CAS.TYPE_NAME_LONG);
+    this.longArrayType = (TypeImpl) getType(CAS.TYPE_NAME_LONG_ARRAY);
+    this.doubleType = (TypeImpl) getType(CAS.TYPE_NAME_DOUBLE);
+    this.doubleArrayType = (TypeImpl) getType(CAS.TYPE_NAME_DOUBLE_ARRAY);
+
+    // Type codes.
+    initTypeCodeVars();
+  }
+
+
+  private final void initTypeCodeVars() {
+    this.intTypeCode = this.intType.getCode();
+    this.stringTypeCode = this.stringType.getCode();
+    this.floatTypeCode = this.floatType.getCode();
+    // this.arrayBaseTypeCode = arrayBaseType.getCode();
+    this.intArrayTypeCode = this.intArrayType.getCode();
+    this.floatArrayTypeCode = this.floatArrayType.getCode();
+    this.stringArrayTypeCode = this.stringArrayType.getCode();
+    this.fsArrayTypeCode = this.fsArrayType.getCode();
+    this.sofaTypeCode = this.sofaType.getCode();
+    this.annotTypeCode = this.annotType.getCode();
+    this.annotBaseTypeCode = this.annotBaseType.getCode();
+
+    this.byteArrayTypeCode = this.byteArrayType.getCode();
+    this.byteTypeCode = this.byteType.getCode();
+    this.booleanTypeCode = this.booleanType.getCode();
+    this.booleanArrayTypeCode = this.booleanArrayType.getCode();
+    this.shortTypeCode = this.shortType.getCode();
+    this.shortArrayTypeCode = this.shortArrayType.getCode();
+    this.longTypeCode = this.longType.getCode();
+    this.longArrayTypeCode = this.longArrayType.getCode();
+    this.doubleTypeCode = this.doubleType.getCode();
+    this.doubleArrayTypeCode = this.doubleArrayType.getCode();
+    
+    this.arrayBaseTypeCode = this.arrayBaseType.getCode();
+   
+    final Type sofaT = this.sofaType;
+    this.sofaNumFeatCode = ll_getCodeForFeature(
+            sofaT.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_SOFANUM));
+    this.sofaIdFeatCode = ll_getCodeForFeature(
+            sofaT.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_SOFAID));
+    this.sofaMimeFeatCode = ll_getCodeForFeature(
+            sofaT.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_SOFAMIME));
+    this.sofaUriFeatCode = ll_getCodeForFeature(
+            sofaT.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_SOFAURI));
+    this.sofaArrayFeatCode = ll_getCodeForFeature(
+            sofaT.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_SOFAARRAY));
+    this.annotSofaFeatCode = ll_getCodeForFeature(
+        this.annotBaseType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_SOFA));
+    this.startFeatCode = ll_getCodeForFeature(
+        this.annotType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_BEGIN));
+    this.endFeatCode = ll_getCodeForFeature(
+        this.annotType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_END));
+    this.langFeatCode = ll_getCodeForFeature(
+        this.docType.getFeatureByBaseName(CAS.FEATURE_BASE_NAME_LANGUAGE));
   }
 
   // Some implementation helpers for users of the type system.
@@ -274,7 +437,7 @@
   }
 
   final int getSmallestFeature() {
-    return LEAST_FEATUE_CODE;
+    return LEAST_FEATURE_CODE;
   }
 
   final int getTypeArraySize() {
@@ -385,25 +548,34 @@
    * @return An feature object, or <code>null</code> if no such feature exists.
    */
   public Feature getFeatureByFullName(String featureName) {
-    if (!this.featureMap.containsKey(featureName)) {
-      return null;
-    }
-    final int featCode = this.featureMap.get(featureName);
-    return (Feature) this.features.get(featCode);
+//    if (!this.featureMap.containsKey(featureName)) {
+//      return null;
+//    }
+//    final int featCode = this.featureMap.get(featureName);
+//    return (Feature) this.features.get(featCode);
+    // will return null if feature not present because
+    //   the featureMap.get will return 0, and
+    //   getFeature returns null for code of 0
+    return getFeature(this.featureMap.get(featureName));
   }
 
   private static final String getArrayTypeName(String typeName) {
-    if (arrayComponentTypeNameMap.containsKey(typeName)) {
-      return (String) arrayComponentTypeNameMap.get(typeName);
-    }
-    return typeName + arrayTypeSuffix;
+    final String arrayTypeName = (String) arrayComponentTypeNameMap.get(typeName);
+    return (null == arrayTypeName) ? 
+            typeName + arrayTypeSuffix :
+            arrayTypeName;
+//    if (arrayComponentTypeNameMap.containsKey(typeName)) {
+//      return (String) arrayComponentTypeNameMap.get(typeName);
+//    }
+//    return typeName + arrayTypeSuffix;
   }
 
   private static final String getBuiltinArrayComponent(String typeName) {
-    if (arrayTypeComponentNameMap.containsKey(typeName)) {
+    // if typeName is not contained in the map, the "get" returns null
+//    if (arrayTypeComponentNameMap.containsKey(typeName)) {
       return (String) arrayTypeComponentNameMap.get(typeName);
-    }
-    return null;
+//    }
+//    return null;
   }
 
   /**
@@ -425,6 +597,7 @@
       throw e;
     }
     // Check type name syntax.
+    // Handle the built-in array types, like BooleanArray, FSArray, etc.
     String componentTypeName = getBuiltinArrayComponent(typeName);
     if (componentTypeName != null) {
       return getArrayType(getType(componentTypeName));
@@ -935,40 +1108,18 @@
     if (this.locked == true)
       return; // might be called multiple times, but only need to do once
     this.locked = true;
-    initTypeCodes(); // needs to preceed cas.commitTypeSystem()
     // because subsumes depends on it
     // and generator initialization uses subsumes
     this.numCommittedTypes = this.types.size(); // do before
     // cas.commitTypeSystem -
     // because it will call the type system iterator
-
+    this.casMetadata.setupFeaturesAndCreatableTypes();
     // ts should never point to a CAS. Many CASes can share one ts.
     // if (this.cas != null) {
     // this.cas.commitTypeSystem();
     // }
   }
-
-  private final void initTypeCodes() {
-    this.booleanTypeCode = ll_getCodeForTypeName(CAS.TYPE_NAME_BOOLEAN);
-    this.byteTypeCode = ll_getCodeForTypeName(CAS.TYPE_NAME_BYTE);
-    this.shortTypeCode = ll_getCodeForTypeName(CAS.TYPE_NAME_SHORT);
-    this.intTypeCode = ll_getCodeForTypeName(CAS.TYPE_NAME_INTEGER);
-    this.floatTypeCode = ll_getCodeForTypeName(CAS.TYPE_NAME_FLOAT);
-    this.longTypeCode = ll_getCodeForTypeName(CAS.TYPE_NAME_LONG);
-    this.doubleTypeCode = ll_getCodeForTypeName(CAS.TYPE_NAME_DOUBLE);
-    this.stringTypeCode = ll_getCodeForTypeName(CAS.TYPE_NAME_STRING);
-
-    this.arrayBaseTypeCode = ll_getCodeForTypeName(CAS.TYPE_NAME_ARRAY_BASE);
-    this.booleanArrayTypeCode = ll_getCodeForTypeName(CAS.TYPE_NAME_BOOLEAN_ARRAY);
-    this.byteArrayTypeCode = ll_getCodeForTypeName(CAS.TYPE_NAME_BYTE_ARRAY);
-    this.shortArrayTypeCode = ll_getCodeForTypeName(CAS.TYPE_NAME_SHORT_ARRAY);
-    this.intArrayTypeCode = ll_getCodeForTypeName(CAS.TYPE_NAME_INTEGER_ARRAY);
-    this.floatArrayTypeCode = ll_getCodeForTypeName(CAS.TYPE_NAME_FLOAT_ARRAY);
-    this.longArrayTypeCode = ll_getCodeForTypeName(CAS.TYPE_NAME_LONG_ARRAY);
-    this.doubleArrayTypeCode = ll_getCodeForTypeName(CAS.TYPE_NAME_DOUBLE_ARRAY);
-    this.stringArrayTypeCode = ll_getCodeForTypeName(CAS.TYPE_NAME_STRING_ARRAY);
-    this.fsArrayTypeCode = ll_getCodeForTypeName(CAS.TYPE_NAME_FS_ARRAY);
-  }
+  
 
   /**
    * @see org.apache.uima.cas.admin.TypeSystemMgr#isCommitted()
@@ -1171,7 +1322,7 @@
     if (typeCode == this.doubleTypeCode) {
       return LowLevelCAS.TYPE_CLASS_DOUBLE;
     }
-    if (this.ll_subsumes(this.stringTypeCode, typeCode)) {
+    if (ll_subsumes(this.stringTypeCode, typeCode)) {
       return LowLevelCAS.TYPE_CLASS_STRING;
     }
     if (typeCode == this.booleanArrayTypeCode) {
@@ -1240,8 +1391,8 @@
     // array are all over the place. Would be nice to just remove it.
     // Add an edge to the tree.
     if (!isCommitted()) {
-      final int arrayBaseType = ll_getCodeForTypeName(CAS.TYPE_NAME_ARRAY_BASE);
-      ((IntVector) this.tree.get(arrayBaseType)).add(arrayTypeCode);
+      final int arrayBaseTypeCodeBeforeCommitted = ll_getCodeForTypeName(CAS.TYPE_NAME_ARRAY_BASE);
+      ((IntVector) this.tree.get(arrayBaseTypeCodeBeforeCommitted)).add(arrayTypeCode);
       // Update subsumption relation.
       updateSubsumption(arrayTypeCode, this.arrayBaseTypeCode);
     }

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java?view=diff&rev=540312&r1=540311&r2=540312
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java Mon May 21 14:49:16 2007
@@ -104,7 +104,7 @@
     private Locator locator;
 
     // The CAS we're filling.
-    private CASImpl cas;
+    private CASImpl casBeingFilled;
 
     // Store address of every FS we've deserialized, since we need to back
     // and apply fix-ups afterwards.
@@ -208,7 +208,7 @@
     private XmiCasDeserializerHandler(CASImpl aCAS, boolean lenient,
             XmiSerializationSharedData sharedData, int mergePoint) {
       super();
-      this.cas = aCAS.getBaseCAS();
+      this.casBeingFilled = aCAS.getBaseCAS();
       this.lenient = lenient;
       this.sharedData = 
         sharedData != null ? sharedData : new XmiSerializationSharedData();
@@ -216,7 +216,7 @@
       if (mergePoint < 0) {
         //If not merging, reset the CAS. 
         //Necessary to get Sofas to work properly.
-        cas.resetNoQuestions();
+        casBeingFilled.resetNoQuestions();
         
         // clear ID mappings stored in the SharedData (from previous deserializations)
         this.sharedData.clearIdMap();
@@ -226,35 +226,35 @@
       this.buffer = new StringBuffer();
       this.indexRepositories = new ArrayList();
       this.views = new ArrayList();
-      indexRepositories.add(this.cas.getBaseIndexRepository());
+      indexRepositories.add(this.casBeingFilled.getBaseIndexRepository());
       // There should always be another index for the Initial View
-      indexRepositories.add(this.cas.getView(CAS.NAME_DEFAULT_SOFA).getIndexRepository());
+      indexRepositories.add(this.casBeingFilled.getView(CAS.NAME_DEFAULT_SOFA).getIndexRepository());
       //add an entry to indexRepositories for each Sofa in the CAS (which can only happen if
       //a mergePoint was specified)
-      FSIterator sofaIter = this.cas.getSofaIterator();
+      FSIterator sofaIter = this.casBeingFilled.getSofaIterator();
       while(sofaIter.hasNext()) {
         SofaFS sofa = (SofaFS)sofaIter.next();
         if (sofa.getSofaRef() == 1) {
-          cas.registerInitialSofa();
+          casBeingFilled.registerInitialSofa();
         } else {
           // add indexRepo for views other than the initial view
-          indexRepositories.add(cas.getSofaIndexRepository(sofa));
+          indexRepositories.add(casBeingFilled.getSofaIndexRepository(sofa));
         }        
       }      
-      
-      this.sofaTypeCode = cas.ts.getTypeCode(CAS.TYPE_NAME_SOFA);
-      this.sofaNumFeatCode = cas.ts.getFeatureCode(CAS.FEATURE_FULL_NAME_SOFANUM);
-      this.sofaFeatCode = cas.ts.getFeatureCode(CAS.FEATURE_FULL_NAME_SOFA);
+      final TypeSystemImpl tsOfReceivingCas = casBeingFilled.getTypeSystemImpl();
+      this.sofaTypeCode = tsOfReceivingCas.getTypeCode(CAS.TYPE_NAME_SOFA);
+      this.sofaNumFeatCode = tsOfReceivingCas.getFeatureCode(CAS.FEATURE_FULL_NAME_SOFANUM);
+      this.sofaFeatCode = tsOfReceivingCas.getFeatureCode(CAS.FEATURE_FULL_NAME_SOFA);
       this.nextSofaNum = 2;
-      this.listUtils = new ListUtils(cas, UIMAFramework.getLogger(XmiCasDeserializer.class), null);
+      this.listUtils = new ListUtils(casBeingFilled, UIMAFramework.getLogger(XmiCasDeserializer.class), null);
 
       // populate feature type table
-      this.featureType = new int[cas.ts.getNumberOfFeatures() + 1];
+      this.featureType = new int[tsOfReceivingCas.getNumberOfFeatures() + 1];
       FeatureImpl feat;
-      Iterator it = cas.ts.getFeatures();
+      Iterator it = tsOfReceivingCas.getFeatures();
       while (it.hasNext()) {
         feat = (FeatureImpl) it.next();
-        featureType[feat.getCode()] = classifyType(cas.ts.range(feat.getCode()));
+        featureType[feat.getCode()] = classifyType(tsOfReceivingCas.range(feat.getCode()));
       }
     }
 
@@ -419,7 +419,7 @@
               new XmlElementName(nameSpaceURI, localName, qualifiedName), attrs);                  
         }
         return;
-      } else if (cas.isArrayType(currentType)) {
+      } else if (casBeingFilled.isArrayType(currentType)) {
         // store ID and array values (if specified as attribute).
         // we will actually create the array later, in endElement.
         String idStr = attrs.getValue(ID_ATTR_NAME);
@@ -429,7 +429,7 @@
         // special parsing for byte arrays (they are serialized as a hex
         // string. And we create them here instead of parsing to a string
         // array, for efficiency.
-        if (cas.isByteArrayType(currentType)) {
+        if (casBeingFilled.isByteArrayType(currentType)) {
           createByteArray(elements, currentArrayId);
         } else {
           if (elements != null) {
@@ -440,7 +440,7 @@
           }
         }
       } else {
-        final int addr = cas.ll_createFS(currentType.getCode());
+        final int addr = casBeingFilled.ll_createFS(currentType.getCode());
         readFS(addr, attrs);
       }
     }
@@ -464,7 +464,7 @@
           // translate sofa's xmi:id into its sofanum
           int sofaXmiId = Integer.parseInt(sofa);
           int sofaAddr = getFsAddrForXmiId(sofaXmiId);
-          sofaNum = cas.getFeatureValue(sofaAddr, sofaNumFeatCode);
+          sofaNum = casBeingFilled.getFeatureValue(sofaAddr, sofaNumFeatCode);
         }
         FSIndexRepositoryImpl indexRep = (FSIndexRepositoryImpl) indexRepositories.get(sofaNum);
 
@@ -505,8 +505,8 @@
       this.currentAddr = addr;
       int id = -1;
       String attrName, attrValue;
-      final int typeCode = cas.getHeapValue(addr);
-      final Type type = cas.ts.getType(typeCode);
+      final int typeCode = casBeingFilled.getHeapValue(addr);
+      final Type type = casBeingFilled.getTypeSystemImpl().getType(typeCode);
       int thisSofaNum = 0;
 
       if (sofaTypeCode == typeCode) {
@@ -542,15 +542,15 @@
       }
       if (sofaTypeCode == typeCode) {
         // If a Sofa, create CAS view to get new indexRepository
-        SofaFS sofa = (SofaFS) cas.createFS(addr);
+        SofaFS sofa = (SofaFS) casBeingFilled.createFS(addr);
         // also add to indexes so we can retrieve the Sofa later
-        cas.getBaseIndexRepository().addFS(sofa);
-        CAS view = cas.getView(sofa);
+        casBeingFilled.getBaseIndexRepository().addFS(sofa);
+        CAS view = casBeingFilled.getView(sofa);
         if (sofa.getSofaRef() == 1) {
-          cas.registerInitialSofa();
+          casBeingFilled.registerInitialSofa();
         } else {
           // add indexRepo for views other than the initial view
-          indexRepositories.add(cas.getSofaIndexRepository(sofa));
+          indexRepositories.add(casBeingFilled.getSofaIndexRepository(sofa));
         }
         ((CASImpl) view).registerView(sofa);
         views.add(view);
@@ -616,10 +616,10 @@
                 // it from a sofa reference into a sofa number
                 int sofaXmiId = Integer.parseInt(featVal);
                 int sofaAddr = getFsAddrForXmiId(sofaXmiId);
-                int sofaNum = cas.getFeatureValue(sofaAddr, sofaNumFeatCode);
-                cas.setFeatureValue(addr, featCode, sofaNum);
+                int sofaNum = casBeingFilled.getFeatureValue(sofaAddr, sofaNumFeatCode);
+                casBeingFilled.setFeatureValue(addr, featCode, sofaNum);
               } else {
-                cas.setFeatureValue(addr, featCode, Integer.parseInt(featVal));
+                casBeingFilled.setFeatureValue(addr, featCode, Integer.parseInt(featVal));
               }
             }
           } catch (NumberFormatException e) {
@@ -635,7 +635,7 @@
         case LowLevelCAS.TYPE_CLASS_DOUBLE: {
           try {
             if (!emptyVal(featVal)) {
-              cas.setFeatureValueFromString(addr, featCode, featVal);
+              casBeingFilled.setFeatureValueFromString(addr, featCode, featVal);
               // cas.setFloatValue(addr, featCode, Float.parseFloat(featVal));
             }
           } catch (NumberFormatException e) {
@@ -646,14 +646,14 @@
         case LowLevelCAS.TYPE_CLASS_STRING: {
           if (featVal != null) // do not use empty value since that would filter out ""
           {
-            cas.setStringValue(addr, featCode, featVal);
+            casBeingFilled.setStringValue(addr, featCode, featVal);
           }
           break;
         }
         case LowLevelCAS.TYPE_CLASS_FS: {
           try {
             if (!emptyVal(featVal)) {
-              cas.setFeatureValue(addr, featCode, Integer.parseInt(featVal));
+              casBeingFilled.setFeatureValue(addr, featCode, Integer.parseInt(featVal));
             }
           } catch (NumberFormatException e) {
             throw createException(XCASParsingException.INTEGER_EXPECTED, featVal);
@@ -678,7 +678,7 @@
             // do the usual FS deserialization
             try {
               if (!emptyVal(featVal)) {
-                cas.setFeatureValue(addr, featCode, Integer.parseInt(featVal));
+                casBeingFilled.setFeatureValue(addr, featCode, Integer.parseInt(featVal));
               }
             } catch (NumberFormatException e) {
               throw createException(XCASParsingException.INTEGER_EXPECTED, featVal);
@@ -688,7 +688,7 @@
             // However, byte arrays have a special serialization (as hex digits)
             if (featureType[featCode] == LowLevelCAS.TYPE_CLASS_BYTEARRAY) {
               int casArray = createByteArray(featVal, -1);
-              cas.setFeatureValue(addr, featCode, casArray);
+              casBeingFilled.setFeatureValue(addr, featCode, casArray);
             } else {
               String[] arrayVals = parseArray(featVal);
               handleFeature(addr, featCode, Arrays.asList(arrayVals));
@@ -706,7 +706,7 @@
             // do the usual FS deserialization
             try {
               if (!emptyVal(featVal)) {
-                cas.setFeatureValue(addr, featCode, Integer.parseInt(featVal));
+                casBeingFilled.setFeatureValue(addr, featCode, Integer.parseInt(featVal));
               }
             } catch (NumberFormatException e) {
               throw createException(XCASParsingException.INTEGER_EXPECTED, featVal);
@@ -782,28 +782,28 @@
         case LowLevelCAS.TYPE_CLASS_SHORTARRAY:
         case LowLevelCAS.TYPE_CLASS_LONGARRAY:
         case LowLevelCAS.TYPE_CLASS_DOUBLEARRAY: {
-          int casArray = createArray(cas.ts.range(featCode), featVals, -1);
-          cas.setFeatureValue(addr, featCode, casArray);
+          int casArray = createArray(casBeingFilled.getTypeSystemImpl().range(featCode), featVals, -1);
+          casBeingFilled.setFeatureValue(addr, featCode, casArray);
           break;
         }
         case LowLevelCAS.TYPE_CLASS_FSARRAY: {
-          int casArray = createArray(cas.ts.range(featCode), featVals, -1);
-          cas.setFeatureValue(addr, featCode, casArray);
+          int casArray = createArray(casBeingFilled.getTypeSystemImpl().range(featCode), featVals, -1);
+          casBeingFilled.setFeatureValue(addr, featCode, casArray);
           break;
         }
         case XmiCasSerializer.TYPE_CLASS_INTLIST: {
           int listFS = listUtils.createIntList(featVals);
-          cas.setFeatureValue(addr, featCode, listFS);
+          casBeingFilled.setFeatureValue(addr, featCode, listFS);
           break;
         }
         case XmiCasSerializer.TYPE_CLASS_FLOATLIST: {
           int listFS = listUtils.createFloatList(featVals);
-          cas.setFeatureValue(addr, featCode, listFS);
+          casBeingFilled.setFeatureValue(addr, featCode, listFS);
           break;
         }
         case XmiCasSerializer.TYPE_CLASS_STRINGLIST: {
           int listFS = listUtils.createStringList(featVals);
-          cas.setFeatureValue(addr, featCode, listFS);
+          casBeingFilled.setFeatureValue(addr, featCode, listFS);
           break;
         }
         case XmiCasSerializer.TYPE_CLASS_FSLIST: {
@@ -812,7 +812,7 @@
           // We need this so we can go back through later and reset the addresses of the
           // "head" features of these lists nodes (but not reset the tail features).
           int listFS = listUtils.createFsList(featVals, fsListNodesFromMultivaluedProperties);
-          cas.setFeatureValue(addr, featCode, listFS);
+          casBeingFilled.setFeatureValue(addr, featCode, listFS);
           break;
         }
         default: {
@@ -835,24 +835,24 @@
     private int createArray(int arrayType, List values, int xmiId) {
 
       FeatureStructureImplC fs;
-      if (cas.isBooleanArrayType(arrayType)) {
-        fs = (FeatureStructureImplC) cas.createBooleanArrayFS(values.size());
-      } else if (cas.isByteArrayType(arrayType)) {
-        fs = (FeatureStructureImplC) cas.createByteArrayFS(values.size());
-      } else if (cas.isShortArrayType(arrayType)) {
-        fs = (FeatureStructureImplC) cas.createShortArrayFS(values.size());
-      } else if (cas.isLongArrayType(arrayType)) {
-        fs = (FeatureStructureImplC) cas.createLongArrayFS(values.size());
-      } else if (cas.isDoubleArrayType(arrayType)) {
-        fs = (FeatureStructureImplC) cas.createDoubleArrayFS(values.size());
+      if (casBeingFilled.isBooleanArrayType(arrayType)) {
+        fs = (FeatureStructureImplC) casBeingFilled.createBooleanArrayFS(values.size());
+      } else if (casBeingFilled.isByteArrayType(arrayType)) {
+        fs = (FeatureStructureImplC) casBeingFilled.createByteArrayFS(values.size());
+      } else if (casBeingFilled.isShortArrayType(arrayType)) {
+        fs = (FeatureStructureImplC) casBeingFilled.createShortArrayFS(values.size());
+      } else if (casBeingFilled.isLongArrayType(arrayType)) {
+        fs = (FeatureStructureImplC) casBeingFilled.createLongArrayFS(values.size());
+      } else if (casBeingFilled.isDoubleArrayType(arrayType)) {
+        fs = (FeatureStructureImplC) casBeingFilled.createDoubleArrayFS(values.size());
       } else {
-        int addr = cas.createTempArray(arrayType, values.size());
-        fs = new FeatureStructureImplC(cas, addr);
+        int addr = casBeingFilled.createTempArray(arrayType, values.size());
+        fs = new FeatureStructureImplC(casBeingFilled, addr);
       }
       int casArray = fs.getAddress();
       for (int i = 0; i < values.size(); i++) {
         String stringVal = (String) values.get(i);
-        cas.setArrayValueFromString(casArray, i, stringVal);
+        casBeingFilled.setArrayValueFromString(casArray, i, stringVal);
       }
 
       deserializedFsAddrs.add(casArray);
@@ -873,7 +873,7 @@
      */
     private int createByteArray(String hexString, int xmiId) {
       int arrayLen = hexString.length() / 2;
-      ByteArrayFS fs = cas.createByteArrayFS(arrayLen);
+      ByteArrayFS fs = casBeingFilled.createByteArrayFS(arrayLen);
       for (int i = 0; i < arrayLen; i++) {
         byte high = hexCharToByte(hexString.charAt(i * 2));
         byte low = hexCharToByte(hexString.charAt(i * 2 + 1));
@@ -975,7 +975,7 @@
             this.outOfTypeSystemElement = null;
           }
           else if (currentType != null) {
-            if (cas.isArrayType(currentType) && !cas.isByteArrayType(currentType)) {
+            if (casBeingFilled.isArrayType(currentType) && !casBeingFilled.isByteArrayType(currentType)) {
               // create the array now. elements may have been provided either as
               // attributes or child elements, but not both.
               // BUT - not byte arrays! They are created immediately, to avoid
@@ -1040,21 +1040,21 @@
      * @param fsInfo
      */
     private void finalizeFS(int addr) {
-      final int type = cas.getHeapValue(addr);
-      if (cas.isArrayType(type)) {
+      final int type = casBeingFilled.getHeapValue(addr);
+      if (casBeingFilled.isArrayType(type)) {
         finalizeArray(type, addr);
         return;
       }
       // remap IDs for all nonprimtive, non-multivalued-property features
-      int[] feats = cas.getTypeSystemImpl().getAppropriateFeatures(type);
+      int[] feats = casBeingFilled.getTypeSystemImpl().getAppropriateFeatures(type);
       Feature feat;
       for (int i = 0; i < feats.length; i++) {
         feat = ts.getFeature(feats[i]);
         int typeCode = ts.ll_getRangeType(feats[i]);
-        if (cas.ll_isRefType(typeCode)
+        if (casBeingFilled.ll_isRefType(typeCode)
                 && (featureType[feats[i]] == LowLevelCAS.TYPE_CLASS_FS || feat
                         .isMultipleReferencesAllowed())) {
-          int featVal = cas.getFeatureValue(addr, feats[i]);
+          int featVal = casBeingFilled.getFeatureValue(addr, feats[i]);
           if (featVal != CASImpl.NULL) {
             int fsValAddr = CASImpl.NULL;
             try {
@@ -1071,7 +1071,7 @@
                         addr, feat.getShortName(), Integer.toString(featVal));
               }
             }
-            cas.setFeatureValue(addr, feats[i], fsValAddr);
+            casBeingFilled.setFeatureValue(addr, feats[i], fsValAddr);
           }
         }
       }
@@ -1085,14 +1085,14 @@
      * @param i
      */
     private void remapFSListHeads(int addr) {
-      final int type = cas.getHeapValue(addr);
+      final int type = casBeingFilled.getHeapValue(addr);
       if (!listUtils.isFsListType(type))
         return;
-      int[] feats = cas.getTypeSystemImpl().getAppropriateFeatures(type);
+      int[] feats = casBeingFilled.getTypeSystemImpl().getAppropriateFeatures(type);
       if (feats.length == 0)
         return;
       int headFeat = feats[0];
-      int featVal = cas.getFeatureValue(addr, headFeat);
+      int featVal = casBeingFilled.getFeatureValue(addr, headFeat);
       if (featVal != CASImpl.NULL) {
         int fsValAddr = CASImpl.NULL;
         try {
@@ -1106,7 +1106,7 @@
             this.sharedData.addOutOfTypeSystemAttribute(addr, CAS.FEATURE_BASE_NAME_HEAD, Integer.toString(featVal));
           }
         }
-        cas.setFeatureValue(addr, headFeat, fsValAddr);
+        casBeingFilled.setFeatureValue(addr, headFeat, fsValAddr);
       }
     }
 
@@ -1119,13 +1119,13 @@
      *          address of the array
      */
     private void finalizeArray(int type, int addr) {
-      if (!cas.isFSArrayType(type)) {
+      if (!casBeingFilled.isFSArrayType(type)) {
         // Nothing to do.
         return;
       }
-      final int size = cas.ll_getArraySize(addr);
+      final int size = casBeingFilled.ll_getArraySize(addr);
       for (int i = 0; i < size; i++) {
-        int arrayVal = cas.getArrayValue(addr, i);
+        int arrayVal = casBeingFilled.getArrayValue(addr, i);
         if (arrayVal != CASImpl.NULL) {
           int arrayValAddr = CASImpl.NULL;
           try {
@@ -1140,7 +1140,7 @@
               this.sharedData.addOutOfTypeSystemArrayElement(addr, i, arrayVal);
             }
           }
-          cas.setArrayValue(addr, i, arrayValAddr);
+          casBeingFilled.setArrayValue(addr, i, arrayValAddr);
         }
       }
     }
@@ -1249,7 +1249,7 @@
       if (listUtils.isFsListType(type)) {
         return XmiCasSerializer.TYPE_CLASS_FSLIST;
       }
-      return cas.ll_getTypeClass(type);
+      return casBeingFilled.ll_getTypeClass(type);
     }
     
     /**

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasSerializer.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasSerializer.java?view=diff&rev=540312&r1=540311&r2=540312
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasSerializer.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasSerializer.java Mon May 21 14:49:16 2007
@@ -162,12 +162,12 @@
       this.visited = new IntRedBlackTree();
       this.queue = new IntStack();
       this.indexedFSs = new IntVector();
-      // this.sofaTypeCode = cas.ts.getTypeCode(CAS.TYPE_NAME_SOFA);
-      // this.annotationTypeCode = cas.ts.getTypeCode(CAS.TYPE_NAME_ANNOTATION);
+      // this.sofaTypeCode = cas.getTypeSystemImpl().getTypeCode(CAS.TYPE_NAME_SOFA);
+      // this.annotationTypeCode = cas.getTypeSystemImpl().getTypeCode(CAS.TYPE_NAME_ANNOTATION);
       this.listUtils = new ListUtils(cas, logger, eh);
       this.arrayAndListFSs = new IntRedBlackTree();
       this.sharedData = sharedData;
-      this.isFiltering = filterTypeSystem != null && filterTypeSystem != cas.ts;
+      this.isFiltering = filterTypeSystem != null && filterTypeSystem != cas.getTypeSystemImpl();
     }
 
     // TODO: internationalize
@@ -192,7 +192,7 @@
     /**
      * Starts serialization
      */
-    private void serialize() throws IOException, SAXException {
+    private void serialize() throws SAXException {
       // populate nsUriToPrefixMap and xmiTypeNames structures based on CAS 
       // type system, and out of typesytem data if any
       initTypeAndNamespaceMappings();
@@ -382,7 +382,7 @@
         return;
       }
       if (isFiltering) {
-        String typeName = cas.ts.getTypeName(cas.getHeapValue(addr));
+        String typeName = cas.getTypeSystemImpl().getTypeName(cas.getHeapValue(addr));
         if (filterTypeSystem.getType(typeName) == null) {
           return; // this type is not in the target type system
         }
@@ -403,7 +403,7 @@
       }
       int typeCode = cas.getHeapValue(addr);
       if (isFiltering) {
-        String typeName = cas.ts.getTypeName(typeCode);
+        String typeName = cas.getTypeSystemImpl().getTypeName(typeCode);
         if (filterTypeSystem.getType(typeName) == null) {
           return; // this type is not in the target type system
         }
@@ -430,12 +430,12 @@
      */
     private void enqueueFeatures(int addr, int typeCode) throws SAXException {
       boolean insideListNode = listUtils.isListType(typeCode);
-      int[] feats = cas.ts.getAppropriateFeatures(typeCode);
+      int[] feats = cas.getTypeSystemImpl().getAppropriateFeatures(typeCode);
       int featAddr, featVal, fsClass;
       for (int i = 0; i < feats.length; i++) {
         if (isFiltering) {
           // skip features that aren't in the target type system
-          String fullFeatName = cas.ts.getFeatureName(feats[i]);
+          String fullFeatName = cas.getTypeSystemImpl().getFeatureName(feats[i]);
           if (filterTypeSystem.getFeatureByFullName(fullFeatName) == null) {
             continue;
           }
@@ -447,7 +447,7 @@
         }
 
         // enqueue behavior depends on range type of feature
-        fsClass = classifyType(cas.ts.range(feats[i]));
+        fsClass = classifyType(cas.getTypeSystemImpl().range(feats[i]));
         switch (fsClass) {
           case LowLevelCAS.TYPE_CLASS_FS: {
             enqueue(featVal);
@@ -464,7 +464,7 @@
           case LowLevelCAS.TYPE_CLASS_FSARRAY: {
             // we only enqueue arrays as first-class objects if the feature has
             // multipleReferencesAllowed = true
-            if (cas.ts.getFeature(feats[i]).isMultipleReferencesAllowed()) {
+            if (cas.getTypeSystemImpl().getFeature(feats[i]).isMultipleReferencesAllowed()) {
               enqueue(featVal);
             } else if (fsClass == LowLevelCAS.TYPE_CLASS_FSARRAY) {
               // but we do need to enqueue any FSs reachable from an FSArray
@@ -479,7 +479,7 @@
             // we only enqueue lists as first-class objects if the feature has
             // multipleReferencesAllowed = true
             // OR if we're already inside a list node (this handles the tail feature correctly)
-            if (cas.ts.getFeature(feats[i]).isMultipleReferencesAllowed() || insideListNode) {
+            if (cas.getTypeSystemImpl().getFeature(feats[i]).isMultipleReferencesAllowed() || insideListNode) {
               enqueue(featVal);
             } else if (fsClass == TYPE_CLASS_FSLIST) {
               // also, we need to enqueue any FSs reachable from an FSList
@@ -531,7 +531,7 @@
      * @throws IOException
      * @throws SAXException
      */
-    private void encodeIndexed() throws IOException, SAXException {
+    private void encodeIndexed() throws SAXException {
       final int max = indexedFSs.size();
       for (int i = 0; i < max; i++) {
         encodeFS(indexedFSs.get(i));
@@ -545,7 +545,7 @@
      * @throws IOException
      * @throws SAXException
      */
-    private void encodeQueued() throws IOException, SAXException {
+    private void encodeQueued() throws SAXException {
       int addr;
       while (!queue.empty()) {
         addr = queue.pop();
@@ -558,10 +558,9 @@
      * 
      * @param addr
      *          The address to be encoded.
-     * @throws IOException
      * @throws SAXException
      */
-    private void encodeFS(int addr) throws IOException, SAXException {
+    private void encodeFS(int addr) throws SAXException {
       ++fsCount;
       workAttrs.clear();
 
@@ -637,7 +636,7 @@
       }
       if (isFiltering) // return as null any references to types not in target TS
       {
-        String typeName = cas.ts.getTypeName(cas.getHeapValue(addr));
+        String typeName = cas.getTypeSystemImpl().getTypeName(cas.getHeapValue(addr));
         if (filterTypeSystem.getType(typeName) == null) {
           return null;
         }
@@ -689,7 +688,7 @@
             throws SAXException {
       List childElements = new ArrayList();
       int heapValue = cas.getHeapValue(addr);
-      int[] feats = cas.ts.getAppropriateFeatures(heapValue);
+      int[] feats = cas.getTypeSystemImpl().getAppropriateFeatures(heapValue);
       int featAddr, featVal, fsClass;
       String featName, attrValue;
       // boolean isSofa = false;
@@ -701,7 +700,7 @@
       for (int i = 0; i < feats.length; i++) {
         if (isFiltering) {
           // skip features that aren't in the target type system
-          String fullFeatName = cas.ts.getFeatureName(feats[i]);
+          String fullFeatName = cas.getTypeSystemImpl().getFeatureName(feats[i]);
           if (filterTypeSystem.getFeatureByFullName(fullFeatName) == null) {
             continue;
           }
@@ -709,8 +708,8 @@
 
         featAddr = addr + cas.getFeatureOffset(feats[i]);
         featVal = cas.getHeapValue(featAddr);
-        featName = cas.ts.getFeature(feats[i]).getShortName();
-        fsClass = classifyType(cas.ts.range(feats[i]));
+        featName = cas.getTypeSystemImpl().getFeature(feats[i]).getShortName();
+        fsClass = classifyType(cas.getTypeSystemImpl().range(feats[i]));
         switch (fsClass) {
           case LowLevelCAS.TYPE_CLASS_INT:
           case LowLevelCAS.TYPE_CLASS_FLOAT:
@@ -741,7 +740,7 @@
           case LowLevelCAS.TYPE_CLASS_FSARRAY: {
             // If the feature has multipleReferencesAllowed = true, serialize as any other FS.
             // If false, serialize as a multi-valued property.
-            if (cas.ts.getFeature(feats[i]).isMultipleReferencesAllowed()) {
+            if (cas.getTypeSystemImpl().getFeature(feats[i]).isMultipleReferencesAllowed()) {
               attrValue = getXmiId(featVal);
             } else {
               attrValue = arrayToString(featVal, fsClass);
@@ -753,7 +752,7 @@
           case LowLevelCAS.TYPE_CLASS_STRINGARRAY: {
             // If the feature has multipleReferencesAllowed = true, serialize as any other FS.
             // If false, serialize as a multi-valued property.
-            if (cas.ts.getFeature(feats[i]).isMultipleReferencesAllowed()) {
+            if (cas.getTypeSystemImpl().getFeature(feats[i]).isMultipleReferencesAllowed()) {
               attrValue = getXmiId(featVal);
             } else {
               stringArrayToElementList(featName, featVal, childElements);
@@ -768,7 +767,7 @@
             // If the feature has multipleReferencesAllowed = true OR if we're already
             // inside another list node (i.e. this is the "tail" feature), serialize as a normal FS.
             // Otherwise, serialize as a multi-valued property.
-            if (cas.ts.getFeature(feats[i]).isMultipleReferencesAllowed() || insideListNode) {
+            if (cas.getTypeSystemImpl().getFeature(feats[i]).isMultipleReferencesAllowed() || insideListNode) {
               attrValue = getXmiId(featVal);
             } else {
               attrValue = listToString(featVal, fsClass);
@@ -778,7 +777,7 @@
             // special case for StringLists, which stored values as child elements rather
             // than attributes.
           case TYPE_CLASS_STRINGLIST: {
-            if (cas.ts.getFeature(feats[i]).isMultipleReferencesAllowed() || insideListNode) {
+            if (cas.getTypeSystemImpl().getFeature(feats[i]).isMultipleReferencesAllowed() || insideListNode) {
               attrValue = getXmiId(featVal);
             } else {
               // it is not safe to use a space-separated attribute, which would
@@ -1054,7 +1053,7 @@
      */
     private void initTypeAndNamespaceMappings() {
       nsUriToPrefixMap.put(XMI_NS_URI, XMI_NS_PREFIX);
-      xmiTypeNames = new XmlElementName[cas.ts.getLargestTypeCode() + 1];
+      xmiTypeNames = new XmlElementName[cas.getTypeSystemImpl().getLargestTypeCode() + 1];
 
       //Add any namespace prefix mappings used by out of type system data.
       //Need to do this before the in-typesystem namespaces so that the prefix
@@ -1072,7 +1071,7 @@
         }
       }
       
-      Iterator it = cas.ts.getTypeIterator();
+      Iterator it = cas.getTypeSystemImpl().getTypeIterator();
       while (it.hasNext()) {
         TypeImpl t = (TypeImpl) it.next();
         xmiTypeNames[t.getCode()] = uimaTypeName2XmiElementName(t.getName());
@@ -1299,7 +1298,7 @@
    * @throws IOException
    * @throws SAXException
    */
-  public void serialize(CAS cas, ContentHandler contentHandler) throws IOException, SAXException {
+  public void serialize(CAS cas, ContentHandler contentHandler) throws SAXException {
     this.serialize(cas, contentHandler, null);
   }
 
@@ -1316,7 +1315,7 @@
    * @throws SAXException
    */
   public void serialize(CAS cas, ContentHandler contentHandler, ErrorHandler errorHandler)
-          throws IOException, SAXException {
+          throws SAXException {
     contentHandler.startDocument();
     XmiCasDocSerializer ser = new XmiCasDocSerializer(contentHandler, errorHandler, ((CASImpl) cas)
             .getBaseCAS(), null);
@@ -1339,7 +1338,7 @@
    * @throws SAXException
    */
   public void serialize(CAS cas, ContentHandler contentHandler, ErrorHandler errorHandler,
-          XmiSerializationSharedData sharedData) throws IOException, SAXException {
+          XmiSerializationSharedData sharedData) throws SAXException {
     contentHandler.startDocument();
     XmiCasDocSerializer ser = new XmiCasDocSerializer(contentHandler, errorHandler, ((CASImpl) cas)
             .getBaseCAS(), sharedData);
@@ -1360,7 +1359,7 @@
    * @throws IOException
    *           if an I/O failure occurs
    */
-  public static void serialize(CAS aCAS, OutputStream aStream) throws SAXException, IOException {
+  public static void serialize(CAS aCAS, OutputStream aStream) throws SAXException {
     serialize(aCAS, null, aStream, false, null);
   }
 
@@ -1383,7 +1382,7 @@
    *           if an I/O failure occurs
    */
   public static void serialize(CAS aCAS, TypeSystem aTargetTypeSystem, OutputStream aStream)
-          throws SAXException, IOException {
+          throws SAXException {
     serialize(aCAS, aTargetTypeSystem, aStream, false, null);
   }
   
@@ -1411,7 +1410,7 @@
    */
   public static void serialize(CAS aCAS, TypeSystem aTargetTypeSystem, OutputStream aStream, boolean aPrettyPrint, 
           XmiSerializationSharedData aSharedData)
-          throws SAXException, IOException {
+          throws SAXException {
     XmiCasSerializer xmiCasSerializer = new XmiCasSerializer(aTargetTypeSystem);
     XMLSerializer sax2xml = new XMLSerializer(aStream, aPrettyPrint);
     xmiCasSerializer.serialize(aCAS, sax2xml.getContentHandler(), null, aSharedData);