01: /*
02: * Project: AMODA - Abstract Modeled Application
03: * Class: de.gulden.framework.amoda.generic.behaviour.GenericCondition
04: * Version: snapshot-beautyj-1.1
05: *
06: * Date: 2004-09-29
07: *
08: * This is a snapshot version of the AMODA 0.2 development branch,
09: * it is not released as a seperate version.
10: * For AMODA, see http://amoda.berlios.de/.
11: *
12: * This is licensed under the GNU Lesser General Public License (LGPL)
13: * and comes with NO WARRANTY.
14: *
15: * Author: Jens Gulden
16: * Email: amoda@jensgulden.de
17: */
18:
19: package de.gulden.framework.amoda.generic.behaviour;
20:
21: import de.gulden.framework.amoda.model.behaviour.Condition;
22: import java.lang.*;
23: import java.util.*;
24:
25: /**
26: * Class GenericCondition.
27: *
28: * @author Jens Gulden
29: * @version snapshot-beautyj-1.1
30: */
31: public abstract class GenericCondition extends
32: GenericBehaviourMemberAbstract implements Condition {
33:
34: // ------------------------------------------------------------------------
35: // --- field ---
36: // ------------------------------------------------------------------------
37:
38: protected Object object;
39:
40: // ------------------------------------------------------------------------
41: // --- methods ---
42: // ------------------------------------------------------------------------
43:
44: public abstract boolean test();
45:
46: public boolean test(Object o) {
47: setObject(o);
48: return test();
49: }
50:
51: public Object getObject() {
52: return object;
53: }
54:
55: public void setObject(Object _object) {
56: object = _object;
57: }
58:
59: public Collection filter(Collection c) {
60: ArrayList result = new ArrayList();
61: for (Iterator it = c.iterator(); it.hasNext();) {
62: Object o = it.next();
63: this .setObject(o);
64: if (this .test()) {
65: result.add(o);
66: }
67: }
68: return result;
69: }
70:
71: } // end GenericCondition
|