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 2006/12/24 19:48:38 UTC
svn commit: r490058 - in /incubator/uima/uimaj/trunk/uimaj-tools/src/main:
java/org/apache/uima/tools/jcasgen/ org.apache.uima.tools.jcasgen/
org.apache.uima.tools.jcasgen/includedTemplates/
org.apache.uima.tools.jcasgen/templates/
Author: schor
Date: Sun Dec 24 10:48:37 2006
New Revision: 490058
URL: http://svn.apache.org/viewvc?view=rev&rev=490058
Log:
UIMA-141 Added template javajet sources, updated with changes
for Apache licensing.
Added Annotation_Methods.javajet method for low level
get-covered-text.;
added call to this included template in
JCas_Type.javajet template
Replaced bad (previously commented out) version
in uima_core: org.apache.uima.jcas.tcas.Annotation_Type.java.
Added:
incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/
incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/
incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/AnnotationMethods.javajet
incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/Annotation_Methods.javajet
incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/ArrayBoundsChecking.javajet
incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/FeatOkTesting.javajet
incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/FeatOk_Testing.javajet
incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/templates/
incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/templates/JCasType.javajet
incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/templates/JCas_Type.javajet
Modified:
incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/JCasTypeTemplate.java
incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/JCas_TypeTemplate.java
Modified: incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/JCasTypeTemplate.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/JCasTypeTemplate.java?view=diff&rev=490058&r1=490057&r2=490058
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/JCasTypeTemplate.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/JCasTypeTemplate.java Sun Dec 24 10:48:37 2006
@@ -20,9 +20,8 @@
package org.apache.uima.tools.jcasgen;
import java.util.Iterator;
-
-import org.apache.uima.resource.metadata.FeatureDescription;
import org.apache.uima.resource.metadata.TypeDescription;
+import org.apache.uima.resource.metadata.FeatureDescription;
public class JCasTypeTemplate {
@@ -30,31 +29,31 @@
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("\n\n");
- Object[] args = (Object[]) argument;
- Jg jg = (Jg) args[0];
- TypeDescription td = (TypeDescription) args[1];
- jg.packageName = jg.getJavaPkg(td);
+ Object [] args = (Object [])argument;
+ Jg jg = (Jg)args[0];
+ TypeDescription td = (TypeDescription)args[1];
+ jg.packageName = jg.getJavaPkg(td);
stringBuffer.append("/* First created by JCasGen ");
stringBuffer.append(jg.getDate());
stringBuffer.append(" */\n");
- if (0 != jg.packageName.length()) {
- stringBuffer.append("package ");
- stringBuffer.append(jg.packageName);
- stringBuffer.append(";\n");
- } else
- jg.error.newError(IError.WARN, jg.getString("pkgMissing", new Object[] { td.getName() }),
- null);
- stringBuffer
- .append("\nimport org.apache.uima.jcas.impl.JCas; \nimport org.apache.uima.jcas.cas.TOP_Type;\n\n");
- for (Iterator i = jg.collectImports(td, false).iterator(); i.hasNext();) {
- stringBuffer.append("import ");
- stringBuffer.append((String) i.next());
- stringBuffer.append(";\n");
- }
+ if (0 != jg.packageName.length()) {
+ stringBuffer.append("package ");
+ stringBuffer.append(jg.packageName);
+ stringBuffer.append(";\n");
+ }
+ else
+ jg.error.newError(IError.WARN,
+ jg.getString("pkgMissing", new Object[] {td.getName()}), null);
+ stringBuffer.append("\nimport org.apache.uima.jcas.impl.JCas; \nimport org.apache.uima.jcas.cas.TOP_Type;\n\n");
+ for(Iterator i=jg.collectImports(td, false).iterator(); i.hasNext();) {
+ stringBuffer.append("import ");
+ stringBuffer.append((String)i.next());
+ stringBuffer.append(";\n");
+ }
stringBuffer.append("\n\n");
- String typeName = jg.getJavaName(td);
- String typeName_Type = typeName + "_Type";
- String jcasTypeCasted = "((" + typeName_Type + ")jcasType)";
+ String typeName = jg.getJavaName(td);
+ String typeName_Type = typeName + "_Type";
+ String jcasTypeCasted = "((" + typeName_Type + ")jcasType)";
stringBuffer.append("/** ");
stringBuffer.append(jg.nullBlank(td.getDescription()));
@@ -66,156 +65,151 @@
stringBuffer.append(typeName);
stringBuffer.append(" extends ");
stringBuffer.append(jg.getJavaName(td.getSupertypeName()));
- stringBuffer
- .append(" {\n /** @generated\n * @ordered \n */\n public final static int typeIndexID = JCas.getNextIndex();\n /** @generated\n * @ordered \n */\n public final static int type = typeIndexID;\n /** @generated */\n public int getTypeIndexID() {return typeIndexID;}\n \n /** Never called. Disable default constructor\n * @generated */\n protected ");
+ stringBuffer.append(" {\n /** @generated\n * @ordered \n */\n public final static int typeIndexID = JCas.getNextIndex();\n /** @generated\n * @ordered \n */\n public final static int type = typeIndexID;\n /** @generated */\n public int getTypeIndexID() {return typeIndexID;}\n \n /** Never called. Disable default constructor\n * @generated */\n protected ");
stringBuffer.append(typeName);
- stringBuffer
- .append("() {}\n \n /** Internal - constructor used by generator \n * @generated */\n public ");
+ stringBuffer.append("() {}\n \n /** Internal - constructor used by generator \n * @generated */\n public ");
stringBuffer.append(typeName);
- stringBuffer
- .append("(int addr, TOP_Type type) {\n super(addr, type);\n readObject();\n }\n \n /** @generated */\n public ");
+ stringBuffer.append("(int addr, TOP_Type type) {\n super(addr, type);\n readObject();\n }\n \n /** @generated */\n public ");
stringBuffer.append(typeName);
stringBuffer.append("(JCas jcas) {\n super(jcas);\n readObject(); \n } \n");
- if (jg.isSubTypeOfAnnotation(td)) {
- stringBuffer.append(" \n /** @generated */\n public ");
- stringBuffer.append(typeName);
- stringBuffer
- .append("(JCas jcas, int begin, int end) {\n super(jcas);\n setBegin(begin);\n setEnd(end);\n readObject();\n } \n");
- }
- stringBuffer
- .append("\n /** <!-- begin-user-doc -->\n * Write your own initialization here\n * <!-- end-user-doc -->\n @generated modifiable */\n private void readObject() {}\n \n");
- FeatureDescription[] fds = td.getFeatures();
- for (int i = 0; i < fds.length; i++) {
- FeatureDescription fd = fds[i];
-
- String featName = fd.getName();
- String featUName = jg.uc1(featName); // upper case first letter
- if (Jg.reservedFeatureNames.contains(featUName))
- jg.error.newError(IError.ERROR, jg.getString("reservedNameUsed", new Object[] { featName,
- td.getName() }), null);
-
- String featDesc = jg.nullBlank(fd.getDescription());
- String featDescCmt = featDesc;
-
- String rangeType = jg.getJavaRangeType(fd);
- String elemType = jg.getJavaRangeArrayElementType(fd);
-
- stringBuffer.append(" \n \n //*--------------*\n //* Feature: ");
- stringBuffer.append(featName);
- stringBuffer.append("\n\n /** getter for ");
- stringBuffer.append(featName);
- stringBuffer.append(" - gets ");
- stringBuffer.append(featDescCmt);
- stringBuffer.append("\n * @generated */\n public ");
- stringBuffer.append(rangeType);
- stringBuffer.append(" get");
- stringBuffer.append(featUName);
- stringBuffer.append("() {\n ");
- stringBuffer.append("if (");
- stringBuffer.append(typeName_Type);
- stringBuffer.append(".featOkTst && ");
- stringBuffer.append(jcasTypeCasted);
- stringBuffer.append(".casFeat_");
- stringBuffer.append(featName);
- stringBuffer.append(" == null)\n JCas.throwFeatMissing(\"");
- stringBuffer.append(featName);
- stringBuffer.append("\", \"");
- stringBuffer.append(td.getName());
- stringBuffer.append("\");\n");
- stringBuffer.append(" return ");
- stringBuffer.append(jg.getFeatureValue(fd, td));
- stringBuffer.append(";}\n \n /** setter for ");
- stringBuffer.append(featName);
- stringBuffer.append(" - sets ");
- stringBuffer.append(featDescCmt);
- stringBuffer.append(" \n * @generated */\n public void set");
- stringBuffer.append(featUName);
- stringBuffer.append("(");
- stringBuffer.append(rangeType);
- stringBuffer.append(" v) {\n ");
- stringBuffer.append("if (");
- stringBuffer.append(typeName_Type);
- stringBuffer.append(".featOkTst && ");
- stringBuffer.append(jcasTypeCasted);
- stringBuffer.append(".casFeat_");
- stringBuffer.append(featName);
- stringBuffer.append(" == null)\n JCas.throwFeatMissing(\"");
- stringBuffer.append(featName);
- stringBuffer.append("\", \"");
- stringBuffer.append(td.getName());
- stringBuffer.append("\");\n");
- stringBuffer.append(" ");
- stringBuffer.append(jg.setFeatureValue(fd, td));
- stringBuffer.append(";} \n ");
- if (jg.hasArrayRange(fd)) {
- stringBuffer.append(" \n /** indexed getter for ");
- stringBuffer.append(featName);
- stringBuffer.append(" - gets an indexed value - ");
- stringBuffer.append(featDescCmt);
- stringBuffer.append("\n * @generated */\n public ");
- stringBuffer.append(elemType);
- stringBuffer.append(" get");
- stringBuffer.append(featUName);
- stringBuffer.append("(int i) {\n ");
- stringBuffer.append("if (");
- stringBuffer.append(typeName_Type);
- stringBuffer.append(".featOkTst && ");
- stringBuffer.append(jcasTypeCasted);
- stringBuffer.append(".casFeat_");
- stringBuffer.append(featName);
- stringBuffer.append(" == null)\n JCas.throwFeatMissing(\"");
- stringBuffer.append(featName);
- stringBuffer.append("\", \"");
- stringBuffer.append(td.getName());
- stringBuffer.append("\");\n");
- stringBuffer.append(" ");
- stringBuffer.append("jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ");
- stringBuffer.append(jcasTypeCasted);
- stringBuffer.append(".casFeatCode_");
- stringBuffer.append(featName);
- stringBuffer.append("), i);\n");
- stringBuffer.append(" return ");
- stringBuffer.append(jg.getArrayFeatureValue(fd, td));
- stringBuffer.append(";}\n\n /** indexed setter for ");
- stringBuffer.append(featName);
- stringBuffer.append(" - sets an indexed value - ");
- stringBuffer.append(featDescCmt);
- stringBuffer.append("\n * @generated */\n public void set");
- stringBuffer.append(featUName);
- stringBuffer.append("(int i, ");
- stringBuffer.append(elemType);
- stringBuffer.append(" v) { \n ");
- stringBuffer.append("if (");
- stringBuffer.append(typeName_Type);
- stringBuffer.append(".featOkTst && ");
- stringBuffer.append(jcasTypeCasted);
- stringBuffer.append(".casFeat_");
- stringBuffer.append(featName);
- stringBuffer.append(" == null)\n JCas.throwFeatMissing(\"");
- stringBuffer.append(featName);
- stringBuffer.append("\", \"");
- stringBuffer.append(td.getName());
- stringBuffer.append("\");\n");
- stringBuffer.append(" ");
- stringBuffer.append("jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ");
- stringBuffer.append(jcasTypeCasted);
- stringBuffer.append(".casFeatCode_");
- stringBuffer.append(featName);
- stringBuffer.append("), i);\n");
- stringBuffer.append(" ");
- stringBuffer.append(jg.setArrayFeatureValue(fd, td));
- stringBuffer.append(";}\n ");
- } /* of hasArray */
- stringBuffer.append("");
- } /* of Features iteration */
+ if (jg.isSubTypeOfAnnotation(td)) {
+ stringBuffer.append("\n /** @generated */ \n public ");
+ stringBuffer.append(typeName);
+ stringBuffer.append("(JCas jcas, int begin, int end) {\n super(jcas);\n setBegin(begin);\n setEnd(end);\n readObject();\n } \n");
+ }
+ stringBuffer.append("\n /** <!-- begin-user-doc -->\n * Write your own initialization here\n * <!-- end-user-doc -->\n @generated modifiable */\n private void readObject() {}\n \n");
+ FeatureDescription [] fds = td.getFeatures();
+ for (int i = 0; i < fds.length; i++) {
+ FeatureDescription fd = fds[i];
+
+ String featName = fd.getName();
+ String featUName = jg.uc1(featName); // upper case first letter
+ if (Jg.reservedFeatureNames.contains(featUName))
+ jg.error.newError(IError.ERROR,
+ jg.getString("reservedNameUsed", new Object[] { featName, td.getName() }),
+ null);
+
+ String featDesc = jg.nullBlank(fd.getDescription());
+ String featDescCmt = featDesc;
+
+ String rangeType = jg.getJavaRangeType(fd);
+ String elemType = jg.getJavaRangeArrayElementType(fd);
+
+ stringBuffer.append(" \n \n //*--------------*\n //* Feature: ");
+ stringBuffer.append(featName);
+ stringBuffer.append("\n\n /** getter for ");
+ stringBuffer.append(featName);
+ stringBuffer.append(" - gets ");
+ stringBuffer.append(featDescCmt);
+ stringBuffer.append("\n * @generated */\n public ");
+ stringBuffer.append(rangeType);
+ stringBuffer.append(" get");
+ stringBuffer.append(featUName);
+ stringBuffer.append("() {\n ");
+ stringBuffer.append("if (");
+ stringBuffer.append(typeName_Type);
+ stringBuffer.append(".featOkTst && ");
+ stringBuffer.append(jcasTypeCasted);
+ stringBuffer.append(".casFeat_");
+ stringBuffer.append(featName);
+ stringBuffer.append(" == null)\n JCas.throwFeatMissing(\"");
+ stringBuffer.append(featName);
+ stringBuffer.append("\", \"");
+ stringBuffer.append(td.getName());
+ stringBuffer.append("\");\n");
+ stringBuffer.append(" return ");
+ stringBuffer.append(jg.getFeatureValue(fd, td));
+ stringBuffer.append(";}\n \n /** setter for ");
+ stringBuffer.append(featName);
+ stringBuffer.append(" - sets ");
+ stringBuffer.append(featDescCmt);
+ stringBuffer.append(" \n * @generated */\n public void set");
+ stringBuffer.append(featUName);
+ stringBuffer.append("(");
+ stringBuffer.append(rangeType);
+ stringBuffer.append(" v) {\n ");
+ stringBuffer.append("if (");
+ stringBuffer.append(typeName_Type);
+ stringBuffer.append(".featOkTst && ");
+ stringBuffer.append(jcasTypeCasted);
+ stringBuffer.append(".casFeat_");
+ stringBuffer.append(featName);
+ stringBuffer.append(" == null)\n JCas.throwFeatMissing(\"");
+ stringBuffer.append(featName);
+ stringBuffer.append("\", \"");
+ stringBuffer.append(td.getName());
+ stringBuffer.append("\");\n");
+ stringBuffer.append(" ");
+ stringBuffer.append(jg.setFeatureValue(fd, td));
+ stringBuffer.append(";} \n ");
+ if (jg.hasArrayRange(fd)) {
+ stringBuffer.append(" \n /** indexed getter for ");
+ stringBuffer.append(featName);
+ stringBuffer.append(" - gets an indexed value - ");
+ stringBuffer.append(featDescCmt);
+ stringBuffer.append("\n * @generated */\n public ");
+ stringBuffer.append(elemType);
+ stringBuffer.append(" get");
+ stringBuffer.append(featUName);
+ stringBuffer.append("(int i) {\n ");
+ stringBuffer.append("if (");
+ stringBuffer.append(typeName_Type);
+ stringBuffer.append(".featOkTst && ");
+ stringBuffer.append(jcasTypeCasted);
+ stringBuffer.append(".casFeat_");
+ stringBuffer.append(featName);
+ stringBuffer.append(" == null)\n JCas.throwFeatMissing(\"");
+ stringBuffer.append(featName);
+ stringBuffer.append("\", \"");
+ stringBuffer.append(td.getName());
+ stringBuffer.append("\");\n");
+ stringBuffer.append(" ");
+ stringBuffer.append("jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ");
+ stringBuffer.append(jcasTypeCasted);
+ stringBuffer.append(".casFeatCode_");
+ stringBuffer.append(featName);
+ stringBuffer.append("), i);\n");
+ stringBuffer.append(" return ");
+ stringBuffer.append(jg.getArrayFeatureValue(fd, td));
+ stringBuffer.append(";}\n\n /** indexed setter for ");
+ stringBuffer.append(featName);
+ stringBuffer.append(" - sets an indexed value - ");
+ stringBuffer.append(featDescCmt);
+ stringBuffer.append("\n * @generated */\n public void set");
+ stringBuffer.append(featUName);
+ stringBuffer.append("(int i, ");
+ stringBuffer.append(elemType);
+ stringBuffer.append(" v) { \n ");
+ stringBuffer.append("if (");
+ stringBuffer.append(typeName_Type);
+ stringBuffer.append(".featOkTst && ");
+ stringBuffer.append(jcasTypeCasted);
+ stringBuffer.append(".casFeat_");
+ stringBuffer.append(featName);
+ stringBuffer.append(" == null)\n JCas.throwFeatMissing(\"");
+ stringBuffer.append(featName);
+ stringBuffer.append("\", \"");
+ stringBuffer.append(td.getName());
+ stringBuffer.append("\");\n");
+ stringBuffer.append(" ");
+ stringBuffer.append("jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ");
+ stringBuffer.append(jcasTypeCasted);
+ stringBuffer.append(".casFeatCode_");
+ stringBuffer.append(featName);
+ stringBuffer.append("), i);\n");
+ stringBuffer.append(" ");
+ stringBuffer.append(jg.setArrayFeatureValue(fd, td));
+ stringBuffer.append(";}\n ");
+ } /* of hasArray */
+ stringBuffer.append("");
+ } /* of Features iteration */
+ stringBuffer.append("");
+ if (td.getName().equals("uima.cas.Annotation")) {
+ stringBuffer.append(" ");
+ stringBuffer.append(" /** Constructor with begin and end passed as arguments \n * @generated */\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 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 public int getStart() {return getBegin();}\n \n /** @see org.apache.uima.cas.text.AnnotationFS#getCoveredText() \n * @generated */ \n public String getCoveredText(int inst) { \n final TCASImpl tcasImpl = (TCASImpl) casImpl; \n final String text = tcasImpl.getDocumentText(); \n if (text == null) \n return null; \n return text.s
ubstring(getBegin(inst), getEnd(inst)); \n }\n");
stringBuffer.append("");
- if (td.getName().equals("uima.cas.Annotation")) {
- stringBuffer.append(" ");
- stringBuffer
- .append(" /** Constructor with begin and end passed as arguments \n * @generated */\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 public String getCoveredText() { \n final TCASImpl tcasImpl = (TCASImpl)jcasType.casImpl; \n String text = tcasImpl.getDocumentText(); \n if (text == null) \n return null; \n return text.substring(getBegin(), getEnd()); \n } \n \n /** @deprecated \n * @generated */\n public int getStart() {return getBegin();}\n \n /** @see org.apache.uima.cas.text.AnnotationFS#getCoveredText() \n * @generated */ \n public String getCoveredText(int inst) { \n final TCASImpl tcasImpl = (TCASImpl) casImpl; \n final String text = tcasImpl.getDocumentText(); \n if (text == null) \n return null; \n return text.substring(g
etBegin(inst), getEnd(inst)); \n }\n");
- stringBuffer.append("");
- } /* of Annotation if-statement */
+ } /* of Annotation if-statement */
stringBuffer.append("}\n\n ");
return stringBuffer.toString();
}
-}
+}
\ No newline at end of file
Modified: incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/JCas_TypeTemplate.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/JCas_TypeTemplate.java?view=diff&rev=490058&r1=490057&r2=490058
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/JCas_TypeTemplate.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-tools/src/main/java/org/apache/uima/tools/jcasgen/JCas_TypeTemplate.java Sun Dec 24 10:48:37 2006
@@ -20,9 +20,8 @@
package org.apache.uima.tools.jcasgen;
import java.util.Iterator;
-
-import org.apache.uima.resource.metadata.FeatureDescription;
import org.apache.uima.resource.metadata.TypeDescription;
+import org.apache.uima.resource.metadata.FeatureDescription;
public class JCas_TypeTemplate {
@@ -30,37 +29,34 @@
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("\n");
-
- Object[] args = (Object[]) argument;
- Jg jg = (Jg) args[0];
- TypeDescription td = (TypeDescription) args[1];
- jg.packageName = jg.getJavaPkg(td);
+
+ Object [] args = (Object [])argument;
+ Jg jg = (Jg)args[0];
+ TypeDescription td = (TypeDescription)args[1];
+ jg.packageName = jg.getJavaPkg(td);
stringBuffer.append("/* First created by JCasGen ");
stringBuffer.append(jg.getDate());
stringBuffer.append(" */\n");
- if (0 != jg.packageName.length()) {
- stringBuffer.append("package ");
- stringBuffer.append(jg.packageName);
- stringBuffer.append(";\n");
- }
- stringBuffer
- .append("\nimport org.apache.uima.jcas.impl.JCas;\nimport org.apache.uima.cas.impl.CASImpl;\nimport org.apache.uima.cas.impl.FSGenerator;\nimport org.apache.uima.cas.FeatureStructure;\nimport org.apache.uima.cas.impl.TypeImpl;\nimport org.apache.uima.cas.Type;\n");
- if (td.getFeatures().length > 0) {
- stringBuffer
- .append("import org.apache.uima.cas.impl.FeatureImpl;\nimport org.apache.uima.cas.Feature;\n");
- }
- stringBuffer.append("");
- for (Iterator i = jg.collectImports(td, true).iterator(); i.hasNext();) {
- String imp = (String) i.next();
- if (!imp.equals(jg.getJavaNameWithPkg(td.getName() + "_Type"))) {
- stringBuffer.append("import ");
- stringBuffer.append(imp);
- stringBuffer.append(";\n");
- }
- }
+ if (0 != jg.packageName.length()) {
+ stringBuffer.append("package ");
+ stringBuffer.append(jg.packageName);
+ stringBuffer.append(";\n");
+ }
+ stringBuffer.append("\nimport org.apache.uima.jcas.impl.JCas;\nimport org.apache.uima.cas.impl.CASImpl;\nimport org.apache.uima.cas.impl.FSGenerator;\nimport org.apache.uima.cas.FeatureStructure;\nimport org.apache.uima.cas.impl.TypeImpl;\nimport org.apache.uima.cas.Type;\n");
+ if (td.getFeatures().length > 0) {
+ stringBuffer.append("import org.apache.uima.cas.impl.FeatureImpl;\nimport org.apache.uima.cas.Feature;\n");
+ }
+ stringBuffer.append("");
+ for(Iterator i=jg.collectImports(td, true).iterator(); i.hasNext();) {
+ String imp = (String)i.next();
+ if (!imp.equals(jg.getJavaNameWithPkg(td.getName()+"_Type"))) {
+ stringBuffer.append("import ");
+ stringBuffer.append(imp);
+ stringBuffer.append(";\n");
+ }}
stringBuffer.append("\n");
- String typeName = jg.getJavaName(td);
- String typeName_Type = typeName + "_Type";
+ String typeName = jg.getJavaName(td);
+ String typeName_Type = typeName + "_Type";
stringBuffer.append("/** ");
stringBuffer.append(jg.nullBlank(td.getDescription()));
stringBuffer.append("\n * Updated by JCasGen ");
@@ -69,177 +65,174 @@
stringBuffer.append(typeName_Type);
stringBuffer.append(" extends ");
stringBuffer.append(jg.getJavaName(td.getSupertypeName()) + "_Type");
- stringBuffer
- .append(" {\n /** @generated */\n protected FSGenerator getFSGenerator() {return fsGenerator;}\n /** @generated */\n private final FSGenerator fsGenerator = \n new FSGenerator() {\n public FeatureStructure createFS(int addr, CASImpl cas) {\n if (");
+ stringBuffer.append(" {\n /** @generated */\n protected FSGenerator getFSGenerator() {return fsGenerator;}\n /** @generated */\n private final FSGenerator fsGenerator = \n new FSGenerator() {\n public FeatureStructure createFS(int addr, CASImpl cas) {\n if (");
stringBuffer.append(typeName_Type);
- stringBuffer
- .append(".this.useExistingInstance) {\n // Return eq fs instance if already created\n FeatureStructure fs = ");
+ stringBuffer.append(".this.useExistingInstance) {\n // Return eq fs instance if already created\n FeatureStructure fs = ");
stringBuffer.append(typeName_Type);
- stringBuffer
- .append(".this.jcas.getJfsFromCaddr(addr);\n if (null == fs) {\n fs = new ");
+ stringBuffer.append(".this.jcas.getJfsFromCaddr(addr);\n if (null == fs) {\n fs = new ");
stringBuffer.append(typeName);
stringBuffer.append("(addr, ");
stringBuffer.append(typeName_Type);
stringBuffer.append(".this);\n ");
stringBuffer.append(typeName_Type);
- stringBuffer
- .append(".this.jcas.putJfsFromCaddr(addr, fs);\n return fs;\n }\n return fs;\n } else return new ");
+ stringBuffer.append(".this.jcas.putJfsFromCaddr(addr, fs);\n return fs;\n }\n return fs;\n } else return new ");
stringBuffer.append(typeName);
stringBuffer.append("(addr, ");
stringBuffer.append(typeName_Type);
- stringBuffer
- .append(".this);\n }\n };\n /** @generated */\n public final static int typeIndexID = ");
+ stringBuffer.append(".this);\n }\n };\n /** @generated */\n public final static int typeIndexID = ");
stringBuffer.append(typeName);
- stringBuffer
- .append(".typeIndexID;\n /** @generated \n @modifiable */\n public final static boolean featOkTst = JCas.getFeatOkTst(\"");
+ stringBuffer.append(".typeIndexID;\n /** @generated \n @modifiable */\n public final static boolean featOkTst = JCas.getFeatOkTst(\"");
+ stringBuffer.append(td.getName());
+ stringBuffer.append("\");\n");
+ FeatureDescription [] fds = td.getFeatures();
+ for (int i = 0; i < fds.length; i++) {
+ FeatureDescription fd = fds[i];
+
+ String featName = fd.getName();
+ String featUName = jg.uc1(featName); // upper case first letter
+
+ String rangeType = jg.getJavaRangeType(fd);
+ String getSetNamePart = jg.sc(rangeType);
+ String returnType = getSetNamePart.equals("Ref") ? "int" : rangeType;
+ String getSetArrayNamePart = jg.getGetSetArrayNamePart(fd);
+
+ String elemType = jg.getJavaRangeArrayElementType(fd);
+ if (jg.sc(elemType).equals("Ref"))
+ elemType = "int";
+ String casFeatCode = "casFeatCode_" + featName;
+
+ stringBuffer.append(" \n /** @generated */\n final Feature casFeat_");
+ stringBuffer.append(featName);
+ stringBuffer.append(";\n /** @generated */\n final int ");
+ stringBuffer.append(casFeatCode);
+ stringBuffer.append(";\n /** @generated */ \n public ");
+ stringBuffer.append(returnType);
+ stringBuffer.append(" get");
+ stringBuffer.append(featUName);
+ stringBuffer.append("(int addr) {\n ");
+ stringBuffer.append("");
+
+/* checks to insure that cas has the feature */
+
+ stringBuffer.append(" if (featOkTst && casFeat_");
+ stringBuffer.append(featName);
+ stringBuffer.append(" == null)\n JCas.throwFeatMissing(\"");
+ stringBuffer.append(featName);
+ stringBuffer.append("\", \"");
+ stringBuffer.append(td.getName());
+ stringBuffer.append("\");\n");
+ stringBuffer.append(" return ll_cas.ll_get");
+ stringBuffer.append(getSetNamePart);
+ stringBuffer.append("Value(addr, ");
+ stringBuffer.append(casFeatCode);
+ stringBuffer.append(");\n }\n /** @generated */ \n public void set");
+ stringBuffer.append(featUName);
+ stringBuffer.append("(int addr, ");
+ stringBuffer.append(returnType);
+ stringBuffer.append(" v) {\n ");
+ stringBuffer.append("");
+
+/* checks to insure that cas has the feature */
+
+ stringBuffer.append(" if (featOkTst && casFeat_");
+ stringBuffer.append(featName);
+ stringBuffer.append(" == null)\n JCas.throwFeatMissing(\"");
+ stringBuffer.append(featName);
+ stringBuffer.append("\", \"");
+ stringBuffer.append(td.getName());
+ stringBuffer.append("\");\n");
+ stringBuffer.append(" ll_cas.ll_set");
+ stringBuffer.append(getSetNamePart);
+ stringBuffer.append("Value(addr, ");
+ stringBuffer.append(casFeatCode);
+ stringBuffer.append(", v);}\n \n ");
+ if (jg.hasArrayRange(fd)) {
+ stringBuffer.append(" /** @generated */\n public ");
+ stringBuffer.append(elemType);
+ stringBuffer.append(" get");
+ stringBuffer.append(featUName);
+ stringBuffer.append("(int addr, int i) {\n ");
+ stringBuffer.append("");
+
+/* checks to insure that cas has the feature */
+
+ stringBuffer.append(" if (featOkTst && casFeat_");
+ stringBuffer.append(featName);
+ stringBuffer.append(" == null)\n JCas.throwFeatMissing(\"");
+ stringBuffer.append(featName);
+ stringBuffer.append("\", \"");
+ stringBuffer.append(td.getName());
+ stringBuffer.append("\");\n");
+ stringBuffer.append(" if (lowLevelTypeChecks)\n return ll_cas.ll_get");
+ stringBuffer.append(getSetArrayNamePart);
+ stringBuffer.append("ArrayValue(ll_cas.ll_getRefValue(addr, ");
+ stringBuffer.append(casFeatCode);
+ stringBuffer.append("), i, true);\n jcas.checkArrayBounds(ll_cas.ll_getRefValue(addr, ");
+ stringBuffer.append(casFeatCode);
+ stringBuffer.append("), i);\n return ll_cas.ll_get");
+ stringBuffer.append(getSetArrayNamePart);
+ stringBuffer.append("ArrayValue(ll_cas.ll_getRefValue(addr, ");
+ stringBuffer.append(casFeatCode);
+ stringBuffer.append("), i);\n }\n \n /** @generated */ \n public void set");
+ stringBuffer.append(featUName);
+ stringBuffer.append("(int addr, int i, ");
+ stringBuffer.append(elemType);
+ stringBuffer.append(" v) {\n ");
+ stringBuffer.append("");
+
+/* checks to insure that cas has the feature */
+
+ stringBuffer.append(" if (featOkTst && casFeat_");
+ stringBuffer.append(featName);
+ stringBuffer.append(" == null)\n JCas.throwFeatMissing(\"");
+ stringBuffer.append(featName);
+ stringBuffer.append("\", \"");
stringBuffer.append(td.getName());
stringBuffer.append("\");\n");
- FeatureDescription[] fds = td.getFeatures();
- for (int i = 0; i < fds.length; i++) {
- FeatureDescription fd = fds[i];
-
- String featName = fd.getName();
- String featUName = jg.uc1(featName); // upper case first letter
-
- String rangeType = jg.getJavaRangeType(fd);
- String getSetNamePart = jg.sc(rangeType);
- String returnType = getSetNamePart.equals("Ref") ? "int" : rangeType;
- String getSetArrayNamePart = jg.getGetSetArrayNamePart(fd);
-
- String elemType = jg.getJavaRangeArrayElementType(fd);
- if (jg.sc(elemType).equals("Ref"))
- elemType = "int";
- String casFeatCode = "casFeatCode_" + featName;
-
- stringBuffer.append(" \n /** @generated */\n final Feature casFeat_");
- stringBuffer.append(featName);
- stringBuffer.append(";\n /** @generated */\n final int ");
- stringBuffer.append(casFeatCode);
- stringBuffer.append(";\n /** @generated */ \n public ");
- stringBuffer.append(returnType);
- stringBuffer.append(" get");
- stringBuffer.append(featUName);
- stringBuffer.append("(int addr) {\n ");
- stringBuffer.append("");
-
- /* checks to insure that cas has the feature */
-
- stringBuffer.append(" if (featOkTst && casFeat_");
- stringBuffer.append(featName);
- stringBuffer.append(" == null)\n JCas.throwFeatMissing(\"");
- stringBuffer.append(featName);
- stringBuffer.append("\", \"");
- stringBuffer.append(td.getName());
- stringBuffer.append("\");\n");
- stringBuffer.append(" return ll_cas.ll_get");
- stringBuffer.append(getSetNamePart);
- stringBuffer.append("Value(addr, ");
- stringBuffer.append(casFeatCode);
- stringBuffer.append(");\n }\n /** @generated */ \n public void set");
- stringBuffer.append(featUName);
- stringBuffer.append("(int addr, ");
- stringBuffer.append(returnType);
- stringBuffer.append(" v) {\n ");
- stringBuffer.append("");
-
- /* checks to insure that cas has the feature */
-
- stringBuffer.append(" if (featOkTst && casFeat_");
- stringBuffer.append(featName);
- stringBuffer.append(" == null)\n JCas.throwFeatMissing(\"");
- stringBuffer.append(featName);
- stringBuffer.append("\", \"");
- stringBuffer.append(td.getName());
- stringBuffer.append("\");\n");
- stringBuffer.append(" ll_cas.ll_set");
- stringBuffer.append(getSetNamePart);
- stringBuffer.append("Value(addr, ");
- stringBuffer.append(casFeatCode);
- stringBuffer.append(", v);}\n \n ");
- if (jg.hasArrayRange(fd)) {
- stringBuffer.append(" /** @generated */\n public ");
- stringBuffer.append(elemType);
- stringBuffer.append(" get");
- stringBuffer.append(featUName);
- stringBuffer.append("(int addr, int i) {\n ");
- stringBuffer.append("");
-
- /* checks to insure that cas has the feature */
-
- stringBuffer.append(" if (featOkTst && casFeat_");
- stringBuffer.append(featName);
- stringBuffer.append(" == null)\n JCas.throwFeatMissing(\"");
- stringBuffer.append(featName);
- stringBuffer.append("\", \"");
- stringBuffer.append(td.getName());
- stringBuffer.append("\");\n");
- stringBuffer.append(" if (lowLevelTypeChecks)\n return ll_cas.ll_get");
- stringBuffer.append(getSetArrayNamePart);
- stringBuffer.append("ArrayValue(ll_cas.ll_getRefValue(addr, ");
- stringBuffer.append(casFeatCode);
- stringBuffer.append("), i, true);\n jcas.checkArrayBounds(ll_cas.ll_getRefValue(addr, ");
- stringBuffer.append(casFeatCode);
- stringBuffer.append("), i);\n return ll_cas.ll_get");
- stringBuffer.append(getSetArrayNamePart);
- stringBuffer.append("ArrayValue(ll_cas.ll_getRefValue(addr, ");
- stringBuffer.append(casFeatCode);
- stringBuffer.append("), i);\n }\n \n /** @generated */ \n public void set");
- stringBuffer.append(featUName);
- stringBuffer.append("(int addr, int i, ");
- stringBuffer.append(elemType);
- stringBuffer.append(" v) {\n ");
- stringBuffer.append("");
-
- /* checks to insure that cas has the feature */
-
- stringBuffer.append(" if (featOkTst && casFeat_");
- stringBuffer.append(featName);
- stringBuffer.append(" == null)\n JCas.throwFeatMissing(\"");
- stringBuffer.append(featName);
- stringBuffer.append("\", \"");
- stringBuffer.append(td.getName());
- stringBuffer.append("\");\n");
- stringBuffer.append(" if (lowLevelTypeChecks)\n ll_cas.ll_set");
- stringBuffer.append(getSetArrayNamePart);
- stringBuffer.append("ArrayValue(ll_cas.ll_getRefValue(addr, ");
- stringBuffer.append(casFeatCode);
- stringBuffer
- .append("), i, v, true);\n jcas.checkArrayBounds(ll_cas.ll_getRefValue(addr, ");
- stringBuffer.append(casFeatCode);
- stringBuffer.append("), i);\n ll_cas.ll_set");
- stringBuffer.append(getSetArrayNamePart);
- stringBuffer.append("ArrayValue(ll_cas.ll_getRefValue(addr, ");
- stringBuffer.append(casFeatCode);
- stringBuffer.append("), i, v);\n }\n");
- }
- stringBuffer.append(" \n");
- }
- stringBuffer
- .append("\n\n /** initialize variables to correspond with Cas Type and Features\n * @generated */\n public ");
- stringBuffer.append(typeName_Type);
- stringBuffer
- .append("(JCas jcas, Type casType) {\n super(jcas, casType);\n casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());\n\n");
- for (int i = 0; i < fds.length; i++) {
- FeatureDescription fd = fds[i];
-
- String featName = fd.getName();
-
- stringBuffer.append(" \n casFeat_");
- stringBuffer.append(featName);
- stringBuffer.append(" = jcas.getRequiredFeatureDE(casType, \"");
- stringBuffer.append(featName);
- stringBuffer.append("\", \"");
- stringBuffer.append(fd.getRangeTypeName());
- stringBuffer.append("\", featOkTst);\n casFeatCode_");
- stringBuffer.append(featName);
- stringBuffer.append(" = (null == casFeat_");
- stringBuffer.append(featName);
- stringBuffer.append(") ? JCas.INVALID_FEATURE_CODE : ((FeatureImpl)casFeat_");
- stringBuffer.append(featName);
- stringBuffer.append(").getCode();\n\n");
- }
- stringBuffer.append(" }\n}\n");
- stringBuffer.append("\n\n\n ");
+ stringBuffer.append(" if (lowLevelTypeChecks)\n ll_cas.ll_set");
+ stringBuffer.append(getSetArrayNamePart);
+ stringBuffer.append("ArrayValue(ll_cas.ll_getRefValue(addr, ");
+ stringBuffer.append(casFeatCode);
+ stringBuffer.append("), i, v, true);\n jcas.checkArrayBounds(ll_cas.ll_getRefValue(addr, ");
+ stringBuffer.append(casFeatCode);
+ stringBuffer.append("), i);\n ll_cas.ll_set");
+ stringBuffer.append(getSetArrayNamePart);
+ stringBuffer.append("ArrayValue(ll_cas.ll_getRefValue(addr, ");
+ stringBuffer.append(casFeatCode);
+ stringBuffer.append("), i, v);\n }\n");
+ }
+ stringBuffer.append(" \n");
+ }
+ stringBuffer.append("\n");
+ if (td.getName().equals("uima.cas.Annotation")) {
+ stringBuffer.append(" ");
+ stringBuffer.append(" /** @see org.apache.uima.cas.text.AnnotationFS#getCoveredText() \n * @generated */ \n public String getCoveredText(int inst) { \n final CASImpl casView = ll_cas.ll_getSofaCasView(inst);\n final String text = casView.getDocumentText();\n if (text == null) {\n return null;\n }\n return text.substring(getBegin(inst), getEnd(inst)); \n }\n");
+ stringBuffer.append("");
+ } /* of Annotation if-statement */
+ stringBuffer.append("\n\n /** initialize variables to correspond with Cas Type and Features\n * @generated */\n public ");
+ stringBuffer.append(typeName_Type);
+ stringBuffer.append("(JCas jcas, Type casType) {\n super(jcas, casType);\n casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());\n\n");
+ for (int i = 0; i < fds.length; i++) {
+ FeatureDescription fd = fds[i];
+
+ String featName = fd.getName();
+
+
+ stringBuffer.append(" \n casFeat_");
+ stringBuffer.append(featName);
+ stringBuffer.append(" = jcas.getRequiredFeatureDE(casType, \"");
+ stringBuffer.append(featName);
+ stringBuffer.append("\", \"");
+ stringBuffer.append(fd.getRangeTypeName());
+ stringBuffer.append("\", featOkTst);\n casFeatCode_");
+ stringBuffer.append(featName);
+ stringBuffer.append(" = (null == casFeat_");
+ stringBuffer.append(featName);
+ stringBuffer.append(") ? JCas.INVALID_FEATURE_CODE : ((FeatureImpl)casFeat_");
+ stringBuffer.append(featName);
+ stringBuffer.append(").getCode();\n\n");
+ }
+ stringBuffer.append(" }\n}\n\n\n\n ");
return stringBuffer.toString();
}
-}
+}
\ No newline at end of file
Added: incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/AnnotationMethods.javajet
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/AnnotationMethods.javajet?view=auto&rev=490058
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/AnnotationMethods.javajet (added)
+++ incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/AnnotationMethods.javajet Sun Dec 24 10:48:37 2006
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+ /** Constructor with begin and end passed as arguments
+ * @generated */
+ public Annotation(JCas jcas, int begin, int end) {
+ this(jcas); // forward to constructor
+ this.setBegin(begin);
+ this.setEnd(end);
+ }
+
+ /** @see org.apache.uima.cas.text.AnnotationFS#getCoveredText()
+ * @generated */
+ public String getCoveredText() {
+ final CAS casView = this.getView();
+ final String text = casView.getDocumentText();
+ if (text == null) {
+ return null;
+ }
+ return text.substring(getBegin(), getEnd());
+ }
+
+ /** @deprecated
+ * @generated */
+ public int getStart() {return getBegin();}
+
+ /** @see org.apache.uima.cas.text.AnnotationFS#getCoveredText()
+ * @generated */
+ public String getCoveredText(int inst) {
+ final TCASImpl tcasImpl = (TCASImpl) casImpl;
+ final String text = tcasImpl.getDocumentText();
+ if (text == null)
+ return null;
+ return text.substring(getBegin(inst), getEnd(inst));
+ }
Added: incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/Annotation_Methods.javajet
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/Annotation_Methods.javajet?view=auto&rev=490058
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/Annotation_Methods.javajet (added)
+++ incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/Annotation_Methods.javajet Sun Dec 24 10:48:37 2006
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+ /** @see org.apache.uima.cas.text.AnnotationFS#getCoveredText()
+ * @generated */
+ public String getCoveredText(int inst) {
+ final CASImpl casView = ll_cas.ll_getSofaCasView(inst);
+ final String text = casView.getDocumentText();
+ if (text == null) {
+ return null;
+ }
+ return text.substring(getBegin(inst), getEnd(inst));
+ }
Added: incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/ArrayBoundsChecking.javajet
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/ArrayBoundsChecking.javajet?view=auto&rev=490058
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/ArrayBoundsChecking.javajet (added)
+++ incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/ArrayBoundsChecking.javajet Sun Dec 24 10:48:37 2006
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, <%=jcasTypeCasted%>.casFeatCode_<%=featName%>), i);
Added: incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/FeatOkTesting.javajet
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/FeatOkTesting.javajet?view=auto&rev=490058
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/FeatOkTesting.javajet (added)
+++ incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/FeatOkTesting.javajet Sun Dec 24 10:48:37 2006
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+if (<%=typeName_Type%>.featOkTst && <%=jcasTypeCasted%>.casFeat_<%=featName%> == null)
+ JCas.throwFeatMissing("<%=featName%>", "<%=td.getName()%>");
Added: incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/FeatOk_Testing.javajet
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/FeatOk_Testing.javajet?view=auto&rev=490058
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/FeatOk_Testing.javajet (added)
+++ incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/includedTemplates/FeatOk_Testing.javajet Sun Dec 24 10:48:37 2006
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+<%
+/* checks to insure that cas has the feature */
+%>
+ if (featOkTst && casFeat_<%=featName%> == null)
+ JCas.throwFeatMissing("<%=featName%>", "<%=td.getName()%>");
Added: incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/templates/JCasType.javajet
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/templates/JCasType.javajet?view=auto&rev=490058
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/templates/JCasType.javajet (added)
+++ incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/templates/JCasType.javajet Sun Dec 24 10:48:37 2006
@@ -0,0 +1,148 @@
+/*
+ * 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.
+ */
+<%@ jet package="org.apache.uima.tools.jcasgen" imports="java.util.Iterator org.apache.uima.resource.metadata.TypeDescription org.apache.uima.resource.metadata.FeatureDescription" class="JCasTypeTemplate" %>
+
+<% Object [] args = (Object [])argument;
+ Jg jg = (Jg)args[0];
+ TypeDescription td = (TypeDescription)args[1];
+ jg.packageName = jg.getJavaPkg(td); %>
+/* First created by JCasGen <%=jg.getDate()%> */
+<% if (0 != jg.packageName.length()) {%>
+package <%=jg.packageName%>;
+<% }
+ else
+ jg.error.newError(IError.WARN,
+ jg.getString("pkgMissing", new Object[] {td.getName()}), null); %>
+
+import org.apache.uima.jcas.impl.JCas;
+import org.apache.uima.jcas.cas.TOP_Type;
+
+<% for(Iterator i=jg.collectImports(td, false).iterator(); i.hasNext();) { %>
+import <%=(String)i.next()%>;
+<% } %>
+
+
+<% String typeName = jg.getJavaName(td);
+ String typeName_Type = typeName + "_Type";
+ String jcasTypeCasted = "((" + typeName_Type + ")jcasType)";
+%>
+/** <%=jg.nullBlank(td.getDescription())%>
+ * Updated by JCasGen <%=jg.getDate()%>
+ * XML source: <%=jg.xmlSourceFileName%>
+ * @generated */
+public class <%=typeName%> extends <%=jg.getJavaName(td.getSupertypeName())%> {
+ /** @generated
+ * @ordered
+ */
+ public final static int typeIndexID = JCas.getNextIndex();
+ /** @generated
+ * @ordered
+ */
+ public final static int type = typeIndexID;
+ /** @generated */
+ public int getTypeIndexID() {return typeIndexID;}
+
+ /** Never called. Disable default constructor
+ * @generated */
+ protected <%=typeName%>() {}
+
+ /** Internal - constructor used by generator
+ * @generated */
+ public <%=typeName%>(int addr, TOP_Type type) {
+ super(addr, type);
+ readObject();
+ }
+
+ /** @generated */
+ public <%=typeName%>(JCas jcas) {
+ super(jcas);
+ readObject();
+ }
+<%if (jg.isSubTypeOfAnnotation(td)) { %>
+
+ /** @generated */
+ public <%=typeName%>(JCas jcas, int begin, int end) {
+ super(jcas);
+ setBegin(begin);
+ setEnd(end);
+ readObject();
+ }
+<%} %>
+
+ /** <!-- begin-user-doc -->
+ * Write your own initialization here
+ * <!-- end-user-doc -->
+ @generated modifiable */
+ private void readObject() {}
+
+<% FeatureDescription [] fds = td.getFeatures();
+ for (int i = 0; i < fds.length; i++) {
+ FeatureDescription fd = fds[i];
+
+ String featName = fd.getName();
+ String featUName = jg.uc1(featName); // upper case first letter
+ if (Jg.reservedFeatureNames.contains(featUName))
+ jg.error.newError(IError.ERROR,
+ jg.getString("reservedNameUsed", new Object[] { featName, td.getName() }),
+ null);
+
+ String featDesc = jg.nullBlank(fd.getDescription());
+ String featDescCmt = featDesc;
+
+ String rangeType = jg.getJavaRangeType(fd);
+ String elemType = jg.getJavaRangeArrayElementType(fd);
+%>
+
+ //*--------------*
+ //* Feature: <%=featName%>
+
+ /** getter for <%=featName%> - gets <%=featDescCmt%>
+ * @generated */
+ public <%=rangeType%> get<%=featUName%>() {
+ <%@ include file="../includedTemplates/FeatOkTesting.javajet"%>
+ return <%=jg.getFeatureValue(fd, td)%>;}
+
+ /** setter for <%=featName%> - sets <%=featDescCmt%>
+ * @generated */
+ public void set<%=featUName%>(<%=rangeType%> v) {
+ <%@ include file="../includedTemplates/FeatOkTesting.javajet"%>
+ <%=jg.setFeatureValue(fd, td)%>;}
+ <%if (jg.hasArrayRange(fd)) {%>
+
+ /** indexed getter for <%=featName%> - gets an indexed value - <%=featDescCmt%>
+ * @generated */
+ public <%=elemType%> get<%=featUName%>(int i) {
+ <%@ include file="../includedTemplates/FeatOkTesting.javajet"%>
+ <%@ include file="../includedTemplates/ArrayBoundsChecking.javajet"%>
+ return <%=jg.getArrayFeatureValue(fd, td)%>;}
+
+ /** indexed setter for <%=featName%> - sets an indexed value - <%=featDescCmt%>
+ * @generated */
+ public void set<%=featUName%>(int i, <%=elemType%> v) {
+ <%@ include file="../includedTemplates/FeatOkTesting.javajet"%>
+ <%@ include file="../includedTemplates/ArrayBoundsChecking.javajet"%>
+ <%=jg.setArrayFeatureValue(fd, td)%>;}
+ <% } /* of hasArray */ %>
+<% } /* of Features iteration */ %>
+<% if (td.getName().equals("uima.cas.Annotation")) { %>
+ <%@ include file="../includedTemplates/AnnotationMethods.javajet" %>
+<% } /* of Annotation if-statement */ %>
+}
+
+
\ No newline at end of file
Added: incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/templates/JCas_Type.javajet
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/templates/JCas_Type.javajet?view=auto&rev=490058
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/templates/JCas_Type.javajet (added)
+++ incubator/uima/uimaj/trunk/uimaj-tools/src/main/org.apache.uima.tools.jcasgen/templates/JCas_Type.javajet Sun Dec 24 10:48:37 2006
@@ -0,0 +1,153 @@
+/*
+ * 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.
+ */
+ <%@ jet package="org.apache.uima.tools.jcasgen" imports="java.util.Iterator org.apache.uima.resource.metadata.TypeDescription org.apache.uima.resource.metadata.FeatureDescription" class="JCas_TypeTemplate" %>
+<%
+ Object [] args = (Object [])argument;
+ Jg jg = (Jg)args[0];
+ TypeDescription td = (TypeDescription)args[1];
+ jg.packageName = jg.getJavaPkg(td);%>
+/* First created by JCasGen <%=jg.getDate()%> */
+<% if (0 != jg.packageName.length()) {%>
+package <%=jg.packageName%>;
+<% } %>
+
+import org.apache.uima.jcas.impl.JCas;
+import org.apache.uima.cas.impl.CASImpl;
+import org.apache.uima.cas.impl.FSGenerator;
+import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.impl.TypeImpl;
+import org.apache.uima.cas.Type;
+<% if (td.getFeatures().length > 0) {%>
+import org.apache.uima.cas.impl.FeatureImpl;
+import org.apache.uima.cas.Feature;
+<% } %>
+<% for(Iterator i=jg.collectImports(td, true).iterator(); i.hasNext();) {
+ String imp = (String)i.next();
+ if (!imp.equals(jg.getJavaNameWithPkg(td.getName()+"_Type"))) {%>
+import <%=imp%>;
+<% }} %>
+
+<% String typeName = jg.getJavaName(td);
+ String typeName_Type = typeName + "_Type"; %>
+/** <%=jg.nullBlank(td.getDescription())%>
+ * Updated by JCasGen <%=jg.getDate()%>
+ * @generated */
+public class <%=typeName_Type%> extends <%=jg.getJavaName(td.getSupertypeName()) + "_Type"%> {
+ /** @generated */
+ protected FSGenerator getFSGenerator() {return fsGenerator;}
+ /** @generated */
+ private final FSGenerator fsGenerator =
+ new FSGenerator() {
+ public FeatureStructure createFS(int addr, CASImpl cas) {
+ if (<%=typeName_Type%>.this.useExistingInstance) {
+ // Return eq fs instance if already created
+ FeatureStructure fs = <%=typeName_Type%>.this.jcas.getJfsFromCaddr(addr);
+ if (null == fs) {
+ fs = new <%=typeName%>(addr, <%=typeName_Type%>.this);
+ <%=typeName_Type%>.this.jcas.putJfsFromCaddr(addr, fs);
+ return fs;
+ }
+ return fs;
+ } else return new <%=typeName%>(addr, <%=typeName_Type%>.this);
+ }
+ };
+ /** @generated */
+ public final static int typeIndexID = <%=typeName%>.typeIndexID;
+ /** @generated
+ @modifiable */
+ public final static boolean featOkTst = JCas.getFeatOkTst("<%=td.getName()%>");
+<% FeatureDescription [] fds = td.getFeatures();
+ for (int i = 0; i < fds.length; i++) {
+ FeatureDescription fd = fds[i];
+
+ String featName = fd.getName();
+ String featUName = jg.uc1(featName); // upper case first letter
+
+ String rangeType = jg.getJavaRangeType(fd);
+ String getSetNamePart = jg.sc(rangeType);
+ String returnType = getSetNamePart.equals("Ref") ? "int" : rangeType;
+ String getSetArrayNamePart = jg.getGetSetArrayNamePart(fd);
+
+ String elemType = jg.getJavaRangeArrayElementType(fd);
+ if (jg.sc(elemType).equals("Ref"))
+ elemType = "int";
+ String casFeatCode = "casFeatCode_" + featName;
+%>
+ /** @generated */
+ final Feature casFeat_<%=featName%>;
+ /** @generated */
+ final int <%=casFeatCode%>;
+ /** @generated */
+ public <%=returnType%> get<%=featUName%>(int addr) {
+ <%@ include file="../includedTemplates/FeatOk_Testing.javajet"%>
+ return ll_cas.ll_get<%=getSetNamePart%>Value(addr, <%=casFeatCode%>);
+ }
+ /** @generated */
+ public void set<%=featUName%>(int addr, <%=returnType%> v) {
+ <%@ include file="../includedTemplates/FeatOk_Testing.javajet"%>
+ ll_cas.ll_set<%=getSetNamePart%>Value(addr, <%=casFeatCode%>, v);}
+
+ <%if (jg.hasArrayRange(fd)) {%>
+ /** @generated */
+ public <%=elemType%> get<%=featUName%>(int addr, int i) {
+ <%@ include file="../includedTemplates/FeatOk_Testing.javajet"%>
+ if (lowLevelTypeChecks)
+ return ll_cas.ll_get<%=getSetArrayNamePart%>ArrayValue(ll_cas.ll_getRefValue(addr, <%=casFeatCode%>), i, true);
+ jcas.checkArrayBounds(ll_cas.ll_getRefValue(addr, <%=casFeatCode%>), i);
+ return ll_cas.ll_get<%=getSetArrayNamePart%>ArrayValue(ll_cas.ll_getRefValue(addr, <%=casFeatCode%>), i);
+ }
+
+ /** @generated */
+ public void set<%=featUName%>(int addr, int i, <%=elemType%> v) {
+ <%@ include file="../includedTemplates/FeatOk_Testing.javajet"%>
+ if (lowLevelTypeChecks)
+ ll_cas.ll_set<%=getSetArrayNamePart%>ArrayValue(ll_cas.ll_getRefValue(addr, <%=casFeatCode%>), i, v, true);
+ jcas.checkArrayBounds(ll_cas.ll_getRefValue(addr, <%=casFeatCode%>), i);
+ ll_cas.ll_set<%=getSetArrayNamePart%>ArrayValue(ll_cas.ll_getRefValue(addr, <%=casFeatCode%>), i, v);
+ }
+<% } %>
+<% } %>
+
+<% if (td.getName().equals("uima.cas.Annotation")) { %>
+ <%@ include file="../includedTemplates/Annotation_Methods.javajet" %>
+<% } /* of Annotation if-statement */ %>
+
+
+ /** initialize variables to correspond with Cas Type and Features
+ * @generated */
+ public <%=typeName_Type%>(JCas jcas, Type casType) {
+ super(jcas, casType);
+ casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());
+
+<% for (int i = 0; i < fds.length; i++) {
+ FeatureDescription fd = fds[i];
+
+ String featName = fd.getName();
+
+%>
+ casFeat_<%=featName%> = jcas.getRequiredFeatureDE(casType, "<%=featName%>", "<%=fd.getRangeTypeName()%>", featOkTst);
+ casFeatCode_<%=featName%> = (null == casFeat_<%=featName%>) ? JCas.INVALID_FEATURE_CODE : ((FeatureImpl)casFeat_<%=featName%>).getCode();
+
+<% } %>
+ }
+}
+
+
+
+
\ No newline at end of file