package org.mockejb.interceptor;
import org.apache.oro.text.regex.*;
class RegexpWrapper {
private Pattern pattern;
private String patternString;
private PatternCompiler compiler = new Perl5Compiler();;
private PatternMatcher matcher = new Perl5Matcher();
public RegexpWrapper( final String patternString ){
this.patternString = patternString;
try {
pattern = compiler.compile( patternString );
}
catch( MalformedPatternException mpe ) {
throw new PointcutException( mpe.getMessage(), mpe);
}
}
public boolean containedInString( String stringToMatch ) {
return matcher.contains( stringToMatch, pattern );
}
public boolean equals( Object obj ){
if ( ! (obj instanceof RegexpWrapper) )
return false;
RegexpWrapper regexpWrapper = (RegexpWrapper ) obj;
return ( patternString.equals( regexpWrapper.patternString ));
}
public int hashCode() {
int result = 17;
result = 37*result+patternString.hashCode();
return result;
}
}