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.IPersonTester;
09:
10: /**
11: * A tester for examining <code>IPerson</code> attributes.
12: * <p>
13: * @author Dan Ellentuck
14: * @version $Revision: 34757 $
15: */
16:
17: public abstract class BaseAttributeTester implements IPersonTester {
18: protected String attributeName;
19: protected String testValue;
20:
21: public BaseAttributeTester(String attribute, String test) {
22: super ();
23: attributeName = attribute;
24: testValue = test;
25: }
26:
27: /**
28: * @return String
29: */
30: public String getAttributeName() {
31: return attributeName;
32: }
33:
34: /**
35: * @return String
36: */
37: public String getTestValue() {
38: return testValue;
39: }
40:
41: /**
42: * return String
43: */
44: public String asString(Object o) {
45: String result = null;
46: if (o instanceof String) {
47: result = (String) o;
48: } else {
49: if (o instanceof String[]) {
50: String[] sa = (String[]) o;
51: if (sa.length > 0) {
52: result = sa[0];
53: }
54: }
55: }
56: return result;
57: }
58:
59: public String toString() {
60: return "Tester for " + getAttributeName() + " : "
61: + getTestValue();
62: }
63:
64: }
|