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 2016/05/06 20:50:02 UTC

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

Author: schor
Date: Fri May  6 20:50:01 2016
New Revision: 1742626

URL: http://svn.apache.org/viewvc?rev=1742626&view=rev
Log:
[UIMA-4674] support arrays of typed FSs

Modified:
    uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl_array.java

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl_array.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl_array.java?rev=1742626&r1=1742625&r2=1742626&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl_array.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeImpl_array.java Fri May  6 20:50:01 2016
@@ -19,7 +19,6 @@
 
 package org.apache.uima.cas.impl;
 
-import org.apache.uima.cas.Type;
 import org.apache.uima.cas.impl.SlotKinds.SlotKind;
 
 public class TypeImpl_array extends TypeImpl implements TypeSystemConstants {
@@ -94,24 +93,31 @@ public class TypeImpl_array extends Type
     //           xxx[] is the supertype of FSArray
     // (this second relation because all we can generate are instances of FSArray
     // and we must be able to assign them to xxx[] )
+    //   *** Correction: there is a way to generate instances of xxx[] - via ll_createArray and CASImpl.createTempArray ***
     
     
     final TypeImpl superType = this;
     final int superTypeCode = getCode();
     
     if (superTypeCode == fsArrayTypeCode) {
-      return !subType.isPrimitiveArrayType();
+      return !subType.isPrimitiveArrayType();    // primitive 
     }
     
     if (subType.getCode() == fsArrayTypeCode) {
-      return superTypeCode == arrayBaseTypeCode ||
+      return superTypeCode == arrayBaseTypeCode ||  // this subsumes FSArray only if this is arrayBaseTypeCode, or 
+                                                    //       this is some Array of specific FSs (seems wrong)
              !isPrimitiveArrayType();
     }
 
-    // at this point, we could have arrays of other primitive types, or
-    // arrays of specific types: xxx[]
-
-    // If both types are arrays, simply compare the components.
+    // at this point, the super type and the subtype are 
+    //  both arrays, 
+    //  not fsArrays
+    //  not equal
+    
+    if (superType.isPrimitiveArrayType() || subType.isPrimitiveArrayType()) {
+      return false; 
+    }
+    
     return getComponentType().subsumes(subType.getComponentType());
  
 //    } else if (isSubArray) {
@@ -121,4 +127,15 @@ public class TypeImpl_array extends Type
 //    }
         
   }
+ 
+  /**
+   * @return true if this array type is a subtype of FSArray over a specific feature structure (other than TOP, or 
+   *              one of the primitives)
+   */
+  @Override
+  public boolean isTypedFsArray() {
+    return componentType.isRefType && 
+           componentType.getCode() != fsArrayTypeCode && 
+           componentType.getCode() != topTypeCode;
+  }
 }