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 2017/10/04 15:21:33 UTC

svn commit: r1811093 - in /uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test: java/org/apache/uima/jcas/tcas/DocMeta.java java/org/apache/uima/jcas/tcas/DocumentAnnotationTest.java resources/ExampleCas/testTypeSystem_docmetadata.xml

Author: schor
Date: Wed Oct  4 15:21:32 2017
New Revision: 1811093

URL: http://svn.apache.org/viewvc?rev=1811093&view=rev
Log:
[UIMA-5595] tests for toString

Modified:
    uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocMeta.java
    uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocumentAnnotationTest.java
    uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/resources/ExampleCas/testTypeSystem_docmetadata.xml

Modified: uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocMeta.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocMeta.java?rev=1811093&r1=1811092&r2=1811093&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocMeta.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocMeta.java Wed Oct  4 15:21:32 2017
@@ -1,10 +1,13 @@
 
 
    
-/* Apache UIMA v3 - First created by JCasGen Fri Sep 22 09:43:59 EDT 2017 */
+/* Apache UIMA v3 - First created by JCasGen Mon Oct 02 16:32:10 EDT 2017 */
 
 package org.apache.uima.jcas.tcas;
 
+import java.lang.invoke.CallSite;
+import java.lang.invoke.MethodHandle;
+
 import org.apache.uima.cas.impl.CASImpl;
 import org.apache.uima.cas.impl.TypeImpl;
 import org.apache.uima.cas.impl.TypeSystemImpl;
@@ -12,10 +15,13 @@ import org.apache.uima.jcas.JCas;
 import org.apache.uima.jcas.JCasRegistry;
 
 
