regular expression matching in the producers.xml file
authorjohn <john>
Tue, 14 Oct 2003 23:44:44 +0000 (23:44 +0000)
committerjohn <john>
Tue, 14 Oct 2003 23:44:44 +0000 (23:44 +0000)
source/mir/util/GeneratorRegularExpressionFunctions.java
source/mir/util/StringRoutines.java

index ed6d3f0..67d95cb 100755 (executable)
@@ -56,4 +56,25 @@ public class GeneratorRegularExpressionFunctions {
       }
     };
   }
-}
\ No newline at end of file
+  public static class regularExpressionMatchFunction implements Generator.GeneratorFunction {
+    public Object perform(List aParameters) throws GeneratorExc, GeneratorFailure {
+      try {
+        if (aParameters.size()!=2)
+          throw new GeneratorExc("regularExpressionMatchFunction: exactly 2 parameters expected: data, search expression");
+        if (aParameters.get(0)==null)
+          return new Boolean(false);
+        if (!(aParameters.get(0) instanceof String) || !(aParameters.get(1) instanceof String))
+          throw new GeneratorExc("regularExpressionReplaceFunction: parameters must be strings");
+
+        return new Boolean(StringRoutines.performRegularExpressionSearch((String) aParameters.get(0), (String) aParameters.get(1)));
+      }
+      catch (Throwable t) {
+        throw new GeneratorFailure(t);
+      }
+    };
+  }
+    
+    
+
+}
index 8610885..16e9846 100755 (executable)
@@ -360,4 +360,4 @@ public class StringRoutines {
 \r
     return result.toString();\r
   }\r
-}
\ No newline at end of file
+}\r