KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > gulden > framework > amoda > generic > behaviour > GenericCondition


1 /*
2  * Project: AMODA - Abstract Modeled Application
3  * Class: de.gulden.framework.amoda.generic.behaviour.GenericCondition
4  * Version: snapshot-beautyj-1.1
5  *
6  * Date: 2004-09-29
7  *
8  * This is a snapshot version of the AMODA 0.2 development branch,
9  * 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 GenericBehaviourMemberAbstract implements Condition {
32
33     // ------------------------------------------------------------------------
34
// --- field ---
35
// ------------------------------------------------------------------------
36

37     protected Object JavaDoc object;
38
39
40     // ------------------------------------------------------------------------
41
// --- methods ---
42
// ------------------------------------------------------------------------
43

44     public abstract boolean test();
45
46     public boolean test(Object JavaDoc o) {
47         setObject(o);
48         return test();
49     }
50
51     public Object JavaDoc getObject() {
52         return object;
53     }
54
55     public void setObject(Object JavaDoc _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 JavaDoc 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
72
Popular Tags