You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2019/06/18 11:35:29 UTC
svn commit: r1861570 - in
/uima/ruta/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree:
FSTreeNode.java PrimitiveTreeNode.java
Author: pkluegl
Date: Tue Jun 18 11:35:29 2019
New Revision: 1861570
URL: http://svn.apache.org/viewvc?rev=1861570&view=rev
Log:
UIMA-6069: create nodes for elements of primitive arrays
Added:
uima/ruta/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/PrimitiveTreeNode.java
Modified:
uima/ruta/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/FSTreeNode.java
Modified: uima/ruta/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/FSTreeNode.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/FSTreeNode.java?rev=1861570&r1=1861569&r2=1861570&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/FSTreeNode.java (original)
+++ uima/ruta/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/FSTreeNode.java Tue Jun 18 11:35:29 2019
@@ -23,7 +23,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Stack;
-import org.apache.commons.lang3.StringUtils;
import org.apache.uima.cas.ArrayFS;
import org.apache.uima.cas.CAS;
import org.apache.uima.cas.CommonArrayFS;
@@ -41,7 +40,8 @@ public class FSTreeNode extends Abstract
this(cas, parent, annotation, new Stack<Type>());
}
- public FSTreeNode(CAS cas, ITreeNode parent, FeatureStructure annotation, Stack<Type> parentTypes) {
+ public FSTreeNode(CAS cas, ITreeNode parent, FeatureStructure annotation,
+ Stack<Type> parentTypes) {
super(cas, parent);
this.fs = annotation;
parentTypes.push(fs.getType());
@@ -92,16 +92,22 @@ public class FSTreeNode extends Abstract
}
}
} else if (featureValue instanceof CommonArrayFS) {
- // handle all other kind of CommonArrayFS nodes (ArrayFS handled above)
+ // handle all other kind of CommonArrayFS nodes (ArrayFS handled above)
CommonArrayFS array = (CommonArrayFS) featureValue;
- String text = "[" + StringUtils.join(array.toStringArray(), ", ") + "]";
- parent.addChild(new ArrayFeatureTreeNode(this, f, text));
+ String text = "Array" + "[" + array.size() + "]";
+ PrimitiveFeatureTreeNode arrayNode = new PrimitiveFeatureTreeNode(this, f, text);
+ parent.addChild(arrayNode);
+ String[] stringArray = array.toStringArray();
+ for (String string : stringArray) {
+ PrimitiveTreeNode stringNode = new PrimitiveTreeNode(arrayNode, string);
+ arrayNode.addChild(stringNode);
+ }
}
} else if (f.getRange().isPrimitive()) {
if ("uima.cas.AnnotationBase:sofa".equals(f.getName())) {
} else {
- parent.addChild(new PrimitiveFeatureTreeNode(this, f, featureStructure
- .getFeatureValueAsString(f)));
+ parent.addChild(
+ new PrimitiveFeatureTreeNode(this, f, featureStructure.getFeatureValueAsString(f)));
}
} else if (f.getRange() instanceof Type) {
FeatureStructure featureValue = featureStructure.getFeatureValue(f);
Added: uima/ruta/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/PrimitiveTreeNode.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/PrimitiveTreeNode.java?rev=1861570&view=auto
==============================================================================
--- uima/ruta/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/PrimitiveTreeNode.java (added)
+++ uima/ruta/trunk/ruta-ep-caseditor/src/main/java/org/apache/uima/ruta/caseditor/view/tree/PrimitiveTreeNode.java Tue Jun 18 11:35:29 2019
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.caseditor.view.tree;
+
+import java.util.Comparator;
+
+import org.apache.uima.cas.Type;
+
+public class PrimitiveTreeNode implements ITreeNode {
+
+ private static final ITreeNode[] EMPTY_NODES = new ITreeNode[0];
+
+ private ITreeNode parent;
+
+ private String value;
+
+ public PrimitiveTreeNode(ITreeNode parent, String value) {
+ this.parent = parent;
+ this.value = value;
+ }
+
+ @Override
+ public void addChild(ITreeNode child) {
+ // nothing to do
+ }
+
+ @Override
+ public ITreeNode[] getChildren() {
+ return EMPTY_NODES;
+ }
+
+ @Override
+ public String getName() {
+ return value;
+ }
+
+ @Override
+ public ITreeNode getParent() {
+ return parent;
+ }
+
+ @Override
+ public Type getType() {
+ return null;
+ }
+
+ @Override
+ public boolean hasChildren() {
+ return false;
+ }
+
+ @Override
+ public void sort(Comparator<ITreeNode> cp) {
+ // nothing to do
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
+
+ if (PrimitiveTreeNode.class.equals(adapter)) {
+ return this;
+ }
+
+ return null;
+ }
+
+}