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 2013/05/17 14:38:36 UTC

svn commit: r1483772 [5/15] - in /uima/sandbox/ruta/trunk: example-projects/ruta-ep-example-extensions/src/main/java/org/apache/uima/ruta/example/extensions/ ruta-core/src/main/antlr3/org/apache/uima/ruta/parser/ ruta-core/src/main/java/org/apache/uima...

Added: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/NumberFeatureExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/NumberFeatureExpression.java?rev=1483772&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/NumberFeatureExpression.java (added)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/NumberFeatureExpression.java Fri May 17 12:38:11 2013
@@ -0,0 +1,97 @@
+/*
+ * 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.expression.number;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.ruta.RutaBlock;
+import org.apache.uima.ruta.RutaStream;
+import org.apache.uima.ruta.UIMAConstants;
+import org.apache.uima.ruta.expression.feature.FeatureExpression;
+
+public class NumberFeatureExpression extends NumberExpression {
+
+  private FeatureExpression fe;
+
+  public NumberFeatureExpression(FeatureExpression fe) {
+    super();
+    this.fe = fe;
+  }
+
+  @Override
+  public int getIntegerValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
+    return getNumberValue(parent, annotation, stream).intValue();
+  }
+
+  @Override
+  public double getDoubleValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
+    return getNumberValue(parent, annotation, stream).doubleValue();
+  }
+
+  @Override
+  public float getFloatValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
+    return getNumberValue(parent, annotation, stream).floatValue();
+  }
+
+  private Number getNumberValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
+    Number result = null;
+    Type type = fe.getTypeExpr().getType(parent);
+    Feature feature = fe.getFeature(parent);
+    Type range = feature.getRange();
+    List<AnnotationFS> list = getTargetAnnotation(annotation, type, stream);
+    Collection<AnnotationFS> featureAnnotations = fe.getFeatureAnnotations(list, stream, parent,
+            false);
+    if (!featureAnnotations.isEmpty()) {
+      AnnotationFS next = featureAnnotations.iterator().next();
+      if (UIMAConstants.TYPE_BYTE.equals(range.getName())) {
+        result = next.getByteValue(feature);
+      } else if (UIMAConstants.TYPE_DOUBLE.equals(range.getName())) {
+        result = next.getDoubleValue(feature);
+      } else if (UIMAConstants.TYPE_FLOAT.equals(range.getName())) {
+        result = next.getFloatValue(feature);
+      } else if (UIMAConstants.TYPE_INTEGER.equals(range.getName())) {
+        result = next.getIntValue(feature);
+      } else if (UIMAConstants.TYPE_LONG.equals(range.getName())) {
+        result = next.getLongValue(feature);
+      } else if (UIMAConstants.TYPE_SHORT.equals(range.getName())) {
+        result = next.getShortValue(feature);
+      }
+    }
+    return result;
+  }
+
+  @Override
+  public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
+    return "" + getNumberValue(parent, annotation, stream);
+  }
+
+  public FeatureExpression getFe() {
+    return fe;
+  }
+
+  public void setFe(FeatureExpression fe) {
+    this.fe = fe;
+  }
+
+}

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/NumberFunctionExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/NumberFunctionExpression.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/NumberFunctionExpression.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/NumberFunctionExpression.java Fri May 17 12:38:11 2013
@@ -15,11 +15,10 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.expression.number;
 
-
 public abstract class NumberFunctionExpression extends NumberExpression {
 
 }

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/ReferenceNumberExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/ReferenceNumberExpression.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/ReferenceNumberExpression.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/ReferenceNumberExpression.java Fri May 17 12:38:11 2013
@@ -15,11 +15,13 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.expression.number;
 
-import org.apache.uima.ruta.RutaStatement;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.ruta.RutaBlock;
+import org.apache.uima.ruta.RutaStream;
 
 public class ReferenceNumberExpression extends NumberExpression {
 
@@ -31,7 +33,7 @@ public class ReferenceNumberExpression e
   }
 
   @Override
-  public double getDoubleValue(RutaStatement parent) {
+  public double getDoubleValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
     Object value = parent.getEnvironment().getVariableValue(getVar());
     double variableValue = 0;
     if (value instanceof Number) {
@@ -41,7 +43,7 @@ public class ReferenceNumberExpression e
   }
 
   @Override
-  public float getFloatValue(RutaStatement parent) {
+  public float getFloatValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
     Object value = parent.getEnvironment().getVariableValue(getVar());
     float variableValue = 0;
     if (value instanceof Number) {
@@ -49,9 +51,9 @@ public class ReferenceNumberExpression e
     }
     return variableValue;
   }
-  
+
   @Override
-  public int getIntegerValue(RutaStatement parent) {
+  public int getIntegerValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
     Object value = parent.getEnvironment().getVariableValue(getVar());
     int variableValue = 0;
     if (value instanceof Number) {
@@ -61,12 +63,12 @@ public class ReferenceNumberExpression e
   }
 
   @Override
-  public String getStringValue(RutaStatement parent) {
+  public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
     Class<?> variableType = parent.getEnvironment().getVariableType(getVar());
     if (variableType.equals(Integer.class)) {
-      return "" + getIntegerValue(parent);
+      return "" + getIntegerValue(parent, null, stream);
     } else {
-      return "" + getDoubleValue(parent);
+      return "" + getDoubleValue(parent, null, stream);
     }
   }
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/SimpleNumberExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/SimpleNumberExpression.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/SimpleNumberExpression.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/number/SimpleNumberExpression.java Fri May 17 12:38:11 2013
@@ -15,11 +15,13 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.expression.number;
 
-import org.apache.uima.ruta.RutaStatement;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.ruta.RutaBlock;
+import org.apache.uima.ruta.RutaStream;
 
 public class SimpleNumberExpression extends NumberExpression {
 
@@ -31,17 +33,17 @@ public class SimpleNumberExpression exte
   }
 
   @Override
-  public double getDoubleValue(RutaStatement parent) {
+  public double getDoubleValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
     return number.doubleValue();
   }
 
   @Override
-  public float getFloatValue(RutaStatement parent) {
+  public float getFloatValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
     return number.floatValue();
   }
-  
+
   @Override
-  public int getIntegerValue(RutaStatement parent) {
+  public int getIntegerValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
     return number.intValue();
   }
 
@@ -50,12 +52,12 @@ public class SimpleNumberExpression exte
   }
 
   @Override
-  public String getStringValue(RutaStatement parent) {
+  public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
     boolean floating = number.intValue() != number.doubleValue();
     if (floating) {
-      return "" + getDoubleValue(parent);
+      return "" + getDoubleValue(parent, null, stream);
     } else {
-      return "" + getIntegerValue(parent);
+      return "" + getIntegerValue(parent, null, stream);
     }
   }
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/LiteralWordListExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/LiteralWordListExpression.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/LiteralWordListExpression.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/LiteralWordListExpression.java Fri May 17 12:38:11 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.expression.resource;
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/LiteralWordTableExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/LiteralWordTableExpression.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/LiteralWordTableExpression.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/LiteralWordTableExpression.java Fri May 17 12:38:11 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.expression.resource;
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/ReferenceWordListExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/ReferenceWordListExpression.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/ReferenceWordListExpression.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/ReferenceWordListExpression.java Fri May 17 12:38:11 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.expression.resource;
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/ReferenceWordTableExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/ReferenceWordTableExpression.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/ReferenceWordTableExpression.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/ReferenceWordTableExpression.java Fri May 17 12:38:11 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.expression.resource;
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/WordListExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/WordListExpression.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/WordListExpression.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/WordListExpression.java Fri May 17 12:38:11 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.expression.resource;
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/WordTableExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/WordTableExpression.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/WordTableExpression.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/resource/WordTableExpression.java Fri May 17 12:38:11 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.expression.resource;
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/ComposedStringExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/ComposedStringExpression.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/ComposedStringExpression.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/ComposedStringExpression.java Fri May 17 12:38:11 2013
@@ -15,14 +15,15 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.expression.string;
 
 import java.util.List;
 
-import org.apache.uima.ruta.RutaStatement;
-
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.ruta.RutaBlock;
+import org.apache.uima.ruta.RutaStream;
 
 public class ComposedStringExpression extends LiteralStringExpression {
 
@@ -34,10 +35,10 @@ public class ComposedStringExpression ex
   }
 
   @Override
-  public String getStringValue(RutaStatement parent) {
+  public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
     StringBuilder result = new StringBuilder();
     for (StringExpression each : getExpressions()) {
-      result.append(each.getStringValue(parent));
+      result.append(each.getStringValue(parent, annotation, stream));
     }
     return result.toString();
   }

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/LiteralStringExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/LiteralStringExpression.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/LiteralStringExpression.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/LiteralStringExpression.java Fri May 17 12:38:11 2013
@@ -15,11 +15,10 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.expression.string;
 
-
 public abstract class LiteralStringExpression extends StringExpression {
 
 }

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/ReferenceStringExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/ReferenceStringExpression.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/ReferenceStringExpression.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/ReferenceStringExpression.java Fri May 17 12:38:11 2013
@@ -15,11 +15,13 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.expression.string;
 
-import org.apache.uima.ruta.RutaStatement;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.ruta.RutaBlock;
+import org.apache.uima.ruta.RutaStream;
 
 public class ReferenceStringExpression extends LiteralStringExpression {
 
@@ -31,7 +33,7 @@ public class ReferenceStringExpression e
   }
 
   @Override
-  public String getStringValue(RutaStatement parent) {
+  public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
     String variableValue = parent.getEnvironment().getVariableValue(getVar(), String.class);
     return variableValue;
   }

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/RemoveFunction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/RemoveFunction.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/RemoveFunction.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/RemoveFunction.java Fri May 17 12:38:11 2013
@@ -15,14 +15,15 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.expression.string;
 
 import java.util.List;
 
-import org.apache.uima.ruta.RutaStatement;
-
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.ruta.RutaBlock;
+import org.apache.uima.ruta.RutaStream;
 
 public class RemoveFunction extends StringFunctionExpression {
 
@@ -37,11 +38,11 @@ public class RemoveFunction extends Stri
   }
 
   @Override
-  public String getStringValue(RutaStatement parent) {
+  public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
     StringBuilder result = new StringBuilder();
     String value = parent.getEnvironment().getVariableValue(var, String.class);
     for (StringExpression each : list) {
-      String string = each.getStringValue(parent);
+      String string = each.getStringValue(parent, annotation, stream);
       String[] split = value.split(string);
       for (String r : split) {
         result.append(r);

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/SimpleStringExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/SimpleStringExpression.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/SimpleStringExpression.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/SimpleStringExpression.java Fri May 17 12:38:11 2013
@@ -19,7 +19,9 @@
 
 package org.apache.uima.ruta.expression.string;
 
-import org.apache.uima.ruta.RutaStatement;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.ruta.RutaBlock;
+import org.apache.uima.ruta.RutaStream;
 
 public class SimpleStringExpression extends LiteralStringExpression {
 
@@ -39,7 +41,7 @@ public class SimpleStringExpression exte
   }
 
   @Override
-  public String getStringValue(RutaStatement parent) {
+  public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
     return getValue();
   }
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/StringExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/StringExpression.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/StringExpression.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/StringExpression.java Fri May 17 12:38:11 2013
@@ -15,15 +15,32 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.expression.string;
 
-import org.apache.uima.ruta.RutaStatement;
+import java.util.List;
+
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.ruta.RutaBlock;
+import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.expression.RutaExpression;
+import org.apache.uima.ruta.rule.RuleElement;
+import org.apache.uima.ruta.rule.RuleMatch;
 
 public abstract class StringExpression extends RutaExpression {
 
-  public abstract String getStringValue(RutaStatement parent);
+  public String getStringValue(RutaBlock parent, RuleMatch match, RuleElement element,
+          RutaStream stream) {
+    List<AnnotationFS> matchedAnnotationsOf = match.getMatchedAnnotationsOf(element);
+    // TODO: do we need to select the correct annotation?
+    AnnotationFS annotation = null;
+    if (!matchedAnnotationsOf.isEmpty()) {
+      annotation = matchedAnnotationsOf.get(0);
+    }
+    return getStringValue(parent, annotation, stream);
+  }
+
+  public abstract String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream);
 
 }

Added: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/StringFeatureExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/StringFeatureExpression.java?rev=1483772&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/StringFeatureExpression.java (added)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/StringFeatureExpression.java Fri May 17 12:38:11 2013
@@ -0,0 +1,63 @@
+/*
+ * 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.expression.string;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.uima.cas.Feature;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.ruta.RutaBlock;
+import org.apache.uima.ruta.RutaStream;
+import org.apache.uima.ruta.expression.feature.FeatureExpression;
+
+public class StringFeatureExpression extends StringExpression {
+
+  private FeatureExpression fe;
+
+  public StringFeatureExpression(FeatureExpression fe) {
+    super();
+    this.fe = fe;
+  }
+
+  @Override
+  public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
+    Type type = fe.getTypeExpr().getType(parent);
+    Feature feature = fe.getFeature(parent);
+    List<AnnotationFS> list = getTargetAnnotation(annotation, type, stream);
+    Collection<AnnotationFS> featureAnnotations = fe.getFeatureAnnotations(list, stream, parent,
+            false);
+    if (!featureAnnotations.isEmpty()) {
+      AnnotationFS next = featureAnnotations.iterator().next();
+      return next.getStringValue(feature);
+    }
+    return null;
+  }
+
+  public FeatureExpression getFe() {
+    return fe;
+  }
+
+  public void setFe(FeatureExpression fe) {
+    this.fe = fe;
+  }
+
+}

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/StringFunctionExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/StringFunctionExpression.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/StringFunctionExpression.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/string/StringFunctionExpression.java Fri May 17 12:38:11 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.expression.string;
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/ReferenceTypeExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/ReferenceTypeExpression.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/ReferenceTypeExpression.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/ReferenceTypeExpression.java Fri May 17 12:38:11 2013
@@ -20,7 +20,9 @@
 package org.apache.uima.ruta.expression.type;
 
 import org.apache.uima.cas.Type;
-import org.apache.uima.ruta.RutaStatement;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.ruta.RutaBlock;
+import org.apache.uima.ruta.RutaStream;
 
 public class ReferenceTypeExpression extends TypeExpression {
 
@@ -41,12 +43,12 @@ public class ReferenceTypeExpression ext
   }
 
   @Override
-  public Type getType(RutaStatement parent) {
+  public Type getType(RutaBlock parent) {
     return parent.getEnvironment().getVariableValue(var, Type.class);
   }
 
   @Override
-  public String getStringValue(RutaStatement parent) {
+  public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
     Type type = getType(parent);
     return type != null ? type.getName() : "null";
   }

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/SimpleTypeExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/SimpleTypeExpression.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/SimpleTypeExpression.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/SimpleTypeExpression.java Fri May 17 12:38:11 2013
@@ -20,7 +20,9 @@
 package org.apache.uima.ruta.expression.type;
 
 import org.apache.uima.cas.Type;
-import org.apache.uima.ruta.RutaStatement;
+import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.ruta.RutaBlock;
+import org.apache.uima.ruta.RutaStream;
 
 public class SimpleTypeExpression extends TypeExpression {
 
@@ -32,7 +34,7 @@ public class SimpleTypeExpression extend
   }
 
   @Override
-  public Type getType(RutaStatement parent) {
+  public Type getType(RutaBlock parent) {
     return parent.getEnvironment().getType(typeString);
   }
 
@@ -42,7 +44,7 @@ public class SimpleTypeExpression extend
   }
 
   @Override
-  public String getStringValue(RutaStatement parent) {
+  public String getStringValue(RutaBlock parent, AnnotationFS annotation, RutaStream stream) {
     return typeString;
   }
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/TypeExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/TypeExpression.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/TypeExpression.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/TypeExpression.java Fri May 17 12:38:11 2013
@@ -20,11 +20,11 @@
 package org.apache.uima.ruta.expression.type;
 
 import org.apache.uima.cas.Type;
-import org.apache.uima.ruta.RutaStatement;
+import org.apache.uima.ruta.RutaBlock;
 import org.apache.uima.ruta.expression.string.StringExpression;
 
 public abstract class TypeExpression extends StringExpression {
 
-  public abstract Type getType(RutaStatement parent);
+  public abstract Type getType(RutaBlock parent);
 
 }

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/TypeFunctionExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/TypeFunctionExpression.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/TypeFunctionExpression.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/TypeFunctionExpression.java Fri May 17 12:38:11 2013
@@ -15,11 +15,10 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.expression.type;
 
-
 public abstract class TypeFunctionExpression extends TypeExpression {
 
 }

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/DefaultEngineLoader.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/DefaultEngineLoader.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/DefaultEngineLoader.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/DefaultEngineLoader.java Fri May 17 12:38:11 2013
@@ -36,12 +36,15 @@ import org.apache.uima.util.XMLInputSour
 
 public abstract class DefaultEngineLoader implements IEngineLoader {
 
-  public AnalysisEngine loadEngine(String location, String viewName) throws InvalidXMLException, ResourceInitializationException, ResourceConfigurationException, IOException, URISyntaxException  {
+  public AnalysisEngine loadEngine(String location, String viewName) throws InvalidXMLException,
+          ResourceInitializationException, ResourceConfigurationException, IOException,
+          URISyntaxException {
     return loadEngineMyself(location, viewName);
   }
 
   protected AnalysisEngine loadEngineMyself(String location, String viewName) throws IOException,
-          InvalidXMLException, ResourceInitializationException, ResourceConfigurationException, URISyntaxException {
+          InvalidXMLException, ResourceInitializationException, ResourceConfigurationException,
+          URISyntaxException {
     URL url = new File(location).toURL();
     AnalysisEngine ae = Ruta.wrapAnalysisEngine(url, viewName);
     return ae;

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaActionExtension.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaActionExtension.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaActionExtension.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaActionExtension.java Fri May 17 12:38:11 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.extensions;
 
@@ -28,7 +28,6 @@ import antlr.ANTLRException;
 
 public interface IRutaActionExtension extends IRutaExtension {
 
-  AbstractRutaAction createAction(String name, List<RutaExpression> args)
-          throws ANTLRException;
+  AbstractRutaAction createAction(String name, List<RutaExpression> args) throws ANTLRException;
 
 }

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaBooleanFunctionExtension.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaBooleanFunctionExtension.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaBooleanFunctionExtension.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaBooleanFunctionExtension.java Fri May 17 12:38:11 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.extensions;
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaConditionExtension.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaConditionExtension.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaConditionExtension.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaConditionExtension.java Fri May 17 12:38:11 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.extensions;
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaExtension.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaExtension.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaExtension.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaExtension.java Fri May 17 12:38:11 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.extensions;
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaNumberFunctionExtension.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaNumberFunctionExtension.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaNumberFunctionExtension.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaNumberFunctionExtension.java Fri May 17 12:38:11 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.extensions;
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaStringFunctionExtension.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaStringFunctionExtension.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaStringFunctionExtension.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaStringFunctionExtension.java Fri May 17 12:38:11 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.extensions;
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaTypeFunctionExtension.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaTypeFunctionExtension.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaTypeFunctionExtension.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/IRutaTypeFunctionExtension.java Fri May 17 12:38:11 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.extensions;
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/RutaExternalFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/RutaExternalFactory.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/RutaExternalFactory.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/extensions/RutaExternalFactory.java Fri May 17 12:38:11 2013
@@ -58,8 +58,8 @@ public class RutaExternalFactory {
     typeFunctionExtensions = new HashMap<String, IRutaTypeFunctionExtension>();
   }
 
-  public AbstractRutaCondition createExternalCondition(Token id,
-          List<RutaExpression> args) throws ANTLRException {
+  public AbstractRutaCondition createExternalCondition(Token id, List<RutaExpression> args)
+          throws ANTLRException {
     String name = id.getText();
     IRutaConditionExtension extension = conditionExtensions.get(name);
     if (extension != null) {

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/AnonymousWordList.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/AnonymousWordList.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/AnonymousWordList.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/AnonymousWordList.java Fri May 17 12:38:11 2013
@@ -62,8 +62,8 @@ public class AnonymousWordList implement
     return result;
   }
 
-  public List<AnnotationFS> find(RutaStream stream, Map<String, Type> typeMap,
-          boolean ignoreCase, int ignoreLength, boolean edit, double distance, String ignoreToken) {
+  public List<AnnotationFS> find(RutaStream stream, Map<String, Type> typeMap, boolean ignoreCase,
+          int ignoreLength, boolean edit, double distance, String ignoreToken) {
     return new ArrayList<AnnotationFS>();
   }
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/CSVTable.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/CSVTable.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/CSVTable.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/CSVTable.java Fri May 17 12:38:11 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.resource;
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/MultiTreeWordListPersistence.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/MultiTreeWordListPersistence.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/MultiTreeWordListPersistence.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/MultiTreeWordListPersistence.java Fri May 17 12:38:11 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.resource;
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/RutaTable.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/RutaTable.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/RutaTable.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/RutaTable.java Fri May 17 12:38:11 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.resource;
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/RutaWordList.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/RutaWordList.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/RutaWordList.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/RutaWordList.java Fri May 17 12:38:11 2013
@@ -43,7 +43,7 @@ public interface RutaWordList {
   Collection<AnnotationFS> find(RutaStream stream, boolean ignoreCase, int size,
           char[] ignoreToken, int maxIgnoredTokens, boolean ingoreWS);
 
-  Collection<AnnotationFS> find(RutaStream stream, Map<String, Type> typeMap,
-          boolean ignoreCase, int ignoreLength, boolean edit, double distance, String ignoreToken);
+  Collection<AnnotationFS> find(RutaStream stream, Map<String, Type> typeMap, boolean ignoreCase,
+          int ignoreLength, boolean edit, double distance, String ignoreToken);
 
 }

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/TreeWordList.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/TreeWordList.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/TreeWordList.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/TreeWordList.java Fri May 17 12:38:11 2013
@@ -113,22 +113,23 @@ public class TreeWordList implements Rut
    * Creates a new Tree in the existing treeWordList from a file with path pathname
    * 
    * @param stream
-   *          Open InputStream containing the word for the treeWordList, this method will close the stream.
+   *          Open InputStream containing the word for the treeWordList, this method will close the
+   *          stream.
    */
   public void buildNewTree(InputStream stream) throws IOException {
-      Scanner scan = new Scanner(stream, "UTF-8");
-      // creating a new tree
-      this.root = new TextNode();
-      while (scan.hasNextLine()) {
-        String s = scan.nextLine().trim();
-    
-        if (s.endsWith("=")) {
-          s = s.substring(0, s.length() - 1);
-          s = s.trim();
-        }
-        addWord(s);
+    Scanner scan = new Scanner(stream, "UTF-8");
+    // creating a new tree
+    this.root = new TextNode();
+    while (scan.hasNextLine()) {
+      String s = scan.nextLine().trim();
+
+      if (s.endsWith("=")) {
+        s = s.substring(0, s.length() - 1);
+        s = s.trim();
       }
-      scan.close();
+      addWord(s);
+    }
+    scan.close();
   }
 
   /**
@@ -290,8 +291,7 @@ public class TreeWordList implements Rut
     return results;
   }
 
-  public List<AnnotationFS> find(RutaStream stream, boolean ignoreCase, int size,
-          boolean ignoreWS) {
+  public List<AnnotationFS> find(RutaStream stream, boolean ignoreCase, int size, boolean ignoreWS) {
     return find(stream, ignoreCase, size, null, 0, ignoreWS);
   }
 
@@ -373,8 +373,8 @@ public class TreeWordList implements Rut
     return name;
   }
 
-  public List<AnnotationFS> find(RutaStream stream, Map<String, Type> typeMap,
-          boolean ignoreCase, int ignoreLength, boolean edit, double distance, String ignoreToken) {
+  public List<AnnotationFS> find(RutaStream stream, Map<String, Type> typeMap, boolean ignoreCase,
+          int ignoreLength, boolean edit, double distance, String ignoreToken) {
     return null;
   }
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/TrieXMLEventHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/TrieXMLEventHandler.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/TrieXMLEventHandler.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/TrieXMLEventHandler.java Fri May 17 12:38:11 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.resource;
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/XMLEventHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/XMLEventHandler.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/XMLEventHandler.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/resource/XMLEventHandler.java Fri May 17 12:38:11 2013
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
-*/
+ */
 
 package org.apache.uima.ruta.resource;
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/AbstractRule.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/AbstractRule.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/AbstractRule.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/AbstractRule.java Fri May 17 12:38:11 2013
@@ -25,7 +25,7 @@ import org.apache.uima.ruta.RutaStatemen
 public abstract class AbstractRule extends RutaStatement {
 
   private final int id;
-  
+
   public AbstractRule(RutaBlock parent, int id) {
     super(parent);
     this.id = id;
@@ -35,5 +35,4 @@ public abstract class AbstractRule exten
     return id;
   }
 
-  
 }

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/AbstractRuleElement.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/AbstractRuleElement.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/AbstractRuleElement.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/AbstractRuleElement.java Fri May 17 12:38:11 2013
@@ -97,9 +97,9 @@ public abstract class AbstractRuleElemen
     return matchInfo;
   }
 
