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 * Abstract superclass for Criteria using a field to compare with
020 *
021 * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
022 * @version $Id: FieldCriteria.java,v 1.1 2007-08-24 22:17:36 ewestfal Exp $
023 */
024 public class FieldCriteria extends SelectionCriteria
025 {
026 // PAW
027 // static FieldCriteria buildEqualToCriteria(Object anAttribute, Object aValue, String anAlias)
028 static FieldCriteria buildEqualToCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
029 {
030 return new FieldCriteria(anAttribute, aValue, EQUAL, anAlias);
031 }
032
033 // PAW
034 // static FieldCriteria buildNotEqualToCriteria(Object anAttribute, Object aValue, String anAlias)
035 static FieldCriteria buildNotEqualToCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
036 {
037 return new FieldCriteria(anAttribute, aValue, NOT_EQUAL, anAlias);
038 }
039
040 // PAW
041 // static FieldCriteria buildGreaterCriteria(Object anAttribute, Object aValue, String anAlias)
042 static FieldCriteria buildGreaterCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
043 {
044 return new FieldCriteria(anAttribute, aValue,GREATER, anAlias);
045 }
046
047 // PAW
048 // static FieldCriteria buildNotGreaterCriteria(Object anAttribute, Object aValue, String anAlias)
049 static FieldCriteria buildNotGreaterCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
050 {
051 return new FieldCriteria(anAttribute, aValue, NOT_GREATER, anAlias);
052 }
053
054 // PAW
055 // static FieldCriteria buildLessCriteria(Object anAttribute, Object aValue, String anAlias)
056 static FieldCriteria buildLessCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
057 {
058 return new FieldCriteria(anAttribute, aValue, LESS, anAlias);
059 }
060
061 // PAW
062 // static FieldCriteria buildNotLessCriteria(Object anAttribute, Object aValue, String anAlias)
063 static FieldCriteria buildNotLessCriteria(Object anAttribute, Object aValue, UserAlias anAlias)
064 {
065 return new FieldCriteria(anAttribute, aValue, NOT_LESS, anAlias);
066 }
067
068 // BRJ: indicate whether field name should be translated into column name
069 private boolean m_translateField = true;
070 private String m_clause;
071
072 /**
073 * Constructor declaration
074 *
075 * @param anAttribute column- or fieldName
076 * @param aValue the value to compare with
077 * @param negative criteria is negated (ie NOT LIKE instead of LIKE)
078 * @param alias use alias to link anAttribute to
079 */
080 // PAW
081 // FieldCriteria(Object anAttribute, Object aValue, String aClause, String alias)
082 FieldCriteria(Object anAttribute, Object aValue, String aClause, UserAlias alias)
083 {
084 super(anAttribute, aValue, alias);
085 m_clause = aClause;
086 }
087
088 /**
089 * @see SelectionCriteria#isBindable()
090 */
091 protected boolean isBindable()
092 {
093 return false;
094 }
095
096 /**
097 * @return true if field name should be translated into column name
098 */
099 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