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/03/29 22:08:41 UTC

svn commit: r1737041 - in /uima/uimaj/branches/experiment-v3-jcas: uimaj-document-annotation/src/main/java/org/apache/uima/jcas/tcas/ uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/ uimaj-tools/src/main/javajet/jcasgen/includedTemplates/ uimaj...

Author: schor
Date: Tue Mar 29 20:08:41 2016
New Revision: 1737041

URL: http://svn.apache.org/viewvc?rev=1737041&view=rev
Log:
[UIMA-4666][UIMA-4663] redo internal classes and jcasgen support for new style of representing feature structures; remove no longer used javajet includedTemplates

Removed:
    uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/javajet/jcasgen/includedTemplates/Annotation_Methods.javajet
    uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/javajet/jcasgen/includedTemplates/FeatOk_Testing.javajet
Modified:
    uima/uimaj/branches/experiment-v3-jcas/uimaj-document-annotation/src/main/java/org/apache/uima/jcas/tcas/DocumentAnnotation.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/JCasTypeTemplate.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/Jg.java
    uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/javajet/jcasgen/templates/JCasType.javajet

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-document-annotation/src/main/java/org/apache/uima/jcas/tcas/DocumentAnnotation.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-document-annotation/src/main/java/org/apache/uima/jcas/tcas/DocumentAnnotation.java?rev=1737041&r1=1737040&r2=1737041&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-document-annotation/src/main/java/org/apache/uima/jcas/tcas/DocumentAnnotation.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-document-annotation/src/main/java/org/apache/uima/jcas/tcas/DocumentAnnotation.java Tue Mar 29 20:08:41 2016
@@ -43,11 +43,8 @@ public class DocumentAnnotation extends
     return typeIndexID;
   }
 
-  public final static int _FI_language = JCasRegistry.registerFeature(typeIndexID); 
+  public final static int _FI_language = TypeSystemImpl.getAdjustedFeatureOffset("language"); 
         
-  /* local data */
-  private String _F_language;
-
   // Never called. Disable default constructor
   protected DocumentAnnotation() {
   }
@@ -73,13 +70,13 @@ public class DocumentAnnotation extends
    * getter for language
    * @return the language
    */
-  public String getLanguage() { return _F_language; }
+  public String getLanguage() { return _getStringValueNc(_FI_language); }
 
   /**
    * setter for language
    * @param v the language
    */
   public void setLanguage(String v) {
-    _casView.setWithCheckAndJournalJFRI(this, _FI_language,  () ->_F_language = v);
+    _setStringValueNfc(_FI_language, v);
   }
 }

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/JCasTypeTemplate.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/JCasTypeTemplate.java?rev=1737041&r1=1737040&r2=1737041&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/JCasTypeTemplate.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/JCasTypeTemplate.java Tue Mar 29 20:08:41 2016
@@ -44,7 +44,7 @@ public class JCasTypeTemplate implements
    else 
      jg.error.newError(IError.WARN, 
 		jg.getString("pkgMissing", new Object[] {td.getName()}), null); 
