Author: pkluegl
Date: Fri Dec 21 15:49:34 2018
New Revision: 1849485

URL: http://svn.apache.org/viewvc?rev=1849485&view=rev
Log:
UIMA-5480: types may be null

Modified:
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaEnvironment.java
    uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/AbstractMarkAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/AddFilterTypeAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/AddRetainTypeAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ConfigureAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/CreateAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/FillAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/FilterTypeAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GatherAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetFeatureAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkOnceAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkTableAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/RemoveFilterTypeAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/RemoveRetainTypeAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ShiftAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/SplitAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/TransferAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/TrieAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/TrimAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/UnmarkAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/UnmarkAllAction.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/AfterCondition.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/BeforeCondition.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/ContainsCondition.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/ContextCountCondition.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/CountCondition.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/CurrentCountCondition.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/EndsWithCondition.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/ImplicitCondition.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/IsCondition.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/LastCondition.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/NearCondition.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfCondition.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfNeqCondition.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PositionCondition.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/StartsWithCondition.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/TotalCountCondition.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/VoteCondition.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/TypeVariableExpression.java
    
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaAnnotationTypeMatcher.java
    
uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/engine/ParamVarTest.java

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaEnvironment.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaEnvironment.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaEnvironment.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaEnvironment.java
 Fri Dec 21 15:49:34 2018
@@ -760,11 +760,7 @@ public class RutaEnvironment {
     } else if (Boolean.class.equals(type)) {
       return false;
     } else if (Type.class.equals(type)) {
-      if (cas == null) {
-        return annotationTypeDummy;
-      } else {
-        return cas.getAnnotationType();
-      }
+      return null;
     } else if (List.class.equals(type)) {
       return new ArrayList<Object>();
     }

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java 
(original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/RutaStream.java 
Fri Dec 21 15:49:34 2018
@@ -1240,7 +1240,7 @@ public class RutaStream extends FSIterat
 
   public List<AnnotationFS> getBestGuessedAnnotationsAt(AnnotationFS window, 
Type type) {
     List<AnnotationFS> result = new ArrayList<AnnotationFS>();
-    if (window == null) {
+    if (window == null || type == null) {
       return result;
     }
     TypeSystem typeSystem = getCas().getTypeSystem();

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/AbstractMarkAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/AbstractMarkAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/AbstractMarkAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/AbstractMarkAction.java
 Fri Dec 21 15:49:34 2018
@@ -40,6 +40,10 @@ public abstract class AbstractMarkAction
   protected Annotation createAnnotation(AnnotationFS annotation, MatchContext 
context,
           RutaStream stream) {
     Type t = type.getType(context, stream);
+    if (t == null) {
+      return null;
+    }
+
     AnnotationFS newAnnotationFS = stream.getCas().createAnnotation(t, 
annotation.getBegin(),
             annotation.getEnd());
     Annotation newAnnotation = null;

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/AddFilterTypeAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/AddFilterTypeAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/AddFilterTypeAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/AddFilterTypeAction.java
 Fri Dec 21 15:49:34 2018
@@ -39,7 +39,10 @@ public class AddFilterTypeAction extends
   public void execute(MatchContext context, RutaStream stream, InferenceCrowd 
crowd) {
     List<Type> types = new ArrayList<Type>();
     for (ITypeExpression each : list) {
-      types.add(each.getType(context, stream));
+      Type type = each.getType(context, stream);
+      if (type != null) {
+        types.add(type);
+      }
     }
     stream.addFilterTypes(types);
   }
@@ -50,5 +53,4 @@ public class AddFilterTypeAction extends
 
   private List<ITypeExpression> list;
 
-  
 }

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/AddRetainTypeAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/AddRetainTypeAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/AddRetainTypeAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/AddRetainTypeAction.java
 Fri Dec 21 15:49:34 2018
@@ -39,7 +39,10 @@ public class AddRetainTypeAction extends
   public void execute(MatchContext context, RutaStream stream, InferenceCrowd 
crowd) {
     List<Type> types = new ArrayList<Type>();
     for (ITypeExpression each : list) {
-      types.add(each.getType(context, stream));
+      Type type = each.getType(context, stream);
+      if (type != null) {
+        types.add(type);
+      }
     }
     stream.addRetainTypes(types);
   }
@@ -47,6 +50,6 @@ public class AddRetainTypeAction extends
   public List<ITypeExpression> getList() {
     return list;
   }
-  
+
   private List<ITypeExpression> list;
 }

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ConfigureAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ConfigureAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ConfigureAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ConfigureAction.java
 Fri Dec 21 15:49:34 2018
@@ -64,8 +64,9 @@ public class ConfigureAction extends Abs
     RutaBlock parent = element.getParent();
     RutaModule thisScript = parent.getScript();
     AnalysisEngine targetEngine = thisScript.getEngine(namespace);
-    if(targetEngine == null) {
-      throw new IllegalArgumentException("Analysis Engine with name 
'"+namespace+"' is unknown in script " + context.getParent().getName() + ".");
+    if (targetEngine == null) {
+      throw new IllegalArgumentException("Analysis Engine with name '" + 
namespace
+              + "' is unknown in script " + context.getParent().getName() + 
".");
     }
     ConfigurationParameterDeclarations configurationParameterDeclarations = 
targetEngine
             
.getAnalysisEngineMetaData().getConfigurationParameterDeclarations();
@@ -102,7 +103,9 @@ public class ConfigureAction extends Abs
             } else if (value instanceof ITypeExpression) {
               ITypeExpression te = (ITypeExpression) value;
               Type t = te.getType(context, stream);
-              targetEngine.setConfigParameterValue(stringValue, t.getName());
+              if (t != null) {
+                targetEngine.setConfigParameterValue(stringValue, t.getName());
+              }
             }
           }
         } else if (type.equals("Float")) {

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/CreateAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/CreateAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/CreateAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/CreateAction.java
 Fri Dec 21 15:49:34 2018
@@ -65,15 +65,17 @@ public class CreateAction extends Abstra
         return;
       }
       Type type = structureType.getType(context, stream);
-      AnnotationFS annotation = stream.getCas().createAnnotation(type, 0, 0);
-      if (annotation instanceof Annotation) {
-        Annotation a = (Annotation) annotation;
-        a.setBegin(matchedAnnotation.getBegin());
-        a.setEnd(matchedAnnotation.getEnd());
-        context.setAnnotation(matchedAnnotation);
-        stream.assignFeatureValues(annotation, features, context);
-        stream.addAnnotation(a, true, match);
-        addAnnotationToLabel(a, context);
+      if (type != null) {
+        AnnotationFS annotation = stream.getCas().createAnnotation(type, 0, 0);
+        if (annotation instanceof Annotation) {
+          Annotation a = (Annotation) annotation;
+          a.setBegin(matchedAnnotation.getBegin());
+          a.setEnd(matchedAnnotation.getEnd());
+          context.setAnnotation(matchedAnnotation);
+          stream.assignFeatureValues(annotation, features, context);
+          stream.addAnnotation(a, true, match);
+          addAnnotationToLabel(a, context);
+        }
       }
     }
   }

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/FillAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/FillAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/FillAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/FillAction.java
 Fri Dec 21 15:49:34 2018
