1 16 17 package org.springframework.aop.support; 18 19 import java.util.regex.Matcher ; 20 import java.util.regex.Pattern ; 21 import java.util.regex.PatternSyntaxException ; 22 23 44 public class JdkRegexpMethodPointcut extends AbstractRegexpMethodPointcut { 45 46 49 private transient Pattern [] compiledPatterns = new Pattern [0]; 50 51 54 private transient Pattern [] compiledExclusionPatterns = new Pattern [0]; 55 56 59 protected void initPatternRepresentation(String [] patterns) throws PatternSyntaxException { 60 this.compiledPatterns = compilePatterns(patterns); 61 } 62 63 67 protected boolean matches(String pattern, int patternIndex) { 68 Matcher matcher = this.compiledPatterns[patternIndex].matcher(pattern); 69 return matcher.matches(); 70 } 71 72 75 protected void initExcludedPatternRepresentation(String [] excludedPatterns) throws IllegalArgumentException { 76 this.compiledExclusionPatterns = compilePatterns(excludedPatterns); 77 } 78 79 83 protected boolean matchesExclusion(String candidate, int patternIndex) { 84 Matcher matcher = this.compiledExclusionPatterns[patternIndex].matcher(candidate); 85 return matcher.matches(); 86 } 87 88 92 private Pattern [] compilePatterns(String [] source) { 93 Pattern [] destination = new Pattern [source.length]; 94 for (int i = 0; i < source.length; i++) { 95 destination[i] = Pattern.compile(source[i]); 96 } 97 return destination; 98 } 99 100 } 101 | Popular Tags |