Author: schor
Date: Fri Dec 23 21:46:51 2016
New Revision: 1775913

URL: http://svn.apache.org/viewvc?rev=1775913&view=rev
Log:
[UIMA-5233] redo class hierarchy, move things around

Modified:
    
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImpl.java
    
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImplC.java

Modified: 
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImpl.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImpl.java?rev=1775913&r1=1775912&r2=1775913&view=diff
==============================================================================
--- 
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImpl.java
 (original)
+++ 
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImpl.java
 Fri Dec 23 21:46:51 2016
@@ -19,141 +19,24 @@
 
 package org.apache.uima.cas.impl;
 
-import org.apache.uima.cas.CASRuntimeException;
-import org.apache.uima.cas.Feature;
 import org.apache.uima.cas.FeatureStructure;
-import org.apache.uima.cas.Type;
 
 /**
- * Feature structure implementation.
+ * Extra class for V2 compatibility only
+ * Methods here downcast to FeatureStructureImplC
  * 
- * This is the common super class of all Feature Structures
- * 
- *   including the JCAS (derived from TOP)
- *   and non JCas FSs
- * 
- * 
- * @version $Revision: 1.6 $
+ * Methods here - only those not in v2's FeatureStructure
  */
-public abstract class FeatureStructureImpl implements FeatureStructure, 
Cloneable {
-
-       public abstract int getAddress();
-
-       protected abstract CASImpl getCASImpl();
-
-       public Type getType() {
-         return ((FeatureStructureImplC) this).getType();
-       }
-       
-       public int getavoidcollisionTypeCode() {
-    return ((FeatureStructureImplC) this)._getTypeImpl().getCode();
-       }
-
-       public void setFeatureValue(Feature feat, FeatureStructure fs) {
-         ((FeatureStructureImplC) this).setFeatureValue(feat, fs);
-       }
-
-       public void setIntValue(Feature feat, int val) {
-    ((FeatureStructureImplC) this).setIntValue(feat, val);
-  }
-
-       public void setFloatValue(Feature feat, float val) {
-    ((FeatureStructureImplC) this).setFloatValue(feat, val);
-  }
-
-       public void setStringValue(Feature feat, String val) {
-    ((FeatureStructureImplC) this).setStringValue(feat, val);
-  }
-
-       public void setByteValue(Feature feat, byte val) throws 
CASRuntimeException {
-    ((FeatureStructureImplC) this).setByteValue(feat, val);
-  }
-
-       public void setBooleanValue(Feature feat, boolean b) throws 
CASRuntimeException {
-    ((FeatureStructureImplC) this).setBooleanValue(feat, b);
-  }
-
-       public void setShortValue(Feature feat, short val) throws 
CASRuntimeException {
-    ((FeatureStructureImplC) this).setShortValue(feat, val);
-  }
-
-       public void setLongValue(Feature feat, long val) throws 
CASRuntimeException {
-    ((FeatureStructureImplC) this).setLongValue(feat, val);
-  }
-
-       public void setDoubleValue(Feature feat, double val) throws 
CASRuntimeException {
-    ((FeatureStructureImplC) this).setDoubleValue(feat, val);
-  }
-
-       public void setFeatureValueFromString(Feature feat, String s) throws 
CASRuntimeException {
-    ((FeatureStructureImplC) this).setFeatureValueFromString(feat, s);
-  }
-
-       public FeatureStructure getFeatureValue(Feature feat) throws 
CASRuntimeException {
-    return ((FeatureStructureImplC) this).getFeatureValue(feat);
-  }
-
-       public int getIntValue(Feature feat) {
-    return ((FeatureStructureImplC) this).getIntValue(feat);
-  }
-
-       public float getFloatValue(Feature feat) throws CASRuntimeException {
-    return ((FeatureStructureImplC) this).getFloatValue(feat);
-  }
-       
-       public String getStringValue(Feature f) throws CASRuntimeException {
-    return ((FeatureStructureImplC) this).getStringValue(f);
-  }
-         
-       public byte getByteValue(Feature feat) throws CASRuntimeException {
-    return ((FeatureStructureImplC) this).getByteValue(feat);
-  }
-
-       public boolean getBooleanValue(Feature feat) throws CASRuntimeException 
{
-    return ((FeatureStructureImplC) this).getBooleanValue(feat);
-  }
-
-       public short getShortValue(Feature feat) throws CASRuntimeException {
-    return ((FeatureStructureImplC) this).getShortValue(feat);
-  }
-
-       public long getLongValue(Feature feat) throws CASRuntimeException {
-    return ((FeatureStructureImplC) this).getLongValue(feat);
-  }
-
-       public double getDoubleValue(Feature feat) throws CASRuntimeException {
-    return ((FeatureStructureImplC) this).getDoubleValue(feat);
-  }
-
-       public String getFeatureValueAsString(Feature feat) throws 
CASRuntimeException {
-    return ((FeatureStructureImplC) this).getFeatureValueAsString(feat);
-  }
-
-
-       public String toString() {
-    return ((FeatureStructureImplC) this).toString();
-  }
-
-       public String toString(int indent) {
-    return ((FeatureStructureImplC) this).toString(indent);
-  }
-
-       public void prettyPrint(int indent, int incr, StringBuffer buf, boolean 
useShortNames) {
-    ((FeatureStructureImplC) this).prettyPrint(indent, incr, buf, 
useShortNames);
-  }
-
-       public void prettyPrint(int indent, int incr, StringBuffer buf, boolean 
useShortNames, String s) {
-    ((FeatureStructureImplC) this).prettyPrint(indent, incr, buf, 
useShortNames, s);
-  }
-
-       public void prettyPrint(int indent, int incr, StringBuffer buf, boolean 
useShortNames, String s,
-                       FeatureStructureImplC.PrintReferences printRefs) {
-    ((FeatureStructureImplC) this).prettyPrint(
-        indent, incr, new StringBuilder(buf), useShortNames, s, printRefs);
-  }
-
-       public Object clone() throws CASRuntimeException {
-         return ((FeatureStructureImplC) this).clone();
-       }
+public interface FeatureStructureImpl extends FeatureStructure {
 
+  int getAddress(); 
+  
+  String toString(int indent);
+
+  void prettyPrint(int indent, int incr, StringBuffer buf, boolean 
useShortNames);
+  void prettyPrint(int indent, int incr, StringBuilder buf, boolean 
useShortNames);
+  
+  void prettyPrint(int indent, int incr, StringBuffer buf, boolean 
useShortNames, String s);
+  void prettyPrint(int indent, int incr, StringBuilder buf, boolean 
useShortNames, String s);
+  
 }

Modified: 
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImplC.java
URL: 
http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImplC.java?rev=1775913&r1=1775912&r2=1775913&view=diff
==============================================================================
--- 
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImplC.java
 (original)
+++ 
uima/uimaj/branches/experiment-v3-jcas/uimaj-core/src/main/java/org/apache/uima/cas/impl/FeatureStructureImplC.java
 Fri Dec 23 21:46:51 2016
@@ -25,8 +25,10 @@ import java.util.Map;
 import java.util.Set;
 import java.util.function.IntFunction;
 
+import org.apache.uima.UIMARuntimeException;
 import org.apache.uima.cas.CAS;
 import org.apache.uima.cas.CASRuntimeException;
+import org.apache.uima.cas.CommonArrayFS;
 import org.apache.uima.cas.Feature;
 import org.apache.uima.cas.FeatureStructure;
 import org.apache.uima.cas.SofaFS;
@@ -37,7 +39,6 @@ import org.apache.uima.internal.util.Str
 import org.apache.uima.jcas.JCas;
 import org.apache.uima.jcas.cas.BooleanArray;
 import org.apache.uima.jcas.cas.ByteArray;
-import org.apache.uima.jcas.cas.CommonArray;
 import org.apache.uima.jcas.cas.DoubleArray;
 import org.apache.uima.jcas.cas.FSArray;
 import org.apache.uima.jcas.cas.FloatArray;
@@ -68,7 +69,7 @@ import org.apache.uima.jcas.impl.JCasImp
  *     -- can't be static - may be multiple type systems in use
  * 
  */
-public class FeatureStructureImplC extends FeatureStructureImpl implements 
FeatureStructure, Cloneable {
+public class FeatureStructureImplC implements FeatureStructureImpl {
 
   // note: these must be enabled to make the test cases work
   public static final String DISABLE_RUNTIME_FEATURE_VALIDATION = 
"uima.disable_runtime_feature_validation";
@@ -197,7 +198,7 @@ public class FeatureStructureImplC exten
     }
 
     
-    if (traceFSs && !(this instanceof CommonArray)) {
+    if (traceFSs && !(this instanceof CommonArrayFS)) {
       _casView.traceFSCreate(this);
     }
   }
@@ -231,7 +232,7 @@ public class FeatureStructureImplC exten
       _refData = _allocRefData();
     }
     
-    if (traceFSs && !(this instanceof CommonArray)) {
+    if (traceFSs && !(this instanceof CommonArrayFS)) {
       _casView.traceFSCreate(this);
     }
     
@@ -316,6 +317,7 @@ public class FeatureStructureImplC exten
    * NOTE: Possible name collision
    * @return the internal id of this fs - unique to this CAS, a positive int
    */
+  @Override
   public final int getAddress() { return _id; };
 
   @Override
@@ -761,7 +763,7 @@ public class FeatureStructureImplC exten
      * 0 out those bits before or-ing in the high order 32 bits.
      */
 //    final int offset = adjOffset + _getIntDataArrayOffset();
-    return (((long)_intData[adjOffset]) & 0x00000000ffffffffL) | 
(((long)_intData[adjOffset + 1]) << 32); 
+    return ((_intData[adjOffset]) & 0x00000000ffffffffL) | 
(((long)_intData[adjOffset + 1]) << 32); 
   }
   
   @Override
@@ -856,8 +858,8 @@ public class FeatureStructureImplC exten
   public FeatureStructureImplC clone() throws CASRuntimeException { 
         
     if (_typeImpl.isArray()) {
-      CommonArray original = (CommonArray) this;
-      CommonArray copy = (CommonArray) _casView.createArray(_typeImpl, 
original.size());
+      CommonArrayFS original = (CommonArrayFS) this;
+      CommonArrayFS copy = (CommonArrayFS) _casView.createArray(_typeImpl, 
original.size());
       copy.copyValuesFrom(original);      
       return (FeatureStructureImplC) copy;
     }
@@ -929,7 +931,8 @@ public class FeatureStructureImplC exten
     }
 
     int printInfo(FeatureStructure ref) {
-      if (this.tree.get(ref) == null) {
+      String k = this.tree.get(ref);
+      if (k == null || k.equals("seen once")) {
         return NO_LABEL;
       }
       if (this.seen.contains(ref)) {
@@ -975,16 +978,37 @@ public class FeatureStructureImplC exten
     return toString(3);
   }
 
+  @Override
   public String toString(int indent) {
     StringBuilder buf = new StringBuilder();
     prettyPrint(0, indent, buf, true, null);
     return buf.toString();
   }
 
+  /* 
+   * This next bit is to remain backward compatible with callers using 
StringBuilders or
+   * StringBuffers.
+   * (non-Javadoc)
+   * @see org.apache.uima.cas.impl.FeatureStructureImpl#prettyPrint(int, int, 
java.lang.StringBuilder, boolean)
+   */
+  @Override
   public void prettyPrint(int indent, int incr, StringBuilder buf, boolean 
useShortNames) {
     prettyPrint(indent, incr, buf, useShortNames, null);
   }
 
+  @Override
+  public void prettyPrint(int indent, int incr, StringBuffer buf, boolean 
useShortNames) {
+    prettyPrint(indent, incr, buf, useShortNames, null);
+  }
+
+  @Override
+  public void prettyPrint(int indent, int incr, StringBuffer buf, boolean 
useShortNames, String s) {
+    PrintReferences printRefs = new PrintReferences();
+    getPrintRefs(printRefs);
+    prettyPrint(indent, incr, buf, useShortNames, s, printRefs);
+  }
+  
+  @Override
   public void prettyPrint(int indent, int incr, StringBuilder buf, boolean 
useShortNames, String s) {
     PrintReferences printRefs = new PrintReferences();
     getPrintRefs(printRefs);
@@ -994,6 +1018,21 @@ public class FeatureStructureImplC exten
   public void prettyPrint(
       int indent, 
       int incr, 
+      StringBuffer buf, 
+      boolean useShortNames, 
+      String s, 
+      PrintReferences printRefs) {
+   
+    StringBuilder b2 = new StringBuilder(buf);
+    prettyPrint(indent, incr, b2, useShortNames, s, printRefs);
+    
+    buf.setLength(0);
+    buf.append(b2.toString());
+  }
+  
+  public void prettyPrint(
+      int indent, 
+      int incr, 
       StringBuilder buf, 
       boolean useShortNames, 
       String s, 
@@ -1150,7 +1189,7 @@ public class FeatureStructureImplC exten
   }
   
   public int getTypeIndexID() {
-    throw new CASRuntimeException(CASRuntimeException.INTERNAL_ERROR); // 
dummy, always overridden
+    throw new CASRuntimeException(UIMARuntimeException.INTERNAL_ERROR); // 
dummy, always overridden
   }
   
   /**


Reply via email to