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 * Abstract superclass for Criteria using a field to compare with
20 *
21 * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
22 * @version $Id: FieldCriteria.java,v 1.1 2007-08-24 22:17:36 ewestfal Exp $
23 */
24 public class FieldCriteria extends SelectionCriteria
25 {
26 // PAW
27 // static FieldCriteria buildEqualToCriteria(Object anAttribute, Object aValue, String anAlias)
28 static FieldCriteria buildEqualToCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
29 {
30 return new FieldCriteria(anAttribute, aValue, EQUAL, anAlias);
31 }
32
33 // PAW
34 // static FieldCriteria buildNotEqualToCriteria(Object anAttribute, Object aValue, String anAlias)
35 static FieldCriteria buildNotEqualToCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
36 {
37 return new FieldCriteria(anAttribute, aValue, NOT_EQUAL, anAlias);
38 }
39
40 // PAW
41 // static FieldCriteria buildGreaterCriteria(Object anAttribute, Object aValue, String anAlias)
42 static FieldCriteria buildGreaterCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
43 {
44 return new FieldCriteria(anAttribute, aValue,GREATER, anAlias);
45 }
46
47 // PAW
48 // static FieldCriteria buildNotGreaterCriteria(Object anAttribute, Object aValue, String anAlias)
49 static FieldCriteria buildNotGreaterCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
50 {
51 return new FieldCriteria(anAttribute, aValue, NOT_GREATER, anAlias);
52 }
53
54 // PAW
55 // static FieldCriteria buildLessCriteria(Object anAttribute, Object aValue, String anAlias)
56 static FieldCriteria buildLessCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
57 {
58 return new FieldCriteria(anAttribute, aValue, LESS, anAlias);
59 }
60
61 // PAW
62 // static FieldCriteria buildNotLessCriteria(Object anAttribute, Object aValue, String anAlias)
63 static FieldCriteria buildNotLessCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
64 {
65 return new FieldCriteria(anAttribute, aValue, NOT_LESS, anAlias);
66 }
67
68 // BRJ: indicate whether field name should be translated into column name
69 private boolean m_translateField = true;
70 private String m_clause;
71
72 /**
73 * Constructor declaration
74 *
75 * @param anAttribute column- or fieldName
76 * @param aValue the value to compare with
77 * @param negative criteria is negated (ie NOT LIKE instead of LIKE)
78 * @param alias use alias to link anAttribute to
79 */
80 // PAW
81 // FieldCriteria(Object anAttribute, Object aValue, String aClause, String alias)
82 FieldCriteria(Object anAttribute, Object aValue, String aClause, UserAlias alias)
83 {
84 super(anAttribute, aValue, alias);
85 m_clause = aClause;
86 }
87
88 /**
89 * @see SelectionCriteria#isBindable()
90 */
91 protected boolean isBindable()
92 {
93 return false;
94 }
95
96 /**
97 * @return true if field name should be translated into column name
98 */
99 public boolean isTranslateField()
100 {
101 return m_translateField;
102 }
103
104 /**
105 * @param b
106 */
107 void setTranslateField(boolean b)
108 {
109 m_translateField = b;
110 }
111
112 /* (non-Javadoc)
113 * @see org.apache.ojb.broker.query.SelectionCriteria#getClause()
114 */
115 public String getClause()
116 {
117 return m_clause;
118 }
119 }
120