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 2016/02/22 19:26:34 UTC
svn commit: r1731706 - in
/uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/cvd:
FSNode.java FSTreeModel.java
Author: schor
Date: Mon Feb 22 18:26:34 2016
New Revision: 1731706
URL: http://svn.apache.org/viewvc?rev=1731706&view=rev
Log:
[UIMA-4663] update for V3 internals
Modified:
uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/cvd/FSNode.java
uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/cvd/FSTreeModel.java
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/cvd/FSNode.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/cvd/FSNode.java?rev=1731706&r1=1731705&r2=1731706&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/cvd/FSNode.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/cvd/FSNode.java Mon Feb 22 18:26:34 2016
@@ -21,13 +21,36 @@ package org.apache.uima.tools.cvd;
import java.util.ArrayList;
import java.util.List;
+import java.util.function.IntFunction;
import org.apache.uima.cas.Feature;
-import org.apache.uima.cas.Type;
import org.apache.uima.cas.impl.CASImpl;
import org.apache.uima.cas.impl.FeatureImpl;
-import org.apache.uima.cas.impl.LowLevelCAS;
-import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.cas.impl.SlotKinds.SlotKind;
+import org.apache.uima.cas.impl.TypeImpl;
+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;
+import org.apache.uima.jcas.cas.IntegerArray;
+import org.apache.uima.jcas.cas.LongArray;
+import org.apache.uima.jcas.cas.ShortArray;
+import org.apache.uima.jcas.cas.StringArray;
+import org.apache.uima.jcas.cas.TOP;
+import org.apache.uima.jcas.tcas.Annotation;
+import org.apache.uima.util.Misc;
+
+/**
+ * A node in the FS Tree Model
+ *
+ * A node is
+ * - an Feature Structure array
+ * -- elements may be other nodes
+ * - a primitive value, including Strings
+ * - a Feature Structure
+ */
public class FSNode extends FSTreeNode {
@@ -59,34 +82,60 @@ public class FSNode extends FSTreeNode {
private final int nodeClass;
- private final long addr;
+ private final long intOrLongLikeValue;
+
+ private final TOP fs;
+
+ private final String string;
private final Feature feat;
- private final int arrayElem;
+ private final int arrayElemIdx;
private final boolean isArrayElem;
// Remember if we're displaying a shortened string.
private boolean isShortenedString = false;
+
+ private int k2nc(SlotKind kind) {
+ switch(kind) {
+ case Slot_Boolean:
+ case Slot_BooleanRef: return BOOL_FS;
+ case Slot_Byte:
+ case Slot_ByteRef: return BYTE_FS;
+ case Slot_Short:
+ case Slot_ShortRef: return SHORT_FS;
+ case Slot_Int: return INT_FS;
+ case Slot_Float: return FLOAT_FS;
+ case Slot_LongRef: return LONG_FS;
+ case Slot_DoubleRef: return DOUBLE_FS;
+ case Slot_StrRef: return STRING_FS;
+ case Slot_HeapRef: return STD_FS;
+ default: Misc.internalError(); return -1;
+ }
+ }
- FSNode(FSTreeModel fSTreeModel, int nodeClass, long addr, Feature feat) {
+ FSNode(FSTreeModel fSTreeModel, int nodeClass, Object fsOrString, long intOrLongLikeValue, Feature feat) {
super();
this.fSTreeModel = fSTreeModel;
this.nodeClass = nodeClass;
- this.addr = addr;
+ this.intOrLongLikeValue = intOrLongLikeValue;
+ this.fs = (fsOrString instanceof TOP) ? (TOP) fsOrString : null;
+ this.string = (fsOrString instanceof String) ? (String) fsOrString : null;
this.feat = feat;
- this.arrayElem = 0;
+ this.arrayElemIdx = 0;
this.isArrayElem = false;
}
- FSNode(FSTreeModel fSTreeModel, int nodeClass, long addr, int elem) {
+ FSNode(FSTreeModel fSTreeModel, int nodeClass, Object fsOrString, long intOrLongLikeValue, int elementIndex) {
super();
this.fSTreeModel = fSTreeModel;
this.nodeClass = nodeClass;
- this.addr = addr;
+ this.intOrLongLikeValue = intOrLongLikeValue;
+ this.fs = (fsOrString instanceof TOP) ? (TOP) fsOrString : null;
+ this.string = (fsOrString instanceof String) ? (String) fsOrString : null;
this.feat = null;
- this.arrayElem = elem;
+ this.arrayElemIdx = elementIndex;
this.isArrayElem = true;
}
@@ -101,99 +150,123 @@ public class FSNode extends FSTreeNode {
if ((this.nodeClass != STD_FS) && (this.nodeClass != ARRAY_FS)) {
return;
}
- if (this.addr == 0) {
+ // only FSs or Arrays have children
+ if (this.fs == null) {
return;
}
- Type type = getType();
- CASImpl cas = this.fSTreeModel.getCas();
- if (this.fSTreeModel.getCas().isArrayType(type)) {
- int arrayLength = cas.ll_getArraySize((int) this.addr);
+
+ TypeImpl type = getType();
+// CASImpl cas = this.fSTreeModel.getCas();
+ if (type.isArray()) {
+ int arrayLength = ((CommonArray)fs).size();
// if (arrayLength > 20) {
// arrayLength = 20;
// }
- FSNode node = null;
- int arrayPos = cas.getArrayStartAddress((int) this.addr);
- int nodeClass1;
- if (cas.isIntArrayType(type)) {
- nodeClass1 = FSNode.INT_FS;
- } else if (cas.isFloatArrayType(type)) {
- nodeClass1 = FSNode.FLOAT_FS;
- } else if (cas.isStringArrayType(type)) {
- nodeClass1 = FSNode.STRING_FS;
- } else if (cas.isByteArrayType(type)) {
- nodeClass1 = FSNode.BYTE_FS;
- } else if (cas.isBooleanArrayType(type)) {
- nodeClass1 = FSNode.BOOL_FS;
- } else if (cas.isShortArrayType(type)) {
- nodeClass1 = FSNode.SHORT_FS;
- } else if (cas.isLongArrayType(type)) {
- nodeClass1 = FSNode.LONG_FS;
- } else if (cas.isDoubleArrayType(type)) {
- nodeClass1 = FSNode.DOUBLE_FS;
- } else {
- nodeClass1 = FSNode.STD_FS;
- }
+
+// FSNode node = null;
+// int arrayPos = cas.getArrayStartAddress((int) this.addr);
+// int nodeClass1;
+// if (cas.isIntArrayType(type)) {
+// nodeClass1 = FSNode.INT_FS;
+// } else if (cas.isFloatArrayType(type)) {
+// nodeClass1 = FSNode.FLOAT_FS;
+// } else if (cas.isStringArrayType(type)) {
+// nodeClass1 = FSNode.STRING_FS;
+// } else if (cas.isByteArrayType(type)) {
+// nodeClass1 = FSNode.BYTE_FS;
+// } else if (cas.isBooleanArrayType(type)) {
+// nodeClass1 = FSNode.BOOL_FS;
+// } else if (cas.isShortArrayType(type)) {
+// nodeClass1 = FSNode.SHORT_FS;
+// } else if (cas.isLongArrayType(type)) {
+// nodeClass1 = FSNode.LONG_FS;
+// } else if (cas.isDoubleArrayType(type)) {
+// nodeClass1 = FSNode.DOUBLE_FS;
+// } else {
+// nodeClass1 = FSNode.STD_FS;
+// }
List<FSNode> arrayNodes = new ArrayList<FSNode>(arrayLength);
- if (nodeClass1 == INT_FS || nodeClass1 == FLOAT_FS || nodeClass1 == STRING_FS
- || nodeClass1 == STD_FS) {
- for (int i = 0; i < arrayLength; i++) {
- node = new FSNode(this.fSTreeModel, nodeClass1, cas.getHeapValue(arrayPos), i);
- arrayNodes.add(node);
- ++arrayPos;
- }
- } else if (nodeClass1 == BYTE_FS) {
- for (int i = 0; i < arrayLength; i++) {
- node = new FSNode(this.fSTreeModel, nodeClass1, cas.ll_getByteArrayValue((int) this.addr,
- i), i);
- arrayNodes.add(node);
- ++arrayPos;
- }
- } else if (nodeClass1 == SHORT_FS) {
- for (int i = 0; i < arrayLength; i++) {
- node = new FSNode(this.fSTreeModel, nodeClass1, cas.ll_getShortArrayValue(
- (int) this.addr, i), i);
- arrayNodes.add(node);
- ++arrayPos;
- }
- } else if (nodeClass1 == BOOL_FS) {
- for (int i = 0; i < arrayLength; i++) {
- int temp = cas.ll_getBooleanArrayValue((int) this.addr, i) ? 1 : 0;
- node = new FSNode(this.fSTreeModel, nodeClass1, temp, i);
- arrayNodes.add(node);
- ++arrayPos;
- }
- } else if (nodeClass1 == LONG_FS) {
- for (int i = 0; i < arrayLength; i++) {
- long temp = cas.ll_getLongArrayValue((int) this.addr, i);
- node = new FSNode(this.fSTreeModel, nodeClass1, temp, i);
- arrayNodes.add(node);
- ++arrayPos;
- }
- } else if (nodeClass1 == DOUBLE_FS) {
- for (int i = 0; i < arrayLength; i++) {
- double temp = cas.ll_getDoubleArrayValue((int) this.addr, i);
- node = new FSNode(this.fSTreeModel, nodeClass1, CASImpl.double2long(temp), i);
- arrayNodes.add(node);
- ++arrayPos;
+ SlotKind kind = type.getComponentSlotKind();
+ int nc = k2nc(kind);
+ switch (kind) {
+ case Slot_Int: {
+ int[] a = ((IntegerArray)fs)._getTheArray();
+ makeNodes(arrayNodes, i -> new FSNode(this.fSTreeModel, nc, null, a[i], i));
+ break;
}
- }
+ case Slot_Float: {
+ float[] a = ((FloatArray)fs)._getTheArray();
+ makeNodes(arrayNodes, i -> new FSNode(this.fSTreeModel, nc, null, CASImpl.float2int(a[i]), i));
+ break;
+ }
+ case Slot_StrRef: {
+ String[] a = ((StringArray)fs)._getTheArray();
+ makeNodes(arrayNodes, i -> new FSNode(this.fSTreeModel, nc, a[i], 0, i));
+ break;
+ }
+ case Slot_HeapRef: {
+ TOP[] a = ((FSArray)fs)._getTheArray();
+ makeNodes(arrayNodes, i -> new FSNode(this.fSTreeModel, nc, a[i], 0, i));
+ break;
+ }
+ case Slot_BooleanRef: {
+ boolean[] a = ((BooleanArray)fs)._getTheArray();
+ makeNodes(arrayNodes, i -> new FSNode(this.fSTreeModel, nc, null, a[i]? 1 : 0, i));
+ break;
+ }
+ case Slot_ByteRef: {
+ byte[] a = ((ByteArray)fs)._getTheArray();
+ makeNodes(arrayNodes, i -> new FSNode(this.fSTreeModel, nc, null, a[i], i));
+ break;
+ }
+ case Slot_ShortRef: {
+ short[] a = ((ShortArray)fs)._getTheArray();
+ makeNodes(arrayNodes, i -> new FSNode(this.fSTreeModel, nc, null, a[i], i));
+ break;
+ }
+ case Slot_LongRef: {
+ long[] a = ((LongArray)fs)._getTheArray();
+ makeNodes(arrayNodes, i -> new FSNode(this.fSTreeModel, nc, null, a[i], i));
+ break;
+ }
+ case Slot_DoubleRef: {
+ double[] a = ((DoubleArray)fs)._getTheArray();
+ makeNodes(arrayNodes, i -> new FSNode(this.fSTreeModel, nc, null, CASImpl.double2long(a[i]), i));
+ break;
+ }
+ default: Misc.internalError();
+ } // end of switch
+
this.children = FSTreeModel.createArrayChildren(0, arrayLength, arrayNodes, this.fSTreeModel);
} else {
- this.children = new ArrayList<FSTreeNode>();
- List<?> feats = type.getFeatures();
- for (int i = 0; i < feats.size(); i++) {
- FeatureImpl feat1 = (FeatureImpl) feats.get(i);
- long featAddr = cas.getHeapValue((int) this.addr + cas.getFeatureOffset(feat1.getCode()));
- if (cas.isDoubleType(feat1.getRange()) || cas.isLongType(feat1.getRange())) {
- featAddr = cas.ll_getLongValue((int) featAddr);
- }
- FSNode childNode = new FSNode(this.fSTreeModel, this.fSTreeModel.getNodeType(
- (int) this.addr, feat1), featAddr, feat1);
- this.children.add(childNode);
+ this.children = new ArrayList<FSTreeNode>(type.getNumberOfFeatures());
+ List<FeatureImpl> feats = type.getFeatureImpls();
+ for (FeatureImpl f : feats) {
+ SlotKind kind = f.getSlotKind();
+ int nc = k2nc(kind);
+ switch(kind) {
+ case Slot_Boolean: children.add(new FSNode(this.fSTreeModel, nc, null, fs.getBooleanValue(f) ? 1 : 0, f)); break;
+ case Slot_Byte: children.add(new FSNode(this.fSTreeModel, nc, null, fs.getByteValue(f), f)); break;
+ case Slot_Short: children.add(new FSNode(this.fSTreeModel, nc, null, fs.getShortValue(f), f)); break;
+ case Slot_Int: children.add(new FSNode(this.fSTreeModel, nc, null, fs.getIntValue(f), f)); break;
+ case Slot_Float: children.add(new FSNode(this.fSTreeModel, nc, null, CASImpl.float2int(fs.getFloatValue(f)), f)); break;
+ case Slot_LongRef: children.add(new FSNode(this.fSTreeModel, nc, null, fs.getLongValue(f), f)); break;
+ case Slot_DoubleRef:children.add(new FSNode(this.fSTreeModel, nc, null, CASImpl.double2long(fs.getDoubleValue(f)), f)); break;
+ case Slot_StrRef: children.add(new FSNode(this.fSTreeModel, nc, fs.getStringValue(f), 0, f)); break;
+ case Slot_HeapRef: children.add(new FSNode(this.fSTreeModel, nc, fs.getFeatureValue(f), 0, f)); break;
+ default: Misc.internalError();
+ } // end of switch
}
}
}
+ private void makeNodes(List<FSNode> arrayNodes, IntFunction<FSNode> newFSNode) {
+ final int size = arrayNodes.size();
+ for (int idx = 0; idx < size; idx++) {
+ arrayNodes.add(newFSNode.apply(idx));
+ }
+ }
+
public String toString() {
if (this.nodeClass == DISPLAY_NODE) {
return this.fSTreeModel.getRootString();
@@ -202,7 +275,7 @@ public class FSNode extends FSTreeNode {
buf.append("<html>");
if (this.isArrayElem) {
buf.append('[');
- buf.append(this.arrayElem);
+ buf.append(this.arrayElemIdx);
buf.append("] = ");
} else if (this.feat != null) {
buf.append(getFeatureString());
@@ -225,42 +298,41 @@ public class FSNode extends FSTreeNode {
return this.isShortenedString;
}
- /**
- *
+ /**
* @return for string nodes, return the string value (so it can be displayed seperately
*/
String getFullString() {
if (getNodeClass() != STRING_FS) {
return null;
}
- return this.fSTreeModel.getCas().getStringForCode((int) this.addr);
+ return this.string;
}
private String getValueString() {
- CASImpl cas = this.fSTreeModel.getCas();
+
switch (this.nodeClass) {
case INT_FS:
case BYTE_FS:
case SHORT_FS: {
- return Long.toString(this.addr);
+ return Long.toString(this.intOrLongLikeValue);
}
case FLOAT_FS: {
- return Float.toString(CASImpl.int2float((int) this.addr));
+ return Float.toString(CASImpl.int2float((int) this.intOrLongLikeValue));
}
case BOOL_FS: {
- return (0 == this.addr) ? "false" : "true";
+ return (0 == this.intOrLongLikeValue) ? "false" : "true";
}
case LONG_FS: {
- return Long.toString(this.addr);
+ return Long.toString(this.intOrLongLikeValue);
}
case DOUBLE_FS: {
- return Double.toString(CASImpl.long2double(this.addr));
+ return Double.toString(CASImpl.long2double(this.intOrLongLikeValue));
}
case STRING_FS: {
- if (this.addr == LowLevelCAS.NULL_FS_REF) {
+ if (this.string == null) {
return getNullString();
}
- String s = cas.getStringForCode((int) this.addr);
+ String s = this.string;
// Check if we need to shorten the string for display purposes
String s1 = shortenString(s);
// Remember if string is shortened
@@ -268,14 +340,14 @@ public class FSNode extends FSTreeNode {
return "\"" + escapeLt(s1) + "\"";
}
case ARRAY_FS: {
- if (cas.getHeapValue((int) this.addr) == LowLevelCAS.NULL_FS_REF) {
+ if (this.fs == null) {
return getNullString();
}
return "<font color=blue>" + getType().getName() + "</font>["
- + cas.ll_getArraySize((int) this.addr) + "]";
+ + ((CommonArray)fs).size() + "]";
}
case STD_FS: {
- if (cas.getHeapValue((int) this.addr) == LowLevelCAS.NULL_FS_REF) {
+ if (fs == null) {
return getNullString();
}
return "<font color=blue>" + getType().getName() + "</font>";
@@ -323,43 +395,23 @@ public class FSNode extends FSTreeNode {
}
int getArrayPos() {
- return this.arrayElem;
+ return this.arrayElemIdx;
}
- Type getType() {
- CASImpl cas = this.fSTreeModel.getCas();
- return cas.getTypeSystemImpl().ll_getTypeForCode(cas.getHeapValue((int) this.addr));
+ TypeImpl getType() {
+ return fs._typeImpl;
}
public boolean isAnnotation() {
- CASImpl cas = this.fSTreeModel.getCas();
- if (this.nodeClass != STD_FS || this.addr == 0) {
- return false;
- }
- if (cas.getTypeSystem().subsumes(cas.getAnnotationType(), getType())) {
- if (cas == ((AnnotationFS) cas.createFS((int) this.addr)).getView()) {
- return true;
- }
- }
- return false;
+ return fs != null && fs instanceof Annotation;
}
public int getStart() {
- CASImpl cas = this.fSTreeModel.getCas();
- if (isAnnotation()) {
- final FeatureImpl feat1 = (FeatureImpl) cas.getBeginFeature();
- return cas.getHeapValue((int) this.addr + cas.getFeatureOffset(feat1.getCode()));
- }
- return -1;
+ return isAnnotation() ? ((Annotation)fs).getBegin() : -1;
}
public int getEnd() {
- CASImpl cas = this.fSTreeModel.getCas();
- if (isAnnotation()) {
- final FeatureImpl feat1 = (FeatureImpl) cas.getEndFeature();
- return cas.getHeapValue((int) this.addr + cas.getFeatureOffset(feat1.getCode()));
- }
- return -1;
+ return isAnnotation() ? ((Annotation)fs).getEnd() : -1;
}
}
Modified: uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/cvd/FSTreeModel.java
URL: http://svn.apache.org/viewvc/uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/cvd/FSTreeModel.java?rev=1731706&r1=1731705&r2=1731706&view=diff
==============================================================================
--- uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/cvd/FSTreeModel.java (original)
+++ uima/uimaj/branches/experiment-v3-jcas/uimaj-tools/src/main/java/org/apache/uima/tools/cvd/FSTreeModel.java Mon Feb 22 18:26:34 2016
@@ -30,17 +30,17 @@ import javax.swing.tree.TreePath;
import org.apache.uima.cas.CAS;
import org.apache.uima.cas.FSIndex;
import org.apache.uima.cas.FSIterator;
-import org.apache.uima.cas.Feature;
-import org.apache.uima.cas.FeatureStructure;
import org.apache.uima.cas.Type;
import org.apache.uima.cas.impl.CASImpl;
-import org.apache.uima.cas.impl.FeatureImpl;
+import org.apache.uima.cas.impl.TypeImpl;
+import org.apache.uima.cas.impl.TypeImpl_string;
+import org.apache.uima.cas.impl.TypeSystemImpl;
+import org.apache.uima.jcas.cas.TOP;
/**
- * Insert comment for enclosing_type here.
- *
- *
+ * Swing Tree Model for Feature Structures
*/
+
public class FSTreeModel implements TreeModel {
private FSTreeNode root;
@@ -61,7 +61,7 @@ public class FSTreeModel implements Tree
*/
public FSTreeModel() {
super();
- this.root = new FSNode(this, FSNode.DISPLAY_NODE, 0, null);
+ this.root = new FSNode(this, FSNode.DISPLAY_NODE, null, 0, null);
this.root.setChildren(new ArrayList<FSTreeNode>());
}
@@ -71,13 +71,13 @@ public class FSTreeModel implements Tree
final int size = index.size();
this.rootString = "<html><font color=green>" + indexName + "</font> - <font color=blue>"
+ index.getType().getName() + "</font> [" + size + "]</html>";
- this.root = new FSNode(this, FSNode.DISPLAY_NODE, 0, null);
+ this.root = new FSNode(this, FSNode.DISPLAY_NODE, null, 0, null);
this.fss = new ArrayList<FSNode>();
- FSIterator it = index.iterator();
+ FSIterator<TOP> it = index.iterator();
int count = 0;
for (it.moveToFirst(); it.isValid(); it.moveToNext()) {
- FeatureStructure fs = it.get();
- this.fss.add(new FSNode(this, getNodeType(fs.getType()), fs.hashCode(), count));
+ TOP fs = it.get();
+ this.fss.add(new FSNode(this, getNodeType(fs.getType()), fs, fs.id(), count));
++count;
}
List<FSTreeNode> kids = createArrayChildren(0, size, this.fss, this);
@@ -122,55 +122,50 @@ public class FSTreeModel implements Tree
return node.getChildren().get(index);
}
- int getNodeType(int addr, Feature feat) {
- Type domType = feat.getRange();
- if (this.cas.isStringType(domType)) {
- return FSNode.STRING_FS;
- } else if (this.cas.isIntType(domType)) {
- return FSNode.INT_FS;
- } else if (this.cas.isFloatType(domType)) {
- return FSNode.FLOAT_FS;
- } else if (this.cas.isByteType(domType)) {
- return FSNode.BYTE_FS;
- } else if (this.cas.isBooleanType(domType)) {
- return FSNode.BOOL_FS;
- } else if (this.cas.isShortType(domType)) {
- return FSNode.SHORT_FS;
- } else if (this.cas.isLongType(domType)) {
- return FSNode.LONG_FS;
- } else if (this.cas.isDoubleType(domType)) {
- return FSNode.DOUBLE_FS;
- } else if (this.cas.isAbstractArrayType(domType)) {
- final int featAddr = this.cas.getFeatureValue(addr, ((FeatureImpl) feat).getCode());
- if (this.cas.isArrayType(this.cas.getTypeSystemImpl()
- .ll_getTypeForCode(this.cas.getHeapValue(featAddr)))) {
- return FSNode.ARRAY_FS;
- }
- }
- return FSNode.STD_FS;
- }
+// int getNodeType(int addr, Feature feat) {
+// Type domType = feat.getRange();
+// if (this.cas.isStringType(domType)) {
+// return FSNode.STRING_FS;
+// } else if (this.cas.isIntType(domType)) {
+// return FSNode.INT_FS;
+// } else if (this.cas.isFloatType(domType)) {
+// return FSNode.FLOAT_FS;
+// } else if (this.cas.isByteType(domType)) {
+// return FSNode.BYTE_FS;
+// } else if (this.cas.isBooleanType(domType)) {
+// return FSNode.BOOL_FS;
+// } else if (this.cas.isShortType(domType)) {
+// return FSNode.SHORT_FS;
+// } else if (this.cas.isLongType(domType)) {
+// return FSNode.LONG_FS;
+// } else if (this.cas.isDoubleType(domType)) {
+// return FSNode.DOUBLE_FS;
+// } else if (this.cas.isArrayOfFsType(domType)) {
+// final int featAddr = this.cas.getFeatureValue(addr, ((FeatureImpl) feat).getCode());
+// if (this.cas.isArrayType(this.cas.getTypeSystemImpl()
+// .ll_getTypeForCode(this.cas.getHeapValue(featAddr)))) {
+// return FSNode.ARRAY_FS;
+// }
+// }
+// return FSNode.STD_FS;
+// }
int getNodeType(Type type) {
- if (this.cas.isStringType(type)) {
+ if (type instanceof TypeImpl_string) {
return FSNode.STRING_FS;
- } else if (this.cas.isIntType(type)) {
- return FSNode.INT_FS;
- } else if (this.cas.isFloatType(type)) {
- return FSNode.FLOAT_FS;
- } else if (this.cas.isArrayType(type)) {
- return FSNode.ARRAY_FS;
- } else if (this.cas.isByteArrayType(type)) {
- return FSNode.BYTE_FS;
- } else if (this.cas.isBooleanArrayType(type)) {
- return FSNode.BOOL_FS;
- } else if (this.cas.isShortArrayType(type)) {
- return FSNode.SHORT_FS;
- } else if (this.cas.isLongArrayType(type)) {
- return FSNode.LONG_FS;
- } else if (this.cas.isDoubleArrayType(type)) {
- return FSNode.DOUBLE_FS;
+ } else {
+ switch(((TypeImpl)type).getCode()) {
+ case TypeSystemImpl.intTypeCode: return FSNode.INT_FS;
+ case TypeSystemImpl.floatTypeCode: return FSNode.FLOAT_FS;
+ case TypeSystemImpl.fsArrayTypeCode: return FSNode.ARRAY_FS;
+ case TypeSystemImpl.byteArrayTypeCode: return FSNode.BYTE_FS;
+ case TypeSystemImpl.booleanArrayTypeCode: return FSNode.BOOL_FS;
+ case TypeSystemImpl.shortArrayTypeCode: return FSNode.SHORT_FS;
+ case TypeSystemImpl.longArrayTypeCode: return FSNode.LONG_FS;
+ case TypeSystemImpl.doubleArrayTypeCode: return FSNode.DOUBLE_FS;
+ default: return FSNode.STD_FS;
+ }
}
- return FSNode.STD_FS;
}
/**