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 2012/05/23 21:22:00 UTC
svn commit: r1341991 - in /uima/uimaj/trunk/uimaj-core/src:
main/java/org/apache/uima/util/
test/java/org/apache/uima/testTypeSystem_arrays/
test/java/org/apache/uima/util/ test/resources/ExampleCas/
Author: schor
Date: Wed May 23 19:21:59 2012
New Revision: 1341991
URL: http://svn.apache.org/viewvc?rev=1341991&view=rev
Log:
[UIMA-2406] fix, plus add test case (failed before fix, works after)
Added:
uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/
uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfShorts.java (with props)
uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfShorts_Type.java (with props)
uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfStrings.java (with props)
uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfStrings_Type.java (with props)
uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasToInlineXmlTest.java (with props)
uima/uimaj/trunk/uimaj-core/src/test/resources/ExampleCas/testIndexes_arrays.xml (with props)
uima/uimaj/trunk/uimaj-core/src/test/resources/ExampleCas/testTypeSystem_arrays.xml (with props)
Modified:
uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/util/CasToInlineXml.java
Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/util/CasToInlineXml.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/util/CasToInlineXml.java?rev=1341991&r1=1341990&r2=1341991&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/util/CasToInlineXml.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/util/CasToInlineXml.java Wed May 23 19:21:59 2012
@@ -25,20 +25,20 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.uima.UIMARuntimeException;
+import org.apache.uima.cas.BooleanArrayFS;
+import org.apache.uima.cas.ByteArrayFS;
import org.apache.uima.cas.CAS;
import org.apache.uima.cas.CASException;
+import org.apache.uima.cas.DoubleArrayFS;
import org.apache.uima.cas.FSIterator;
import org.apache.uima.cas.FSMatchConstraint;
import org.apache.uima.cas.Feature;
import org.apache.uima.cas.FeatureStructure;
-import org.apache.uima.cas.impl.BooleanArrayFSImpl;
-import org.apache.uima.cas.impl.ByteArrayFSImpl;
-import org.apache.uima.cas.impl.DoubleArrayFSImpl;
-import org.apache.uima.cas.impl.FloatArrayFSImpl;
-import org.apache.uima.cas.impl.IntArrayFSImpl;
-import org.apache.uima.cas.impl.LongArrayFSImpl;
-import org.apache.uima.cas.impl.ShortArrayFSImpl;
-import org.apache.uima.cas.impl.StringArrayFSImpl;
+import org.apache.uima.cas.FloatArrayFS;
+import org.apache.uima.cas.IntArrayFS;
+import org.apache.uima.cas.LongArrayFS;
+import org.apache.uima.cas.ShortArrayFS;
+import org.apache.uima.cas.StringArrayFS;
import org.apache.uima.cas.text.AnnotationFS;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
@@ -251,35 +251,35 @@ public class CasToInlineXml {
//TODO: there should be a better way to get any array value as a string array
String[] vals = null;
if (CAS.TYPE_NAME_STRING_ARRAY.equals(rangeTypeName)) {
- StringArrayFSImpl arrayFS = (StringArrayFSImpl) aFS.getFeatureValue(feat);
+ StringArrayFS arrayFS = (StringArrayFS) aFS.getFeatureValue(feat);
if (arrayFS != null)
vals = arrayFS.toArray();
} else if (CAS.TYPE_NAME_INTEGER_ARRAY.equals(rangeTypeName)) {
- IntArrayFSImpl arrayFS = (IntArrayFSImpl) aFS.getFeatureValue(feat);
+ IntArrayFS arrayFS = (IntArrayFS) aFS.getFeatureValue(feat);
if (arrayFS != null)
vals = arrayFS.toStringArray();
} else if (CAS.TYPE_NAME_FLOAT_ARRAY.equals(rangeTypeName)) {
- FloatArrayFSImpl arrayFS = (FloatArrayFSImpl) aFS.getFeatureValue(feat);
+ FloatArrayFS arrayFS = (FloatArrayFS) aFS.getFeatureValue(feat);
if (arrayFS != null)
vals = arrayFS.toStringArray();
} else if (CAS.TYPE_NAME_BOOLEAN_ARRAY.equals(rangeTypeName)) {
- BooleanArrayFSImpl arrayFS = (BooleanArrayFSImpl) aFS.getFeatureValue(feat);
+ BooleanArrayFS arrayFS = (BooleanArrayFS) aFS.getFeatureValue(feat);
if (arrayFS != null)
vals = arrayFS.toStringArray();
} else if (CAS.TYPE_NAME_BYTE_ARRAY.equals(rangeTypeName)) {
- ByteArrayFSImpl arrayFS = (ByteArrayFSImpl) aFS.getFeatureValue(feat);
+ ByteArrayFS arrayFS = (ByteArrayFS) aFS.getFeatureValue(feat);
if (arrayFS != null)
vals = arrayFS.toStringArray();
} else if (CAS.TYPE_NAME_SHORT_ARRAY.equals(rangeTypeName)) {
- ShortArrayFSImpl arrayFS = (ShortArrayFSImpl) aFS.getFeatureValue(feat);
+ ShortArrayFS arrayFS = (ShortArrayFS) aFS.getFeatureValue(feat);
if (arrayFS != null)
vals = arrayFS.toStringArray();
} else if (CAS.TYPE_NAME_LONG_ARRAY.equals(rangeTypeName)) {
- LongArrayFSImpl arrayFS = (LongArrayFSImpl) aFS.getFeatureValue(feat);
+ LongArrayFS arrayFS = (LongArrayFS) aFS.getFeatureValue(feat);
if (arrayFS != null)
vals = arrayFS.toStringArray();
} else if (CAS.TYPE_NAME_DOUBLE_ARRAY.equals(rangeTypeName)) {
- DoubleArrayFSImpl arrayFS = (DoubleArrayFSImpl) aFS.getFeatureValue(feat);
+ DoubleArrayFS arrayFS = (DoubleArrayFS) aFS.getFeatureValue(feat);
if (arrayFS != null)
vals = arrayFS.toStringArray();
}
Added: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfShorts.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfShorts.java?rev=1341991&view=auto
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfShorts.java (added)
+++ uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfShorts.java Wed May 23 19:21:59 2012
@@ -0,0 +1,97 @@
+
+
+/* First created by JCasGen Wed May 23 14:54:19 EDT 2012 */
+package org.apache.uima.testTypeSystem_arrays;
+
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.JCasRegistry;
+import org.apache.uima.jcas.cas.TOP_Type;
+
+import org.apache.uima.jcas.cas.ShortArray;
+import org.apache.uima.jcas.tcas.Annotation;
+
+
+/**
+ * Updated by JCasGen Wed May 23 14:55:00 EDT 2012
+ * XML source: C:/au/svnCheckouts/trunks/uimaj/uimaj-core/src/test/resources/ExampleCas/testTypeSystem_arrays.xml
+ * @generated */
+public class OfShorts extends Annotation {
+ /** @generated
+ * @ordered
+ */
+ public final static int typeIndexID = JCasRegistry.register(OfShorts.class);
+ /** @generated
+ * @ordered
+ */
+ public final static int type = typeIndexID;
+ /** @generated */
+ public int getTypeIndexID() {return typeIndexID;}
+
+ /** Never called. Disable default constructor
+ * @generated */
+ protected OfShorts() {}
+
+ /** Internal - constructor used by generator
+ * @generated */
+ public OfShorts(int addr, TOP_Type type) {
+ super(addr, type);
+ readObject();
+ }
+
+ /** @generated */
+ public OfShorts(JCas jcas) {
+ super(jcas);
+ readObject();
+ }
+
+ /** @generated */
+ public OfShorts(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() {}
+
+
+
+ //*--------------*
+ //* Feature: f1Shorts
+
+ /** getter for f1Shorts - gets
+ * @generated */
+ public ShortArray getF1Shorts() {
+ if (OfShorts_Type.featOkTst && ((OfShorts_Type)jcasType).casFeat_f1Shorts == null)
+ jcasType.jcas.throwFeatMissing("f1Shorts", "org.apache.uima.testTypeSystem_arrays.OfShorts");
+ return (ShortArray)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((OfShorts_Type)jcasType).casFeatCode_f1Shorts)));}
+
+ /** setter for f1Shorts - sets
+ * @generated */
+ public void setF1Shorts(ShortArray v) {
+ if (OfShorts_Type.featOkTst && ((OfShorts_Type)jcasType).casFeat_f1Shorts == null)
+ jcasType.jcas.throwFeatMissing("f1Shorts", "org.apache.uima.testTypeSystem_arrays.OfShorts");
+ jcasType.ll_cas.ll_setRefValue(addr, ((OfShorts_Type)jcasType).casFeatCode_f1Shorts, jcasType.ll_cas.ll_getFSRef(v));}
+
+ /** indexed getter for f1Shorts - gets an indexed value -
+ * @generated */
+ public short getF1Shorts(int i) {
+ if (OfShorts_Type.featOkTst && ((OfShorts_Type)jcasType).casFeat_f1Shorts == null)
+ jcasType.jcas.throwFeatMissing("f1Shorts", "org.apache.uima.testTypeSystem_arrays.OfShorts");
+ jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((OfShorts_Type)jcasType).casFeatCode_f1Shorts), i);
+ return jcasType.ll_cas.ll_getShortArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((OfShorts_Type)jcasType).casFeatCode_f1Shorts), i);}
+
+ /** indexed setter for f1Shorts - sets an indexed value -
+ * @generated */
+ public void setF1Shorts(int i, short v) {
+ if (OfShorts_Type.featOkTst && ((OfShorts_Type)jcasType).casFeat_f1Shorts == null)
+ jcasType.jcas.throwFeatMissing("f1Shorts", "org.apache.uima.testTypeSystem_arrays.OfShorts");
+ jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((OfShorts_Type)jcasType).casFeatCode_f1Shorts), i);
+ jcasType.ll_cas.ll_setShortArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((OfShorts_Type)jcasType).casFeatCode_f1Shorts), i, v);}
+ }
+
+
\ No newline at end of file
Propchange: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfShorts.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfShorts_Type.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfShorts_Type.java?rev=1341991&view=auto
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfShorts_Type.java (added)
+++ uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfShorts_Type.java Wed May 23 19:21:59 2012
@@ -0,0 +1,98 @@
+
+/* First created by JCasGen Wed May 23 14:54:19 EDT 2012 */
+package org.apache.uima.testTypeSystem_arrays;
+
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.JCasRegistry;
+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;
+import org.apache.uima.cas.impl.FeatureImpl;
+import org.apache.uima.cas.Feature;
+import org.apache.uima.jcas.tcas.Annotation_Type;
+
+/**
+ * Updated by JCasGen Wed May 23 14:55:02 EDT 2012
+ * @generated */
+public class OfShorts_Type extends Annotation_Type {
+ /** @generated */
+ protected FSGenerator getFSGenerator() {return fsGenerator;}
+ /** @generated */
+ private final FSGenerator fsGenerator =
+ new FSGenerator() {
+ public FeatureStructure createFS(int addr, CASImpl cas) {
+ if (OfShorts_Type.this.useExistingInstance) {
+ // Return eq fs instance if already created
+ FeatureStructure fs = OfShorts_Type.this.jcas.getJfsFromCaddr(addr);
+ if (null == fs) {
+ fs = new OfShorts(addr, OfShorts_Type.this);
+ OfShorts_Type.this.jcas.putJfsFromCaddr(addr, fs);
+ return fs;
+ }
+ return fs;
+ } else return new OfShorts(addr, OfShorts_Type.this);
+ }
+ };
+ /** @generated */
+ public final static int typeIndexID = OfShorts.typeIndexID;
+ /** @generated
+ @modifiable */
+ public final static boolean featOkTst = JCasRegistry.getFeatOkTst("org.apache.uima.testTypeSystem_arrays.OfShorts");
+
+ /** @generated */
+ final Feature casFeat_f1Shorts;
+ /** @generated */
+ final int casFeatCode_f1Shorts;
+ /** @generated */
+ public int getF1Shorts(int addr) {
+ if (featOkTst && casFeat_f1Shorts == null)
+ jcas.throwFeatMissing("f1Shorts", "org.apache.uima.testTypeSystem_arrays.OfShorts");
+ return ll_cas.ll_getRefValue(addr, casFeatCode_f1Shorts);
+ }
+ /** @generated */
+ public void setF1Shorts(int addr, int v) {
+ if (featOkTst && casFeat_f1Shorts == null)
+ jcas.throwFeatMissing("f1Shorts", "org.apache.uima.testTypeSystem_arrays.OfShorts");
+ ll_cas.ll_setRefValue(addr, casFeatCode_f1Shorts, v);}
+
+ /** @generated */
+ public short getF1Shorts(int addr, int i) {
+ if (featOkTst && casFeat_f1Shorts == null)
+ jcas.throwFeatMissing("f1Shorts", "org.apache.uima.testTypeSystem_arrays.OfShorts");
+ if (lowLevelTypeChecks)
+ return ll_cas.ll_getShortArrayValue(ll_cas.ll_getRefValue(addr, casFeatCode_f1Shorts), i, true);
+ jcas.checkArrayBounds(ll_cas.ll_getRefValue(addr, casFeatCode_f1Shorts), i);
+ return ll_cas.ll_getShortArrayValue(ll_cas.ll_getRefValue(addr, casFeatCode_f1Shorts), i);
+ }
+
+ /** @generated */
+ public void setF1Shorts(int addr, int i, short v) {
+ if (featOkTst && casFeat_f1Shorts == null)
+ jcas.throwFeatMissing("f1Shorts", "org.apache.uima.testTypeSystem_arrays.OfShorts");
+ if (lowLevelTypeChecks)
+ ll_cas.ll_setShortArrayValue(ll_cas.ll_getRefValue(addr, casFeatCode_f1Shorts), i, v, true);
+ jcas.checkArrayBounds(ll_cas.ll_getRefValue(addr, casFeatCode_f1Shorts), i);
+ ll_cas.ll_setShortArrayValue(ll_cas.ll_getRefValue(addr, casFeatCode_f1Shorts), i, v);
+ }
+
+
+
+
+ /** initialize variables to correspond with Cas Type and Features
+ * @generated */
+ public OfShorts_Type(JCas jcas, Type casType) {
+ super(jcas, casType);
+ casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());
+
+
+ casFeat_f1Shorts = jcas.getRequiredFeatureDE(casType, "f1Shorts", "uima.cas.ShortArray", featOkTst);
+ casFeatCode_f1Shorts = (null == casFeat_f1Shorts) ? JCas.INVALID_FEATURE_CODE : ((FeatureImpl)casFeat_f1Shorts).getCode();
+
+ }
+}
+
+
+
+
\ No newline at end of file
Propchange: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfShorts_Type.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfStrings.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfStrings.java?rev=1341991&view=auto
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfStrings.java (added)
+++ uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfStrings.java Wed May 23 19:21:59 2012
@@ -0,0 +1,97 @@
+
+
+/* First created by JCasGen Wed May 23 14:54:19 EDT 2012 */
+package org.apache.uima.testTypeSystem_arrays;
+
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.JCasRegistry;
+import org.apache.uima.jcas.cas.TOP_Type;
+
+import org.apache.uima.jcas.cas.StringArray;
+import org.apache.uima.jcas.tcas.Annotation;
+
+
+/**
+ * Updated by JCasGen Wed May 23 14:55:02 EDT 2012
+ * XML source: C:/au/svnCheckouts/trunks/uimaj/uimaj-core/src/test/resources/ExampleCas/testTypeSystem_arrays.xml
+ * @generated */
+public class OfStrings extends Annotation {
+ /** @generated
+ * @ordered
+ */
+ public final static int typeIndexID = JCasRegistry.register(OfStrings.class);
+ /** @generated
+ * @ordered
+ */
+ public final static int type = typeIndexID;
+ /** @generated */
+ public int getTypeIndexID() {return typeIndexID;}
+
+ /** Never called. Disable default constructor
+ * @generated */
+ protected OfStrings() {}
+
+ /** Internal - constructor used by generator
+ * @generated */
+ public OfStrings(int addr, TOP_Type type) {
+ super(addr, type);
+ readObject();
+ }
+
+ /** @generated */
+ public OfStrings(JCas jcas) {
+ super(jcas);
+ readObject();
+ }
+
+ /** @generated */
+ public OfStrings(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() {}
+
+
+
+ //*--------------*
+ //* Feature: f1Strings
+
+ /** getter for f1Strings - gets
+ * @generated */
+ public StringArray getF1Strings() {
+ if (OfStrings_Type.featOkTst && ((OfStrings_Type)jcasType).casFeat_f1Strings == null)
+ jcasType.jcas.throwFeatMissing("f1Strings", "org.apache.uima.testTypeSystem_arrays.OfStrings");
+ return (StringArray)(jcasType.ll_cas.ll_getFSForRef(jcasType.ll_cas.ll_getRefValue(addr, ((OfStrings_Type)jcasType).casFeatCode_f1Strings)));}
+
+ /** setter for f1Strings - sets
+ * @generated */
+ public void setF1Strings(StringArray v) {
+ if (OfStrings_Type.featOkTst && ((OfStrings_Type)jcasType).casFeat_f1Strings == null)
+ jcasType.jcas.throwFeatMissing("f1Strings", "org.apache.uima.testTypeSystem_arrays.OfStrings");
+ jcasType.ll_cas.ll_setRefValue(addr, ((OfStrings_Type)jcasType).casFeatCode_f1Strings, jcasType.ll_cas.ll_getFSRef(v));}
+
+ /** indexed getter for f1Strings - gets an indexed value -
+ * @generated */
+ public String getF1Strings(int i) {
+ if (OfStrings_Type.featOkTst && ((OfStrings_Type)jcasType).casFeat_f1Strings == null)
+ jcasType.jcas.throwFeatMissing("f1Strings", "org.apache.uima.testTypeSystem_arrays.OfStrings");
+ jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((OfStrings_Type)jcasType).casFeatCode_f1Strings), i);
+ return jcasType.ll_cas.ll_getStringArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((OfStrings_Type)jcasType).casFeatCode_f1Strings), i);}
+
+ /** indexed setter for f1Strings - sets an indexed value -
+ * @generated */
+ public void setF1Strings(int i, String v) {
+ if (OfStrings_Type.featOkTst && ((OfStrings_Type)jcasType).casFeat_f1Strings == null)
+ jcasType.jcas.throwFeatMissing("f1Strings", "org.apache.uima.testTypeSystem_arrays.OfStrings");
+ jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((OfStrings_Type)jcasType).casFeatCode_f1Strings), i);
+ jcasType.ll_cas.ll_setStringArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((OfStrings_Type)jcasType).casFeatCode_f1Strings), i, v);}
+ }
+
+
\ No newline at end of file
Propchange: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfStrings.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfStrings_Type.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfStrings_Type.java?rev=1341991&view=auto
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfStrings_Type.java (added)
+++ uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfStrings_Type.java Wed May 23 19:21:59 2012
@@ -0,0 +1,98 @@
+
+/* First created by JCasGen Wed May 23 14:54:19 EDT 2012 */
+package org.apache.uima.testTypeSystem_arrays;
+
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.JCasRegistry;
+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;
+import org.apache.uima.cas.impl.FeatureImpl;
+import org.apache.uima.cas.Feature;
+import org.apache.uima.jcas.tcas.Annotation_Type;
+
+/**
+ * Updated by JCasGen Wed May 23 14:55:02 EDT 2012
+ * @generated */
+public class OfStrings_Type extends Annotation_Type {
+ /** @generated */
+ protected FSGenerator getFSGenerator() {return fsGenerator;}
+ /** @generated */
+ private final FSGenerator fsGenerator =
+ new FSGenerator() {
+ public FeatureStructure createFS(int addr, CASImpl cas) {
+ if (OfStrings_Type.this.useExistingInstance) {
+ // Return eq fs instance if already created
+ FeatureStructure fs = OfStrings_Type.this.jcas.getJfsFromCaddr(addr);
+ if (null == fs) {
+ fs = new OfStrings(addr, OfStrings_Type.this);
+ OfStrings_Type.this.jcas.putJfsFromCaddr(addr, fs);
+ return fs;
+ }
+ return fs;
+ } else return new OfStrings(addr, OfStrings_Type.this);
+ }
+ };
+ /** @generated */
+ public final static int typeIndexID = OfStrings.typeIndexID;
+ /** @generated
+ @modifiable */
+ public final static boolean featOkTst = JCasRegistry.getFeatOkTst("org.apache.uima.testTypeSystem_arrays.OfStrings");
+
+ /** @generated */
+ final Feature casFeat_f1Strings;
+ /** @generated */
+ final int casFeatCode_f1Strings;
+ /** @generated */
+ public int getF1Strings(int addr) {
+ if (featOkTst && casFeat_f1Strings == null)
+ jcas.throwFeatMissing("f1Strings", "org.apache.uima.testTypeSystem_arrays.OfStrings");
+ return ll_cas.ll_getRefValue(addr, casFeatCode_f1Strings);
+ }
+ /** @generated */
+ public void setF1Strings(int addr, int v) {
+ if (featOkTst && casFeat_f1Strings == null)
+ jcas.throwFeatMissing("f1Strings", "org.apache.uima.testTypeSystem_arrays.OfStrings");
+ ll_cas.ll_setRefValue(addr, casFeatCode_f1Strings, v);}
+
+ /** @generated */
+ public String getF1Strings(int addr, int i) {
+ if (featOkTst && casFeat_f1Strings == null)
+ jcas.throwFeatMissing("f1Strings", "org.apache.uima.testTypeSystem_arrays.OfStrings");
+ if (lowLevelTypeChecks)
+ return ll_cas.ll_getStringArrayValue(ll_cas.ll_getRefValue(addr, casFeatCode_f1Strings), i, true);
+ jcas.checkArrayBounds(ll_cas.ll_getRefValue(addr, casFeatCode_f1Strings), i);
+ return ll_cas.ll_getStringArrayValue(ll_cas.ll_getRefValue(addr, casFeatCode_f1Strings), i);
+ }
+
+ /** @generated */
+ public void setF1Strings(int addr, int i, String v) {
+ if (featOkTst && casFeat_f1Strings == null)
+ jcas.throwFeatMissing("f1Strings", "org.apache.uima.testTypeSystem_arrays.OfStrings");
+ if (lowLevelTypeChecks)
+ ll_cas.ll_setStringArrayValue(ll_cas.ll_getRefValue(addr, casFeatCode_f1Strings), i, v, true);
+ jcas.checkArrayBounds(ll_cas.ll_getRefValue(addr, casFeatCode_f1Strings), i);
+ ll_cas.ll_setStringArrayValue(ll_cas.ll_getRefValue(addr, casFeatCode_f1Strings), i, v);
+ }
+
+
+
+
+ /** initialize variables to correspond with Cas Type and Features
+ * @generated */
+ public OfStrings_Type(JCas jcas, Type casType) {
+ super(jcas, casType);
+ casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());
+
+
+ casFeat_f1Strings = jcas.getRequiredFeatureDE(casType, "f1Strings", "uima.cas.StringArray", featOkTst);
+ casFeatCode_f1Strings = (null == casFeat_f1Strings) ? JCas.INVALID_FEATURE_CODE : ((FeatureImpl)casFeat_f1Strings).getCode();
+
+ }
+}
+
+
+
+
\ No newline at end of file
Propchange: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/testTypeSystem_arrays/OfStrings_Type.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasToInlineXmlTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasToInlineXmlTest.java?rev=1341991&view=auto
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasToInlineXmlTest.java (added)
+++ uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasToInlineXmlTest.java Wed May 23 19:21:59 2012
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+package org.apache.uima.util;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.cas.ShortArray;
+import org.apache.uima.jcas.cas.StringArray;
+import org.apache.uima.resource.metadata.FsIndexDescription;
+import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.apache.uima.resource.metadata.impl.TypePriorities_impl;
+import org.apache.uima.test.junit_extension.JUnitExtension;
+import org.apache.uima.testTypeSystem_arrays.OfShorts;
+import org.apache.uima.testTypeSystem_arrays.OfStrings;
+
+/**
+ *
+ */
+public class CasToInlineXmlTest extends TestCase {
+ private TypeSystemDescription typeSystem;
+
+ private FsIndexDescription[] indexes;
+
+ protected void setUp() throws Exception {
+ File typeSystemFile1 = JUnitExtension.getFile("ExampleCas/testTypeSystem_arrays.xml");
+ File indexesFile = JUnitExtension.getFile("ExampleCas/testIndexes_arrays.xml");
+
+ typeSystem = UIMAFramework.getXMLParser().parseTypeSystemDescription(
+ new XMLInputSource(typeSystemFile1));
+ indexes = UIMAFramework.getXMLParser().parseFsIndexCollection(new XMLInputSource(indexesFile))
+ .getFsIndexes();
+ }
+
+ public void testCasToInlineXml() throws Exception {
+ // Jira https://issues.apache.org/jira/browse/UIMA-2406
+ CAS srcCas = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(), indexes);
+
+ JCas jcas = srcCas.getJCas();
+
+ jcas.setDocumentText("1 2 3 4 5 6 7 8 9");
+ OfShorts f = new OfShorts(jcas);
+ ShortArray a = new ShortArray(jcas, 3);
+ a.set(0, (short)0);
+ a.set(1, (short)1);
+ a.set(2, (short)2);
+ f.setF1Shorts(a);
+ f.addToIndexes();
+
+ OfStrings ss = new OfStrings(jcas);
+ StringArray sa = new StringArray(jcas, 3);
+ sa.set(0, "0s");
+ sa.set(1, "1s");
+ sa.set(2, "2s");
+ ss.setF1Strings(sa);
+ ss.addToIndexes();
+
+ CasToInlineXml c2x = new CasToInlineXml();
+ String result = c2x.generateXML(srcCas);
+ System.out.println(result);
+ }
+
+
+
+}
Propchange: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/CasToInlineXmlTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/uimaj/trunk/uimaj-core/src/test/resources/ExampleCas/testIndexes_arrays.xml
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/resources/ExampleCas/testIndexes_arrays.xml?rev=1341991&view=auto
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/test/resources/ExampleCas/testIndexes_arrays.xml (added)
+++ uima/uimaj/trunk/uimaj-core/src/test/resources/ExampleCas/testIndexes_arrays.xml Wed May 23 19:21:59 2012
@@ -0,0 +1,27 @@
+<fsIndexCollection xmlns="http://uima.apache.org/resourceSpecifier">
+
+ <!--
+ ***************************************************************
+ * 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.
+ ***************************************************************
+ -->
+
+
+<fsIndexes>
+</fsIndexes>
+</fsIndexCollection>
Propchange: uima/uimaj/trunk/uimaj-core/src/test/resources/ExampleCas/testIndexes_arrays.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: uima/uimaj/trunk/uimaj-core/src/test/resources/ExampleCas/testTypeSystem_arrays.xml
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/resources/ExampleCas/testTypeSystem_arrays.xml?rev=1341991&view=auto
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/test/resources/ExampleCas/testTypeSystem_arrays.xml (added)
+++ uima/uimaj/trunk/uimaj-core/src/test/resources/ExampleCas/testTypeSystem_arrays.xml Wed May 23 19:21:59 2012
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?><typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
+ <name>testTypeSystem_arrays</name>
+ <description/>
+ <version>1.0</version>
+ <vendor/>
+ <types>
+ <typeDescription>
+ <name>org.apache.uima.testTypeSystem_arrays.OfStrings</name>
+ <description/>
+ <supertypeName>uima.tcas.Annotation</supertypeName>
+ <features>
+ <featureDescription>
+ <name>f1Strings</name>
+ <description/>
+ <rangeTypeName>uima.cas.StringArray</rangeTypeName>
+ </featureDescription>
+ </features>
+ </typeDescription>
+ <typeDescription>
+ <name>org.apache.uima.testTypeSystem_arrays.OfShorts</name>
+ <description/>
+ <supertypeName>uima.tcas.Annotation</supertypeName>
+ <features>
+ <featureDescription>
+ <name>f1Shorts</name>
+ <description/>
+ <rangeTypeName>uima.cas.ShortArray</rangeTypeName>
+ </featureDescription>
+ </features>
+ </typeDescription>
+ <typeDescription>
+ <name>org.apache.uima.testTypeSystem_arrays.Plain</name>
+ <description/>
+ <supertypeName>uima.tcas.Annotation</supertypeName>
+ </typeDescription>
+ </types>
+</typeSystemDescription>
\ No newline at end of file
Propchange: uima/uimaj/trunk/uimaj-core/src/test/resources/ExampleCas/testTypeSystem_arrays.xml
------------------------------------------------------------------------------
svn:eol-style = native