001: package org.apache.ojb.broker.query;
002:
003: /* Copyright 2002-2005 The Apache Software Foundation
004: *
005: * Licensed under the Apache License, Version 2.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /**
019: * Models a Criteria comparing an attribute to a value
020: * <br>ie: name = 'Mark' , name like 'M%'
021: *
022: * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
023: * @version $Id: ValueCriteria.java,v 1.8.2.3 2005/12/21 22:27:09 tomdz Exp $
024: */
025: public class ValueCriteria extends SelectionCriteria {
026: static ValueCriteria buildEqualToCriteria(Object anAttribute,
027: Object aValue, String anAlias) {
028: return new ValueCriteria(anAttribute, aValue, EQUAL, anAlias);
029: }
030:
031: static ValueCriteria buildEqualToCriteria(Object anAttribute,
032: Object aValue, UserAlias anAlias) {
033: return new ValueCriteria(anAttribute, aValue, EQUAL, anAlias);
034: }
035:
036: static ValueCriteria buildNotEqualToCriteria(Object anAttribute,
037: Object aValue, String anAlias) {
038: return new ValueCriteria(anAttribute, aValue, NOT_EQUAL,
039: anAlias);
040: }
041:
042: static ValueCriteria buildNotEqualToCriteria(Object anAttribute,
043: Object aValue, UserAlias anAlias) {
044: return new ValueCriteria(anAttribute, aValue, NOT_EQUAL,
045: anAlias);
046: }
047:
048: static ValueCriteria buildGreaterCriteria(Object anAttribute,
049: Object aValue, String anAlias) {
050: return new ValueCriteria(anAttribute, aValue, GREATER, anAlias);
051: }
052:
053: static ValueCriteria buildGreaterCriteria(Object anAttribute,
054: Object aValue, UserAlias anAlias) {
055: return new ValueCriteria(anAttribute, aValue, GREATER, anAlias);
056: }
057:
058: static ValueCriteria buildNotGreaterCriteria(Object anAttribute,
059: Object aValue, String anAlias) {
060: return new ValueCriteria(anAttribute, aValue, NOT_GREATER,
061: anAlias);
062: }
063:
064: static ValueCriteria buildNotGreaterCriteria(Object anAttribute,
065: Object aValue, UserAlias anAlias) {
066: return new ValueCriteria(anAttribute, aValue, NOT_GREATER,
067: anAlias);
068: }
069:
070: static ValueCriteria buildLessCriteria(Object anAttribute,
071: Object aValue, String anAlias) {
072: return new ValueCriteria(anAttribute, aValue, LESS, anAlias);
073: }
074:
075: static ValueCriteria buildLessCriteria(Object anAttribute,
076: Object aValue, UserAlias anAlias) {
077: return new ValueCriteria(anAttribute, aValue, LESS, anAlias);
078: }
079:
080: static ValueCriteria buildNotLessCriteria(Object anAttribute,
081: Object aValue, String anAlias) {
082: return new ValueCriteria(anAttribute, aValue, NOT_LESS, anAlias);
083: }
084:
085: static ValueCriteria buildNotLessCriteria(Object anAttribute,
086: Object aValue, UserAlias anAlias) {
087: return new ValueCriteria(anAttribute, aValue, NOT_LESS, anAlias);
088: }
089:
090: static ValueCriteria buildLikeCriteria(Object anAttribute,
091: Object aValue, String anAlias) {
092: return new LikeCriteria(anAttribute, aValue, LIKE, anAlias);
093: }
094:
095: static ValueCriteria buildLikeCriteria(Object anAttribute,
096: Object aValue, UserAlias anAlias) {
097: return new LikeCriteria(anAttribute, aValue, LIKE, anAlias);
098: }
099:
100: static ValueCriteria buildNotLikeCriteria(Object anAttribute,
101: Object aValue, String anAlias) {
102: return new ValueCriteria(anAttribute, aValue, NOT_LIKE, anAlias);
103: }
104:
105: static ValueCriteria buildNotLikeCriteria(Object anAttribute,
106: Object aValue, UserAlias anAlias) {
107: return new LikeCriteria(anAttribute, aValue, NOT_LIKE, anAlias);
108: }
109:
110: static InCriteria buildInCriteria(Object anAttribute,
111: Object aValue, String anAlias) {
112: return new InCriteria(anAttribute, aValue, IN, anAlias);
113: }
114:
115: static InCriteria buildInCriteria(Object anAttribute,
116: Object aValue, UserAlias anAlias) {
117: return new InCriteria(anAttribute, aValue, IN, anAlias);
118: }
119:
120: static InCriteria buildNotInCriteria(Object anAttribute,
121: Object aValue, String anAlias) {
122: return new InCriteria(anAttribute, aValue, NOT_IN, anAlias);
123: }
124:
125: static InCriteria buildNotInCriteria(Object anAttribute,
126: Object aValue, UserAlias anAlias) {
127: return new InCriteria(anAttribute, aValue, NOT_IN, anAlias);
128: }
129:
130: static NullCriteria buildNullCriteria(String anAttribute,
131: String anAlias) {
132: return new NullCriteria(anAttribute, IS_NULL, anAlias);
133: }
134:
135: static NullCriteria buildNullCriteria(String anAttribute,
136: UserAlias anAlias) {
137: return new NullCriteria(anAttribute, IS_NULL, anAlias);
138: }
139:
140: static NullCriteria buildNotNullCriteria(String anAttribute,
141: String anAlias) {
142: return new NullCriteria(anAttribute, NOT_IS_NULL, anAlias);
143: }
144:
145: static NullCriteria buildNotNullCriteria(String anAttribute,
146: UserAlias anAlias) {
147: return new NullCriteria(anAttribute, NOT_IS_NULL, anAlias);
148: }
149:
150: static BetweenCriteria buildBeweenCriteria(Object anAttribute,
151: Object aValue1, Object aValue2, String anAlias) {
152: return new BetweenCriteria(anAttribute, aValue1, aValue2,
153: BETWEEN, anAlias);
154: }
155:
156: static BetweenCriteria buildBeweenCriteria(Object anAttribute,
157: Object aValue1, Object aValue2, UserAlias anAlias) {
158: return new BetweenCriteria(anAttribute, aValue1, aValue2,
159: BETWEEN, anAlias);
160: }
161:
162: static BetweenCriteria buildNotBeweenCriteria(Object anAttribute,
163: Object aValue1, Object aValue2, String anAlias) {
164: return new BetweenCriteria(anAttribute, aValue1, aValue2,
165: NOT_BETWEEN, anAlias);
166: }
167:
168: static BetweenCriteria buildNotBeweenCriteria(Object anAttribute,
169: Object aValue1, Object aValue2, UserAlias anAlias) {
170: return new BetweenCriteria(anAttribute, aValue1, aValue2,
171: NOT_BETWEEN, anAlias);
172: }
173:
174: private String m_clause;
175:
176: /**
177: * Constructor declaration
178: *
179: * @param anAttribute column- or fieldName
180: * @param aValue the value to compare with
181: * @param aClause the SQL compare clause (ie LIKE, = , IS NULL)
182: * @param anAlias use alias to link anAttribute to
183: */
184: ValueCriteria(Object anAttribute, Object aValue, String aClause,
185: String anAlias) {
186: super (anAttribute, aValue, anAlias);
187: m_clause = aClause;
188: }
189:
190: /**
191: * Constructor declaration
192: *
193: * @param anAttribute column- or fieldName
194: * @param aValue the value to compare with
195: * @param aClause the SQL compare clause (ie LIKE, = , IS NULL)
196: * @param aUserAlias userAlias to link anAttribute to
197: */
198: ValueCriteria(Object anAttribute, Object aValue, String aClause,
199: UserAlias aUserAlias) {
200: super (anAttribute, aValue, aUserAlias);
201: m_clause = aClause;
202: }
203:
204: /**
205: * @see org.apache.ojb.broker.query.SelectionCriteria#getClause()
206: */
207: public String getClause() {
208: return m_clause;
209: }
210:
211: }
|