You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by al...@apache.org on 2006/12/11 22:44:54 UTC

svn commit: r485887 - /incubator/uima/uimaj/trunk/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/CASTransportable.java

Author: alally
Date: Mon Dec 11 13:44:54 2006
New Revision: 485887

URL: http://svn.apache.org/viewvc?view=rev&rev=485887
Log:
Fixed so that getMetadata call does not need to get a CAS from the
CAS pool, so it can be executed even if all CASes are currently in use.

Modified:
    incubator/uima/uimaj/trunk/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/CASTransportable.java

Modified: incubator/uima/uimaj/trunk/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/CASTransportable.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/CASTransportable.java?view=diff&rev=485887&r1=485886&r2=485887
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/CASTransportable.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-adapter-vinci/src/main/java/org/apache/uima/adapter/vinci/CASTransportable.java Mon Dec 11 13:44:54 2006
@@ -333,6 +333,23 @@
       }
     }
     if (Constants.KEYS.equals(qName)) {
+      // the data inside the KEYS element is the contents of an incoming CAS.
+      // So this is where we need to grab a CAS from the CasPool and initialize 
+      //the XCASDeserializer.
+      if (myCas == null) {
+        myCas = myCasPool.getCas(0);
+      }
+      myCas.reset();
+      XCASDeserializer deser = new XCASDeserializer(myCas.getTypeSystem(), this.uimaContext);
+      deser.setDocumentTypeName("Detag:DetagContent");
+      if (!ignoreResponse) {
+        handler = deser.getXCASHandler(myCas, outOfTypeSystemData);
+      } else {
+        handler = new DefaultHandler();
+      }
+      handler.startDocument();
+      handler.startElement("", "CAS", "CAS", null);
+      //set the ready flag to indicate that following elements are CAS data
       ready++;
     }
   }
@@ -341,6 +358,10 @@
     // Debug.p("End element: " + qName);
     if (Constants.KEYS.equals(qName)) {
       ready--;
+      if (ready == 0) {
+        handler.endElement("", "CAS", "CAS");
+        handler.endDocument();
+      }
     }
     if (ready > 0) {
       handler.endElement(uri, name, qName);
@@ -369,22 +390,6 @@
    * @see org.xml.sax.helpers.DefaultHandler#startDocument()
    */
   public void startDocument() throws SAXException {
-    // this gets called from the XTalkToSax parser after it confirms
-    // that there is data to be read from the socket. So this is where we
-    // need to grab a CAS from the CasPool and initialize the XCASDeserializer.
-    if (myCas == null) {
-      myCas = myCasPool.getCas(0);
-    }
-    myCas.reset();
-    XCASDeserializer deser = new XCASDeserializer(myCas.getTypeSystem(), this.uimaContext);
-    deser.setDocumentTypeName("Detag:DetagContent");
-    if (!ignoreResponse) {
-      handler = deser.getXCASHandler(myCas, outOfTypeSystemData);
-    } else {
-      handler = new DefaultHandler();
-    }
-    handler.startDocument();
-    handler.startElement("", "CAS", "CAS", null);
     this.ready = 0;
   }
 
@@ -394,8 +399,6 @@
    * @see org.xml.sax.helpers.DefaultHandler#endDocument()
    */
   public void endDocument() throws SAXException {
-    handler.endElement("", "CAS", "CAS");
-    handler.endDocument();
   }
   
   /**