-    stringBuilder.append("\nimport org.apache.uima.cas.impl.CASImpl;\nimport org.apache.uima.cas.impl.TypeImpl;\nimport org.apache.uima.jcas.JCas; \nimport org.apache.uima.jcas.JCasRegistry;\n\n");
+    stringBuilder.append("\nimport org.apache.uima.cas.impl.CASImpl;\nimport org.apache.uima.cas.impl.TypeImpl;\nimport org.apache.uima.cas.impl.TypeSystemImpl;\nimport org.apache.uima.jcas.JCas; \nimport org.apache.uima.jcas.JCasRegistry;\n\n\n");
    for(Iterator i=jg.collectImports(td, false).iterator(); i.hasNext();) { 
     stringBuilder.append("import ");
     stringBuilder.append((String)i.next());
@@ -70,7 +70,7 @@ public class JCasTypeTemplate implements
    StringBuilder localData = new StringBuilder();
    StringBuilder featRegistry = new StringBuilder();
     
-   featRegistry.append("  /* Register Features */\n");
+   featRegistry.append("  /* Feature Adjusted Offsets */\n");
    
    for (FeatureDescription fd : td.getFeatures()) { 
 
@@ -89,14 +89,13 @@ public class JCasTypeTemplate implements
      String elemType = jg.getJavaRangeArrayElementType(fd);
      
      localData.append("  private ").append(rangeType).append(" _F_").append(featName).append(";  // ").append(featDescCmt).append('\n');
-     featRegistry.append("  public final static int _FI_").append(featName).append(" = JCasRegistry.registerFeature(typeIndexID);\n");   
+     featRegistry.append("  public final static int _FI_").append(featName).append(" = TypeSystemImpl.getAdjustedFeatureOffset(\"")
+                 .append(featName).append("\");\n");   
       
    } /* of Features iteration */ 
-    stringBuilder.append("\n  /* *****************\n   *    Local Data   *\n   * *****************/ \n   \n");
+    stringBuilder.append("\n  /* *******************\n   *   Feature Offsets *\n   * *******************/ \n   \n");
     stringBuilder.append(featRegistry);
-    stringBuilder.append("\n   \n");
-    stringBuilder.append(localData);
-    stringBuilder.append(" \n  /** Never called.  Disable default constructor\n   * @generated */\n  protected ");
+    stringBuilder.append("\n   \n  /** Never called.  Disable default constructor\n   * @generated */\n  protected ");
     stringBuilder.append(typeName);
     stringBuilder.append("() {/* intentionally empty block */}\n    \n  /** Internal - constructor used by generator \n   * @generated\n   * @param casImpl the CAS this Feature Structure belongs to\n   * @param type the type of this Feature Structure \n   */\n  public ");
     stringBuilder.append(typeName);
@@ -128,8 +127,8 @@ public class JCasTypeTemplate implements
     stringBuilder.append(rangeType);
     stringBuilder.append(" get");
     stringBuilder.append(featUName);
-    stringBuilder.append("() { return _F_");
-    stringBuilder.append(featName);
+    stringBuilder.append("() { return ");
+    stringBuilder.append(jg.getFeatureValue(fd, td));
     stringBuilder.append(";}\n    \n  /** setter for ");
     stringBuilder.append(featName);
     stringBuilder.append(" - sets ");
@@ -139,26 +138,8 @@ public class JCasTypeTemplate implements
     stringBuilder.append("(");
     stringBuilder.append(rangeType);
     stringBuilder.append(" v) {\n    ");
-  if (jg.isStringSubtype(fd)) {
-    stringBuilder.append("      _typeImpl.getFeatureByBaseName(\"");
-    stringBuilder.append(featName);
-    stringBuilder.append("\").validateIsInAllowedValue(v);\n    ");
-  }
-    stringBuilder.append("    ");
-  if (jg.isPossibleIndexKey(fd)) {
-    stringBuilder.append("      _casView.setWithCheckAndJournalJFRI(this, _FI_");
-    stringBuilder.append(featName);
-    stringBuilder.append(", () -> _F_");
-    stringBuilder.append(featName);
-    stringBuilder.append(" = v);\n    ");
-  } else {
-    stringBuilder.append(" \n      _casView.setWithJournalJFRI(this, _FI_");
-    stringBuilder.append(featName);
-    stringBuilder.append(", () -> _F_");
-    stringBuilder.append(featName);
-    stringBuilder.append(" = v);\n    ");
-  }
-    stringBuilder.append("  }    \n  ");
+    stringBuilder.append(jg.setFeatureValue(fd, td));
+    stringBuilder.append(";\n  }    \n    \n  ");
   if (jg.hasArrayRange(fd)) {
     stringBuilder.append("  \n  /** indexed getter for ");
     stringBuilder.append(featName);
@@ -168,9 +149,9 @@ public class JCasTypeTemplate implements
     stringBuilder.append(elemType);
     stringBuilder.append(" get");
     stringBuilder.append(featUName);
-    stringBuilder.append("(int i) {\n     return get");
-    stringBuilder.append(featUName);
-    stringBuilder.append("().get(i);} \n\n  /** indexed setter for ");
+    stringBuilder.append("(int i) {\n     return ");
+    stringBuilder.append(jg.getArrayFeatureValue(fd, td));
+    stringBuilder.append(";} \n\n  /** indexed setter for ");
     stringBuilder.append(featName);
     stringBuilder.append(" - sets an indexed value - ");
     stringBuilder.append(featDescCmt);
@@ -178,16 +159,16 @@ public class JCasTypeTemplate implements
     stringBuilder.append(featUName);
     stringBuilder.append("(int i, ");
     stringBuilder.append(elemType);
-    stringBuilder.append(" v) {\n    get");
-    stringBuilder.append(featUName);
-    stringBuilder.append("().set(i, v);}  \n  ");
+    stringBuilder.append(" v) {\n    ");
+    stringBuilder.append(jg.setArrayFeatureValue(fd, td));
+    stringBuilder.append(";\n  }  \n  ");
    } /* of hasArray */ 
     stringBuilder.append("");
    } /* of Features iteration */ 
     stringBuilder.append("");
    if (td.getName().equals("uima.cas.Annotation")) { 
     stringBuilder.append("  ");
-    stringBuilder.append("  /** Constructor with begin and end passed as arguments \n    * @generated\n    * @param jcas JCas this Annotation is in\n    * @param begin the begin offset\n    * @param end the end offset\n    */\n  public Annotation(JCas jcas, int begin, int end) { \n	  this(jcas); // forward to constructor \n	  this.setBegin(begin); \n	  this.setEnd(end);\n	  readObject(); \n  } \n  \n  /** @see org.apache.uima.cas.text.AnnotationFS#getCoveredText() \n    * @generated\n    * @return the covered Text \n    */ \n  public String getCoveredText() { \n    final CAS casView = this.getView();\n    final String text = casView.getDocumentText();\n    if (text == null) {\n      return null;\n    }\n    return text.substring(getBegin(), getEnd());\n  } \n  \n  /** @deprecated \n    * @generated\n    * @return the begin offset \n    */\n  public int getStart() {return getBegin();}\n");
+    stringBuilder.append("  /** Constructor with begin and end passed as arguments \n    * @generated\n    * @param jcas JCas this Annotation is in\n    * @param begin the begin offset\n    * @param end the end offset\n    */\n  public Annotation(JCas jcas, int begin, int end) { \n	  this(jcas); // forward to constructor \n	  this.setBegin(begin); \n	  this.setEnd(end); \n  } \n  \n  /** @see org.apache.uima.cas.text.AnnotationFS#getCoveredText() \n    * @generated\n    * @return the covered Text \n    */ \n  public String getCoveredText() { \n    final CAS casView = this.getView();\n    final String text = casView.getDocumentText();\n    if (text == null) {\n      return null;\n    }\n    return text.substring(getBegin(), getEnd());\n  } \n  \n  /** @deprecated \n    * @generated\n    * @return the begin offset \n    */\n  public int getStart() {return getBegin();}\n");
     stringBuilder.append("");
    } /* of Annotation if-statement */ 
     stringBuilder.append("}\n\n    ");

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/Jg.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/Jg.java?rev=1737041&r1=1737040&r2=1737041&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/Jg.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/Jg.java Tue Mar 29 20:08:41 2016
@@ -59,6 +59,7 @@ import org.apache.uima.cas.Type;
 import org.apache.uima.cas.TypeSystem;
 import org.apache.uima.cas.impl.CASImpl;
 import org.apache.uima.cas.impl.TypeImpl;
