01: package org.apache.ojb.broker.query;
02:
03: /* Copyright 2002-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * 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: * SelectionCriteria for 'between x and y'
20: *
21: * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
22: * @version $Id: BetweenCriteria.java,v 1.10.2.1 2005/12/21 22:27:09 tomdz Exp $
23: */
24: public class BetweenCriteria extends ValueCriteria {
25: private Object value2;
26:
27: BetweenCriteria(Object anAttribute, Object aValue1, Object aValue2,
28: String aClause, String anAlias) {
29: super (anAttribute, aValue1, aClause, anAlias);
30: setValue2(aValue2);
31: }
32:
33: // PAW
34: BetweenCriteria(Object anAttribute, Object aValue1, Object aValue2,
35: String aClause, UserAlias aUserAlias) {
36: super (anAttribute, aValue1, aClause, aUserAlias);
37: setValue2(aValue2);
38: }
39:
40: /**
41: * sets the value of the criteria to newValue.
42: * Used by the ODMG OQLQuery.bind() operation
43: * BRJ: bind get's called twice so we need to know which value to set
44: */
45: public void bind(Object newValue) {
46: if (getValue() == null) {
47: setValue(newValue);
48: } else {
49: setValue2(newValue);
50: setBound(true);
51: }
52: }
53:
54: /**
55: * Gets the value2.
56: * @return Returns a Object
57: */
58: public Object getValue2() {
59: return value2;
60: }
61:
62: /**
63: * Sets the value2.
64: * @param value2 The value2 to set
65: */
66: protected void setValue2(Object value2) {
67: this .value2 = value2;
68: }
69:
70: /**
71: * @see org.apache.ojb.broker.query.SelectionCriteria#isBindable()
72: */
73: protected boolean isBindable() {
74: return (getValue() == null && getValue2() == null);
75: }
76:
77: // PAW
78: /**
79: * String representation
80: */
81: public String toString() {
82: return super .toString() + " AND " + value2;
83: }
84: }
|