+import org.apache.uima.jcas.cas.FSArray;
+import org.apache.uima.jcas.cas.StringArray;
+import org.apache.uima.jcas.cas.IntegerArray;
 
 
 /** 
- * Updated by JCasGen Fri Sep 22 09:43:59 EDT 2017
+ * Updated by JCasGen Mon Oct 02 16:32:10 EDT 2017
  * XML source: C:/au/svnCheckouts/uv3/trunk/uimaj-v3/uimaj-document-annotation/src/test/resources/ExampleCas/testTypeSystem_docmetadata.xml
  * @generated */
 public class DocMeta extends DocumentAnnotation {
@@ -48,10 +54,26 @@ public class DocMeta extends DocumentAnn
    * *******************/ 
    
   public final static String _FeatName_feat = "feat";
+  public final static String _FeatName_feat2 = "feat2";
+  public final static String _FeatName_feat3 = "feat3";
+  public final static String _FeatName_arraystr = "arraystr";
+  public final static String _FeatName_arrayints = "arrayints";
+  public final static String _FeatName_arrayFs = "arrayFs";
 
 
   /* Feature Adjusted Offsets */
-  public final static int _FI_feat = TypeSystemImpl.getAdjustedFeatureOffset("feat");
+  private final static CallSite _FC_feat = TypeSystemImpl.createCallSite(DocMeta.class, "feat");
+  private final static MethodHandle _FH_feat = _FC_feat.dynamicInvoker();
+  private final static CallSite _FC_feat2 = TypeSystemImpl.createCallSite(DocMeta.class, "feat2");
+  private final static MethodHandle _FH_feat2 = _FC_feat2.dynamicInvoker();
+  private final static CallSite _FC_feat3 = TypeSystemImpl.createCallSite(DocMeta.class, "feat3");
+  private final static MethodHandle _FH_feat3 = _FC_feat3.dynamicInvoker();
+  private final static CallSite _FC_arraystr = TypeSystemImpl.createCallSite(DocMeta.class, "arraystr");
+  private final static MethodHandle _FH_arraystr = _FC_arraystr.dynamicInvoker();
+  private final static CallSite _FC_arrayints = TypeSystemImpl.createCallSite(DocMeta.class, "arrayints");
+  private final static MethodHandle _FH_arrayints = _FC_arrayints.dynamicInvoker();
+  private final static CallSite _FC_arrayFs = TypeSystemImpl.createCallSite(DocMeta.class, "arrayFs");
+  private final static MethodHandle _FH_arrayFs = _FC_arrayFs.dynamicInvoker();
 
    
   /** Never called.  Disable default constructor
@@ -107,16 +129,162 @@ public class DocMeta extends DocumentAnn
    * @generated
    * @return value of the feature 
    */
-  public String getFeat() { return _getStringValueNc(_FI_feat);}
+  public String getFeat() { return _getStringValueNc(wrapGetIntCatchException(_FH_feat));}
     
   /** setter for feat - sets  
    * @generated
    * @param v value to set into the feature 
    */
   public void setFeat(String v) {
-    _setStringValueNfc(_FI_feat, v);
+    _setStringValueNfc(wrapGetIntCatchException(_FH_feat), v);
+  }    
+    
+   
+    
+  //*--------------*
+  //* Feature: feat2
+
+  /** getter for feat2 - gets 
+   * @generated
+   * @return value of the feature 
+   */
+  public String getFeat2() { return _getStringValueNc(wrapGetIntCatchException(_FH_feat2));}
+    
+  /** setter for feat2 - sets  
+   * @generated
+   * @param v value to set into the feature 
+   */
+  public void setFeat2(String v) {
+    _setStringValueNfc(wrapGetIntCatchException(_FH_feat2), v);
+  }    
+    
+   
+    
+  //*--------------*
+  //* Feature: feat3
+
+  /** getter for feat3 - gets 
+   * @generated
+   * @return value of the feature 
+   */
+  public String getFeat3() { return _getStringValueNc(wrapGetIntCatchException(_FH_feat3));}
+    
+  /** setter for feat3 - sets  
+   * @generated
+   * @param v value to set into the feature 
+   */
+  public void setFeat3(String v) {
+    _setStringValueNfc(wrapGetIntCatchException(_FH_feat3), v);
+  }    
+    
+   
+    
+  //*--------------*
+  //* Feature: arraystr
+
+  /** getter for arraystr - gets 
+   * @generated
+   * @return value of the feature 
+   */
+  public StringArray getArraystr() { return (StringArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arraystr)));}
+    
+  /** setter for arraystr - sets  
+   * @generated
+   * @param v value to set into the feature 
+   */
+  public void setArraystr(StringArray v) {
+    _setFeatureValueNcWj(wrapGetIntCatchException(_FH_arraystr), v);
+  }    
+    
+    
+  /** indexed getter for arraystr - gets an indexed value - 
+   * @generated
+   * @param i index in the array to get
+   * @return value of the element at index i 
+   */
+  public String getArraystr(int i) {
+     return ((StringArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arraystr)))).get(i);} 
+
+  /** indexed setter for arraystr - sets an indexed value - 
+   * @generated
+   * @param i index in the array to set
+   * @param v value to set into the array 
+   */
+  public void setArraystr(int i, String v) {
+    ((StringArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arraystr)))).set(i, v);
+  }  
+   
+    
+  //*--------------*
+  //* Feature: arrayints
+
+  /** getter for arrayints - gets 
+   * @generated
+   * @return value of the feature 
+   */
+  public IntegerArray getArrayints() { return (IntegerArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayints)));}
+    
+  /** setter for arrayints - sets  
+   * @generated
+   * @param v value to set into the feature 
+   */
+  public void setArrayints(IntegerArray v) {
+    _setFeatureValueNcWj(wrapGetIntCatchException(_FH_arrayints), v);
+  }    
+    
+    
+  /** indexed getter for arrayints - gets an indexed value - 
+   * @generated
+   * @param i index in the array to get
+   * @return value of the element at index i 
+   */
+  public int getArrayints(int i) {
+     return ((IntegerArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayints)))).get(i);} 
+
+  /** indexed setter for arrayints - sets an indexed value - 
+   * @generated
+   * @param i index in the array to set
+   * @param v value to set into the array 
+   */
+  public void setArrayints(int i, int v) {
+    ((IntegerArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayints)))).set(i, v);
+  }  
+   
+    
+  //*--------------*
+  //* Feature: arrayFs
+
+  /** getter for arrayFs - gets 
+   * @generated
+   * @return value of the feature 
+   */
+  public FSArray getArrayFs() { return (FSArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayFs)));}
+    
+  /** setter for arrayFs - sets  
+   * @generated
+   * @param v value to set into the feature 
+   */
+  public void setArrayFs(FSArray v) {
+    _setFeatureValueNcWj(wrapGetIntCatchException(_FH_arrayFs), v);
   }    
     
+    
+  /** indexed getter for arrayFs - gets an indexed value - 
+   * @generated
+   * @param i index in the array to get
+   * @return value of the element at index i 
+   */
+  public Annotation getArrayFs(int i) {
+     return (Annotation)(((FSArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayFs)))).get(i));} 
+
+  /** indexed setter for arrayFs - sets an indexed value - 
+   * @generated
+   * @param i index in the array to set
+   * @param v value to set into the array 
+   */
+  public void setArrayFs(int i, Annotation v) {
+    ((FSArray)(_getFeatureValueNc(wrapGetIntCatchException(_FH_arrayFs)))).set(i, v);
+  }  
   }
 
     
