You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by tw...@apache.org on 2007/02/13 16:39:02 UTC

svn commit: r507048 - /incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/AnnotationBaseImpl.java

Author: twgoetz
Date: Tue Feb 13 07:39:02 2007
New Revision: 507048

URL: http://svn.apache.org/viewvc?view=rev&rev=507048
Log:
Jira UIMA-308: fix toString().

https://issues.apache.org/jira/browse/UIMA-308

Modified:
    incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/AnnotationBaseImpl.java

Modified: incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/AnnotationBaseImpl.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/AnnotationBaseImpl.java?view=diff&rev=507048&r1=507047&r2=507048
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/AnnotationBaseImpl.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/AnnotationBaseImpl.java Tue Feb 13 07:39:02 2007
@@ -22,6 +22,7 @@
 import org.apache.uima.cas.AnnotationBaseFS;
 import org.apache.uima.cas.CAS;
 import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.SofaFS;
 
 /**
  * Class comment for AnnotationImpl.java goes here.
@@ -36,9 +37,6 @@
       super();
     }
 
-    /**
-     * @see org.apache.uima.cas.impl.FSGenerator#createFS(int, LowLevelCAS)
-     */
     public FeatureStructure createFS(int addr, CASImpl cas) {
       return new AnnotationBaseImpl(addr, cas);
     }
@@ -70,9 +68,21 @@
     return toString(3);
   }
 
+  private final String getSofaId() {
+    String sofaID = "<none>";
+    CAS cas = getView();
+    if (cas != null) {
+      SofaFS sofaFs = cas.getSofa();
+      if (sofaFs != null) {
+        sofaID = sofaFs.getSofaID();
+      }
+    }
+    return sofaID;
+  }
+  
   public String toString(int indent) {
     StringBuffer buf = new StringBuffer();
-    prettyPrint(0, indent, buf, true, getView().getSofa().getSofaID());
+    prettyPrint(0, indent, buf, true, getSofaId());
     return buf.toString();
   }
 
@@ -80,6 +90,6 @@
    * see org.apache.uima.cas.AnnotationBase#getView()
    */
   public CAS getView() {
-    return getCASImpl().ll_getSofaCasView(addr);
+    return getCASImpl().ll_getSofaCasView(this.addr);
   }
 }