1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.caleigo.core;
20
21 import org.caleigo.core.event.*;
22
23 /*** The NegateQualifier logically negates another single qualifier that may
24 * however be a CompositeQualifier. This would represent adding a "NOT"
25 * before the contained Qualifier.
26 *
27 * @author Dennis Zikovic
28 * @version 1.00
29 *
30 *//*
31 *
32 * WHEN WHO WHY & WHAT
33 * ------------------------------------------------------------------------------
34 * 2001-07-11 Dennis Zikovic Creation
35 */
36 public class NegateQualifier extends Qualifier
37 {
38
39 private Qualifier mNegatedQualifier;
40
41 private transient RelayListener mRelayListener;
42
43
44
45 /*** Default constructor for NegateQualifier.
46 */
47 public NegateQualifier(Qualifier entityQualifier)
48 {
49 mNegatedQualifier = entityQualifier;
50 }
51
52
53
54 /*** This method returns true if the qualifier does select the
55 * provided entity object.
56 */
57 public boolean doesQualify(IEntity entity)
58 {
59 return !mNegatedQualifier.doesQualify(entity);
60 }
61
62 /*** This method returns true if the qualifier can select entities
63 * of the type defined by the provided entity descriptor.
64 */
65 public boolean canQualify(IEntityDescriptor entityDescriptor)
66 {
67 return mNegatedQualifier.canQualify(entityDescriptor);
68 }
69
70 /*** This method returns true if the qualifier can uniquely select
71 * entities of the type defined by the provided entity descriptor.
72 * If that is the case then the qualifier is an identity qualifier and can
73 * never qualify more then a single entity instance of the specified type.
74 */
75 public boolean canUniquelyQualify(IEntityDescriptor entityDescriptor)
76 {
77 return false;
78 }
79
80 /*** This abstract method must return true if the qualifier can select
81 * entities of the type defined by the provided entity descriptor without
82 * the nead of any complementary data. No other information than can be
83 * accessed through the provided entity descriptor should be neaded if
84 * this method returns true. This validates that the doesQualify method
85 * can be called for the called qualifier.
86 */
87 public boolean canDirectlyQualify(IEntityDescriptor entityDescriptor)
88 {
89 return mNegatedQualifier.canDirectlyQualify(entityDescriptor);
90 }
91
92 /*** Adds an IQualifierListener to receive notifications of contents and
93 * structure changes from the Qualifier object. The NegateQualifier
94 * overrides this method to know when to listen on the negated qualifier.
95 */
96 public void addQualifierListener(IQualifierListener listener)
97 {
98 super.addQualifierListener(listener);
99 if(mRelayListener!=null)
100 {
101 mRelayListener = new RelayListener();
102 mNegatedQualifier.addQualifierListener(mRelayListener);
103 }
104 }
105
106 /*** The toString method returns an "abstract" expression of what the
107 * qualifier selects. Note that this expresion is only intended for visual
108 * aid and is not a valid SQL expresion.
109 */
110 public String toString()
111 {
112 return "NOT "+mNegatedQualifier;
113 }
114
115
116
117 /*** Access method that returns the wrapped contained qualifier that are
118 * defined as negated by the called Qualifier.
119 */
120 public Qualifier getNegatedQualifier()
121 {
122 return mNegatedQualifier;
123 }
124 }