1 23 24 package org.infoglue.cms.util; 25 26 import org.apache.log4j.Logger; 27 import org.apache.oro.text.perl.MalformedPerl5PatternException; 28 import org.apache.oro.text.perl.Perl5Util; 29 import org.infoglue.cms.exception.Bug; 30 31 32 37 public class RegexpHelper 38 { 39 40 private static final StringManager sm = StringManagerFactory.getSystemStringManager(Constants.PACKAGE_NAME); 42 43 private static final Logger logger = Logger.getLogger(RegexpHelper.class.getName()); 45 46 private static final Perl5Util regexpDelegate = new Perl5Util(); 48 49 52 53 private RegexpHelper() 54 { 55 } 56 57 58 59 66 67 public static synchronized boolean match(String pattern, String string) 68 { 69 logger.debug(sm.getString("regexp.match.info", pattern, string)); 70 try 71 { 72 boolean result = regexpDelegate.match("/" + pattern + "/", string); 73 return result; 77 } 78 catch (MalformedPerl5PatternException e) 79 { 80 throw new Bug(sm.getString("regexp.match.pattern_error", pattern), e); 81 } 82 catch (NullPointerException e) 83 { 84 throw new Bug(sm.getString("regexp.match.illegal_parameters_error", pattern, string), e); 85 } 86 } 87 88 } | Popular Tags |