01: /* Copyright 2004 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal.groups.pags.testers;
07:
08: import org.apache.oro.text.perl.Perl5Util;
09:
10: /**
11: * A tester for matching the possibly multiple values of an attribute
12: * against a regular expression. If any of the values matches the pattern,
13: * the tester returns true.
14: * <p>
15: * @author Dan Ellentuck
16: * @version $Revision: 34757 $
17: */
18:
19: public class RegexTester extends StringTester {
20: protected Perl5Util regexMatcher = null;
21: protected String pattern = null;
22: protected char PATTERN_DELIMITER = '/';
23:
24: public RegexTester(String attribute, String test) {
25: super (attribute, test);
26: initialize();
27: }
28:
29: protected void initialize() {
30: regexMatcher = new Perl5Util();
31: pattern = PATTERN_DELIMITER + testValue + PATTERN_DELIMITER;
32: }
33:
34: public boolean test(String att) {
35: boolean result = false;
36: try {
37: result = regexMatcher.match(pattern, att);
38: } catch (Throwable t) {
39: } // Bad pattern?
40: return result;
41: }
42:
43: }
|