| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| BetweenCriteria |
|
| 1.2857142857142858;1.286 |
| 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 | * 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.1 2007-08-24 22:17:36 ewestfal Exp $ | |
| 23 | */ | |
| 24 | public class BetweenCriteria extends ValueCriteria | |
| 25 | { | |
| 26 | private Object value2; | |
| 27 | ||
| 28 | BetweenCriteria(Object anAttribute, Object aValue1, Object aValue2, String aClause, String anAlias) | |
| 29 | { | |
| 30 | super(anAttribute, aValue1, aClause, anAlias); | |
| 31 | setValue2(aValue2); | |
| 32 | } | |
| 33 | ||
| 34 | // PAW | |
| 35 | BetweenCriteria(Object anAttribute, Object aValue1, Object aValue2, String aClause, UserAlias aUserAlias) | |
| 36 | { | |
| 37 | super(anAttribute, aValue1, aClause, aUserAlias); | |
| 38 | setValue2(aValue2); | |
| 39 | } | |
| 40 | ||
| 41 | /** | |
| 42 | * sets the value of the criteria to newValue. | |
| 43 | * Used by the ODMG OQLQuery.bind() operation | |
| 44 | * BRJ: bind get's called twice so we need to know which value to set | |
| 45 | */ | |
| 46 | public void bind(Object newValue) | |
| 47 | { | |
| 48 | if (getValue() == null) | |
| 49 | { | |
| 50 | setValue(newValue); | |
| 51 | } | |
| 52 | else | |
| 53 | { | |
| 54 | setValue2(newValue); | |
| 55 | setBound(true); | |
| 56 | } | |
| 57 | } | |
| 58 | ||
| 59 | ||
| 60 | /** | |
| 61 | * Gets the value2. | |
| 62 | * @return Returns a Object | |
| 63 | */ | |
| 64 | public Object getValue2() | |
| 65 | { | |
| 66 | return value2; | |
| 67 | } | |
| 68 | ||
| 69 | /** | |
| 70 | * Sets the value2. | |
| 71 | * @param value2 The value2 to set | |
| 72 | */ | |
| 73 | protected void setValue2(Object value2) | |
| 74 | { | |
| 75 | this.value2 = value2; | |
| 76 | } | |
| 77 | ||
| 78 | /** | |
| 79 | * @see org.apache.ojb.broker.query.SelectionCriteria#isBindable() | |
| 80 | */ | |
| 81 | protected boolean isBindable() | |
| 82 | { | |
| 83 | return (getValue() == null && getValue2() == null); | |
| 84 | } | |
| 85 | ||
| 86 | // PAW | |
| 87 | /** | |
| 88 | * String representation | |
| 89 | */ | |
| 90 | public String toString() | |
| 91 | { | |
| 92 | return super.toString() + " AND " + value2; | |
| 93 | } | |
| 94 | } | |
| 95 |