\ No newline at end of file

Modified: uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocumentAnnotationTest.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocumentAnnotationTest.java?rev=1811093&r1=1811092&r2=1811093&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocumentAnnotationTest.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/java/org/apache/uima/jcas/tcas/DocumentAnnotationTest.java Wed Oct  4 15:21:32 2017
@@ -27,17 +27,23 @@ import java.io.IOException;
 
 import org.apache.uima.UIMAFramework;
 import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.CASException;
 import org.apache.uima.cas.SerialFormat;
 import org.apache.uima.cas.impl.CASImpl;
 import org.apache.uima.cas.impl.CasCompare;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.jcas.JCas;
+import org.apache.uima.jcas.cas.FSArray;
+import org.apache.uima.jcas.cas.IntegerArray;
+import org.apache.uima.jcas.cas.StringArray;
+import org.apache.uima.resource.ResourceInitializationException;
 import org.apache.uima.resource.metadata.TypeSystemDescription;
 import org.apache.uima.resource.metadata.impl.TypePriorities_impl;
 import org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl;
 import org.apache.uima.test.junit_extension.JUnitExtension;
 import org.apache.uima.util.CasCreationUtils;
 import org.apache.uima.util.CasIOUtils;
+import org.apache.uima.util.InvalidXMLException;
 import org.apache.uima.util.XMLInputSource;
 
 
@@ -110,5 +116,36 @@ public class DocumentAnnotationTest exte
     System.out.println(target.<DocMeta>getDocumentAnnotation());
     assertTrue(CasCompare.compareCASes((CASImpl)source, (CASImpl)target));
   }
+  
+  public void testToString() throws InvalidXMLException, IOException, ResourceInitializationException, CASException {
+    File typeSystemFile = JUnitExtension.getFile("ExampleCas/testTypeSystem_docmetadata.xml");
+    TypeSystemDescription typeSystem = UIMAFramework.getXMLParser().parseTypeSystemDescription(
+            new XMLInputSource(typeSystemFile));
+    
+    source = CasCreationUtils.createCas(typeSystem, new TypePriorities_impl(), null);
+    jcas = source.getJCas();
+    
+    DocMeta d = new DocMeta(jcas);
+    d.setFeat("a string");
+    d.setFeat2("b string");
+    d.setFeat3("c string");
+    
+    FSArray fsa = new FSArray(jcas, 2);
+    fsa.set(0, new Annotation(jcas, 1,2));
+    fsa.set(1, new Annotation(jcas, 3,4));
+    d.setArrayFs(fsa);
+    
+    IntegerArray intarr = new IntegerArray(jcas, 2);
+    intarr.set(0,  10);
+    intarr.set(1,  -10);
+    d.setArrayints(intarr);
+    
+    StringArray strarr = new StringArray(jcas, 2);
+    strarr.set(0,  "first");
+    strarr.set(1,  "second");
+    d.setArraystr(strarr);
+    
+    System.out.println(d.toString());
+  }
 
 }

Modified: uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/resources/ExampleCas/testTypeSystem_docmetadata.xml
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/resources/ExampleCas/testTypeSystem_docmetadata.xml?rev=1811093&r1=1811092&r2=1811093&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/resources/ExampleCas/testTypeSystem_docmetadata.xml (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-document-annotation/src/test/resources/ExampleCas/testTypeSystem_docmetadata.xml Wed Oct  4 15:21:32 2017
@@ -15,6 +15,33 @@
           <description/>
           <rangeTypeName>uima.cas.String</rangeTypeName>
         </featureDescription>
+        <featureDescription>
+          <name>feat2</name>
+          <description/>
+          <rangeTypeName>uima.cas.String</rangeTypeName>
+        </featureDescription>
+        <featureDescription>
+          <name>feat3</name>
+          <description/>
+          <rangeTypeName>uima.cas.String</rangeTypeName>
+        </featureDescription>
+        
+      <featureDescription>
+          <name>arraystr</name>
+          <description/>
+          <rangeTypeName>uima.cas.StringArray</rangeTypeName>
+        </featureDescription>
+        <featureDescription>
+          <name>arrayints</name>
+          <description/>
+          <rangeTypeName>uima.cas.IntegerArray</rangeTypeName>
+        </featureDescription>
+        <featureDescription>
+          <name>arrayFs</name>
+          <description/>
+          <rangeTypeName>uima.cas.FSArray</rangeTypeName>
+          <elementType>uima.tcas.Annotation</elementType>
+        </featureDescription>
       </features>
     </typeDescription>
   </types>