1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.wotonomy.control;
20
21 import net.wotonomy.foundation.internal.WotonomyException;
22
23 /***
24 * EONotQualifiier negates a specified qualifier,
25 * evaluating to the opposite of the specified qualifier.
26 *
27 * @author michael@mpowers.net
28 * @author yjcheung@intersectsoft.com
29 * @author $Author: cgruber $
30 * @version $Revision: 894 $
31 */
32 public class EONotQualifier extends EOQualifier
33 implements EOKeyValueArchiving, EOQualifierEvaluation
34 {
35 private EOQualifier qualifier;
36
37 public EONotQualifier(
38 EOQualifier aQualifier )
39 {
40 qualifier = aQualifier;
41 }
42
43 /***
44 * Returns the qualifier that this qualifier negates.
45 */
46 public EOQualifier qualifier()
47 {
48 return qualifier;
49 }
50
51 /***
52 * Evaluates this qualifier for the specified object,
53 * and returns whether the object is qualified.
54 * evaluateWithObject is invoked on qualifier
55 * and the result is negated and returned.
56 */
57 public boolean evaluateWithObject( Object anObject )
58 {
59 return !(qualifier.evaluateWithObject(anObject));
60 }
61
62 /***
63 * Returns a string representation of this qualifier.
64 */
65 public String toString()
66 {
67 return (new StringBuffer("Not ").append(qualifier.toString()).toString());
68 }
69
70 public static Object decodeWithKeyValueUnarchiver(EOKeyValueUnarchiver arch) {
71 EOQualifier q = (EOQualifier)arch.decodeObjectForKey("qualifier");
72 if (q == null)
73 return null;
74 return new EONotQualifier(q);
75 }
76
77 public void encodeWithKeyValueArchiver(EOKeyValueArchiver arch) {
78 arch.encodeObject("EONotQualifier", "class");
79 if (qualifier instanceof EOKeyValueArchiving) {
80 EOKeyValueArchiver ar2 = new EOKeyValueArchiver();
81 ((EOKeyValueArchiving)qualifier).encodeWithKeyValueArchiver(ar2);
82 arch.encodeObject(ar2.dictionary(), "qualifiers");
83 } else
84 throw new WotonomyException("Cannot archive instance of " + qualifier.getClass().getName());
85 }
86
87 }
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129