@@ -50,12 +50,16 @@ public class FillAction extends Abstract
   public void execute(MatchContext context, RutaStream stream, InferenceCrowd 
crowd) {
     RuleMatch match = context.getRuleMatch();
     RuleElement element = context.getElement();
+    Type type = getStructureType().getType(context, stream);
+    if (type == null) {
+      return;
+    }
+
     List<AnnotationFS> matchedAnnotations = 
match.getMatchedAnnotationsOfElement(element);
     for (AnnotationFS matchedAnnotation : matchedAnnotations) {
       if (matchedAnnotation == null) {
         return;
       }
-      Type type = getStructureType().getType(context, stream);
       List<AnnotationFS> list = 
stream.getAnnotationsInWindow(matchedAnnotation, type);
       if (list.isEmpty()) {
         list = stream.getOverappingAnnotations(matchedAnnotation, type);

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/FilterTypeAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/FilterTypeAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/FilterTypeAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/FilterTypeAction.java
 Fri Dec 21 15:49:34 2018
@@ -30,7 +30,6 @@ import org.apache.uima.ruta.visitor.Infe
 
 public class FilterTypeAction extends AbstractRutaAction {
 
-
   public FilterTypeAction(List<ITypeExpression> list) {
     super();
     this.list = list;
@@ -41,7 +40,10 @@ public class FilterTypeAction extends Ab
     context.getElement();
     List<Type> types = new ArrayList<Type>();
     for (ITypeExpression each : list) {
-      types.add(each.getType(context, stream));
+      Type type = each.getType(context, stream);
+      if (type != null) {
+        types.add(type);
+      }
     }
     stream.filterTypes(types);
   }
@@ -49,7 +51,7 @@ public class FilterTypeAction extends Ab
   public List<ITypeExpression> getList() {
     return list;
   }
-  
+
   private List<ITypeExpression> list;
 
 }

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GatherAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GatherAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GatherAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GatherAction.java
 Fri Dec 21 15:49:34 2018
@@ -71,6 +71,12 @@ public class GatherAction extends Abstra
   public void execute(MatchContext context, RutaStream stream, InferenceCrowd 
crowd) {
     RuleMatch match = context.getRuleMatch();
     RuleElement element = context.getElement();
+    Type type = structureType.getType(context, stream);
+
+    if (type == null) {
+      return;
+    }
+
     List<Integer> indexList = getIndexList(indexes, context, stream);
     List<AnnotationFS> matchedAnnotations = 
match.getMatchedAnnotations(indexList,
             element.getContainer());
@@ -78,7 +84,6 @@ public class GatherAction extends Abstra
       if (matchedAnnotation == null) {
         return;
       }
-      Type type = structureType.getType(context, stream);
       FeatureStructure newFS = stream.getCas().createFS(type);
       if (newFS instanceof Annotation) {
         Annotation a = (Annotation) newFS;

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetFeatureAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetFeatureAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetFeatureAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/GetFeatureAction.java
 Fri Dec 21 15:49:34 2018
@@ -59,6 +59,10 @@ public class GetFeatureAction extends Ab
     if (element instanceof RutaRuleElement) {
       type = ((RutaRuleElement) element).getMatcher().getType(parent, stream);
     }
+    if (type == null) {
+      return;
+    }
+
     String stringValue = featureStringExpression.getStringValue(context, 
stream);
     Feature featureByBaseName = type.getFeatureByBaseName(stringValue);
     RutaEnvironment environment = parent.getEnvironment();

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkAction.java
 Fri Dec 21 15:49:34 2018
@@ -20,6 +20,8 @@
 package org.apache.uima.ruta.action;
 
 import java.util.List;
+
+import org.apache.uima.cas.Type;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.fit.util.CasUtil;
 import org.apache.uima.jcas.tcas.Annotation;
@@ -38,7 +40,8 @@ public class MarkAction extends Abstract
 
   protected final List<INumberExpression> list;
 
-  public MarkAction(ITypeExpression type, INumberExpression scoreValue, 
List<INumberExpression> list) {
+  public MarkAction(ITypeExpression type, INumberExpression scoreValue,
+          List<INumberExpression> list) {
     super(type);
     this.score = scoreValue;
     this.list = list;
@@ -67,17 +70,21 @@ public class MarkAction extends Abstract
 
   protected void updateHeuristicAnnotation(MatchContext context, RutaStream 
stream,
           AnnotationFS matchedAnnotation, double deltaScore) {
-    
+
     Annotation targetAnnotation = null;
 
-    List<AnnotationFS> annotationsInSpan = CasUtil.selectAt(stream.getCas(),
-            this.type.getType(context, stream), matchedAnnotation.getBegin(),
-            matchedAnnotation.getEnd());
+    Type t = this.type.getType(context, stream);
+
+    if (t == null) {
+      return;
+    }
+    List<AnnotationFS> annotationsInSpan = CasUtil.selectAt(stream.getCas(), t,
+            matchedAnnotation.getBegin(), matchedAnnotation.getEnd());
     if (annotationsInSpan.isEmpty()) {
       targetAnnotation = this.createAnnotation(matchedAnnotation, context, 
stream);
     } else {
       targetAnnotation = (Annotation) annotationsInSpan.get(0);
-      
+
     }
 
     if (targetAnnotation == null) {

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkOnceAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkOnceAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkOnceAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkOnceAction.java
 Fri Dec 21 15:49:34 2018
@@ -47,6 +47,11 @@ public class MarkOnceAction extends Mark
     List<AnnotationFS> matchedAnnotations = 
match.getMatchedAnnotations(indexList,
             element.getContainer());
     Type targetType = type.getType(context, stream);
+
+    if (targetType == null) {
+      return;
+    }
+
     for (AnnotationFS matchedAnnotation : matchedAnnotations) {
       boolean partof = false;
       List<RutaBasic> basicsInWindow = 
stream.getBasicsInWindow(matchedAnnotation);

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkTableAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkTableAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkTableAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/MarkTableAction.java
 Fri Dec 21 15:49:34 2018
@@ -97,6 +97,11 @@ public class MarkTableAction extends Abs
     }
     int index = indexExpr.getIntegerValue(context, stream);
     Type type = typeExpr.getType(context, stream);
+
+    if (type == null) {
+      return;
+    }
+
     Map<String, Integer> map = new HashMap<String, Integer>();
     for (IStringExpression each : featureMap.keySet()) {
       map.put(each.getStringValue(context, stream),

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/RemoveFilterTypeAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/RemoveFilterTypeAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/RemoveFilterTypeAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/RemoveFilterTypeAction.java
 Fri Dec 21 15:49:34 2018
@@ -40,7 +40,10 @@ public class RemoveFilterTypeAction exte
     context.getElement();
     List<Type> types = new ArrayList<Type>();
     for (ITypeExpression each : list) {
-      types.add(each.getType(context, stream));
+      Type type = each.getType(context, stream);
+      if (type != null) {
+        types.add(type);
+      }
     }
     stream.removeFilterTypes(types);
   }
@@ -48,7 +51,7 @@ public class RemoveFilterTypeAction exte
   public List<ITypeExpression> getList() {
     return list;
   }
-  
+
   private List<ITypeExpression> list;
 
 }

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/RemoveRetainTypeAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/RemoveRetainTypeAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/RemoveRetainTypeAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/RemoveRetainTypeAction.java
 Fri Dec 21 15:49:34 2018
@@ -40,7 +40,10 @@ public class RemoveRetainTypeAction exte
     context.getElement();
     List<Type> types = new ArrayList<Type>();
     for (ITypeExpression each : list) {
-      types.add(each.getType(context, stream));
+      Type type = each.getType(context, stream);
+      if (type != null) {
+        types.add(type);
+      }
     }
     stream.removeRetainTypes(types);
   }
@@ -48,7 +51,7 @@ public class RemoveRetainTypeAction exte
   public List<ITypeExpression> getList() {
     return list;
   }
-  
+
   private List<ITypeExpression> list;
 
 }

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ShiftAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ShiftAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ShiftAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/ShiftAction.java
 Fri Dec 21 15:49:34 2018
@@ -53,6 +53,10 @@ public class ShiftAction extends MarkAct
     RuleElement element = context.getElement();
     Type targetType = type.getType(context, stream);
 
+    if (targetType == null) {
+      return;
+    }
+
     List<Integer> indexList = getIndexList(context, list, stream);
     List<AnnotationFS> destinationAnnotationSpans = 
match.getMatchedAnnotations(indexList,
             element.getContainer());

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/SplitAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/SplitAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/SplitAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/SplitAction.java
 Fri Dec 21 15:49:34 2018
@@ -65,6 +65,11 @@ public class SplitAction extends Abstrac
     List<AnnotationFS> matchedAnnotationsOf = 
match.getMatchedAnnotationsOfElement(element);
     element.getParent();
     Type typeToSplit = splitOnType.getType(context, stream);
+
+    if (typeToSplit == null) {
+      return;
+    }
+
     boolean splitOnCompleteAnnotation = complete.getBooleanValue(context, 
stream);
     boolean addToBegin = appendToBegin.getBooleanValue(context, stream);
     boolean addToEnd = appendToEnd.getBooleanValue(context, stream);
@@ -81,11 +86,11 @@ public class SplitAction extends Abstrac
     if (annotation instanceof Annotation) {
 
       if (splitOnCompleteAnnotation) {
-        splitAnnotationOnComplete((Annotation) annotation, typeToSplit, 
addToBegin, addToEnd,
-                match, stream);
+        splitAnnotationOnComplete((Annotation) annotation, typeToSplit, 
addToBegin, addToEnd, match,
+                stream);
       } else {
-        splitAnnotationOnBoundary((Annotation) annotation, typeToSplit, 
addToBegin, addToEnd,
-                match, stream);
+        splitAnnotationOnBoundary((Annotation) annotation, typeToSplit, 
addToBegin, addToEnd, match,
+                stream);
       }
     }
   }

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/TransferAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/TransferAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/TransferAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/TransferAction.java
 Fri Dec 21 15:49:34 2018
@@ -47,6 +47,11 @@ public class TransferAction extends Type
     List<List<RuleElementMatch>> list = match.getMatchInfo(element);
     CAS cas = stream.getCas();
     Type t = type.getType(context, stream);
+
+    if (t == null) {
+      return;
+    }
+
     for (List<RuleElementMatch> eachList : list) {
       for (RuleElementMatch each : eachList) {
         List<AnnotationFS> matched = each.getTextsMatched();

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/TrieAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/TrieAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/TrieAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/TrieAction.java
 Fri Dec 21 15:49:34 2018
@@ -80,7 +80,9 @@ public class TrieAction extends Abstract
       IRutaExpression expression = map.get(eachKey);
       if (expression instanceof ITypeExpression) {
         Type typeValue = ((ITypeExpression) expression).getType(context, 
stream);
-        typeMap.put(stringValue, typeValue);
+        if (typeValue != null) {
+          typeMap.put(stringValue, typeValue);
+        }
       } else if (expression instanceof UntypedListExpression) {
         List<Object> innerList = ((UntypedListExpression) 
expression).getList(context, stream);
         typeMap.put(stringValue, innerList);

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/TrimAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/TrimAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/TrimAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/TrimAction.java
 Fri Dec 21 15:49:34 2018
@@ -114,7 +114,10 @@ public class TrimAction extends Abstract
     List<Type> result = new ArrayList<Type>();
     if (types != null) {
       for (ITypeExpression each : types) {
-        result.add(each.getType(context, stream));
+        Type type = each.getType(context, stream);
+        if (type != null) {
+          result.add(type);
+        }
       }
     } else if (typeList != null) {
       result = typeList.getList(context, stream);

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/UnmarkAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/UnmarkAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/UnmarkAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/UnmarkAction.java
 Fri Dec 21 15:49:34 2018
@@ -82,6 +82,11 @@ public class UnmarkAction extends TypeSe
 
   private void removeTypeBased(MatchContext context, RutaStream stream, 
RuleMatch match,
           RuleElement element, Type t) {
+
+    if (t == null) {
+      return;
+    }
+
     boolean allAtAnchor = false;
     if (allAnchor != null) {
       allAtAnchor = allAnchor.getBooleanValue(context, stream);

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/UnmarkAllAction.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/UnmarkAllAction.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/UnmarkAllAction.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/action/UnmarkAllAction.java
 Fri Dec 21 15:49:34 2018
@@ -55,6 +55,10 @@ public class UnmarkAllAction extends Typ
       retainList = list.getList(context, stream);
     }
     Type t = type.getType(context, stream);
+    if (t == null) {
+      return;
+    }
+
     TypeSystem typeSystem = stream.getCas().getTypeSystem();
     List<AnnotationFS> toRemove = new LinkedList<AnnotationFS>();
     List<List<RuleElementMatch>> matchInfo = match.getMatchInfo(element);

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/AfterCondition.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/AfterCondition.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/AfterCondition.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/AfterCondition.java
 Fri Dec 21 15:49:34 2018
@@ -62,7 +62,7 @@ public class AfterCondition extends Type
   }
 
   private boolean check(AnnotationFS annotation, RutaStream stream, Type t) {
-    if (annotation == null) {
+    if (annotation == null || t == null) {
       return false;
     }
     boolean result = false;

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/BeforeCondition.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/BeforeCondition.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/BeforeCondition.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/BeforeCondition.java
 Fri Dec 21 15:49:34 2018
@@ -62,7 +62,7 @@ public class BeforeCondition extends Typ
   }
 
   private boolean check(AnnotationFS annotation, RutaStream stream, Type t) {
-    if (annotation == null) {
+    if (annotation == null || t == null) {
       return false;
     }
     boolean result = false;

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/ContainsCondition.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/ContainsCondition.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/ContainsCondition.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/ContainsCondition.java
 Fri Dec 21 15:49:34 2018
@@ -90,20 +90,20 @@ public class ContainsCondition extends T
     int anchorCount = 0;
     int totalCount = 0;
 
-    boolean usePredefinedBoundaries = minIntValue == 1 && maxIntValue == 
Integer.MAX_VALUE ? false : true;
-    
+    boolean usePredefinedBoundaries = minIntValue == 1 && maxIntValue == 
Integer.MAX_VALUE ? false
+            : true;
+
     if (type != null) {
-      if (annotation != null) {
+      Type t = type.getType(context, stream);
+      if (annotation != null && t != null) {
         if (!usePredefinedBoundaries && !usePercentage) {
           // shortcut for simple CONTAINS(Type)
-          Type t = type.getType(context, stream);
           boolean annotationExsits = checkExistingAnnotation(t, annotation, 
stream);
           return new EvaluatedCondition(this, annotationExsits);
         } else {
           List<RutaBasic> annotations = stream.getBasicsInWindow(annotation);
           for (RutaBasic each : annotations) {
             totalCount++;
-            Type t = type.getType(context, stream);
             if (each.beginsWith(t) || 
stream.getCas().getTypeSystem().subsumes(t, each.getType())) {
               Collection<AnnotationFS> beginAnchors = each.getBeginAnchors(t);
               anchorCount = incrementAnchorsWithinStrictBoundaries(annotation, 
anchorCount,
@@ -170,7 +170,7 @@ public class ContainsCondition extends T
       }
       anchorCount = basicCount;
     }
-    
+
     if (usePercentage) {
       double percentValue = 0;
       if (totalCount != 0) {
@@ -198,7 +198,7 @@ public class ContainsCondition extends T
   private boolean checkExistingAnnotation(Type type, AnnotationFS annotation, 
RutaStream stream) {
     int begin = annotation.getBegin();
     int end = annotation.getEnd();
-    
+
     FSIterator<AnnotationFS> it = 
stream.getCas().getAnnotationIndex(type).iterator();
     it.moveTo(annotation);
     if (!it.isValid()) {
@@ -232,7 +232,7 @@ public class ContainsCondition extends T
       if (a.getEnd() > end) {
         continue;
       }
-      if(stream.isVisible(a)) {
+      if (stream.isVisible(a)) {
         return true;
       }
 

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/ContextCountCondition.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/ContextCountCondition.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/ContextCountCondition.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/ContextCountCondition.java
 Fri Dec 21 15:49:34 2018
@@ -57,6 +57,11 @@ public class ContextCountCondition exten
     RuleElement element = context.getElement();
 
     Type contextType = type.getType(context, stream);
+
+    if (contextType == null) {
+      return new EvaluatedCondition(this, false);
+    }
+
     stream.moveToFirst();
     List<AnnotationFS> visibleContexts = new ArrayList<AnnotationFS>();
     while (stream.isValid()) {

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/CountCondition.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/CountCondition.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/CountCondition.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/CountCondition.java
 Fri Dec 21 15:49:34 2018
@@ -62,8 +62,8 @@ public class CountCondition extends Type
     this.var = var;
   }
 
-  public CountCondition(@SuppressWarnings("rawtypes") ListExpression list, 
IRutaExpression a, INumberExpression min,
-          INumberExpression max, String var) {
+  public CountCondition(@SuppressWarnings("rawtypes") ListExpression list, 
IRutaExpression a,
+          INumberExpression min, INumberExpression max, String var) {
     super((ITypeExpression) null);
     this.list = list;
     this.arg = a;
@@ -78,8 +78,12 @@ public class CountCondition extends Type
     RuleElement element = context.getElement();
 
     if (arg == null) {
-      List<AnnotationFS> annotationsInWindow = 
stream.getAnnotationsInWindow(annotation,
-              type.getType(context, stream));
+      Type t = type.getType(context, stream);
+      if (t == null) {
+        return new EvaluatedCondition(this, false);
+      }
+
+      List<AnnotationFS> annotationsInWindow = 
stream.getAnnotationsInWindow(annotation, t);
       int count = annotationsInWindow.size();
       if (var != null) {
         element.getParent().getEnvironment().setVariableValue(var, count);

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/CurrentCountCondition.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/CurrentCountCondition.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/CurrentCountCondition.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/CurrentCountCondition.java
 Fri Dec 21 15:49:34 2018
@@ -21,6 +21,7 @@ package org.apache.uima.ruta.condition;
 
 import java.util.Iterator;
 
+import org.apache.uima.cas.Type;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.expression.number.INumberExpression;
@@ -51,10 +52,14 @@ public class CurrentCountCondition exten
     AnnotationFS annotation = context.getAnnotation();
     RuleElement element = context.getElement();
 
+    Type t = type.getType(context, stream);
+    if (t == null) {
+      return new EvaluatedCondition(this, false);
+    }
+
     int count = 0;
     if (annotation != null) {
-      Iterator<AnnotationFS> it = 
stream.getCas().getAnnotationIndex(type.getType(context, stream))
-              .iterator();
+      Iterator<AnnotationFS> it = 
stream.getCas().getAnnotationIndex(t).iterator();
       while (it.hasNext()) {
         AnnotationFS next = it.next();
         if (next.getBegin() < annotation.getBegin()) {

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/EndsWithCondition.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/EndsWithCondition.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/EndsWithCondition.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/EndsWithCondition.java
 Fri Dec 21 15:49:34 2018
@@ -63,7 +63,7 @@ public class EndsWithCondition extends T
   }
 
   private boolean check(RutaStream stream, AnnotationFS annotation, Type 
givenType) {
-    if (annotation == null) {
+    if (annotation == null || givenType == null) {
       return false;
     }
     RutaBasic endAnchor = stream.getEndAnchor(annotation.getEnd());

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/ImplicitCondition.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/ImplicitCondition.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/ImplicitCondition.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/ImplicitCondition.java
 Fri Dec 21 15:49:34 2018
@@ -84,7 +84,7 @@ public class ImplicitCondition extends A
   private List<AnnotationFS> getAnnotationsToCheck(AnnotationFS annotation, 
Type type,
           FeatureMatchExpression fme, RutaStream stream) {
 
-    if (annotation == null) {
+    if (annotation == null || type == null) {
       return Collections.emptyList();
     }
 

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/IsCondition.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/IsCondition.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/IsCondition.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/IsCondition.java
 Fri Dec 21 15:49:34 2018
@@ -52,14 +52,16 @@ public class IsCondition extends TypeSen
 
     RutaBasic beginAnchor = stream.getBeginAnchor(annotation.getBegin());
     if (!isWorkingOnList()) {
-      Collection<AnnotationFS> beginAnchors = beginAnchor
-              .getBeginAnchors(type.getType(context, stream));
+      Type t = type.getType(context, stream);
       boolean result = false;
-      if (beginAnchors != null) {
-        for (AnnotationFS annotationFS : beginAnchors) {
-          result |= check(annotation, annotationFS);
-          if (result == true) {
-            break;
+      if (t != null) {
+        Collection<AnnotationFS> beginAnchors = beginAnchor.getBeginAnchors(t);
+        if (beginAnchors != null) {
+          for (AnnotationFS annotationFS : beginAnchors) {
+            result |= check(annotation, annotationFS);
+            if (result == true) {
+              break;
+            }
           }
         }
       }

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/LastCondition.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/LastCondition.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/LastCondition.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/LastCondition.java
 Fri Dec 21 15:49:34 2018
@@ -44,6 +44,11 @@ public class LastCondition extends TypeS
 
     RutaBasic endAnchor = stream.getEndAnchor(annotation.getEnd());
     Type t = type.getType(context, stream);
+
+    if (t == null) {
+      return new EvaluatedCondition(this, false);
+    }
+
     boolean result = endAnchor.beginsWith(t) && endAnchor.endsWith(t);
     return new EvaluatedCondition(this, result);
   }

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/NearCondition.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/NearCondition.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/NearCondition.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/NearCondition.java
 Fri Dec 21 15:49:34 2018
@@ -21,6 +21,7 @@ package org.apache.uima.ruta.condition;
 
 import org.apache.uima.cas.FSIterator;
 import org.apache.uima.cas.FeatureStructure;
+import org.apache.uima.cas.Type;
 import org.apache.uima.cas.text.AnnotationFS;
 import org.apache.uima.ruta.RutaStream;
 import org.apache.uima.ruta.expression.bool.IBooleanExpression;
@@ -56,7 +57,9 @@ public class NearCondition extends TypeS
   public EvaluatedCondition eval(MatchContext context, RutaStream stream, 
InferenceCrowd crowd) {
     AnnotationFS annotation = context.getAnnotation();
 
-    if (annotation == null) {
+    Type t = type.getType(context, stream);
+
+    if (annotation == null || t == null) {
       return new EvaluatedCondition(this, false);
     }
 
@@ -79,7 +82,7 @@ public class NearCondition extends TypeS
         FeatureStructure featureStructure = it.get();
         if (featureStructure instanceof RutaBasic) {
           RutaBasic each = (RutaBasic) featureStructure;
-          if (each.isPartOf(type.getType(context, stream))) {
+          if (each.isPartOf(t)) {
             return new EvaluatedCondition(this, true);
           }
         }

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfCondition.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfCondition.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfCondition.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfCondition.java
 Fri Dec 21 15:49:34 2018
@@ -65,7 +65,7 @@ public class PartOfCondition extends Typ
   }
 
   private boolean check(Type t, AnnotationFS annotation, RuleElement element, 
RutaStream stream) {
-    if (annotation == null) {
+    if (annotation == null || t == null) {
       return false;
     }
     RutaBasic beginAnchor = stream.getBeginAnchor(annotation.getBegin());

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfNeqCondition.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfNeqCondition.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfNeqCondition.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PartOfNeqCondition.java
 Fri Dec 21 15:49:34 2018
@@ -64,7 +64,7 @@ public class PartOfNeqCondition extends
 
   private boolean check(AnnotationFS annotation, RutaStream stream, Type t) {
 
-    if (annotation == null) {
+    if (annotation == null || t == null) {
       return false;
     }
 

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PositionCondition.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PositionCondition.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PositionCondition.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/PositionCondition.java
 Fri Dec 21 15:49:34 2018
@@ -53,12 +53,13 @@ public class PositionCondition extends T
   public EvaluatedCondition eval(MatchContext context, RutaStream stream, 
InferenceCrowd crowd) {
     AnnotationFS annotation = context.getAnnotation();
 
-    if (annotation == null) {
+    Type t = type.getType(context, stream);
+
+    if (annotation == null || t == null) {
       return new EvaluatedCondition(this, false);
     }
 
     RuleElement element = context.getElement();
-    Type t = type.getType(context, stream);
 
     RutaBasic beginAnchor = stream.getBeginAnchor(annotation.getBegin());
     RutaBasic endAnchor = stream.getEndAnchor(annotation.getEnd());

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/StartsWithCondition.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/StartsWithCondition.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/StartsWithCondition.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/StartsWithCondition.java
 Fri Dec 21 15:49:34 2018
@@ -66,7 +66,7 @@ public class StartsWithCondition extends
 
   private boolean check(AnnotationFS annotation, Type t, RutaStream stream) {
 
-    if (annotation == null) {
+    if (annotation == null || t == null) {
       return false;
     }
     RutaBasic beginAnchor = stream.getBeginAnchor(annotation.getBegin());

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/TotalCountCondition.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/TotalCountCondition.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/TotalCountCondition.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/TotalCountCondition.java
 Fri Dec 21 15:49:34 2018
@@ -51,6 +51,11 @@ public class TotalCountCondition extends
     RuleElement element = context.getElement();
     int count = 0;
     Type t = type.getType(context, stream);
+
+    if (t == null) {
+      return new EvaluatedCondition(this, false);
+    }
+
     AnnotationIndex<Annotation> annotationIndex = 
stream.getJCas().getAnnotationIndex(t);
     count = annotationIndex.size();
     if (var != null) {

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/VoteCondition.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/VoteCondition.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/VoteCondition.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/condition/VoteCondition.java
 Fri Dec 21 15:49:34 2018
@@ -47,10 +47,11 @@ public class VoteCondition extends Termi
     AnnotationFS annotation = context.getAnnotation();
     int count1 = 0;
     int count2 = 0;
-    if (annotation != null) {
+    Type t1 = type1.getType(context, stream);
+    Type t2 = type2.getType(context, stream);
+
+    if (annotation != null && t1 != null && t2 != null) {
       List<RutaBasic> annotations = stream.getBasicsInWindow(annotation);
-      Type t1 = type1.getType(context, stream);
-      Type t2 = type2.getType(context, stream);
       for (RutaBasic each : annotations) {
         if (each.beginsWith(t1)) {
           count1++;

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/TypeVariableExpression.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/TypeVariableExpression.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/TypeVariableExpression.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/expression/type/TypeVariableExpression.java
 Fri Dec 21 15:49:34 2018
@@ -53,10 +53,6 @@ public class TypeVariableExpression exte
   public Type getType(MatchContext context, RutaStream stream) {
     RutaBlock parent = context.getParent();
     Type type = parent.getEnvironment().getVariableValue(var, Type.class, 
stream);
-    if (type == null) {
-      throw new IllegalArgumentException("Not able to resolve type variable: " 
+ var + 
-              " in script " +context.getParent().getName());
-    }
     return type;
   }
 

Modified: 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaAnnotationTypeMatcher.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaAnnotationTypeMatcher.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaAnnotationTypeMatcher.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/main/java/org/apache/uima/ruta/rule/RutaAnnotationTypeMatcher.java
 Fri Dec 21 15:49:34 2018
@@ -67,7 +67,9 @@ public class RutaAnnotationTypeMatcher i
       } else {
         Type type = getType(context.getParent(), stream);
         types = new ArrayList<>(1);
-        types.add(type);
+        if (type != null) {
+          types.add(type);
+        }
       }
       result = new ArrayList<>();
       for (Type type : types) {

Modified: 
uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/engine/ParamVarTest.java
URL: 
http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/engine/ParamVarTest.java?rev=1849485&r1=1849484&r2=1849485&view=diff
==============================================================================
--- 
uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/engine/ParamVarTest.java
 (original)
+++ 
uima/ruta/trunk/ruta-core/src/test/java/org/apache/uima/ruta/engine/ParamVarTest.java
 Fri Dec 21 15:49:34 2018
@@ -92,10 +92,10 @@ public class ParamVarTest {
     Ruta.apply(cas, script, params);
 
     RutaTestUtils.assertAnnotationsEquals(cas, 1, 2, "Some", "text");
-    
+
     cas.release();
   }
-  
+
   @Test(expected = AnalysisEngineProcessException.class)
   public void testWithStrictImport() throws Exception {
     String document = "Some text.";
@@ -109,15 +109,44 @@ public class ParamVarTest {
     Map<String, Object> params = new HashMap<String, Object>();
     params.put(RutaEngine.PARAM_STRICT_IMPORTS, true);
     params.put(RutaEngine.PARAM_VAR_NAMES, new String[] { "t1", "t2", "tl" });
-    params.put(RutaEngine.PARAM_VAR_VALUES, new String[] 
{"org.apache.uima.T1", "org.apache.uima.T2", 
-        "org.apache.uima.T1,org.apache.uima.T2"  });
+    params.put(RutaEngine.PARAM_VAR_VALUES, new String[] { 
"org.apache.uima.T1",
+        "org.apache.uima.T2", "org.apache.uima.T1,org.apache.uima.T2" });
 
     CAS cas = RutaTestUtils.getCAS(document);
     Ruta.apply(cas, script, params);
 
     RutaTestUtils.assertAnnotationsEquals(cas, 3, 2, "Some", "text");
-    
+
     cas.release();
   }
-  
+
+  @Test
+  public void testKnownVariableValue() throws Exception {
+    String document = "Some text.";
+    String script = "";
+    script += "TYPE tvar;";
+    script += "tvar{ -> T1};";
+    Map<String, Object> params = new HashMap<String, Object>();
+    params.put(RutaEngine.PARAM_VAR_NAMES, new String[] { "tvar" });
+    params.put(RutaEngine.PARAM_VAR_VALUES, new String[] { "some.UnknownType" 
});
+
+    CAS cas = RutaTestUtils.getCAS(document);
+    Ruta.apply(cas, script, params);
+
+    RutaTestUtils.assertAnnotationsEquals(cas, 1, 0);
+  }
+
+  @Test
+  public void testMissingVariableValue() throws Exception {
+    String document = "Some text.";
+    String script = "";
+    script += "TYPE tvar;";
+    script += "tvar{ -> T1};";
+    Map<String, Object> params = new HashMap<String, Object>();
+
+    CAS cas = RutaTestUtils.getCAS(document);
+    Ruta.apply(cas, script, params);
+
+    RutaTestUtils.assertAnnotationsEquals(cas, 1, 0);
+  }
 }


Reply via email to