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.groups.pags.testers.BaseAttributeTester;
09: import org.jasig.portal.security.IPerson;
10:
11: /**
12: * Tests whether the attribute is null or none of the
13: * values of the attribute equal the specified attribute value.
14: * @author Eric Dalquist, edalquist@unicon.net
15: * @version $Revision: 34851 $
16: */
17: public class ValueMissingTester extends BaseAttributeTester {
18:
19: public ValueMissingTester(String attribute, String test) {
20: super (attribute, test);
21: }
22:
23: public boolean test(IPerson person) {
24: // Get the list of values for the attribute
25: Object[] vals = person.getAttributeValues(getAttributeName());
26:
27: // No values, test passed
28: if (vals == null) {
29: return true;
30: } else {
31: // Loop through the values of the attribute, if one is equal
32: // to the test case the test fails and returns false
33: for (int i = 0; i < vals.length; i++) {
34: String val = (String) vals[i];
35:
36: if (val.equalsIgnoreCase(testValue)) {
37: return false;
38: }
39: }
40:
41: // None of the values equaled the test case, test passed
42: return true;
43: }
44: }
45: }
|