KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > broker > query > ValueCriteria


1 package org.apache.ojb.broker.query;
2
3 /* Copyright 2002-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /**
19  * Models a Criteria comparing an attribute to a value
20  * <br>ie: name = 'Mark' , name like 'M%'
21  *
22  * @author <a HREF="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
23  * @version $Id: ValueCriteria.java,v 1.8.2.3 2005/12/21 22:27:09 tomdz Exp $
24  */

25 public class ValueCriteria extends SelectionCriteria
26 {
27     static ValueCriteria buildEqualToCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, String JavaDoc anAlias)
28     {
29         return new ValueCriteria(anAttribute, aValue, EQUAL, anAlias);
30     }
31     
32     static ValueCriteria buildEqualToCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, UserAlias anAlias)
33     {
34         return new ValueCriteria(anAttribute, aValue, EQUAL, anAlias);
35     }
36
37     static ValueCriteria buildNotEqualToCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, String JavaDoc anAlias)
38     {
39         return new ValueCriteria(anAttribute, aValue, NOT_EQUAL, anAlias);
40     }
41     static ValueCriteria buildNotEqualToCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, UserAlias anAlias)
42     {
43         return new ValueCriteria(anAttribute, aValue, NOT_EQUAL, anAlias);
44     }
45
46     static ValueCriteria buildGreaterCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, String JavaDoc anAlias)
47     {
48         return new ValueCriteria(anAttribute, aValue,GREATER, anAlias);
49     }
50     static ValueCriteria buildGreaterCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, UserAlias anAlias)
51     {
52         return new ValueCriteria(anAttribute, aValue,GREATER, anAlias);
53     }
54
55     static ValueCriteria buildNotGreaterCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, String JavaDoc anAlias)
56     {
57         return new ValueCriteria(anAttribute, aValue, NOT_GREATER, anAlias);
58     }
59     static ValueCriteria buildNotGreaterCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, UserAlias anAlias)
60     {
61         return new ValueCriteria(anAttribute, aValue, NOT_GREATER, anAlias);
62     }
63
64     static ValueCriteria buildLessCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, String JavaDoc anAlias)
65     {
66         return new ValueCriteria(anAttribute, aValue, LESS, anAlias);
67     }
68     static ValueCriteria buildLessCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, UserAlias anAlias)
69     {
70         return new ValueCriteria(anAttribute, aValue, LESS, anAlias);
71     }
72
73     static ValueCriteria buildNotLessCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, String JavaDoc anAlias)
74     {
75         return new ValueCriteria(anAttribute, aValue, NOT_LESS, anAlias);
76     }
77     static ValueCriteria buildNotLessCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, UserAlias anAlias)
78     {
79         return new ValueCriteria(anAttribute, aValue, NOT_LESS, anAlias);
80     }
81
82     static ValueCriteria buildLikeCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, String JavaDoc anAlias)
83     {
84         return new LikeCriteria(anAttribute, aValue, LIKE, anAlias);
85     }
86     static ValueCriteria buildLikeCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, UserAlias anAlias)
87     {
88         return new LikeCriteria(anAttribute, aValue, LIKE, anAlias);
89     }
90
91     static ValueCriteria buildNotLikeCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, String JavaDoc anAlias)
92     {
93         return new ValueCriteria(anAttribute, aValue, NOT_LIKE, anAlias);
94     }
95     static ValueCriteria buildNotLikeCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, UserAlias anAlias)
96     {
97         return new LikeCriteria(anAttribute, aValue, NOT_LIKE, anAlias);
98     }
99
100     static InCriteria buildInCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, String JavaDoc anAlias)
101     {
102         return new InCriteria(anAttribute, aValue, IN, anAlias);
103     }
104     static InCriteria buildInCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, UserAlias anAlias)
105     {
106         return new InCriteria(anAttribute, aValue, IN, anAlias);
107     }
108
109     static InCriteria buildNotInCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, String JavaDoc anAlias)
110     {
111         return new InCriteria(anAttribute, aValue, NOT_IN, anAlias);
112     }
113     static InCriteria buildNotInCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, UserAlias anAlias)
114     {
115         return new InCriteria(anAttribute, aValue, NOT_IN, anAlias);
116     }
117
118     static NullCriteria buildNullCriteria(String JavaDoc anAttribute, String JavaDoc anAlias)
119     {
120         return new NullCriteria(anAttribute, IS_NULL, anAlias);
121     }
122     static NullCriteria buildNullCriteria(String JavaDoc anAttribute, UserAlias anAlias)
123     {
124         return new NullCriteria(anAttribute, IS_NULL, anAlias);
125     }
126
127     static NullCriteria buildNotNullCriteria(String JavaDoc anAttribute, String JavaDoc anAlias)
128     {
129         return new NullCriteria(anAttribute, NOT_IS_NULL, anAlias);
130     }
131     static NullCriteria buildNotNullCriteria(String JavaDoc anAttribute, UserAlias anAlias)
132     {
133         return new NullCriteria(anAttribute, NOT_IS_NULL, anAlias);
134     }
135    
136     static BetweenCriteria buildBeweenCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue1, Object JavaDoc aValue2, String JavaDoc anAlias)
137     {
138         return new BetweenCriteria(anAttribute, aValue1, aValue2, BETWEEN, anAlias);
139     }
140     static BetweenCriteria buildBeweenCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue1, Object JavaDoc aValue2, UserAlias anAlias)
141     {
142         return new BetweenCriteria(anAttribute, aValue1, aValue2, BETWEEN, anAlias);
143     }
144
145     static BetweenCriteria buildNotBeweenCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue1, Object JavaDoc aValue2, String JavaDoc anAlias)
146     {
147         return new BetweenCriteria(anAttribute, aValue1, aValue2, NOT_BETWEEN, anAlias);
148     }
149     static BetweenCriteria buildNotBeweenCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue1, Object JavaDoc aValue2, UserAlias anAlias)
150     {
151         return new BetweenCriteria(anAttribute, aValue1, aValue2, NOT_BETWEEN, anAlias);
152     }
153     
154     private String JavaDoc m_clause;
155
156     /**
157      * Constructor declaration
158      *
159      * @param anAttribute column- or fieldName
160      * @param aValue the value to compare with
161      * @param aClause the SQL compare clause (ie LIKE, = , IS NULL)
162      * @param anAlias use alias to link anAttribute to
163      */

164     ValueCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, String JavaDoc aClause, String JavaDoc anAlias)
165     {
166         super(anAttribute, aValue, anAlias);
167         m_clause = aClause;
168     }
169
170     /**
171      * Constructor declaration
172      *
173      * @param anAttribute column- or fieldName
174      * @param aValue the value to compare with
175      * @param aClause the SQL compare clause (ie LIKE, = , IS NULL)
176      * @param aUserAlias userAlias to link anAttribute to
177      */

178     ValueCriteria(Object JavaDoc anAttribute, Object JavaDoc aValue, String JavaDoc aClause, UserAlias aUserAlias)
179     {
180         super(anAttribute, aValue, aUserAlias);
181         m_clause = aClause;
182     }
183
184     /**
185      * @see org.apache.ojb.broker.query.SelectionCriteria#getClause()
186      */

187     public String JavaDoc getClause()
188     {
189         return m_clause;
190     }
191
192 }
193
Popular Tags