You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2007/01/09 17:41:15 UTC

svn commit: r494480 - /incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/Jg.java

Author: schor
Date: Tue Jan  9 08:41:12 2007
New Revision: 494480

URL: http://svn.apache.org/viewvc?view=rev&rev=494480
Log:
UIMA-166 Changed JCasGen so that DocumentAnnotation is not generated
unless it has features beyond the one that is built-in.

Modified:
    incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/Jg.java

Modified: incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/Jg.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/Jg.java?view=diff&rev=494480&r1=494479&r2=494480
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/Jg.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/Jg.java Tue Jan  9 08:41:12 2007
@@ -137,6 +137,7 @@
       Type type = (Type) it.next();
       if (type.isFeatureFinal()) {
         noGenTypes.add(type.getName());
+        continue;
       }
       String typeName = type.getName();
       List fs = type.getFeatures();
@@ -470,6 +471,12 @@
   void generateAllTypes(String outputDirectory, TypeDescription[] tds, CASImpl aCas)
           throws IOException {
     Set generatedBuiltInTypes = new TreeSet();
+
+    this.cas = aCas;
+    this.typeSystem = cas.getTypeSystem();
+    this.casStringType = typeSystem.getType(CAS.TYPE_NAME_STRING);
+    this.tcasAnnotationType = typeSystem.getType(TCAS.TYPE_NAME_ANNOTATION);
+
     for (int i = 0; i < tds.length; i++) {
       TypeDescription td = tds[i];
       // System.out.println("Description: " + td.getDescription() );
@@ -492,16 +499,22 @@
           for (int j = builtInFeatures.length, k = 0; k < newFeaturesSize; j++, k++)
             newFds[j] = (FeatureDescription) newFeatures.get(k);
           td.setFeatures(newFds);
+        } else {
+          // The only built-in type which is extensible is DocumentAnnotation.
+          // If we get here, the user defined DocumentAnnotation, but did not add any features
+          //   In this case, skip generation
+          continue;
         }
       }
-
-      this.cas = aCas;
-      this.typeSystem = cas.getTypeSystem();
-      this.casStringType = typeSystem.getType(CAS.TYPE_NAME_STRING);
-      this.tcasAnnotationType = typeSystem.getType(TCAS.TYPE_NAME_ANNOTATION);
       generateClasses(td, outputDirectory);
     }
 
+    /* 
+     * This code was supposed to generate extendable built-in types that were not 
+     * extended by the input types
+     * But the only extendable built-in type is DocumentAnnotation, and it should
+     * not be generated by default - there's one provided by the framework.
+     * 
     for (Iterator it = extendableBuiltInTypes.entrySet().iterator(); it.hasNext();) {
       Map.Entry entry = (Map.Entry) it.next();
       String typeName = (String) entry.getKey();
@@ -510,6 +523,7 @@
       TypeDescription td = createTdFromType(typeName);
       generateClasses(td, outputDirectory);
     }
+    */
   }
 
   private TypeDescription createTdFromType(String typeName) {