You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by ea...@apache.org on 2010/04/30 16:26:44 UTC

svn commit: r939688 - in /uima/uimaj/trunk: uima-docbooks/src/docbook/tutorials_and_users_guides/ uimaj-core/src/main/java/org/apache/uima/cas/impl/ uimaj-core/src/test/java/org/apache/uima/cas/test/

Author: eae
Date: Fri Apr 30 14:26:43 2010
New Revision: 939688

URL: http://svn.apache.org/viewvc?rev=939688&view=rev
Log:
UIMA-1774

Modified:
    uima/uimaj/trunk/uima-docbooks/src/docbook/tutorials_and_users_guides/tug.aas.xml
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/SofaFSImpl.java
    uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java

Modified: uima/uimaj/trunk/uima-docbooks/src/docbook/tutorials_and_users_guides/tug.aas.xml
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uima-docbooks/src/docbook/tutorials_and_users_guides/tug.aas.xml?rev=939688&r1=939687&r2=939688&view=diff
==============================================================================
--- uima/uimaj/trunk/uima-docbooks/src/docbook/tutorials_and_users_guides/tug.aas.xml (original)
+++ uima/uimaj/trunk/uima-docbooks/src/docbook/tutorials_and_users_guides/tug.aas.xml Fri Apr 30 14:26:43 2010
@@ -115,8 +115,7 @@ aCas.<emphasis role="bold">setSofaDataUR
         be set and retrieved by user code.</para>
       
       <para>Feature Structure primitive arrays are all the UIMA Array types except arrays of
-        Feature Structures, Strings, and Booleans. Typically, these are arrays of bytes,
-        but can be other types, such as floats, longs, etc.</para>
+        Feature Structures and Booleans.</para>
       
       <para>The URI string should conform to the standard URI format.</para>
       

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java?rev=939688&r1=939687&r2=939688&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/CASImpl.java Fri Apr 30 14:26:43 2010
@@ -717,7 +717,18 @@ public class CASImpl extends AbstractCas
         int arraySize = this.ll_getArraySize(fs.getAddress());
         ByteBuffer buf = null;
         Type type = fs.getType();
-        if (type.getName().equals(CAS.TYPE_NAME_INTEGER_ARRAY)) {
+        if (type.getName().equals(CAS.TYPE_NAME_STRING_ARRAY)) {
+          StringBuffer sb = new StringBuffer();
+          for (int i=0; i<((StringArrayFS)fs).size(); i++) {
+            if (i==0) {
+              sb.append( ((StringArrayFS)fs).get(i) );
+            } else {
+              sb.append( "\n" + ((StringArrayFS)fs).get(i) );
+            }
+          }
+          ByteArrayInputStream bis = new ByteArrayInputStream( sb.toString().getBytes("UTF-8") );
+          return bis;
+        } else if (type.getName().equals(CAS.TYPE_NAME_INTEGER_ARRAY)) {
           arrayStart = getArrayStartAddress(fs.getAddress());
           buf = ByteBuffer.allocate(arraySize * 4);
           IntBuffer intbuf = buf.asIntBuffer();

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/SofaFSImpl.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/SofaFSImpl.java?rev=939688&r1=939687&r2=939688&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/SofaFSImpl.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/SofaFSImpl.java Fri Apr 30 14:26:43 2010
@@ -85,7 +85,8 @@ public class SofaFSImpl extends FeatureS
 				&& !type.getName().equals(CAS.TYPE_NAME_FLOAT_ARRAY)
 				&& !type.getName().equals(CAS.TYPE_NAME_INTEGER_ARRAY)
 				&& !type.getName().equals(CAS.TYPE_NAME_LONG_ARRAY)
-				&& !type.getName().equals(CAS.TYPE_NAME_SHORT_ARRAY)) {
+				&& !type.getName().equals(CAS.TYPE_NAME_SHORT_ARRAY)
+				&& !type.getName().equals(CAS.TYPE_NAME_STRING_ARRAY)) {
 			CASRuntimeException e = new CASRuntimeException(CASRuntimeException.INAPPROP_TYPE,
 					new String[] { "Byte/Float/Integer/Short/String/Long/Double Array", type.getName() });
 			throw e;

Modified: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java?rev=939688&r1=939687&r2=939688&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/test/SofaTest.java Fri Apr 30 14:26:43 2010
@@ -52,6 +52,7 @@ import org.apache.uima.cas.IntArrayFS;
 import org.apache.uima.cas.LongArrayFS;
 import org.apache.uima.cas.ShortArrayFS;
 import org.apache.uima.cas.SofaFS;
+import org.apache.uima.cas.StringArrayFS;
 import org.apache.uima.cas.Type;
 import org.apache.uima.cas.admin.CASFactory;
 import org.apache.uima.cas.admin.CASMgr;
@@ -356,6 +357,16 @@ public class SofaTest extends TestCase {
       CAS intArrayView =this.cas.createView("intArraySofaData");
       intArrayView.setSofaDataArray(intArrayFS, "integers");
 
+      // create a string array fs
+      StringArrayFS stringArrayFS =this.cas.createStringArrayFS(5);
+      stringArrayFS.set(0, "This");
+      stringArrayFS.set(1, "beer");
+      stringArrayFS.set(2, "is");
+      stringArrayFS.set(3, "really");
+      stringArrayFS.set(4, "good");
+      CAS stringArrayView =this.cas.createView("stringArraySofaData");
+      stringArrayView.setSofaDataArray(stringArrayFS, "strings");
+
       // create a float array fs
       FloatArrayFS floatArrayFS =this.cas.createFloatArrayFS(5);
       floatArrayFS.set(0, (float) 0.1);
@@ -460,6 +471,15 @@ public class SofaTest extends TestCase {
         assertTrue(ByteBuffer.wrap(dest).getInt() == intArrayFS.get(i++));
       }
 
+      is.close();
+      is = stringArrayView.getSofaDataStream();
+      assertTrue(is != null);
+      BufferedReader br = new BufferedReader(new InputStreamReader(is));
+      i = 0;
+      while (br.ready()) {
+        assertTrue(stringArrayFS.get(i++).equals(br.readLine()));
+      }
+
       // is = floatarraySofaFS.getSofaDataStream();
       is.close();
       is = floatArrayView.getSofaDataStream();