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.jasig.portal.security.IPerson;
09:
10: /**
11: * Abstract class tests the possibly multiple values of an
12: * <code>IPerson</code> integer attribute.
13: * <p>
14: * @author Dan Ellentuck
15: * @version $Revision: 34757 $
16: */
17:
18: public abstract class IntegerTester extends BaseAttributeTester {
19: protected int testInteger = Integer.MIN_VALUE;
20:
21: public IntegerTester(String attribute, String test) {
22: super (attribute, test);
23: testInteger = Integer.parseInt(test);
24: }
25:
26: public int getTestInteger() {
27: return testInteger;
28: }
29:
30: public boolean test(IPerson person) {
31: boolean result = false;
32: Object[] atts = person.getAttributeValues(getAttributeName());
33: if (atts != null) {
34: for (int i = 0; i < atts.length && result == false; i++) {
35: try {
36: int integerAtt = Integer.parseInt((String) atts[i]);
37: result = test(integerAtt);
38: } catch (NumberFormatException nfe) {
39: } // result stays false
40: }
41: }
42: return result;
43: }
44:
45: public boolean test(int attributeValue) {
46: return false;
47: }
48:
49: }
|