1 15 package org.apache.hivemind.test; 16 17 import org.apache.hivemind.ApplicationRuntimeException; 18 import org.apache.oro.text.regex.Pattern; 19 import org.apache.oro.text.regex.Perl5Compiler; 20 import org.apache.oro.text.regex.Perl5Matcher; 21 22 30 public class RegexpMatcher extends AbstractArgumentMatcher 31 { 32 private static Perl5Compiler _compiler = new Perl5Compiler(); 33 34 private static Perl5Matcher _matcher = new Perl5Matcher(); 35 36 public boolean compareArguments(Object expected, Object actual) 37 { 38 return matchRegexp((String ) expected, (String ) actual); 39 } 40 41 private boolean matchRegexp(String expectedRegexp, String actualString) 42 { 43 try 44 { 45 Pattern p = _compiler.compile(expectedRegexp); 46 47 return _matcher.matches(actualString, p); 48 } 49 catch (Exception ex) 50 { 51 throw new ApplicationRuntimeException(ex); 52 } 53 } 54 } | Popular Tags |