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 2014/09/29 23:38:03 UTC
svn commit: r1628323 - in /uima/uimaj/trunk/uimaj-core/src:
main/java/org/apache/uima/cas/impl/CASImpl.java
main/java/org/apache/uima/cas/impl/TypeSystemImpl.java
test/java/org/apache/uima/cas/test/TypeSystemTest.java
Author: schor
Date: Mon Sep 29 21:38:03 2014
New Revision: 1628323
URL: http://svn.apache.org/r1628323
Log:
[UIMA-4031] fix wrong parent of built-in array types, add test case.
Modified:
uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java
uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeSystemTest.java
Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java?rev=1628323&r1=1628322&r2=1628323&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java Mon Sep 29 21:38:03 2014
@@ -2312,38 +2312,59 @@ public class CASImpl extends AbstractCas
Type top = ts.addTopType(CAS.TYPE_NAME_TOP);
// Add basic data types.
Type intT = ts.addType(CAS.TYPE_NAME_INTEGER, top);
+ ts.intType = (TypeImpl) intT;
+ ts.intTypeCode = ts.intType.getCode();
+
Type floatT = ts.addType(CAS.TYPE_NAME_FLOAT, top);
+ ts.floatType = (TypeImpl) floatT;
+ ts.floatTypeCode = ts.floatType.getCode();
+
Type stringT = ts.addType(CAS.TYPE_NAME_STRING, top);
+ ts.stringType = (TypeImpl) stringT;
+ ts.stringTypeCode = ts.stringType.getCode();
+
+
// Add arrays.
Type array = ts.addType(CAS.TYPE_NAME_ARRAY_BASE, top);
ts.arrayBaseType = (TypeImpl) array; // do here - used in next
ts.arrayBaseTypeCode = ts.arrayBaseType.getCode();
- TypeImpl fsArray = (TypeImpl) ts.addType(CAS.TYPE_NAME_FS_ARRAY, array);
- ts.fsArrayType = fsArray; // do here - used in next
+
+ TypeImpl fsArray = ts.fsArrayType = (TypeImpl) ts.addType(CAS.TYPE_NAME_FS_ARRAY, array);
ts.fsArrayTypeCode = fsArray.getCode();
- TypeImpl floatArray = (TypeImpl) ts.addType(CAS.TYPE_NAME_FLOAT_ARRAY, array);
- TypeImpl intArray = (TypeImpl) ts.addType(CAS.TYPE_NAME_INTEGER_ARRAY, array);
- TypeImpl stringArray = (TypeImpl) ts.addType(CAS.TYPE_NAME_STRING_ARRAY, array);
+
+ TypeImpl floatArray = ts.floatArrayType = (TypeImpl) ts.addType(CAS.TYPE_NAME_FLOAT_ARRAY, array);
+ ts.floatArrayTypeCode = floatArray.getCode();
+
+ TypeImpl intArray = ts.intArrayType = (TypeImpl) ts.addType(CAS.TYPE_NAME_INTEGER_ARRAY, array);
+ ts.intArrayTypeCode = intArray.getCode();
+
+ TypeImpl stringArray = ts.stringArrayType = (TypeImpl) ts.addType(CAS.TYPE_NAME_STRING_ARRAY, array);
+ ts.stringArrayTypeCode = stringArray.getCode();
+
// Add lists.
Type list = ts.addType(CAS.TYPE_NAME_LIST_BASE, top);
+
// FS lists.
Type fsList = ts.addType(CAS.TYPE_NAME_FS_LIST, list);
Type fsEList = ts.addType(CAS.TYPE_NAME_EMPTY_FS_LIST, fsList);
Type fsNeList = ts.addType(CAS.TYPE_NAME_NON_EMPTY_FS_LIST, fsList);
ts.addFeature(CAS.FEATURE_BASE_NAME_HEAD, fsNeList, top, true);
ts.addFeature(CAS.FEATURE_BASE_NAME_TAIL, fsNeList, fsList, true);
+
// Float lists.
Type floatList = ts.addType(CAS.TYPE_NAME_FLOAT_LIST, list);
Type floatEList = ts.addType(CAS.TYPE_NAME_EMPTY_FLOAT_LIST, floatList);
Type floatNeList = ts.addType(CAS.TYPE_NAME_NON_EMPTY_FLOAT_LIST, floatList);
ts.addFeature(CAS.FEATURE_BASE_NAME_HEAD, floatNeList, floatT, false);
ts.addFeature(CAS.FEATURE_BASE_NAME_TAIL, floatNeList, floatList, true);
+
// Integer lists.
Type intList = ts.addType(CAS.TYPE_NAME_INTEGER_LIST, list);
Type intEList = ts.addType(CAS.TYPE_NAME_EMPTY_INTEGER_LIST, intList);
Type intNeList = ts.addType(CAS.TYPE_NAME_NON_EMPTY_INTEGER_LIST, intList);
ts.addFeature(CAS.FEATURE_BASE_NAME_HEAD, intNeList, intT, false);
ts.addFeature(CAS.FEATURE_BASE_NAME_TAIL, intNeList, intList, true);
+
// String lists.
Type stringList = ts.addType(CAS.TYPE_NAME_STRING_LIST, list);
Type stringEList = ts.addType(CAS.TYPE_NAME_EMPTY_STRING_LIST, stringList);
@@ -2352,20 +2373,46 @@ public class CASImpl extends AbstractCas
ts.addFeature(CAS.FEATURE_BASE_NAME_TAIL, stringNeList, stringList, true);
Type booleanT = ts.addType(CAS.TYPE_NAME_BOOLEAN, top);
+ ts.booleanType = (TypeImpl) booleanT;
+ ts.booleanTypeCode = ts.booleanType.getCode();
+
Type byteT = ts.addType(CAS.TYPE_NAME_BYTE, top);
+ ts.byteType = (TypeImpl) byteT;
+ ts.byteTypeCode = ts.byteType.getCode();
+
Type shortT = ts.addType(CAS.TYPE_NAME_SHORT, top);
+ ts.shortType = (TypeImpl) shortT;
+ ts.shortTypeCode = ts.shortType.getCode();
+
Type longT = ts.addType(CAS.TYPE_NAME_LONG, top);
+ ts.longType = (TypeImpl) longT;
+ ts.longTypeCode = ts.longType.getCode();
+
Type doubleT = ts.addType(CAS.TYPE_NAME_DOUBLE, top);
+ ts.doubleType = (TypeImpl) doubleT;
+ ts.doubleTypeCode = ts.doubleType.getCode();
// array type initialization must follow the component type it's based on
- TypeImpl booleanArray = (TypeImpl) ts.addType(CAS.TYPE_NAME_BOOLEAN_ARRAY, array);
- TypeImpl byteArray = (TypeImpl) ts.addType(CAS.TYPE_NAME_BYTE_ARRAY, array);
- TypeImpl shortArray = (TypeImpl) ts.addType(CAS.TYPE_NAME_SHORT_ARRAY, array);
- TypeImpl longArray = (TypeImpl) ts.addType(CAS.TYPE_NAME_LONG_ARRAY, array);
- TypeImpl doubleArray = (TypeImpl) ts.addType(CAS.TYPE_NAME_DOUBLE_ARRAY, array);
+ TypeImpl booleanArray = ts.booleanArrayType = (TypeImpl) ts.addType(CAS.TYPE_NAME_BOOLEAN_ARRAY, array);
+ ts.booleanArrayTypeCode = booleanArray.getCode();
+
+ TypeImpl byteArray = ts.byteArrayType = (TypeImpl) ts.addType(CAS.TYPE_NAME_BYTE_ARRAY, array);
+ ts.byteArrayTypeCode = byteArray.getCode();
+
+ TypeImpl shortArray = ts.shortArrayType = (TypeImpl) ts.addType(CAS.TYPE_NAME_SHORT_ARRAY, array);
+ ts.shortArrayTypeCode = shortArray.getCode();
+
+ TypeImpl longArray = ts.longArrayType = (TypeImpl) ts.addType(CAS.TYPE_NAME_LONG_ARRAY, array);
+ ts.longArrayTypeCode = longArray.getCode();
+
+ TypeImpl doubleArray = ts.doubleArrayType = (TypeImpl) ts.addType(CAS.TYPE_NAME_DOUBLE_ARRAY, array);
+ ts.doubleArrayTypeCode = doubleArray.getCode();
// Sofa Stuff
Type sofa = ts.addType(CAS.TYPE_NAME_SOFA, top);
+ ts.sofaType = (TypeImpl) sofa;
+ ts.sofaTypeCode = ts.sofaType.getCode();
+
ts.addFeature(CAS.FEATURE_BASE_NAME_SOFANUM, sofa, intT, false);
ts.addFeature(CAS.FEATURE_BASE_NAME_SOFAID, sofa, stringT, false);
ts.addFeature(CAS.FEATURE_BASE_NAME_SOFAMIME, sofa, stringT, false);
@@ -2377,11 +2424,21 @@ public class CASImpl extends AbstractCas
// Annotations
Type annotBaseType = ts.addType(CAS.TYPE_NAME_ANNOTATION_BASE, top);
+ ts.annotBaseType = (TypeImpl) annotBaseType;
+ ts.annotBaseTypeCode = ts.annotBaseType.getCode();
+
ts.addFeature(CAS.FEATURE_BASE_NAME_SOFA, annotBaseType, sofa, false);
+
Type annotType = ts.addType(CAS.TYPE_NAME_ANNOTATION, annotBaseType);
+ ts.annotType = (TypeImpl) annotType;
+ ts.annotTypeCode = ts.annotType.getCode();
+
ts.addFeature(CAS.FEATURE_BASE_NAME_BEGIN, annotType, intT, false);
ts.addFeature(CAS.FEATURE_BASE_NAME_END, annotType, intT, false);
+
Type docType = ts.addType(CAS.TYPE_NAME_DOCUMENT_ANNOTATION, annotType);
+ ts.docType = (TypeImpl) docType;
+
ts.addFeature(CAS.FEATURE_BASE_NAME_LANGUAGE, docType, stringT, false);
// Lock individual types.
Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java?rev=1628323&r1=1628322&r2=1628323&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/TypeSystemImpl.java Mon Sep 29 21:38:03 2014
@@ -385,63 +385,63 @@ public class TypeSystemImpl implements T
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.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.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);
+// 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.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.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();
+// this.arrayBaseTypeCode = this.arrayBaseType.getCode();
final Type sofaT = this.sofaType;
this.sofaNumFeatCode = ll_getCodeForFeature(sofaT
Modified: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeSystemTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeSystemTest.java?rev=1628323&r1=1628322&r2=1628323&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeSystemTest.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/TypeSystemTest.java Mon Sep 29 21:38:03 2014
@@ -316,6 +316,13 @@ public class TypeSystemTest extends Test
this.ts = null;
}
+ public void testSuperTypeBuiltIn() {
+ CAS cas = CASInitializer.initCas(new SetupTest());
+ TypeSystem ts = cas.getTypeSystem();
+ Type stringArray = ts.getType("uima.cas.StringArray");
+ assertEquals("uima.cas.ArrayBase", ts.getParent(stringArray).getName());
+ }
+
public void testNameChecking() {
CAS tcas = CASInitializer.initCas(new SetupTest());
assertTrue(tcas != null);