-  public List<RuleElementMatch> evaluateMatches(List<RuleElementMatch> matches,
-          RutaBlock parent) {
-    return quantifier.evaluateMatches(matches, parent, emptyCrowd);
+  public List<RuleElementMatch> evaluateMatches(List<RuleElementMatch> matches, RutaBlock parent,
+          RutaStream stream) {
+    return quantifier.evaluateMatches(matches, parent, stream, emptyCrowd);
   }
 
   public List<Integer> getSelfIndexList() {

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/AbstractRuleMatch.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/AbstractRuleMatch.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/AbstractRuleMatch.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/AbstractRuleMatch.java Fri May 17 12:38:11 2013
@@ -22,7 +22,6 @@ package org.apache.uima.ruta.rule;
 import java.util.List;
 
 import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.ruta.RutaStream;
 
 public abstract class AbstractRuleMatch<T extends AbstractRule> {
 
@@ -47,11 +46,6 @@ public abstract class AbstractRuleMatch<
     return true;
   }
 
-//  public abstract List<AnnotationFS> getMatchedAnnotations(RutaStream stream,
-//          List<Integer> indexes, RuleElementContainer container);
-
-  public abstract List<AnnotationFS> getMatchedAnnotationsOfRoot(RutaStream stream);
-  
- 
+  public abstract List<AnnotationFS> getMatchedAnnotationsOfRoot();
 
 }

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElement.java Fri May 17 12:38:11 2013
@@ -54,14 +54,14 @@ public class ComposedRuleElement extends
           ComposedRuleElementMatch containerMatch, RuleElement entryPoint, RutaStream stream,
           InferenceCrowd crowd) {
     RuleElement anchorElement = getAnchoringRuleElement(stream);
-    ComposedRuleElementMatch composedMatch = createComposedMatch(ruleMatch, containerMatch);
+    ComposedRuleElementMatch composedMatch = createComposedMatch(ruleMatch, containerMatch, stream);
     anchorElement.startMatch(ruleMatch, ruleApply, composedMatch, entryPoint, stream, crowd);
   }
 
   protected ComposedRuleElementMatch createComposedMatch(RuleMatch ruleMatch,
-          ComposedRuleElementMatch containerMatch) {
+          ComposedRuleElementMatch containerMatch, RutaStream stream) {
     ComposedRuleElementMatch composedMatch = new ComposedRuleElementMatch(this, containerMatch);
-    includeMatch(ruleMatch, containerMatch, composedMatch);
+    includeMatch(ruleMatch, containerMatch, composedMatch, stream);
     return composedMatch;
   }
 