+import org.apache.uima.cas.impl.TypeImpl_string;
 import org.apache.uima.cas.impl.TypeSystemImpl;
 import org.apache.uima.resource.ResourceInitializationException;
 import org.apache.uima.resource.ResourceManager;
@@ -143,9 +144,8 @@ public class Jg {
       // never get here
     }
 
-    builtInTypeSystem = ((CASImpl) tcas).getTypeSystemImpl();
     ((CASImpl) tcas).commitTypeSystem();
-    builtInTypeSystem = ((CASImpl) tcas).getTypeSystemImpl();  // needed because commit may reuse existing type system
+    builtInTypeSystem = ((CASImpl) tcas).getTypeSystemImpl();  // follow commit because commit may reuse existing type system
 
     for (Iterator it = builtInTypeSystem.getTypeIterator(); it.hasNext();) {
       Type type = (Type) it.next();
@@ -362,7 +362,7 @@ public class Jg {
     try {
       // Generate type classes by using DEFAULT templates
       mainGenerateAllTypesFromTemplates(aMerger, aProgressMonitor, aError, inputFile,
-              outputDirectory, tds, aCas, JCasTypeTemplate.class, JCas_TypeTemplate.class,
+              outputDirectory, tds, aCas, JCasTypeTemplate.class,
               projectPathDir, limitJCasGenToProjectScope, mergedTypesAddingFeatures);
       // convert thrown things to IOExceptions to avoid changing API for this
       // FIXME later
@@ -381,13 +381,12 @@ public class Jg {
       throws IOException, InstantiationException, IllegalAccessException {
     mainGenerateAllTypesFromTemplates(aMerger, aProgressMonitor, 
              aError, inputFile, outputDirectory, tds, aCas, 
-             jcasTypeClass, jcas_TypeClass, "", false, null);
+             jcasTypeClass, "", false, null);
   }
   
   public void mainGenerateAllTypesFromTemplates(IMerge aMerger, IProgressMonitor aProgressMonitor,
           IError aError, String inputFile, String outputDirectory, TypeDescription[] tds,
           CASImpl aCas, Class jcasTypeClass, // Template class
-          Class jcas_TypeClass,
           String projectPathDir, boolean limitJCasGenToProjectScope,
           Map<String, Set<String>> mergedTypesAddingFeatures) // Template class
           throws IOException, InstantiationException, IllegalAccessException {
@@ -400,7 +399,7 @@ public class Jg {
     this.mergedTypesAddingFeatures = mergedTypesAddingFeatures;
 
     // Generate type classes by using SPECIFIED templates
-    generateAllTypesFromTemplates(outputDirectory, tds, aCas, jcasTypeClass, jcas_TypeClass);
+    generateAllTypesFromTemplates(outputDirectory, tds, aCas, jcasTypeClass);
   }
 
   public int main0(String[] args, IMerge aMerger, IProgressMonitor aProgressMonitor, IError aError) {
@@ -567,8 +566,7 @@ public class Jg {
         tds = typeSystemDescription.getTypes();
 
         // Generate type classes from DEFAULT templates
-        generateAllTypesFromTemplates(outputDirectory, tds, casLocal, JCasTypeTemplate.class,
-                JCas_TypeTemplate.class);
+        generateAllTypesFromTemplates(outputDirectory, tds, casLocal, JCasTypeTemplate.class);
 
       } catch (IOException e) {
         error.newError(IError.ERROR, getString("IOException", new Object[] {}), e);
@@ -611,12 +609,11 @@ public class Jg {
 
   // This is also the interface for CDE
   private void generateAllTypesFromTemplates(String outputDirectory, TypeDescription[] tds,
-          CASImpl aCas, Class jcasTypeClass, Class jcas_TypeClass) throws IOException,
+          CASImpl aCas, Class jcasTypeClass) throws IOException,
           InstantiationException, IllegalAccessException {
 
     // Create instances of Template classes
     IJCasTypeTemplate jcasTypeInstance = (IJCasTypeTemplate) jcasTypeClass.newInstance();
-    IJCasTypeTemplate jcas_TypeInstance = (IJCasTypeTemplate) jcas_TypeClass.newInstance();
 
     Set generatedBuiltInTypes = new TreeSet();
 
@@ -667,7 +664,7 @@ public class Jg {
           continue;
         }
       }
-      generateClassesFromTemplate(td, outputDirectory, jcasTypeInstance, jcas_TypeInstance);
+      generateClassesFromTemplate(td, outputDirectory, jcasTypeInstance);
     }
 
     /* 
@@ -790,7 +787,7 @@ public class Jg {
    * @return void
    */
   private void generateClassesFromTemplate(TypeDescription td, String outputDirectory,
-          IJCasTypeTemplate jcasTypeInstance, IJCasTypeTemplate jcas_TypeInstance)
+          IJCasTypeTemplate jcasTypeInstance)
           throws IOException {
     simpleClassName = removePkg(getJavaName(td));
     generateClass(progressMonitor, outputDirectory, td, jcasTypeInstance.generate(new Object[] {
@@ -873,7 +870,7 @@ public class Jg {
       return "Long";
     if (v.equals("double"))
       return "Double";
-    return "Ref"; // for user defined features and other built-ins
+    return "Feature"; // for user defined features and other built-ins which are FSs
   }
 
   // * Functions that convert between CAS fully-qualified names and Java names.
@@ -982,7 +979,7 @@ public class Jg {
     String rangeTypeNameCAS = fd.getRangeTypeName();
     if (null != typeSystem) {
       Type rangeCasType = typeSystem.getType(rangeTypeNameCAS);
-      if (typeSystem.subsumes(casStringType, rangeCasType)) {
+      if (rangeCasType instanceof TypeImpl_string) {
         // type is a subtype of string, make its java type = to string
         return "String";
       }
@@ -1053,7 +1050,7 @@ public class Jg {
   // * castResult *
   // *******************************
   String castResult(String resultType, String core) {
-    if ("Ref".equals(sc(resultType)) && resultType != null
+    if ("Feature".equals(sc(resultType)) && resultType != null
             && !resultType.equals("FeatureStructure"))
       return "(" + resultType + ")(" + core + ")";
     return core;
@@ -1063,27 +1060,42 @@ public class Jg {
   // get/setIntValue
   // get/setStringValue String
   // get/setFloatValue float
-  // range = Ref, String, Float, Int
+  // range = Feature, String, Float, Int
 
+  /**
+   * 
+   * @param core string representing the get or set code
+   * @param range Boolean, Byte, Short, Int, Long, Float, Double, String, or Feature
+   * @return -
+   */
   String wrapToGetFS(String core, String range) {
-    if (range.equals("Ref"))
+    if (range.equals("Feature"))
       return "jcasType.ll_cas.ll_getFSForRef(" + core + ")";
     return core;
   }
 
-  String simpleCore(String get_set, String range, String fname, String tname_Type) {
-    
-    
+  /**
+   * 
+   * @param get_set get or set
+   * @param range Boolean, Byte, Short, Int, Long, Float, Double, String, or Feature
+   * @param fname feature name (e.g. "begin"
+   * @param tname_Type _type name 
+   * @return
+   */
+  String simpleCore(String get_set, String range, String fname) {
     String v = ", v";
-    if (get_set.equals("set") && range.equals("Ref"))
-      v = ", jcasType.ll_cas.ll_getFSRef(v)";
-    return "jcasType.ll_cas.ll_" + get_set + range + "Value(addr, ((" + tname_Type
-            + ")jcasType).casFeatCode_" + fname + ((get_set.equals("set")) ? v : "") + ")";
+//    if (get_set.equals("set") && range.equals("Feature"))
+//      v = ", jcasType.ll_cas.ll_getFSRef(v)";
+    boolean isInInt = ! (range.equals("String") || range.equals("Feature") || range.equals("JavaObject"));
+    String chksfx = getCheckSuffix(get_set, range);
+    String featOrOffset = "_FI_" + fname;
+    return "_" + get_set + range + "Value" + chksfx + "(" + featOrOffset  +
+        ((get_set.equals("set")) ? v : "") + ")";
   }
 
   String simpleLLCore(String get_set, String range, String fname) {
     String v = ", v";
-    // if (get_set.equals("set") && range.equals("Ref"))
+    // if (get_set.equals("set") && range.equals("Feature"))
     // v = ", ll_cas.ll_getFSRef(v)";
     return "ll_cas.ll_" + get_set + range + "Value(addr, casFeatCode_" + fname
             + ((get_set.equals("set")) ? v : "") + ")";
@@ -1091,47 +1103,54 @@ public class Jg {
 
   // return string that starts with FS whose value is not an array object, but
   // a normal CAS type, one of whose features is the array object
-  String arrayCore(String get_set, String range, String fname, String tname_Type) {
+  /**
+   * 
+   * @param get_set  get or set
+   * @param range the component range: Boolean, Byte, Short, Int, Long, Float, Double, String, Feature
+   * @param arrayRange: BooleanArray, ByteArray, ShortArray, IntegerArray, LongArray, FloatArray, DoubleArray, StringArray, JavaObjectArray, FSArray  
+   * @param fname
+   * @param tname_Type
+   * @return
+   */
+  String arrayCore(String get_set, String range, String arrayRange, String fname) {
     String v = ", v";
-    if (get_set.equals("set") && range.equals("Ref"))
-      v = ", jcasType.ll_cas.ll_getFSRef(v)";
-    return "jcasType.ll_cas.ll_" + get_set + range + "ArrayValue("
-            + simpleCore("get", "Ref", fname, tname_Type) + ", i"
-            + ((get_set.equals("set")) ? v : "") + ")";
+//    if (get_set.equals("set") && range.equals("Feature"))
+//      v = ", jcasType.ll_cas.ll_getFSRef(v)";
+    return 
+        "((" + arrayRange + ")(" + simpleCore("get", "Feature", fname) + "))." + get_set +
+        "(i" + ((get_set.equals("set")) ? v : "") + ")"; 
   }
 
   String arrayLLCore(String get_set, String range, String fname) {
     String v = ", v";
-    return "ll_cas.ll_" + get_set + range + "ArrayValue(" + simpleLLCore("get", "Ref", fname)
+    return "ll_cas.ll_" + get_set + range + "ArrayValue(" + simpleLLCore("get", "Feature", fname)
             + ", i" + ((get_set.equals("set")) ? v : "") + ")";
   }
 
   String arrayLLCoreChk(String get_set, String range, String fname) {
     String v = ", v";
-    return "ll_cas.ll_" + get_set + range + "ArrayValue(" + simpleLLCore("get", "Ref", fname)
+    return "ll_cas.ll_" + get_set + range + "ArrayValue(" + simpleLLCore("get", "Feature", fname)
             + ", i" + ((get_set.equals("set")) ? v : "") + ", true)";
   }
 
   String getFeatureValue(FeatureDescription fd, TypeDescription td) {
     String getSetNamePart = getGetSetNamePart(fd);
-    String core = wrapToGetFS(simpleCore("get", getSetNamePart, fd.getName(), getJavaName(td)
-            + "_Type"), getSetNamePart);
+    String core = simpleCore("get", getSetNamePart, fd.getName());
     return castResult(getJavaRangeType(fd), core);
   }
 
   String setFeatureValue(FeatureDescription fd, TypeDescription td) {
-    return simpleCore("set", getGetSetNamePart(fd), fd.getName(), getJavaName(td) + "_Type");
+    return simpleCore("set", getGetSetNamePart(fd), fd.getName());
   }
 
   String getArrayFeatureValue(FeatureDescription fd, TypeDescription td) {
     String getSetArrayNamePart = getGetSetArrayNamePart(fd);
-    String core = wrapToGetFS(arrayCore("get", getSetArrayNamePart, fd.getName(), getJavaName(td)
-            + "_Type"), getSetArrayNamePart);
+    String core = arrayCore("get", getSetArrayNamePart, getJavaRangeType(fd), fd.getName());
     return castResult(getJavaRangeArrayElementType(fd), core);
   }
 
   String setArrayFeatureValue(FeatureDescription fd, TypeDescription td) {
-    return arrayCore("set", getGetSetArrayNamePart(fd), fd.getName(), getJavaName(td) + "_Type");
+    return arrayCore("set", getGetSetArrayNamePart(fd), getJavaRangeType(fd), fd.getName());
   }
 
   String getGetSetNamePart(FeatureDescription fd) {
@@ -1188,5 +1207,11 @@ public class Jg {
       return false;
     return true;
   }
+  
+  private String getCheckSuffix(String get_set, String range) {
+    if (get_set.equals("get")) return "Nc";
+    
+    return (range.equals("Feature")) ? "NcWj" : "Nfc";  
+  }
 
 }

Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/javajet/jcasgen/templates/JCasType.javajet
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/javajet/jcasgen/templates/JCasType.javajet?rev=1737041&r1=1737040&r2=1737041&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/javajet/jcasgen/templates/JCasType.javajet (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/javajet/jcasgen/templates/JCasType.javajet Tue Mar 29 20:08:41 2016
@@ -34,9 +34,11 @@ package <%=jg.packageName%>;
 
 import org.apache.uima.cas.impl.CASImpl;
 import org.apache.uima.cas.impl.TypeImpl;
+import org.apache.uima.cas.impl.TypeSystemImpl;
 import org.apache.uima.jcas.JCas; 
 import org.apache.uima.jcas.JCasRegistry;
 
+
 <% for(Iterator i=jg.collectImports(td, false).iterator(); i.hasNext();) { %>
 import <%=(String)i.next()%>;
 <% } %>
@@ -69,7 +71,7 @@ public class <%=typeName%> extends <%=jg
    StringBuilder localData = new StringBuilder();
    StringBuilder featRegistry = new StringBuilder();
     
-   featRegistry.append("  /* Register Features */\n");
+   featRegistry.append("  /* Feature Adjusted Offsets */\n");
    
    for (FeatureDescription fd : td.getFeatures()) { 
 
@@ -88,17 +90,17 @@ public class <%=typeName%> extends <%=jg
      String elemType = jg.getJavaRangeArrayElementType(fd);
      
      localData.append("  private ").append(rangeType).append(" _F_").append(featName).append(";  // ").append(featDescCmt).append('\n');
-     featRegistry.append("  public final static int _FI_").append(featName).append(" = JCasRegistry.registerFeature(typeIndexID);\n");   
+     featRegistry.append("  public final static int _FI_").append(featName).append(" = TypeSystemImpl.getAdjustedFeatureOffset(\"")
+                 .append(featName).append("\");\n");   
       
    } /* of Features iteration */ %>
 
-  /* *****************
-   *    Local Data   *
-   * *****************/ 
+  /* *******************
+   *   Feature Offsets *
+   * *******************/ 
    
 <%=featRegistry%>
    
-<%=localData%> 
   /** Never called.  Disable default constructor
    * @generated */
   protected <%=typeName%>() {/* intentionally empty block */}
@@ -153,22 +155,16 @@ public class <%=typeName%> extends <%=jg
    * @generated
    * @return value of the feature 
    */
-  public <%=rangeType%> get<%=featUName%>() { return _F_<%=featName%>;}
+  public <%=rangeType%> get<%=featUName%>() { return <%=jg.getFeatureValue(fd, td)%>;}
     
   /** setter for <%=featName%> - sets <%=featDescCmt%> 
    * @generated
    * @param v value to set into the feature 
    */
   public void set<%=featUName%>(<%=rangeType%> v) {
-    <%if (jg.isStringSubtype(fd)) {%>
-      _typeImpl.getFeatureByBaseName("<%=featName%>").validateIsInAllowedValue(v);
-    <%}%>
-    <%if (jg.isPossibleIndexKey(fd)) {%>
-      _casView.setWithCheckAndJournalJFRI(this, _FI_<%=featName%>, () -> _F_<%=featName%> = v);
-    <%} else {%> 
-      _casView.setWithJournalJFRI(this, _FI_<%=featName%>, () -> _F_<%=featName%> = v);
-    <%}%>
+    <%=jg.setFeatureValue(fd, td)%>;
   }    
+    
   <%if (jg.hasArrayRange(fd)) {%>
   
   /** indexed getter for <%=featName%> - gets an indexed value - <%=featDescCmt%>
@@ -177,7 +173,7 @@ public class <%=typeName%> extends <%=jg
    * @return value of the element at index i 
    */
   public <%=elemType%> get<%=featUName%>(int i) {
-     return get<%=featUName%>().get(i);} 
+     return <%=jg.getArrayFeatureValue(fd, td)%>;} 
 
   /** indexed setter for <%=featName%> - sets an indexed value - <%=featDescCmt%>
    * @generated
@@ -185,7 +181,8 @@ public class <%=typeName%> extends <%=jg
    * @param v value to set into the array 
    */
   public void set<%=featUName%>(int i, <%=elemType%> v) {
-    get<%=featUName%>().set(i, v);}  
+    <%=jg.setArrayFeatureValue(fd, td)%>;
+  }  
   <% } /* of hasArray */ %>
 <% } /* of Features iteration */ %>
 <% if (td.getName().equals("uima.cas.Annotation")) { %>