1 /* 2 * Copyright the original author or authors. 3 * 4 * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.mozilla.org/MPL/MPL-1.1.html 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 import org.as2lib.aop.Matcher; 18 import org.as2lib.core.BasicClass; 19 import org.as2lib.regexp.Pattern; 20 21 /** 22 * {@code RegexpMatcher} matches a join point with a regular expression pattern. 23 * 24 * <p>Note that this matcher is less performant than the {@link WildcardMatcher} and 25 * also a little harder to use if you are not familiar with regular expressions. I thus 26 * encourage you to use the wildcard matcher if the supported wildcards fit all your 27 * needs. 28 * 29 * @author Simon Wacker 30 * @see org.as2lib.regexp.Pattern 31 */ 32 class org.as2lib.aop.matcher.RegexpMatcher extends BasicClass implements Matcher { 33 34 /** 35 * Constructs a new {@code RegexpMatcher} instance. 36 */ 37 public function RegexpMatcher(Void) { 38 } 39 40 /** 41 * Checks whether the given join point matches the given regular expression pattern. 42 * 43 * <p>The join point string normally looks something like this: 44 * <code>static org.as2lib.env.log.Logger.info</code> 45 * 46 * <p>And the regular expression pattern may look like this: 47 * <code>.* org\\.as2lib\\..*\\.log\\.Logger\\.info</code> 48 * 49 * <p>For more information on what keywords can be used in the pattern take a look 50 * at the {@link org.as2lib.regexp.Pattern} class. 51 * 52 * @param joinPoint the join point to check whether it matches the given 53 * {@code regexpPattern} 54 * @param regexpPattern the regular expression pattern to check whether it matches 55 * the given {@code joinPoint} 56 * @return {@code true} if the {@code joinPoint} matches the given {@code regexpPattern} 57 * else {@code false} 58 */ 59 public function match(joinPoint:String, regexpPattern:String):Boolean { 60 return Pattern.matches(regexpPattern, joinPoint); 61 } 62 63 }