@@ -71,7 +71,8 @@ public class ComposedRuleElement extends
           InferenceCrowd crowd) {
     RuleElement nextElement = getNextElement(after, this);
     if (nextElement != null) {
-      ComposedRuleElementMatch composedMatch = createComposedMatch(ruleMatch, containerMatch);
+      ComposedRuleElementMatch composedMatch = createComposedMatch(ruleMatch, containerMatch,
+              stream);
       nextElement.continueMatch(after, annotation, ruleMatch, ruleApply, composedMatch,
               sideStepOrigin, entryPoint, stream, crowd);
     } else {
@@ -95,13 +96,15 @@ public class ComposedRuleElement extends
       while (!stopMatching) {
         RuleElement nextElement = getNextElement(after, this);
         if (nextElement != null) {
-          ComposedRuleElementMatch composedMatch = createComposedMatch(ruleMatch, containerMatch);
+          ComposedRuleElementMatch composedMatch = createComposedMatch(ruleMatch, containerMatch,
+                  stream);
           nextElement.continueMatch(after, nextAnnotation, ruleMatch, ruleApply, composedMatch,
                   sideStepOrigin, this, stream, crowd);
           ComposedRuleElementMatch parentContainerMatch = containerMatch.getContainerMatch();
           List<RuleElementMatch> match = getMatch(ruleMatch, parentContainerMatch);
           int lenghtBefore = match.size();
-          List<RuleElementMatch> evaluateMatches = quantifier.evaluateMatches(match, parent, crowd);
+          List<RuleElementMatch> evaluateMatches = quantifier.evaluateMatches(match, parent,
+                  stream, crowd);
           ruleMatch.setMatched(ruleMatch.matched() && evaluateMatches != null);
           if (evaluateMatches.size() != lenghtBefore) {
             failed = true;
@@ -141,7 +144,8 @@ public class ComposedRuleElement extends
       List<RuleElementMatch> match = getMatch(ruleMatch, parentContainerMatch);
       boolean continueMatch = quantifier.continueMatch(after, annotation, this, ruleMatch,
               parentContainerMatch, stream, crowd);
-      List<RuleElementMatch> evaluateMatches = quantifier.evaluateMatches(match, parent, crowd);
+      List<RuleElementMatch> evaluateMatches = quantifier.evaluateMatches(match, parent, stream,
+              crowd);
       ruleMatch.setMatched(ruleMatch.matched() && (evaluateMatches != null || continueMatch));
       if (failed) {
         if (nextElement != null) {
@@ -204,11 +208,11 @@ public class ComposedRuleElement extends
   }
 
   private void includeMatch(RuleMatch ruleMatch, ComposedRuleElementMatch containerMatch,
-          ComposedRuleElementMatch composedMatch) {
+          ComposedRuleElementMatch composedMatch, RutaStream stream) {
     if (containerMatch == null) {
       ruleMatch.setRootMatch(composedMatch);
     } else {
-      containerMatch.addInnerMatch(this, composedMatch, false);
+      containerMatch.addInnerMatch(this, composedMatch, false, stream);
     }
   }
 
@@ -231,7 +235,7 @@ public class ComposedRuleElement extends
       evaluatedConditions.add(eval);
     }
     match.setConditionInfo(evaluatedConditions);
-    match.evaluateInnerMatches(true);
+    match.evaluateInnerMatches(true, stream);
   }
 
   public Collection<AnnotationFS> getAnchors(RutaStream stream) {

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElementMatch.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElementMatch.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElementMatch.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/ComposedRuleElementMatch.java Fri May 17 12:38:11 2013
@@ -30,6 +30,7 @@ import java.util.TreeMap;
 import java.util.TreeSet;
 
 import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.ruta.RutaStream;
 
 public class ComposedRuleElementMatch extends RuleElementMatch {
 
@@ -65,12 +66,13 @@ public class ComposedRuleElementMatch ex
     return innerMatches;
   }
 
-  public void addInnerMatch(RuleElement ruleElement, RuleElementMatch ruleElementMatch) {
-    addInnerMatch(ruleElement, ruleElementMatch, true);
+  public void addInnerMatch(RuleElement ruleElement, RuleElementMatch ruleElementMatch,
+          RutaStream stream) {
+    addInnerMatch(ruleElement, ruleElementMatch, true, stream);
   }
 
   public void addInnerMatch(RuleElement ruleElement, RuleElementMatch ruleElementMatch,
-          boolean included) {
+          boolean included, RutaStream stream) {
     List<RuleElementMatch> list = innerMatches.get(ruleElement);
     if (list == null) {
       list = new ArrayList<RuleElementMatch>();
@@ -79,16 +81,16 @@ public class ComposedRuleElementMatch ex
     list.add(ruleElementMatch);
     textsMatched.addAll(ruleElementMatch.getTextsMatched());
 
-    evaluateInnerMatches(included);
+    evaluateInnerMatches(included, stream);
   }
 
-  public void evaluateInnerMatches(boolean included) {
+  public void evaluateInnerMatches(boolean included, RutaStream stream) {
     boolean allDone = true;
     Set<Entry<RuleElement, List<RuleElementMatch>>> entrySet = innerMatches.entrySet();
     for (Entry<RuleElement, List<RuleElementMatch>> entry : entrySet) {
       RuleElement element = entry.getKey();
       List<RuleElementMatch> value = entry.getValue();
-      allDone &= (element.getQuantifier().isOptional(element.getParent()) || value != null);
+      allDone &= (element.getQuantifier().isOptional(element.getParent(), stream) || value != null);
       if (value != null && !value.isEmpty() && included) {
         for (RuleElementMatch ruleElementMatch : value) {
           allDone &= ruleElementMatch.matched();
@@ -181,16 +183,14 @@ public class ComposedRuleElementMatch ex
         if (value != null) {
           for (RuleElementMatch each : value) {
             if (each instanceof ComposedRuleElementMatch) {
-              ((ComposedRuleElementMatch)each).update(extendedContainerMatch);
+              ((ComposedRuleElementMatch) each).update(extendedContainerMatch);
             }
           }
-        } 
+        }
       }
     }
   }
 
-  
-  
   public String toString() {
     return "CREM" + innerMatches.toString();
   }
@@ -217,5 +217,4 @@ public class ComposedRuleElementMatch ex
 
   }
 
- 
 }

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RegExpRule.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RegExpRule.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RegExpRule.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RegExpRule.java Fri May 17 12:38:11 2013
@@ -71,13 +71,13 @@ public class RegExpRule extends Abstract
     RuleApply ruleApply = new RuleApply(this, false);
     crowd.beginVisit(this, ruleApply);
 
-    String regexpString = regexpExpr.getStringValue(getParent());
+    String regexpString = regexpExpr.getStringValue(getParent(), null, stream);
     AnnotationFS documentAnnotation = stream.getDocumentAnnotation();
     String document = documentAnnotation.getCoveredText();
     int delta = documentAnnotation.getBegin();
 
-    Map<Integer, List<Type>> groupTypes = getGroup2Types();
-    Map<Integer, Map<Type, Map<String, Object>>> fa = getFeatureAssignmentMap();
+    Map<Integer, List<Type>> groupTypes = getGroup2Types(stream);
+    Map<Integer, Map<Type, Map<String, Object>>> fa = getFeatureAssignmentMap(stream);
 
     Pattern pattern = Pattern.compile(regexpString, Pattern.MULTILINE | Pattern.DOTALL);
     Matcher matcher = pattern.matcher(document);
@@ -98,7 +98,7 @@ public class RegExpRule extends Abstract
           ruleMatch.addMatched(0, afs);
         }
       }
-      if (!ruleMatch.getMatchedAnnotationsOfRoot(stream).isEmpty()) {
+      if (!ruleMatch.getMatchedAnnotationsOfRoot().isEmpty()) {
         ruleApply.add(ruleMatch);
       }
     }
@@ -107,7 +107,7 @@ public class RegExpRule extends Abstract
     return ruleApply;
   }
 
-  private Map<Integer, Map<Type, Map<String, Object>>> getFeatureAssignmentMap() {
+  private Map<Integer, Map<Type, Map<String, Object>>> getFeatureAssignmentMap(RutaStream stream) {
     Map<Integer, Map<Type, Map<String, Object>>> result = new HashMap<Integer, Map<Type, Map<String, Object>>>();
     Set<Entry<TypeExpression, Map<StringExpression, RutaExpression>>> entrySet = featureAssignments
             .entrySet();
@@ -116,7 +116,7 @@ public class RegExpRule extends Abstract
       Type type = key.getType(getParent());
       Map<StringExpression, RutaExpression> value = entry.getValue();
       NumberExpression cgExpr = typeMap.get(key);
-      int cg = cgExpr.getIntegerValue(getParent());
+      int cg = cgExpr.getIntegerValue(getParent(), null, stream);
       Map<Type, Map<String, Object>> map = result.get(cg);
       if (map == null) {
         map = new HashMap<Type, Map<String, Object>>();
@@ -131,20 +131,20 @@ public class RegExpRule extends Abstract
       for (Entry<StringExpression, RutaExpression> entry2 : entrySet2) {
         StringExpression key2 = entry2.getKey();
         RutaExpression value2 = entry2.getValue();
-        String stringValue = key2.getStringValue(getParent());
+        String stringValue = key2.getStringValue(getParent(), null, stream);
         typeMap.put(stringValue, value2);
       }
     }
     return result;
   }
 
-  private Map<Integer, List<Type>> getGroup2Types() {
+  private Map<Integer, List<Type>> getGroup2Types(RutaStream stream) {
     Map<Integer, List<Type>> groupTypes = new TreeMap<Integer, List<Type>>();
     Set<Entry<TypeExpression, NumberExpression>> entrySet = typeMap.entrySet();
     for (Entry<TypeExpression, NumberExpression> entry : entrySet) {
       Type type = entry.getKey().getType(getParent());
       NumberExpression value = entry.getValue();
-      int group = value == null ? 0 : value.getIntegerValue(getParent());
+      int group = value == null ? 0 : value.getIntegerValue(getParent(), null, stream);
       List<Type> list = groupTypes.get(group);
       if (list == null) {
         list = new ArrayList<Type>();
@@ -192,7 +192,7 @@ public class RegExpRule extends Abstract
             Type range = feature.getRange();
             if (argExpr instanceof NumberExpression) {
               NumberExpression ne = (NumberExpression) argExpr;
-              int cg = ne.getIntegerValue(getParent());
+              int cg = ne.getIntegerValue(getParent(), afs, stream);
               if (range.getName().equals(UIMAConstants.TYPE_STRING)) {
                 String s = matchResult.group(cg);
                 afs.setStringValue(feature, s);
@@ -232,7 +232,7 @@ public class RegExpRule extends Abstract
               } else if (argExpr instanceof StringExpression
                       && range.getName().equals(UIMAConstants.TYPE_STRING)) {
                 afs.setStringValue(feature,
-                        ((StringExpression) argExpr).getStringValue(getParent()));
+                        ((StringExpression) argExpr).getStringValue(getParent(), afs, stream));
                 // numbers are reserved for capturing groups
                 //
                 // } else if (argExpr instanceof NumberExpression) {
@@ -258,7 +258,7 @@ public class RegExpRule extends Abstract
               } else if (argExpr instanceof BooleanExpression
                       && range.getName().equals(UIMAConstants.TYPE_BOOLEAN)) {
                 afs.setBooleanValue(feature,
-                        ((BooleanExpression) argExpr).getBooleanValue(getParent()));
+                        ((BooleanExpression) argExpr).getBooleanValue(getParent(), null, stream));
               } else if (argExpr instanceof TypeExpression) {
                 TypeExpression typeExpr = (TypeExpression) argExpr;
                 List<AnnotationFS> annotationsInWindow = stream.getAnnotationsInWindow(afs,
@@ -306,5 +306,5 @@ public class RegExpRule extends Abstract
   public Map<TypeExpression, Map<StringExpression, RutaExpression>> getFeatureAssignments() {
     return featureAssignments;
   }
-  
+
 }

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RegExpRuleMatch.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RegExpRuleMatch.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RegExpRuleMatch.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RegExpRuleMatch.java Fri May 17 12:38:11 2013
@@ -25,7 +25,6 @@ import java.util.Map;
 import java.util.TreeMap;
 
 import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.ruta.RutaStream;
 
 public class RegExpRuleMatch extends AbstractRuleMatch<RegExpRule> {
 
@@ -36,7 +35,7 @@ public class RegExpRuleMatch extends Abs
   }
 
   @Override
-  public List<AnnotationFS> getMatchedAnnotationsOfRoot(RutaStream stream) {
+  public List<AnnotationFS> getMatchedAnnotationsOfRoot() {
     return map.get(0);
   }
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleApply.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleApply.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleApply.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleApply.java Fri May 17 12:38:11 2013
@@ -22,19 +22,19 @@ package org.apache.uima.ruta.rule;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.uima.ruta.ScriptApply;
 import org.apache.uima.ruta.RutaStatement;
+import org.apache.uima.ruta.ScriptApply;
 
 public class RuleApply extends ScriptApply {
 
   private List<AbstractRuleMatch<? extends AbstractRule>> list;
-  
+
   protected int tried = 0;
 
   protected int applied = 0;
-  
+
   private boolean acceptMatches;
-  
+
   public RuleApply(RutaStatement tme, boolean remember) {
     super(tme);
     list = new ArrayList<AbstractRuleMatch<? extends AbstractRule>>();
@@ -54,7 +54,7 @@ public class RuleApply extends ScriptApp
       list.add(match);
     }
   }
-  
+
   public int getTried() {
     return tried;
   }
@@ -70,11 +70,11 @@ public class RuleApply extends ScriptApp
   public void setAcceptMatches(boolean acceptMatches) {
     this.acceptMatches = acceptMatches;
   }
-  
+
   public void addAll(List<RuleMatch> matches) {
     for (RuleMatch ruleMatch : matches) {
       add(ruleMatch);
     }
   }
-  
+
 }

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleElement.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleElement.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleElement.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleElement.java Fri May 17 12:38:11 2013
@@ -48,8 +48,8 @@ public interface RuleElement {
           RutaRuleElement sideStepOrigin, RuleElement entryPoint, RutaStream stream,
           InferenceCrowd crowd);
 
-  
-  List<RuleElementMatch> evaluateMatches(List<RuleElementMatch> matches, RutaBlock parent);
+  List<RuleElementMatch> evaluateMatches(List<RuleElementMatch> matches, RutaBlock parent,
+          RutaStream stream);
 
   Collection<AnnotationFS> getAnchors(RutaStream symbolStream);
 
@@ -71,4 +71,3 @@ public interface RuleElement {
 
   boolean hasAncestor(boolean after);
 }
- 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleElementCaretaker.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleElementCaretaker.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleElementCaretaker.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleElementCaretaker.java Fri May 17 12:38:11 2013
@@ -85,9 +85,9 @@ public class RuleElementCaretaker implem
 
   private boolean containsLiteralMatcher(List<RuleElement> ruleElements) {
     for (RuleElement each : ruleElements) {
-      if(each instanceof RutaRuleElement) {
+      if (each instanceof RutaRuleElement) {
         RutaRuleElement re = (RutaRuleElement) each;
-        if(re.getMatcher() instanceof RutaLiteralMatcher) {
+        if (re.getMatcher() instanceof RutaLiteralMatcher) {
           return true;
         }
       }

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleElementMatch.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleElementMatch.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleElementMatch.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleElementMatch.java Fri May 17 12:38:11 2013
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.uima.cas.text.AnnotationFS;
+import org.apache.uima.ruta.RutaStream;
 
 public class RuleElementMatch {
 
@@ -48,7 +49,7 @@ public class RuleElementMatch {
   }
 
   public void setMatchInfo(boolean baseCondition, List<AnnotationFS> texts,
-          List<EvaluatedCondition> conditionList) {
+          List<EvaluatedCondition> conditionList, RutaStream stream) {
     baseConditionMatched = baseCondition;
     textsMatched = texts;
     conditions = conditionList;
@@ -59,7 +60,7 @@ public class RuleElementMatch {
       }
     }
     if (containerMatch != null) {
-      containerMatch.addInnerMatch(ruleElement, this);
+      containerMatch.addInnerMatch(ruleElement, this, stream);
     }
   }
 

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleMatch.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleMatch.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleMatch.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RuleMatch.java Fri May 17 12:38:11 2013
@@ -27,10 +27,10 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
+import org.apache.uima.cas.CAS;
 import org.apache.uima.cas.text.AnnotationFS;
-import org.apache.uima.jcas.tcas.Annotation;
-import org.apache.uima.ruta.ScriptApply;
 import org.apache.uima.ruta.RutaStream;
+import org.apache.uima.ruta.ScriptApply;
 import org.apache.uima.ruta.action.AbstractRutaAction;
 
 public class RuleMatch extends AbstractRuleMatch<RutaRule> {
@@ -45,8 +45,6 @@ public class RuleMatch extends AbstractR
     }
   }
 
-  private RuleMatchComparator ruleElementComparator = new RuleMatchComparator();
-
   private boolean applied = false;
 
   private Map<AbstractRutaAction, ScriptApply> delegateApply;
@@ -79,28 +77,25 @@ public class RuleMatch extends AbstractR
     return result;
   }
 
-
-
   public boolean matchedCompletely() {
     return matched && rootMatch.matched();
   }
 
-  public List<AnnotationFS> getMatchedAnnotationsOf(RuleElement element, RutaStream stream) {
-    return getMatchedAnnotations(stream, element.getSelfIndexList(), element.getContainer());
+  public List<AnnotationFS> getMatchedAnnotationsOf(RuleElement element) {
+    return getMatchedAnnotations(element.getSelfIndexList(), element.getContainer());
   }
 
   @Override
-  public List<AnnotationFS> getMatchedAnnotationsOfRoot(RutaStream stream) {
-    return getMatchedAnnotationsOf(((RutaRule)getRule()).getRoot(), stream);
+  public List<AnnotationFS> getMatchedAnnotationsOfRoot() {
+    return getMatchedAnnotationsOf(((RutaRule) getRule()).getRoot());
   }
-  
-  
-  public List<AnnotationFS> getMatchedAnnotations(RutaStream stream, List<Integer> indexes,
+
+  public List<AnnotationFS> getMatchedAnnotations(List<Integer> indexes,
           RuleElementContainer container) {
     List<AnnotationFS> result = new ArrayList<AnnotationFS>();
     indexes = extendIndexes(indexes);
     if (container == null) {
-      container = ((RutaRule)rule).getRoot();
+      container = ((RutaRule) rule).getRoot();
     }
 
     // TODO refactor this!
@@ -146,25 +141,26 @@ public class RuleMatch extends AbstractR
         i++;
       }
     }
+    CAS cas = null;
     for (List<List<RuleElementMatch>> list : reverseList) {
       int begin = Integer.MAX_VALUE;
       int end = 0;
       for (List<RuleElementMatch> list2 : list) {
         if (list2 != null) {
           for (RuleElementMatch ruleElementMatch : list2) {
-
             List<AnnotationFS> textsMatched = ruleElementMatch.getTextsMatched();
             if (textsMatched != null && !textsMatched.isEmpty()) {
               begin = Math.min(textsMatched.get(0).getBegin(), begin);
               end = Math.max(textsMatched.get(textsMatched.size() - 1).getEnd(), end);
+              if (cas == null) {
+                cas = textsMatched.get(0).getCAS();
+              }
             }
           }
         }
       }
-      if (stream.getJCas() != null && end != 0) {
-        Annotation annotation = new Annotation(stream.getJCas());
-        annotation.setBegin(begin);
-        annotation.setEnd(end);
+      if (cas != null && end != 0) {
+        AnnotationFS annotation = cas.createAnnotation(cas.getAnnotationType(), begin, end);
         result.add(annotation);
       }
     }
@@ -172,13 +168,13 @@ public class RuleMatch extends AbstractR
   }
 
   public static List<Integer> extendIndexes(List<Integer> indexes) {
-    if(indexes == null || indexes.size() <=1) {
+    if (indexes == null || indexes.size() <= 1) {
       return indexes;
     }
     List<Integer> result = new ArrayList<Integer>();
     int pointer = indexes.get(0);
     for (Integer each : indexes) {
-      while(pointer < each-1) {
+      while (pointer < each - 1) {
         pointer++;
         result.add(pointer);
       }
@@ -222,7 +218,7 @@ public class RuleMatch extends AbstractR
     copy.setDelegateApply(newDelegateApply);
     return copy;
   }
-  
+
   public void update(ComposedRuleElementMatch extendedContainerMatch) {
     if (extendedContainerMatch.getContainerMatch() == null) {
       setRootMatch(extendedContainerMatch);
@@ -281,5 +277,4 @@ public class RuleMatch extends AbstractR
     return result;
   }
 
-
 }

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaDisjunctiveMatcher.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaDisjunctiveMatcher.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaDisjunctiveMatcher.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaDisjunctiveMatcher.java Fri May 17 12:38:11 2013
@@ -33,26 +33,24 @@ import org.apache.uima.ruta.expression.s
 
 public class RutaDisjunctiveMatcher implements RutaMatcher {
   private final List<RutaExpression> expressions;
-  
-  private List<RutaMatcher> matchers ;
-  
+
+  private List<RutaMatcher> matchers;
+
   public RutaDisjunctiveMatcher(List<RutaExpression> expressions) {
     super();
     this.expressions = expressions;
     matchers = new ArrayList<RutaMatcher>();
     for (RutaExpression each : expressions) {
-      if(each instanceof MatchReference) {
+      if (each instanceof MatchReference) {
         matchers.add(new RutaTypeMatcher((MatchReference) each));
-      } else if(each instanceof StringExpression) {
+      } else if (each instanceof StringExpression) {
         matchers.add(new RutaLiteralMatcher((StringExpression) each));
       }
     }
-    
-    
+
   }
 
-  public Collection<AnnotationFS> getMatchingAnnotations(RutaStream stream,
-          RutaBlock parent) {
+  public Collection<AnnotationFS> getMatchingAnnotations(RutaStream stream, RutaBlock parent) {
     Collection<AnnotationFS> result = new ArrayList<AnnotationFS>();
     for (RutaMatcher each : matchers) {
       result.addAll(each.getMatchingAnnotations(stream, parent));
@@ -63,7 +61,7 @@ public class RutaDisjunctiveMatcher impl
   public boolean match(AnnotationFS annotation, RutaStream stream, RutaBlock parent) {
     for (RutaMatcher each : matchers) {
       boolean match = each.match(annotation, stream, parent);
-      if(match) {
+      if (match) {
         return true;
       }
     }
@@ -115,6 +113,5 @@ public class RutaDisjunctiveMatcher impl
   public String toString() {
     return matchers.toString();
   }
-  
- 
+
 }

Modified: uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaLiteralMatcher.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaLiteralMatcher.java?rev=1483772&r1=1483771&r2=1483772&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaLiteralMatcher.java (original)
+++ uima/sandbox/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaLiteralMatcher.java Fri May 17 12:38:11 2013
@@ -27,7 +27,6 @@ import org.apache.uima.cas.Type;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.ruta.RutaBlock;
 import org.apache.uima.ruta.RutaStream;
-import org.apache.uima.ruta.expression.RutaExpression;
 import org.apache.uima.ruta.expression.string.StringExpression;
 import org.apache.uima.ruta.type.RutaBasic;
 
@@ -45,7 +44,7 @@ public class RutaLiteralMatcher implemen
     AnnotationFS windowAnnotation = stream.getDocumentAnnotation();
     List<RutaBasic> list = stream.getBasicsInWindow(windowAnnotation);
     for (RutaBasic each : list) {
-      if (each.getCoveredText().equals(expression.getStringValue(parent))) {
+      if (each.getCoveredText().equals(expression.getStringValue(parent, null, stream))) {
         result.add(each);
       }
     }
@@ -56,7 +55,7 @@ public class RutaLiteralMatcher implemen
     if (annotation == null) {
       return false;
     }
-    return annotation.getCoveredText().equals(expression.getStringValue(parent));
+    return annotation.getCoveredText().equals(expression.getStringValue(parent, null, stream));
   }
 
   @Override
@@ -82,15 +81,15 @@ public class RutaLiteralMatcher implemen
     return getNextAnnotations(true, annotation, stream, parent);
   }
 
-  private Collection<AnnotationFS> getNextAnnotations(boolean before, AnnotationFS annotation, RutaStream stream,
-          RutaBlock parent) {
+  private Collection<AnnotationFS> getNextAnnotations(boolean before, AnnotationFS annotation,
+          RutaStream stream, RutaBlock parent) {
     List<AnnotationFS> result = new ArrayList<AnnotationFS>(1);
     RutaBasic basicNextTo = stream.getBasicNextTo(before, annotation);
-    if(basicNextTo == null) { 
+    if (basicNextTo == null) {
       return result;
     }
-    String stringValue = expression.getStringValue(parent);
-    if(stringValue.equals(basicNextTo.getCoveredText())) {
+    String stringValue = expression.getStringValue(parent, annotation, stream);
+    if (stringValue.equals(basicNextTo.getCoveredText())) {
       result.add(basicNextTo);
     }
     return result;