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 2008/08/30 00:11:30 UTC

svn commit: r690405 [10/26] - in /incubator/uima/uimaj/trunk/uimaj-core: ./ src/main/java/org/apache/uima/ src/main/java/org/apache/uima/analysis_component/ src/main/java/org/apache/uima/analysis_engine/ src/main/java/org/apache/uima/analysis_engine/an...

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIndexRepositoryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIntArrayIndex.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIntConstraintImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIteratorAggregate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIteratorImplBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSIteratorWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSLeafIndexImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSListIteratorImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSRBTIndex.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSRBTSetIndex.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSRefIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSStringConstraintImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSTypeConstraintImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FSVectorIndex.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeaturePathImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImplC.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureValuePathImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FilteredIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FloatArrayFSImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/FloatConstraint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/Heap.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/Heap.java?rev=690405&r1=690404&r2=690405&view=diff
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/Heap.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/Heap.java Fri Aug 29 15:10:52 2008
@@ -1,253 +1,253 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.uima.cas.impl;
-
-import java.util.Arrays;
-
-import org.apache.uima.internal.util.IntArrayUtils;
-
-/**
- * A heap for CAS.
- * 
- * <p>
- * This class is agnostic about what you store on the heap. It only copies
- * values from integer arrays.
- */
-public final class Heap {
-
-  /**
-   * Minimum size of the heap. Currently set to <code>1000</code>.
-   */
-  public static final int MIN_SIZE = 1000;
-
-  /**
-   * Default size of the heap. Currently set to <code>500000</code>(2 MB).
-   */
-  public static final int DEFAULT_SIZE = 500000; // 2 MB pages
-
-  // Initial size of the heap. This is also the size the heap will be reset to
-  // on a full reset.
-  private int initialSize;
-
-  // The array that represents the actual heap is package private and
-  // can be directly addressed by the LowLevelCAS.
-  int[] heap;
-  
-  // Next free position on the heap.
-  private int pos;
-
-  // End of heap. In the current implementation, this is the same as
-  // this.heap.length at all times.
-  private int max;
-
-  // Serialization constants. There are holes in the numbering for historical
-  // reasons. Keep the holes for compatibility.
-  private static final int SIZE_POS = 0;
-
-  private static final int TMPP_POS = 1;
-
-  private static final int TMPM_POS = 2;
-
-  private static final int PGSZ_POS = 5;
-
-  private static final int AVSZ_POS = 6;
-
-  private static final int AVST_POS = 7;
-
-  /**
-   * Default constructor.
-   */
-  public Heap() {
-    this(DEFAULT_SIZE);
-  }
-
-  /**
-   * Constructor lets you set initial heap size. Use only if you know what
-   * you're doing.
-   * 
-   * @param initialSize
-   *                The initial heap size. If this is smaller than the
-   *                {@link #MIN_SIZE MIN_SIZE}, the default will be used
-   *                instead.
-   */
-  public Heap(int initialSize) {
-    super();
-    if (initialSize < MIN_SIZE) {
-      initialSize = MIN_SIZE;
-    }
-    this.initialSize = initialSize;
-    initHeap();
-  }
-
-  private final void initHeap() {
-    this.heap = new int[this.initialSize];
-    this.pos = 1; // 0 is not a valid address
-    this.max = this.heap.length;
-  }
-
-  void reinit(int[] md, int[] shortHeap) {
-    if (md == null) {
-      reinitNoMetaData(shortHeap);
-      return;
-    }
-    // assert(md != null);
-    // assert(shortHeap != null);
-    final int heapSize = md[SIZE_POS];
-    this.pos = md[TMPP_POS];
-    this.max = md[TMPM_POS];
-    this.initialSize = md[PGSZ_POS];
-
-    // Copy the shortened version of the heap into a full version.
-    this.heap = new int[heapSize];
-    System.arraycopy(shortHeap, 0, this.heap, 0, shortHeap.length);
-
-  }
-
-  /**
-   * Re-init the heap without metadata. Use default values for metadata.
-   * 
-   * @param shortHeap
-   */
-  private void reinitNoMetaData(int[] shortHeap) {
-    this.initialSize = (shortHeap.length < MIN_SIZE) ? MIN_SIZE : shortHeap.length;
-    if (shortHeap.length >= this.initialSize) {
-      this.heap = shortHeap;
-    } else {
-      System.arraycopy(shortHeap, 0, this.heap, 0, shortHeap.length);
-    }
-    // Set position and max.
-    this.pos = shortHeap.length;
-    this.max = this.initialSize;
-  }
-
-  /**
-   * Re-create the heap for the given size. Just use the size of the incoming
-   * heap, unless it's smaller than our minimum. It is expected that the caller
-   * will then fill in the new heap up to newSize.
-   * 
-   * @param newSize
-   */
-  void reinitSizeOnly(int newSize) {
-    this.initialSize = (newSize < MIN_SIZE) ? MIN_SIZE : newSize;
-    this.heap = new int[this.initialSize];
-    // Set position and max.
-    this.pos = newSize;
-    this.max = this.initialSize;
-  }
-
-  /**
-   * Return the number of cells used.
-   */
-  int getCellsUsed() {
-    return this.pos;
-  }
-
-  /**
-   * @return The overall size of the heap (including unused space).
-   */
-  int getHeapSize() {
-    return this.heap.length;
-  }
-
-  int[] getMetaData() {
-    final int arSize = AVST_POS;
-    int[] ar = new int[arSize];
-    ar[SIZE_POS] = this.heap.length;
-    ar[TMPP_POS] = this.pos;
-    ar[TMPM_POS] = this.max;
-    ar[PGSZ_POS] = this.initialSize;
-    final int availablePagesSize = 0;
-    ar[AVSZ_POS] = availablePagesSize;
-
-    return ar;
-  }
-
-  // Grow the heap.
-  private void grow() {
-    final int start = this.heap.length;
-    // This will grow the heap by doubling its size if it's smaller than
-    // DEFAULT_SIZE, and by DEFAULT_SIZE if it's larger.
-    this.heap = IntArrayUtils.ensure_size(this.heap, start + this.initialSize, 2, DEFAULT_SIZE);
-    this.max = this.heap.length;
-  }
-
-  /**
-   * Reset the temporary heap.
-   */
-  public void reset() {
-    this.reset(false);
-  }
-
-  /**
-   * Reset the temporary heap.
-   */
-  void reset(boolean doFullReset) {
-    if (doFullReset) {
-      this.initHeap();
-    } else {
-      Arrays.fill(this.heap, 0, this.pos, 0);
-      this.pos = 1;
-    }
-  }
-
-  /**
-   * Add a structure to the heap.
-   * 
-   * @param fs
-   *                The input structure.
-   * @return The position where the structure was added, i.e., a pointer to the
-   *         first element of the structure.
-   */
-  public int add(int[] fs) {
-    while ((this.pos + fs.length) >= this.max) {
-      grow();
-    }
-    System.arraycopy(fs, 0, this.heap, this.pos, fs.length);
-    final int pos1 = this.pos;
-    this.pos += fs.length;
-    return pos1;
-  }
-
-  /**
-   * Reserve space for <code>len</code> items on the heap and set the first
-   * item to <code>val</code>. The other items are set to <code>0</code>.
-   * 
-   * @param len
-   *                The length of the new structure.
-   * @param val
-   *                The value of the first cell in the new structure.
-   * @return The position where the structure was added, i.e., a pointer to the
-   *         first element of the structure.
-   */
-  public int add(int len, int val) {
-    while ((this.pos + len) >= this.max) {
-      grow();
-    }
-    final int pos1 = this.pos;
-    this.pos += len;
-    this.heap[pos1] = val;
-    return pos1;
-  }
-  
-  public int getNextId() {
-	  return pos;
-  }
-	  
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.cas.impl;
+
+import java.util.Arrays;
+
+import org.apache.uima.internal.util.IntArrayUtils;
+
+/**
+ * A heap for CAS.
+ * 
+ * <p>
+ * This class is agnostic about what you store on the heap. It only copies
+ * values from integer arrays.
+ */
+public final class Heap {
+
+  /**
+   * Minimum size of the heap. Currently set to <code>1000</code>.
+   */
+  public static final int MIN_SIZE = 1000;
+
+  /**
+   * Default size of the heap. Currently set to <code>500000</code>(2 MB).
+   */
+  public static final int DEFAULT_SIZE = 500000; // 2 MB pages
+
+  // Initial size of the heap. This is also the size the heap will be reset to
+  // on a full reset.
+  private int initialSize;
+
+  // The array that represents the actual heap is package private and
+  // can be directly addressed by the LowLevelCAS.
+  int[] heap;
+  
+  // Next free position on the heap.
+  private int pos;
+
+  // End of heap. In the current implementation, this is the same as
+  // this.heap.length at all times.
+  private int max;
+
+  // Serialization constants. There are holes in the numbering for historical
+  // reasons. Keep the holes for compatibility.
+  private static final int SIZE_POS = 0;
+
+  private static final int TMPP_POS = 1;
+
+  private static final int TMPM_POS = 2;
+
+  private static final int PGSZ_POS = 5;
+
+  private static final int AVSZ_POS = 6;
+
+  private static final int AVST_POS = 7;
+
+  /**
+   * Default constructor.
+   */
+  public Heap() {
+    this(DEFAULT_SIZE);
+  }
+
+  /**
+   * Constructor lets you set initial heap size. Use only if you know what
+   * you're doing.
+   * 
+   * @param initialSize
+   *                The initial heap size. If this is smaller than the
+   *                {@link #MIN_SIZE MIN_SIZE}, the default will be used
+   *                instead.
+   */
+  public Heap(int initialSize) {
+    super();
+    if (initialSize < MIN_SIZE) {
+      initialSize = MIN_SIZE;
+    }
+    this.initialSize = initialSize;
+    initHeap();
+  }
+
+  private final void initHeap() {
+    this.heap = new int[this.initialSize];
+    this.pos = 1; // 0 is not a valid address
+    this.max = this.heap.length;
+  }
+
+  void reinit(int[] md, int[] shortHeap) {
+    if (md == null) {
+      reinitNoMetaData(shortHeap);
+      return;
+    }
+    // assert(md != null);
+    // assert(shortHeap != null);
+    final int heapSize = md[SIZE_POS];
+    this.pos = md[TMPP_POS];
+    this.max = md[TMPM_POS];
+    this.initialSize = md[PGSZ_POS];
+
+    // Copy the shortened version of the heap into a full version.
+    this.heap = new int[heapSize];
+    System.arraycopy(shortHeap, 0, this.heap, 0, shortHeap.length);
+
+  }
+
+  /**
+   * Re-init the heap without metadata. Use default values for metadata.
+   * 
+   * @param shortHeap
+   */
+  private void reinitNoMetaData(int[] shortHeap) {
+    this.initialSize = (shortHeap.length < MIN_SIZE) ? MIN_SIZE : shortHeap.length;
+    if (shortHeap.length >= this.initialSize) {
+      this.heap = shortHeap;
+    } else {
+      System.arraycopy(shortHeap, 0, this.heap, 0, shortHeap.length);
+    }
+    // Set position and max.
+    this.pos = shortHeap.length;
+    this.max = this.initialSize;
+  }
+
+  /**
+   * Re-create the heap for the given size. Just use the size of the incoming
+   * heap, unless it's smaller than our minimum. It is expected that the caller
+   * will then fill in the new heap up to newSize.
+   * 
+   * @param newSize
+   */
+  void reinitSizeOnly(int newSize) {
+    this.initialSize = (newSize < MIN_SIZE) ? MIN_SIZE : newSize;
+    this.heap = new int[this.initialSize];
+    // Set position and max.
+    this.pos = newSize;
+    this.max = this.initialSize;
+  }
+
+  /**
+   * Return the number of cells used.
+   */
+  int getCellsUsed() {
+    return this.pos;
+  }
+
+  /**
+   * @return The overall size of the heap (including unused space).
+   */
+  int getHeapSize() {
+    return this.heap.length;
+  }
+
+  int[] getMetaData() {
+    final int arSize = AVST_POS;
+    int[] ar = new int[arSize];
+    ar[SIZE_POS] = this.heap.length;
+    ar[TMPP_POS] = this.pos;
+    ar[TMPM_POS] = this.max;
+    ar[PGSZ_POS] = this.initialSize;
+    final int availablePagesSize = 0;
+    ar[AVSZ_POS] = availablePagesSize;
+
+    return ar;
+  }
+
+  // Grow the heap.
+  private void grow() {
+    final int start = this.heap.length;
+    // This will grow the heap by doubling its size if it's smaller than
+    // DEFAULT_SIZE, and by DEFAULT_SIZE if it's larger.
+    this.heap = IntArrayUtils.ensure_size(this.heap, start + this.initialSize, 2, DEFAULT_SIZE);
+    this.max = this.heap.length;
+  }
+
+  /**
+   * Reset the temporary heap.
+   */
+  public void reset() {
+    this.reset(false);
+  }
+
+  /**
+   * Reset the temporary heap.
+   */
+  void reset(boolean doFullReset) {
+    if (doFullReset) {
+      this.initHeap();
+    } else {
+      Arrays.fill(this.heap, 0, this.pos, 0);
+      this.pos = 1;
+    }
+  }
+
+  /**
+   * Add a structure to the heap.
+   * 
+   * @param fs
+   *                The input structure.
+   * @return The position where the structure was added, i.e., a pointer to the
+   *         first element of the structure.
+   */
+  public int add(int[] fs) {
+    while ((this.pos + fs.length) >= this.max) {
+      grow();
+    }
+    System.arraycopy(fs, 0, this.heap, this.pos, fs.length);
+    final int pos1 = this.pos;
+    this.pos += fs.length;
+    return pos1;
+  }
+
+  /**
+   * Reserve space for <code>len</code> items on the heap and set the first
+   * item to <code>val</code>. The other items are set to <code>0</code>.
+   * 
+   * @param len
+   *                The length of the new structure.
+   * @param val
+   *                The value of the first cell in the new structure.
+   * @return The position where the structure was added, i.e., a pointer to the
+   *         first element of the structure.
+   */
+  public int add(int len, int val) {
+    while ((this.pos + len) >= this.max) {
+      grow();
+    }
+    final int pos1 = this.pos;
+    this.pos += len;
+    this.heap[pos1] = val;
+    return pos1;
+  }
+  
+  public int getNextId() {
+	  return pos;
+  }
+	  
+}

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/Heap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/IntArrayFSImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/IntConstraint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/LLUnambiguousIteratorImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/LinearTypeOrderBuilderImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/ListUtils.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/ListUtils.java?rev=690405&r1=690404&r2=690405&view=diff
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/ListUtils.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/ListUtils.java Fri Aug 29 15:10:52 2008
@@ -1,731 +1,731 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.uima.cas.impl;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.apache.uima.cas.CAS;
-import org.apache.uima.cas.impl.XmiSerializationSharedData.OotsElementData;
-import org.apache.uima.internal.util.IntVector;
-import org.apache.uima.internal.util.XmlAttribute;
-import org.apache.uima.internal.util.rb_trees.IntRedBlackTree;
-import org.apache.uima.util.Level;
-import org.apache.uima.util.Logger;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Utilities for dealing with CAS List types.
- * 
- */
-public class ListUtils {
-  CASImpl cas;
-
-  // list type and feature codes
-  private int intListType;
-
-  private int floatListType;
-
-  private int stringListType;
-
-  private int fsListType;
-
-  private int neIntListType;
-
-  private int neFloatListType;
-
-  private int neStringListType;
-
-  private int neFsListType;
-
-  private int eIntListType;
-
-  private int eFloatListType;
-
-  private int eStringListType;
-
-  private int eFsListType;
-
-  private int intHeadFeat;
-
-  private int intTailFeat;
-
-  private int floatHeadFeat;
-
-  private int floatTailFeat;
-
-  private int stringHeadFeat;
-
-  private int stringTailFeat;
-
-  private int fsHeadFeat;
-
-  private int fsTailFeat;
-
-  private Logger logger;
-
-  private ErrorHandler eh;
-
-  /**
-   * Creates a new ListUtils object.
-   * 
-   * @param aCASImpl
-   *          the CAS that this ListUtils will operate on
-   * @param aLogger
-   *          optional logger, to receive warning messages
-   * @param aErrorHandler
-   *          optional SAX ErrorHandler, to receive warning messages
-   */
-  public ListUtils(CASImpl aCASImpl, Logger aLogger, ErrorHandler aErrorHandler) {
-    this.cas = aCASImpl;
-    this.logger = aLogger;
-    this.eh = aErrorHandler;
-    TypeSystemImpl ts = aCASImpl.getTypeSystemImpl();
-    this.intListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_INTEGER_LIST);
-    this.floatListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_FLOAT_LIST);
-    this.stringListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_STRING_LIST);
-    this.fsListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_FS_LIST);
-    this.neIntListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_NON_EMPTY_INTEGER_LIST);
-    this.neFloatListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_NON_EMPTY_FLOAT_LIST);
-    this.neStringListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_NON_EMPTY_STRING_LIST);
-    this.neFsListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_NON_EMPTY_FS_LIST);
-    this.eIntListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_EMPTY_INTEGER_LIST);
-    this.eFloatListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_EMPTY_FLOAT_LIST);
-    this.eStringListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_EMPTY_STRING_LIST);
-    this.eFsListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_EMPTY_FS_LIST);
-    this.intHeadFeat = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_INTEGER_LIST_HEAD);
-    this.floatHeadFeat = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_FLOAT_LIST_HEAD);
-    this.stringHeadFeat = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_STRING_LIST_HEAD);
-    this.fsHeadFeat = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_FS_LIST_HEAD);
-    this.intTailFeat = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_INTEGER_LIST_TAIL);
-    this.floatTailFeat = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_FLOAT_LIST_TAIL);
-    this.stringTailFeat = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_STRING_LIST_TAIL);
-    this.fsTailFeat = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_FS_LIST_TAIL);
-  }
-
-  public boolean isIntListType(int type) {
-    return (type == this.intListType || type == this.neIntListType || type == this.eIntListType);
-  }
-
-  public boolean isFloatListType(int type) {
-    return (type == this.floatListType || type == this.neFloatListType || type == this.eFloatListType);
-  }
-
-  public boolean isStringListType(int type) {
-    return (type == this.stringListType || type == this.neStringListType || type == this.eStringListType);
-  }
-
-  public boolean isFsListType(int type) {
-    return (type == this.fsListType || type == this.neFsListType || type == this.eFsListType);
-  }
-
-  public boolean isListType(int type) {
-    return isIntListType(type) || isFloatListType(type) || isStringListType(type)
-            || isFsListType(type);
-  }
-
-  public int getLength(int type, int addr) {
-	int neListType = -1;
-	int tailFeat = -1;
-	if (isIntListType(type)) {
-	  neListType = neIntListType;
-	  tailFeat = intTailFeat;
-	} else if ( isFloatListType(type)) {
-	  neListType = neFloatListType;
-	  tailFeat = floatTailFeat;
-	} else if (isStringListType(type)) {
-      neListType = neStringListType;
-	  tailFeat = stringTailFeat;
-	} else if (isFsListType(type)) {
-	  neListType = neFsListType;
-	  tailFeat = fsTailFeat;
-	}
-	IntRedBlackTree visited = new IntRedBlackTree();
-	boolean foundCycle = false;
-	// first count length of list so we can allocate array
-	int length = 0;
-	int curNode = addr;
-	while (cas.getHeapValue(curNode) == neListType) {
-	  if (!visited.put(curNode, curNode)) {
-	    foundCycle = true;
-	    break;
-	  }
-	  length++;
-	  curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(tailFeat));
-	}
-	return length;
-  }
-  
-  public String[] intListToStringArray(int addr) throws SAXException {
-    IntRedBlackTree visited = new IntRedBlackTree();
-    boolean foundCycle = false;
-    // first count length of list so we can allocate array
-    int length = 0;
-    int curNode = addr;
-    while (cas.getHeapValue(curNode) == neIntListType) {
-      if (!visited.put(curNode, curNode)) {
-        foundCycle = true;
-        break;
-      }
-      length++;
-      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(intTailFeat));
-    }
-
-    String[] array = new String[length];
-
-    // now populate list
-    curNode = addr;
-    for (int i = 0; i < length; i++) {
-      array[i] = Integer.toString(cas.getHeapValue(curNode + cas.getFeatureOffset(intHeadFeat)));
-      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(intTailFeat));
-    }
-    if (foundCycle) {
-      reportWarning("Found a cycle in an IntegerList.  List truncated to "
-              + Arrays.asList(array).toString());
-    }
-    return array;
-  }
-
-  public String[] floatListToStringArray(int addr) throws SAXException {
-    boolean foundCycle = false;
-    IntRedBlackTree visited = new IntRedBlackTree();
-    // first count length of list so we can allocate array
-    int length = 0;
-    int curNode = addr;
-    while (cas.getHeapValue(curNode) == neFloatListType) {
-      if (!visited.put(curNode, curNode)) {
-        foundCycle = true;
-        break;
-      }
-      length++;
-      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(floatTailFeat));
-    }
-
-    String[] array = new String[length];
-
-    // now populate list
-    curNode = addr;
-    for (int i = 0; i < length; i++) {
-      array[i] = Float.toString(CASImpl.int2float(cas.getHeapValue(curNode
-              + cas.getFeatureOffset(floatHeadFeat))));
-      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(floatTailFeat));
-    }
-    if (foundCycle) {
-      reportWarning("Found a cycle in a FloatList.  List truncated to "
-              + Arrays.asList(array).toString() + ".");
-    }
-    return array;
-  }
-
-  public String[] stringListToStringArray(int addr) throws SAXException {
-    boolean foundCycle = false;
-    IntRedBlackTree visited = new IntRedBlackTree();
-    // first count length of list so we can allocate array
-    int length = 0;
-    int curNode = addr;
-    while (cas.getHeapValue(curNode) == neStringListType) {
-      if (!visited.put(curNode, curNode)) {
-        foundCycle = true;
-        break;
-      }
-      length++;
-      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(stringTailFeat));
-    }
-
-    String[] array = new String[length];
-
-    // now populate list
-    curNode = addr;
-    for (int i = 0; i < length; i++) {
-      array[i] = cas.getStringForCode(cas.getHeapValue(curNode
-              + cas.getFeatureOffset(stringHeadFeat)));
-      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(stringTailFeat));
-    }
-    if (foundCycle) {
-      reportWarning("Found a cycle in a StringList.  List truncated to "
-              + Arrays.asList(array).toString() + ".");
-    }
-    return array;
-  }
-
-  public String[] fsListToXmiIdStringArray(int addr, XmiSerializationSharedData sharedData)
-          throws SAXException {
-    boolean foundCycle = false;
-    IntRedBlackTree visited = new IntRedBlackTree();
-    // first count length of list so we can allocate array
-    int length = 0;
-    int curNode = addr;
-    while (cas.getHeapValue(curNode) == neFsListType) {
-      if (!visited.put(curNode, curNode)) {
-        foundCycle = true;
-        break;
-      }
-      length++;
-      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(fsTailFeat));
-    }
-
-    String[] strArray = new String[length];
-
-    // now populate list
-    curNode = addr;
-    for (int i = 0; i < length; i++) {
-      int heapVal = cas.getHeapValue(curNode + cas.getFeatureOffset(fsHeadFeat));
-      if (heapVal == 0) {
-        //null value in list.  Represent with "0".
-        strArray[i] = "0";
-        // However, this may be null because the element was originally a reference to an 
-        // out-of-typesystem FS, so chck the XmiSerializationSharedData
-        if (sharedData != null) {
-          OotsElementData oed = sharedData.getOutOfTypeSystemFeatures(curNode);
-          if (oed != null) {
-            assert oed.attributes.size() == 1; //only the head feature can possibly be here
-            XmlAttribute attr = (XmlAttribute)oed.attributes.get(0);
-            assert CAS.FEATURE_BASE_NAME_HEAD.equals(attr.name);
-            strArray[i] = attr.value;
-          }
-        }        
-      }
-      else {
-        if (sharedData != null) {
-          strArray[i] = heapVal == 0 ? null : sharedData.getXmiId(heapVal);
-        } else {
-          strArray[i] = Integer.toString(heapVal);
-        }
-      }
-      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(fsTailFeat));
-    }
-    if (foundCycle) {
-      reportWarning("Found a cycle in an FSList.  List truncated to "
-              + Arrays.asList(strArray).toString() + ".");
-    }
-    return strArray;
-  }
-
-  public int[] fsListToAddressArray(int addr) throws SAXException {
-    boolean foundCycle = false;
-    IntRedBlackTree visited = new IntRedBlackTree();
-    // first count length of list so we can allocate array
-    int length = 0;
-    int curNode = addr;
-    while (cas.getHeapValue(curNode) == neFsListType) {
-      if (!visited.put(curNode, curNode)) {
-        foundCycle = true;
-        break;
-      }
-      length++;
-      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(fsTailFeat));
-    }
-
-    int[] array = new int[length];
-
-    // now populate list
-    curNode = addr;
-    for (int i = 0; i < length; i++) {
-      array[i] = cas.getHeapValue(curNode + cas.getFeatureOffset(fsHeadFeat));
-      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(fsTailFeat));
-    }
-    if (foundCycle) {
-      reportWarning("Found a cycle in an FSList.  List truncated where cycle occurs.");
-    }
-    return array;
-  }
-
-  public int createIntList(List stringValues) {
-    int first = cas.ll_createFS(eIntListType);
-    ListIterator iter = stringValues.listIterator(stringValues.size());
-    while (iter.hasPrevious()) {
-      int value = Integer.parseInt((String) iter.previous());
-      int node = cas.ll_createFS(neIntListType);
-      cas.setFeatureValue(node, intHeadFeat, value);
-      cas.setFeatureValue(node, intTailFeat, first);
-      first = node;
-    }
-    return first;
-  }
-  
-  public int createFloatList(List stringValues) {
-    int first = cas.ll_createFS(eFloatListType);
-    ListIterator iter = stringValues.listIterator(stringValues.size());
-    while (iter.hasPrevious()) {
-      float value = Float.parseFloat((String) iter.previous());
-      int node = cas.ll_createFS(neFloatListType);
-      cas.setFeatureValue(node, floatHeadFeat, CASImpl.float2int(value));
-      cas.setFeatureValue(node, floatTailFeat, first);
-      first = node;
-    }
-    return first;
-  }
-
-  public int createStringList(List stringValues) {
-    int first = cas.ll_createFS(eStringListType);
-    ListIterator iter = stringValues.listIterator(stringValues.size());
-    while (iter.hasPrevious()) {
-      String value = (String) iter.previous();
-      int node = cas.ll_createFS(neStringListType);
-      cas.setFeatureValue(node, stringHeadFeat, cas.addString(value));
-      cas.setFeatureValue(node, stringTailFeat, first);
-      first = node;
-    }
-    return first;
-  }
-
-  public int createFsList(List stringValues, IntVector fsAddresses) {
-    int first = cas.ll_createFS(eFsListType);
-    ListIterator iter = stringValues.listIterator(stringValues.size());
-    while (iter.hasPrevious()) {
-      int value = Integer.parseInt((String) iter.previous());
-      int node = cas.ll_createFS(neFsListType);
-      fsAddresses.add(node);
-      cas.setFeatureValue(node, fsHeadFeat, value);
-      cas.setFeatureValue(node, fsTailFeat, first);
-      first = node;
-    }
-    return first;
-  }
-
-  public int updateIntList(int addr, List stringValues) throws SAXException  {
-    int first = addr;
-    int currLength = this.getLength(this.neIntListType, addr);
-    int curNode = addr;
-    int prevNode = 0;
-    IntRedBlackTree visited = new IntRedBlackTree();
-    boolean foundCycle = false;
-    int i =0;
-    
-    //if (currLength != stringValues.size() ) {  
-	//   first = createIntList(stringValues);
-	   
-    if (currLength < stringValues.size()) {
-  	  while (cas.getHeapValue(curNode) == neIntListType) {
-  	  	if (!visited.put(curNode, curNode)) {
-  	  	           foundCycle = true;
-  	  	           break;
-  	  	}
-  	  	int value = Integer.parseInt((String) stringValues.get(i++));
-  	    cas.setFeatureValue(curNode,floatHeadFeat, value);
-  	    prevNode = curNode;
-  	  	curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(intTailFeat));
-  	  }
-  	  //add nodes for remaining values
-  	  if (i < stringValues.size()) {
-  	  	int emptyListFs = curNode; 
-  	  	//check that first is eintlisttype
-  	  	while (i < stringValues.size()) {
-  	  	  int newNode = cas.ll_createFS(neIntListType);
-  	  	  int value = Integer.parseInt((String) stringValues.get(i++));
-  	      cas.setFeatureValue(newNode,intHeadFeat, value);
-  	      cas.setFeatureValue(newNode, intTailFeat, emptyListFs);
-  	      cas.setFeatureValue(prevNode, intTailFeat, newNode);
-  	  	  prevNode = newNode;
-  	    }
-  	  }
-  	} else if (currLength > stringValues.size()) {
-  		while (cas.getHeapValue(curNode) == neIntListType && i < stringValues.size()) {
-  		  if (!visited.put(curNode, curNode)) {
-  		  	           foundCycle = true;
-  		  	           break;
-  		  }
-  		  float value = Integer.parseInt((String) stringValues.get(i++));
-  		  cas.setFeatureValue(curNode,intHeadFeat, value);
-  		  curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(intTailFeat));
-  		}	
-  		int finalNode = curNode;
-        //loop till we get a FS that is of type eStringListType
-        while (cas.getHeapValue(curNode) == neIntListType) {
-    	  if (!visited.put(curNode, curNode)) {
-    	    foundCycle = true;
-    	    break;
-    	    //TODO throw exc
-    	  }
-    	  curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(intTailFeat));
-        }
-        //set the tail feature to eStringListType fs
-        cas.setFeatureValue(finalNode, intTailFeat, curNode);   
-    } else {
-      while (cas.getHeapValue(curNode) == neIntListType) {
-        if (!visited.put(curNode, curNode)) {
-           foundCycle = true;
-           break;
-        }
-        int value = Integer.parseInt((String) stringValues.get(i++));
-        cas.setFeatureValue(curNode,intHeadFeat, value );
-        curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(intTailFeat));
-      }
-    }
-    if (foundCycle) {
-        reportWarning("Found a cycle in an IntegerList.  List truncated to "
-                + i);
-    }
-    return first;
-  }
-	  
-  public int updateFloatList(int addr, List stringValues) throws SAXException  {
-    int first = addr;
-    int currLength = this.getLength(this.neFloatListType, addr);
-    int curNode = addr;
-    int prevNode = 0;
-    IntRedBlackTree visited = new IntRedBlackTree();
-    boolean foundCycle = false;
-    int i =0;
-    
-    //if (currLength != stringValues.size() ) {  
-	//   first = createFloatList(stringValues);
-	if (currLength < stringValues.size()) {
-	  while (cas.getHeapValue(curNode) == neFloatListType) {
-	  	if (!visited.put(curNode, curNode)) {
-	  	           foundCycle = true;
-	  	           break;
-	  	}
-	  	float value = Float.parseFloat((String) stringValues.get(i++));
-	    cas.setFeatureValue(curNode,floatHeadFeat, value);
-	    prevNode = curNode;
-	  	curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(floatTailFeat));
-	  }
-	  //add nodes for remaining values
-	  if (i < stringValues.size()) {
-	  	int emptyListFs = curNode; 
-	  	//check that first is efloatlisttype
-	  	while (i < stringValues.size()) {
-	  	  int newNode = cas.ll_createFS(neFloatListType);
-	  	  float value = Float.parseFloat((String) stringValues.get(i++));
-	      cas.setFeatureValue(newNode,floatHeadFeat, value);
-	      cas.setFeatureValue(newNode, floatTailFeat, emptyListFs);
-	      cas.setFeatureValue(prevNode, floatTailFeat, newNode);
-	  	  prevNode = newNode;
-	    }
-	  }
-	} else if (currLength > stringValues.size()) {
-		while (cas.getHeapValue(curNode) == neFloatListType && i < stringValues.size()) {
-		  if (!visited.put(curNode, curNode)) {
-		  	           foundCycle = true;
-		  	           break;
-		  }
-		  float value = Float.parseFloat((String) stringValues.get(i++));
-		  cas.setFeatureValue(curNode,floatHeadFeat, value);
-		  curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(floatTailFeat));
-		}	
-		int finalNode = curNode;
-        //loop till we get a FS that is of type eStringListType
-        while (cas.getHeapValue(curNode) == neFloatListType) {
-  	      if (!visited.put(curNode, curNode)) {
-  	        foundCycle = true;
-  	        break;
-  	      //TODO throw exc
-  	      }
-  	      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(floatTailFeat));
-        }
-        //set the tail feature to eStringListType fs
-      	cas.setFeatureValue(finalNode, floatTailFeat, curNode);
-    } else {
-      while (cas.getHeapValue(curNode) == neFloatListType) {
-        if (!visited.put(curNode, curNode)) {
-           foundCycle = true;
-           break;
-        }
-        float value = Float.parseFloat((String) stringValues.get(i++));
-        cas.setFeatureValue(curNode,floatHeadFeat,  CASImpl.float2int(value));
-        curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(floatTailFeat));
-      }
-    }
-	
-    if (foundCycle) {
-        reportWarning("Found a cycle in an IntegerList.  List truncated to "
-                  + i);
-    }
-    return first;
-  }  
-  
-  public int updateFsList(int addr, List stringValues, IntVector fsAddresses) throws SAXException  {
-    int first = addr;
-    int currLength = this.getLength(this.neFsListType, addr);
-    boolean foundCycle = false;
-    IntRedBlackTree visited = new IntRedBlackTree();
-    int curNode = addr;
-    int prevNode = 0;
-    
-    //if (currLength != stringValues.size() ) {  
-	//   first = createFsList(stringValues, fsAddresses);
-    int i=0;
-    if (currLength < stringValues.size() ) {    
-  	  while (cas.getHeapValue(curNode) == neFsListType) {
-  	    if (!visited.put(curNode, curNode)) {
-  	           foundCycle = true;
-  	           break;
-  	    }
-  	    int value = Integer.parseInt((String) stringValues.get(i++));
-        cas.setFeatureValue(curNode,fsHeadFeat, value);
-        fsAddresses.add(curNode);
-        prevNode = curNode;
-  	    curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(fsTailFeat));
-  	  }
-  	  //add nodes for remaining values
-  	  if (i < stringValues.size()) {
-  	    int emptyListFs = curNode; 
-  	    //check that first is estringlisttype
-  	    while (i < stringValues.size()) {
-  	      int newNode = cas.ll_createFS(neFsListType);
-  	      int value = Integer.parseInt((String) stringValues.get(i++));
-          cas.setFeatureValue(newNode,fsHeadFeat, value);
-          fsAddresses.add(newNode);
-          cas.setFeatureValue(newNode, fsTailFeat, emptyListFs);
-          cas.setFeatureValue(prevNode, fsTailFeat, newNode);
-  	      prevNode = newNode;
-  	    }
-  	  }
-    } else if (currLength > stringValues.size()) {	
-        while (cas.getHeapValue(curNode) == neFsListType && i < stringValues.size()) {
-   	      if (!visited.put(curNode, curNode)) {
-   		    foundCycle = true;
-   		    break;
-   		  }
-   	      int value = Integer.parseInt((String) stringValues.get(i++));
-	      fsAddresses.add(curNode);
-          cas.setFeatureValue(curNode,fsHeadFeat, value);
-   		  curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(fsTailFeat));
-        } 
-        int finalNode = curNode;
-        //loop till we get a FS that is of type eStringListType
-        while (cas.getHeapValue(curNode) == neFsListType) {
-  	      if (!visited.put(curNode, curNode)) {
-  	        foundCycle = true;
-  	        break;
-  	      //TODO throw exc
-  	      }
-  	      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(fsTailFeat));
-        }
-        //set the tail feature to eStringListType fs
-      	cas.setFeatureValue(finalNode, fsTailFeat, curNode);
-    } else {
-      while (cas.getHeapValue(curNode) == neFsListType) {
-        if (!visited.put(curNode, curNode)) {
-           foundCycle = true;
-           break;
-        }
-        int value = Integer.parseInt((String) stringValues.get(i++));
-        cas.setFeatureValue(curNode,fsHeadFeat, value);
-        fsAddresses.add(curNode);
-        curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(fsTailFeat));
-      }
-    }
-    if (foundCycle) {
-      reportWarning("Found a cycle in an IntegerList.  List truncated to "
-                  + i);
-    }
-    return first;
-  }  
-  
-  public int updateStringList(int addr, List stringValues) throws SAXException   {
-    int first = addr;
-    boolean foundCycle = false;
-    IntRedBlackTree visited = new IntRedBlackTree();
-    int curNode = addr;
-    int prevNode = 0;
-    int currLength = this.getLength(this.neStringListType, addr);
-    
-    if (currLength < stringValues.size() ) {    
-      int i =0;
-	  while (cas.getHeapValue(curNode) == neStringListType) {
-	    if (!visited.put(curNode, curNode)) {
-	           foundCycle = true;
-	           break;
-	    }
-	    String curValue = cas.getStringForCode(cas.getHeapValue(curNode
-	              + cas.getFeatureOffset(stringHeadFeat)));
-	    String newValue = (String)stringValues.get(i++);
-        if (!curValue.equals(newValue)) {		  
-          cas.setFeatureValue(curNode, stringHeadFeat, cas.addString(newValue));
-        }
-        prevNode = curNode;
-	    curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(stringTailFeat));
-	 }
-	 //extend the list
-	 if (i < stringValues.size()) {
-	   int emptyListFs = curNode; 
-	   while (i < stringValues.size()) {
-	     int newNode = cas.ll_createFS(neStringListType);
-	     String value = (String) stringValues.get(i++);
-	     cas.setFeatureValue(newNode, stringHeadFeat, cas.addString(value));
-	     cas.setFeatureValue(newNode, stringTailFeat, emptyListFs);
-	     cas.setFeatureValue(prevNode,stringTailFeat, newNode);
-	     prevNode = newNode;
-	   }
-	 }
-    } else if (currLength > stringValues.size()) {
-      int i=0;	
-      while (cas.getHeapValue(curNode) == neStringListType && i < stringValues.size()) {
- 	    if (!visited.put(curNode, curNode)) {
- 		           foundCycle = true;
- 		           break;
- 		}
- 		String curValue = cas.getStringForCode(cas.getHeapValue(curNode
- 		              + cas.getFeatureOffset(stringHeadFeat)));
- 		String newValue = (String)stringValues.get(i++);
-        if (!curValue.equals(newValue)) {		  
-           cas.setFeatureValue(curNode, stringHeadFeat, cas.addString(newValue));
-        }
- 		curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(stringTailFeat));
-      } 
-      int finalNode = curNode;
-      while (cas.getHeapValue(curNode) == neStringListType) {
-	    if (!visited.put(curNode, curNode)) {
-	      foundCycle = true;
-	      break;
-	      //TODO throw exc
-	    }
-	    curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(stringTailFeat));
-      }
-      cas.setFeatureValue(finalNode, stringTailFeat, curNode);
-    } else {
-      int i =0;
-      while (cas.getHeapValue(curNode) == neStringListType) {
-        if (!visited.put(curNode, curNode)) {
-           foundCycle = true;
-           break;
-        }
-        String curValue = cas.getStringForCode(cas.getHeapValue(curNode
-	              + cas.getFeatureOffset(stringHeadFeat)));
-        String newValue = (String)stringValues.get(i++);
-        if (!curValue.equals(newValue)) {		  
-          cas.setFeatureValue(curNode, stringHeadFeat, cas.addString(newValue));
-        }
-        curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(stringTailFeat));
-      }
-    }
-    
-    if (foundCycle) {
-        reportWarning("Found a cycle in an IntegerList.  List truncated. ");
-    }
-    return first;
-  }  
-		  
-	  
-  
-  private void reportWarning(String message) throws SAXException {
-    if (this.logger != null) {
-      logger.log(Level.WARNING, message);
-    }
-    if (this.eh != null) {
-      this.eh.warning(new SAXParseException(message, null));
-    }
-  }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.cas.impl;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.impl.XmiSerializationSharedData.OotsElementData;
+import org.apache.uima.internal.util.IntVector;
+import org.apache.uima.internal.util.XmlAttribute;
+import org.apache.uima.internal.util.rb_trees.IntRedBlackTree;
+import org.apache.uima.util.Level;
+import org.apache.uima.util.Logger;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * Utilities for dealing with CAS List types.
+ * 
+ */
+public class ListUtils {
+  CASImpl cas;
+
+  // list type and feature codes
+  private int intListType;
+
+  private int floatListType;
+
+  private int stringListType;
+
+  private int fsListType;
+
+  private int neIntListType;
+
+  private int neFloatListType;
+
+  private int neStringListType;
+
+  private int neFsListType;
+
+  private int eIntListType;
+
+  private int eFloatListType;
+
+  private int eStringListType;
+
+  private int eFsListType;
+
+  private int intHeadFeat;
+
+  private int intTailFeat;
+
+  private int floatHeadFeat;
+
+  private int floatTailFeat;
+
+  private int stringHeadFeat;
+
+  private int stringTailFeat;
+
+  private int fsHeadFeat;
+
+  private int fsTailFeat;
+
+  private Logger logger;
+
+  private ErrorHandler eh;
+
+  /**
+   * Creates a new ListUtils object.
+   * 
+   * @param aCASImpl
+   *          the CAS that this ListUtils will operate on
+   * @param aLogger
+   *          optional logger, to receive warning messages
+   * @param aErrorHandler
+   *          optional SAX ErrorHandler, to receive warning messages
+   */
+  public ListUtils(CASImpl aCASImpl, Logger aLogger, ErrorHandler aErrorHandler) {
+    this.cas = aCASImpl;
+    this.logger = aLogger;
+    this.eh = aErrorHandler;
+    TypeSystemImpl ts = aCASImpl.getTypeSystemImpl();
+    this.intListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_INTEGER_LIST);
+    this.floatListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_FLOAT_LIST);
+    this.stringListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_STRING_LIST);
+    this.fsListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_FS_LIST);
+    this.neIntListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_NON_EMPTY_INTEGER_LIST);
+    this.neFloatListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_NON_EMPTY_FLOAT_LIST);
+    this.neStringListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_NON_EMPTY_STRING_LIST);
+    this.neFsListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_NON_EMPTY_FS_LIST);
+    this.eIntListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_EMPTY_INTEGER_LIST);
+    this.eFloatListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_EMPTY_FLOAT_LIST);
+    this.eStringListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_EMPTY_STRING_LIST);
+    this.eFsListType = ts.ll_getCodeForTypeName(CAS.TYPE_NAME_EMPTY_FS_LIST);
+    this.intHeadFeat = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_INTEGER_LIST_HEAD);
+    this.floatHeadFeat = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_FLOAT_LIST_HEAD);
+    this.stringHeadFeat = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_STRING_LIST_HEAD);
+    this.fsHeadFeat = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_FS_LIST_HEAD);
+    this.intTailFeat = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_INTEGER_LIST_TAIL);
+    this.floatTailFeat = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_FLOAT_LIST_TAIL);
+    this.stringTailFeat = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_STRING_LIST_TAIL);
+    this.fsTailFeat = ts.ll_getCodeForFeatureName(CAS.FEATURE_FULL_NAME_FS_LIST_TAIL);
+  }
+
+  public boolean isIntListType(int type) {
+    return (type == this.intListType || type == this.neIntListType || type == this.eIntListType);
+  }
+
+  public boolean isFloatListType(int type) {
+    return (type == this.floatListType || type == this.neFloatListType || type == this.eFloatListType);
+  }
+
+  public boolean isStringListType(int type) {
+    return (type == this.stringListType || type == this.neStringListType || type == this.eStringListType);
+  }
+
+  public boolean isFsListType(int type) {
+    return (type == this.fsListType || type == this.neFsListType || type == this.eFsListType);
+  }
+
+  public boolean isListType(int type) {
+    return isIntListType(type) || isFloatListType(type) || isStringListType(type)
+            || isFsListType(type);
+  }
+
+  public int getLength(int type, int addr) {
+	int neListType = -1;
+	int tailFeat = -1;
+	if (isIntListType(type)) {
+	  neListType = neIntListType;
+	  tailFeat = intTailFeat;
+	} else if ( isFloatListType(type)) {
+	  neListType = neFloatListType;
+	  tailFeat = floatTailFeat;
+	} else if (isStringListType(type)) {
+      neListType = neStringListType;
+	  tailFeat = stringTailFeat;
+	} else if (isFsListType(type)) {
+	  neListType = neFsListType;
+	  tailFeat = fsTailFeat;
+	}
+	IntRedBlackTree visited = new IntRedBlackTree();
+	boolean foundCycle = false;
+	// first count length of list so we can allocate array
+	int length = 0;
+	int curNode = addr;
+	while (cas.getHeapValue(curNode) == neListType) {
+	  if (!visited.put(curNode, curNode)) {
+	    foundCycle = true;
+	    break;
+	  }
+	  length++;
+	  curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(tailFeat));
+	}
+	return length;
+  }
+  
+  public String[] intListToStringArray(int addr) throws SAXException {
+    IntRedBlackTree visited = new IntRedBlackTree();
+    boolean foundCycle = false;
+    // first count length of list so we can allocate array
+    int length = 0;
+    int curNode = addr;
+    while (cas.getHeapValue(curNode) == neIntListType) {
+      if (!visited.put(curNode, curNode)) {
+        foundCycle = true;
+        break;
+      }
+      length++;
+      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(intTailFeat));
+    }
+
+    String[] array = new String[length];
+
+    // now populate list
+    curNode = addr;
+    for (int i = 0; i < length; i++) {
+      array[i] = Integer.toString(cas.getHeapValue(curNode + cas.getFeatureOffset(intHeadFeat)));
+      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(intTailFeat));
+    }
+    if (foundCycle) {
+      reportWarning("Found a cycle in an IntegerList.  List truncated to "
+              + Arrays.asList(array).toString());
+    }
+    return array;
+  }
+
+  public String[] floatListToStringArray(int addr) throws SAXException {
+    boolean foundCycle = false;
+    IntRedBlackTree visited = new IntRedBlackTree();
+    // first count length of list so we can allocate array
+    int length = 0;
+    int curNode = addr;
+    while (cas.getHeapValue(curNode) == neFloatListType) {
+      if (!visited.put(curNode, curNode)) {
+        foundCycle = true;
+        break;
+      }
+      length++;
+      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(floatTailFeat));
+    }
+
+    String[] array = new String[length];
+
+    // now populate list
+    curNode = addr;
+    for (int i = 0; i < length; i++) {
+      array[i] = Float.toString(CASImpl.int2float(cas.getHeapValue(curNode
+              + cas.getFeatureOffset(floatHeadFeat))));
+      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(floatTailFeat));
+    }
+    if (foundCycle) {
+      reportWarning("Found a cycle in a FloatList.  List truncated to "
+              + Arrays.asList(array).toString() + ".");
+    }
+    return array;
+  }
+
+  public String[] stringListToStringArray(int addr) throws SAXException {
+    boolean foundCycle = false;
+    IntRedBlackTree visited = new IntRedBlackTree();
+    // first count length of list so we can allocate array
+    int length = 0;
+    int curNode = addr;
+    while (cas.getHeapValue(curNode) == neStringListType) {
+      if (!visited.put(curNode, curNode)) {
+        foundCycle = true;
+        break;
+      }
+      length++;
+      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(stringTailFeat));
+    }
+
+    String[] array = new String[length];
+
+    // now populate list
+    curNode = addr;
+    for (int i = 0; i < length; i++) {
+      array[i] = cas.getStringForCode(cas.getHeapValue(curNode
+              + cas.getFeatureOffset(stringHeadFeat)));
+      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(stringTailFeat));
+    }
+    if (foundCycle) {
+      reportWarning("Found a cycle in a StringList.  List truncated to "
+              + Arrays.asList(array).toString() + ".");
+    }
+    return array;
+  }
+
+  public String[] fsListToXmiIdStringArray(int addr, XmiSerializationSharedData sharedData)
+          throws SAXException {
+    boolean foundCycle = false;
+    IntRedBlackTree visited = new IntRedBlackTree();
+    // first count length of list so we can allocate array
+    int length = 0;
+    int curNode = addr;
+    while (cas.getHeapValue(curNode) == neFsListType) {
+      if (!visited.put(curNode, curNode)) {
+        foundCycle = true;
+        break;
+      }
+      length++;
+      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(fsTailFeat));
+    }
+
+    String[] strArray = new String[length];
+
+    // now populate list
+    curNode = addr;
+    for (int i = 0; i < length; i++) {
+      int heapVal = cas.getHeapValue(curNode + cas.getFeatureOffset(fsHeadFeat));
+      if (heapVal == 0) {
+        //null value in list.  Represent with "0".
+        strArray[i] = "0";
+        // However, this may be null because the element was originally a reference to an 
+        // out-of-typesystem FS, so chck the XmiSerializationSharedData
+        if (sharedData != null) {
+          OotsElementData oed = sharedData.getOutOfTypeSystemFeatures(curNode);
+          if (oed != null) {
+            assert oed.attributes.size() == 1; //only the head feature can possibly be here
+            XmlAttribute attr = (XmlAttribute)oed.attributes.get(0);
+            assert CAS.FEATURE_BASE_NAME_HEAD.equals(attr.name);
+            strArray[i] = attr.value;
+          }
+        }        
+      }
+      else {
+        if (sharedData != null) {
+          strArray[i] = heapVal == 0 ? null : sharedData.getXmiId(heapVal);
+        } else {
+          strArray[i] = Integer.toString(heapVal);
+        }
+      }
+      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(fsTailFeat));
+    }
+    if (foundCycle) {
+      reportWarning("Found a cycle in an FSList.  List truncated to "
+              + Arrays.asList(strArray).toString() + ".");
+    }
+    return strArray;
+  }
+
+  public int[] fsListToAddressArray(int addr) throws SAXException {
+    boolean foundCycle = false;
+    IntRedBlackTree visited = new IntRedBlackTree();
+    // first count length of list so we can allocate array
+    int length = 0;
+    int curNode = addr;
+    while (cas.getHeapValue(curNode) == neFsListType) {
+      if (!visited.put(curNode, curNode)) {
+        foundCycle = true;
+        break;
+      }
+      length++;
+      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(fsTailFeat));
+    }
+
+    int[] array = new int[length];
+
+    // now populate list
+    curNode = addr;
+    for (int i = 0; i < length; i++) {
+      array[i] = cas.getHeapValue(curNode + cas.getFeatureOffset(fsHeadFeat));
+      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(fsTailFeat));
+    }
+    if (foundCycle) {
+      reportWarning("Found a cycle in an FSList.  List truncated where cycle occurs.");
+    }
+    return array;
+  }
+
+  public int createIntList(List stringValues) {
+    int first = cas.ll_createFS(eIntListType);
+    ListIterator iter = stringValues.listIterator(stringValues.size());
+    while (iter.hasPrevious()) {
+      int value = Integer.parseInt((String) iter.previous());
+      int node = cas.ll_createFS(neIntListType);
+      cas.setFeatureValue(node, intHeadFeat, value);
+      cas.setFeatureValue(node, intTailFeat, first);
+      first = node;
+    }
+    return first;
+  }
+  
+  public int createFloatList(List stringValues) {
+    int first = cas.ll_createFS(eFloatListType);
+    ListIterator iter = stringValues.listIterator(stringValues.size());
+    while (iter.hasPrevious()) {
+      float value = Float.parseFloat((String) iter.previous());
+      int node = cas.ll_createFS(neFloatListType);
+      cas.setFeatureValue(node, floatHeadFeat, CASImpl.float2int(value));
+      cas.setFeatureValue(node, floatTailFeat, first);
+      first = node;
+    }
+    return first;
+  }
+
+  public int createStringList(List stringValues) {
+    int first = cas.ll_createFS(eStringListType);
+    ListIterator iter = stringValues.listIterator(stringValues.size());
+    while (iter.hasPrevious()) {
+      String value = (String) iter.previous();
+      int node = cas.ll_createFS(neStringListType);
+      cas.setFeatureValue(node, stringHeadFeat, cas.addString(value));
+      cas.setFeatureValue(node, stringTailFeat, first);
+      first = node;
+    }
+    return first;
+  }
+
+  public int createFsList(List stringValues, IntVector fsAddresses) {
+    int first = cas.ll_createFS(eFsListType);
+    ListIterator iter = stringValues.listIterator(stringValues.size());
+    while (iter.hasPrevious()) {
+      int value = Integer.parseInt((String) iter.previous());
+      int node = cas.ll_createFS(neFsListType);
+      fsAddresses.add(node);
+      cas.setFeatureValue(node, fsHeadFeat, value);
+      cas.setFeatureValue(node, fsTailFeat, first);
+      first = node;
+    }
+    return first;
+  }
+
+  public int updateIntList(int addr, List stringValues) throws SAXException  {
+    int first = addr;
+    int currLength = this.getLength(this.neIntListType, addr);
+    int curNode = addr;
+    int prevNode = 0;
+    IntRedBlackTree visited = new IntRedBlackTree();
+    boolean foundCycle = false;
+    int i =0;
+    
+    //if (currLength != stringValues.size() ) {  
+	//   first = createIntList(stringValues);
+	   
+    if (currLength < stringValues.size()) {
+  	  while (cas.getHeapValue(curNode) == neIntListType) {
+  	  	if (!visited.put(curNode, curNode)) {
+  	  	           foundCycle = true;
+  	  	           break;
+  	  	}
+  	  	int value = Integer.parseInt((String) stringValues.get(i++));
+  	    cas.setFeatureValue(curNode,floatHeadFeat, value);
+  	    prevNode = curNode;
+  	  	curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(intTailFeat));
+  	  }
+  	  //add nodes for remaining values
+  	  if (i < stringValues.size()) {
+  	  	int emptyListFs = curNode; 
+  	  	//check that first is eintlisttype
+  	  	while (i < stringValues.size()) {
+  	  	  int newNode = cas.ll_createFS(neIntListType);
+  	  	  int value = Integer.parseInt((String) stringValues.get(i++));
+  	      cas.setFeatureValue(newNode,intHeadFeat, value);
+  	      cas.setFeatureValue(newNode, intTailFeat, emptyListFs);
+  	      cas.setFeatureValue(prevNode, intTailFeat, newNode);
+  	  	  prevNode = newNode;
+  	    }
+  	  }
+  	} else if (currLength > stringValues.size()) {
+  		while (cas.getHeapValue(curNode) == neIntListType && i < stringValues.size()) {
+  		  if (!visited.put(curNode, curNode)) {
+  		  	           foundCycle = true;
+  		  	           break;
+  		  }
+  		  float value = Integer.parseInt((String) stringValues.get(i++));
+  		  cas.setFeatureValue(curNode,intHeadFeat, value);
+  		  curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(intTailFeat));
+  		}	
+  		int finalNode = curNode;
+        //loop till we get a FS that is of type eStringListType
+        while (cas.getHeapValue(curNode) == neIntListType) {
+    	  if (!visited.put(curNode, curNode)) {
+    	    foundCycle = true;
+    	    break;
+    	    //TODO throw exc
+    	  }
+    	  curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(intTailFeat));
+        }
+        //set the tail feature to eStringListType fs
+        cas.setFeatureValue(finalNode, intTailFeat, curNode);   
+    } else {
+      while (cas.getHeapValue(curNode) == neIntListType) {
+        if (!visited.put(curNode, curNode)) {
+           foundCycle = true;
+           break;
+        }
+        int value = Integer.parseInt((String) stringValues.get(i++));
+        cas.setFeatureValue(curNode,intHeadFeat, value );
+        curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(intTailFeat));
+      }
+    }
+    if (foundCycle) {
+        reportWarning("Found a cycle in an IntegerList.  List truncated to "
+                + i);
+    }
+    return first;
+  }
+	  
+  public int updateFloatList(int addr, List stringValues) throws SAXException  {
+    int first = addr;
+    int currLength = this.getLength(this.neFloatListType, addr);
+    int curNode = addr;
+    int prevNode = 0;
+    IntRedBlackTree visited = new IntRedBlackTree();
+    boolean foundCycle = false;
+    int i =0;
+    
+    //if (currLength != stringValues.size() ) {  
+	//   first = createFloatList(stringValues);
+	if (currLength < stringValues.size()) {
+	  while (cas.getHeapValue(curNode) == neFloatListType) {
+	  	if (!visited.put(curNode, curNode)) {
+	  	           foundCycle = true;
+	  	           break;
+	  	}
+	  	float value = Float.parseFloat((String) stringValues.get(i++));
+	    cas.setFeatureValue(curNode,floatHeadFeat, value);
+	    prevNode = curNode;
+	  	curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(floatTailFeat));
+	  }
+	  //add nodes for remaining values
+	  if (i < stringValues.size()) {
+	  	int emptyListFs = curNode; 
+	  	//check that first is efloatlisttype
+	  	while (i < stringValues.size()) {
+	  	  int newNode = cas.ll_createFS(neFloatListType);
+	  	  float value = Float.parseFloat((String) stringValues.get(i++));
+	      cas.setFeatureValue(newNode,floatHeadFeat, value);
+	      cas.setFeatureValue(newNode, floatTailFeat, emptyListFs);
+	      cas.setFeatureValue(prevNode, floatTailFeat, newNode);
+	  	  prevNode = newNode;
+	    }
+	  }
+	} else if (currLength > stringValues.size()) {
+		while (cas.getHeapValue(curNode) == neFloatListType && i < stringValues.size()) {
+		  if (!visited.put(curNode, curNode)) {
+		  	           foundCycle = true;
+		  	           break;
+		  }
+		  float value = Float.parseFloat((String) stringValues.get(i++));
+		  cas.setFeatureValue(curNode,floatHeadFeat, value);
+		  curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(floatTailFeat));
+		}	
+		int finalNode = curNode;
+        //loop till we get a FS that is of type eStringListType
+        while (cas.getHeapValue(curNode) == neFloatListType) {
+  	      if (!visited.put(curNode, curNode)) {
+  	        foundCycle = true;
+  	        break;
+  	      //TODO throw exc
+  	      }
+  	      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(floatTailFeat));
+        }
+        //set the tail feature to eStringListType fs
+      	cas.setFeatureValue(finalNode, floatTailFeat, curNode);
+    } else {
+      while (cas.getHeapValue(curNode) == neFloatListType) {
+        if (!visited.put(curNode, curNode)) {
+           foundCycle = true;
+           break;
+        }
+        float value = Float.parseFloat((String) stringValues.get(i++));
+        cas.setFeatureValue(curNode,floatHeadFeat,  CASImpl.float2int(value));
+        curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(floatTailFeat));
+      }
+    }
+	
+    if (foundCycle) {
+        reportWarning("Found a cycle in an IntegerList.  List truncated to "
+                  + i);
+    }
+    return first;
+  }  
+  
+  public int updateFsList(int addr, List stringValues, IntVector fsAddresses) throws SAXException  {
+    int first = addr;
+    int currLength = this.getLength(this.neFsListType, addr);
+    boolean foundCycle = false;
+    IntRedBlackTree visited = new IntRedBlackTree();
+    int curNode = addr;
+    int prevNode = 0;
+    
+    //if (currLength != stringValues.size() ) {  
+	//   first = createFsList(stringValues, fsAddresses);
+    int i=0;
+    if (currLength < stringValues.size() ) {    
+  	  while (cas.getHeapValue(curNode) == neFsListType) {
+  	    if (!visited.put(curNode, curNode)) {
+  	           foundCycle = true;
+  	           break;
+  	    }
+  	    int value = Integer.parseInt((String) stringValues.get(i++));
+        cas.setFeatureValue(curNode,fsHeadFeat, value);
+        fsAddresses.add(curNode);
+        prevNode = curNode;
+  	    curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(fsTailFeat));
+  	  }
+  	  //add nodes for remaining values
+  	  if (i < stringValues.size()) {
+  	    int emptyListFs = curNode; 
+  	    //check that first is estringlisttype
+  	    while (i < stringValues.size()) {
+  	      int newNode = cas.ll_createFS(neFsListType);
+  	      int value = Integer.parseInt((String) stringValues.get(i++));
+          cas.setFeatureValue(newNode,fsHeadFeat, value);
+          fsAddresses.add(newNode);
+          cas.setFeatureValue(newNode, fsTailFeat, emptyListFs);
+          cas.setFeatureValue(prevNode, fsTailFeat, newNode);
+  	      prevNode = newNode;
+  	    }
+  	  }
+    } else if (currLength > stringValues.size()) {	
+        while (cas.getHeapValue(curNode) == neFsListType && i < stringValues.size()) {
+   	      if (!visited.put(curNode, curNode)) {
+   		    foundCycle = true;
+   		    break;
+   		  }
+   	      int value = Integer.parseInt((String) stringValues.get(i++));
+	      fsAddresses.add(curNode);
+          cas.setFeatureValue(curNode,fsHeadFeat, value);
+   		  curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(fsTailFeat));
+        } 
+        int finalNode = curNode;
+        //loop till we get a FS that is of type eStringListType
+        while (cas.getHeapValue(curNode) == neFsListType) {
+  	      if (!visited.put(curNode, curNode)) {
+  	        foundCycle = true;
+  	        break;
+  	      //TODO throw exc
+  	      }
+  	      curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(fsTailFeat));
+        }
+        //set the tail feature to eStringListType fs
+      	cas.setFeatureValue(finalNode, fsTailFeat, curNode);
+    } else {
+      while (cas.getHeapValue(curNode) == neFsListType) {
+        if (!visited.put(curNode, curNode)) {
+           foundCycle = true;
+           break;
+        }
+        int value = Integer.parseInt((String) stringValues.get(i++));
+        cas.setFeatureValue(curNode,fsHeadFeat, value);
+        fsAddresses.add(curNode);
+        curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(fsTailFeat));
+      }
+    }
+    if (foundCycle) {
+      reportWarning("Found a cycle in an IntegerList.  List truncated to "
+                  + i);
+    }
+    return first;
+  }  
+  
+  public int updateStringList(int addr, List stringValues) throws SAXException   {
+    int first = addr;
+    boolean foundCycle = false;
+    IntRedBlackTree visited = new IntRedBlackTree();
+    int curNode = addr;
+    int prevNode = 0;
+    int currLength = this.getLength(this.neStringListType, addr);
+    
+    if (currLength < stringValues.size() ) {    
+      int i =0;
+	  while (cas.getHeapValue(curNode) == neStringListType) {
+	    if (!visited.put(curNode, curNode)) {
+	           foundCycle = true;
+	           break;
+	    }
+	    String curValue = cas.getStringForCode(cas.getHeapValue(curNode
+	              + cas.getFeatureOffset(stringHeadFeat)));
+	    String newValue = (String)stringValues.get(i++);
+        if (!curValue.equals(newValue)) {		  
+          cas.setFeatureValue(curNode, stringHeadFeat, cas.addString(newValue));
+        }
+        prevNode = curNode;
+	    curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(stringTailFeat));
+	 }
+	 //extend the list
+	 if (i < stringValues.size()) {
+	   int emptyListFs = curNode; 
+	   while (i < stringValues.size()) {
+	     int newNode = cas.ll_createFS(neStringListType);
+	     String value = (String) stringValues.get(i++);
+	     cas.setFeatureValue(newNode, stringHeadFeat, cas.addString(value));
+	     cas.setFeatureValue(newNode, stringTailFeat, emptyListFs);
+	     cas.setFeatureValue(prevNode,stringTailFeat, newNode);
+	     prevNode = newNode;
+	   }
+	 }
+    } else if (currLength > stringValues.size()) {
+      int i=0;	
+      while (cas.getHeapValue(curNode) == neStringListType && i < stringValues.size()) {
+ 	    if (!visited.put(curNode, curNode)) {
+ 		           foundCycle = true;
+ 		           break;
+ 		}
+ 		String curValue = cas.getStringForCode(cas.getHeapValue(curNode
+ 		              + cas.getFeatureOffset(stringHeadFeat)));
+ 		String newValue = (String)stringValues.get(i++);
+        if (!curValue.equals(newValue)) {		  
+           cas.setFeatureValue(curNode, stringHeadFeat, cas.addString(newValue));
+        }
+ 		curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(stringTailFeat));
+      } 
+      int finalNode = curNode;
+      while (cas.getHeapValue(curNode) == neStringListType) {
+	    if (!visited.put(curNode, curNode)) {
+	      foundCycle = true;
+	      break;
+	      //TODO throw exc
+	    }
+	    curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(stringTailFeat));
+      }
+      cas.setFeatureValue(finalNode, stringTailFeat, curNode);
+    } else {
+      int i =0;
+      while (cas.getHeapValue(curNode) == neStringListType) {
+        if (!visited.put(curNode, curNode)) {
+           foundCycle = true;
+           break;
+        }
+        String curValue = cas.getStringForCode(cas.getHeapValue(curNode
+	              + cas.getFeatureOffset(stringHeadFeat)));
+        String newValue = (String)stringValues.get(i++);
+        if (!curValue.equals(newValue)) {		  
+          cas.setFeatureValue(curNode, stringHeadFeat, cas.addString(newValue));
+        }
+        curNode = cas.getHeapValue(curNode + cas.getFeatureOffset(stringTailFeat));
+      }
+    }
+    
+    if (foundCycle) {
+        reportWarning("Found a cycle in an IntegerList.  List truncated. ");
+    }
+    return first;
+  }  
+		  
+	  
+  
+  private void reportWarning(String message) throws SAXException {
+    if (this.logger != null) {
+      logger.log(Level.WARNING, message);
+    }
+    if (this.eh != null) {
+      this.eh.warning(new SAXParseException(message, null));
+    }
+  }
+}

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/ListUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/LongArrayFSImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/LongHeap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelCAS.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelIndex.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelIndexRepository.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelIteratorWrapper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelTypeSystem.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/MarkerImpl.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/MarkerImpl.java?rev=690405&r1=690404&r2=690405&view=diff
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/MarkerImpl.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/MarkerImpl.java Fri Aug 29 15:10:52 2008
@@ -1,69 +1,69 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.uima.cas.impl;
-
-import org.apache.uima.cas.CASRuntimeException;
-import org.apache.uima.cas.FeatureStructure;
-import org.apache.uima.cas.Marker;
-
-public class MarkerImpl implements Marker {
-	
-  private int nextFSId;
-  CASImpl cas;
-
-  MarkerImpl(int nextPos, CASImpl cas) {
-    this.nextFSId = nextPos;
-    this.cas = cas;
-  }
-
-  public boolean isNew(FeatureStructure fs) {
-	//check if same CAS instance
-	//TODO: define a CASRuntimeException
-	if (((FeatureStructureImpl) fs).getCASImpl() != this.cas) {
-		CASRuntimeException e = new CASRuntimeException(
-		          CASRuntimeException.CAS_MISMATCH,
-		          new String[] { "FS and Marker are not from the same CAS." });
-		      throw e;
-	}
-	return isNew( ((FeatureStructureImpl) fs).getAddress());
-  }
-
-  public boolean isModified(FeatureStructure fs) {
-	if (((FeatureStructureImpl) fs).getCASImpl() != this.cas) {
-		CASRuntimeException e = new CASRuntimeException(
-		          CASRuntimeException.CAS_MISMATCH,
-		          new String[] { "FS and Marker are not from the same CAS." });
-		      throw e;
-	}
-	int addr = ((FeatureStructureImpl) fs).getAddress();
-	return isModified(addr);
-  }
-  
-  boolean isNew(int addr) {
-	return (addr == nextFSId || addr > nextFSId);
-  }
-  
-  boolean isModified(int addr) {
-	if (isNew(addr)) {
-		return false;
-    }
-	return this.cas.getModifiedFSList().contains(addr);
-  }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.cas.impl;
+
+import org.apache.uima.cas.CASRuntimeException;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.Marker;
+
+public class MarkerImpl implements Marker {
+	
+  private int nextFSId;
+  CASImpl cas;
+
+  MarkerImpl(int nextPos, CASImpl cas) {
+    this.nextFSId = nextPos;
+    this.cas = cas;
+  }
+
+  public boolean isNew(FeatureStructure fs) {
+	//check if same CAS instance
+	//TODO: define a CASRuntimeException
+	if (((FeatureStructureImpl) fs).getCASImpl() != this.cas) {
+		CASRuntimeException e = new CASRuntimeException(
+		          CASRuntimeException.CAS_MISMATCH,
+		          new String[] { "FS and Marker are not from the same CAS." });
+		      throw e;
+	}
+	return isNew( ((FeatureStructureImpl) fs).getAddress());
+  }
+
+  public boolean isModified(FeatureStructure fs) {
+	if (((FeatureStructureImpl) fs).getCASImpl() != this.cas) {
+		CASRuntimeException e = new CASRuntimeException(
+		          CASRuntimeException.CAS_MISMATCH,
+		          new String[] { "FS and Marker are not from the same CAS." });
+		      throw e;
+	}
+	int addr = ((FeatureStructureImpl) fs).getAddress();
+	return isModified(addr);
+  }
+  
+  boolean isNew(int addr) {
+	return (addr == nextFSId || addr > nextFSId);
+  }
+  
+  boolean isModified(int addr) {
+	if (isNew(addr)) {
+		return false;
+    }
+	return this.cas.getModifiedFSList().contains(addr);
+  }
+}

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/MarkerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/OutOfTypeSystemData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/PathConstraint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/Serialization.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/ShortArrayFSImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/ShortHeap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/SofaFSImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/StringArrayFSImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/StringConstraint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/StringHeap.java
------------------------------------------------------------------------------
    svn:eol-style = native