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.9.2.1 2005/12/21 22:27:09 tomdz Exp $
023: */
024: public class FieldCriteria extends SelectionCriteria {
025: // PAW
026: // static FieldCriteria buildEqualToCriteria(Object anAttribute, Object aValue, String anAlias)
027: static FieldCriteria buildEqualToCriteria(Object anAttribute,
028: Object aValue, UserAlias anAlias) {
029: return new FieldCriteria(anAttribute, aValue, EQUAL, anAlias);
030: }
031:
032: // PAW
033: // static FieldCriteria buildNotEqualToCriteria(Object anAttribute, Object aValue, String anAlias)
034: static FieldCriteria buildNotEqualToCriteria(Object anAttribute,
035: Object aValue, UserAlias anAlias) {
036: return new FieldCriteria(anAttribute, aValue, NOT_EQUAL,
037: anAlias);
038: }
039:
040: // PAW
041: // static FieldCriteria buildGreaterCriteria(Object anAttribute, Object aValue, String anAlias)
042: static FieldCriteria buildGreaterCriteria(Object anAttribute,
043: Object aValue, UserAlias anAlias) {
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,
050: Object aValue, UserAlias anAlias) {
051: return new FieldCriteria(anAttribute, aValue, NOT_GREATER,
052: anAlias);
053: }
054:
055: // PAW
056: // static FieldCriteria buildLessCriteria(Object anAttribute, Object aValue, String anAlias)
057: static FieldCriteria buildLessCriteria(Object anAttribute,
058: Object aValue, UserAlias anAlias) {
059: return new FieldCriteria(anAttribute, aValue, LESS, anAlias);
060: }
061:
062: // PAW
063: // static FieldCriteria buildNotLessCriteria(Object anAttribute, Object aValue, String anAlias)
064: static FieldCriteria buildNotLessCriteria(Object anAttribute,
065: Object aValue, UserAlias anAlias) {
066: return new FieldCriteria(anAttribute, aValue, NOT_LESS, anAlias);
067: }
068:
069: // BRJ: indicate whether field name should be translated into column name
070: private boolean m_translateField = true;
071: private String m_clause;
072:
073: /**
074: * Constructor declaration
075: *
076: * @param anAttribute column- or fieldName
077: * @param aValue the value to compare with
078: * @param negative criteria is negated (ie NOT LIKE instead of LIKE)
079: * @param alias use alias to link anAttribute to
080: */
081: // PAW
082: // FieldCriteria(Object anAttribute, Object aValue, String aClause, String alias)
083: FieldCriteria(Object anAttribute, Object aValue, String aClause,
084: UserAlias alias) {
085: super (anAttribute, aValue, alias);
086: m_clause = aClause;
087: }
088:
089: /**
090: * @see SelectionCriteria#isBindable()
091: */
092: protected boolean isBindable() {
093: return false;
094: }
095:
096: /**
097: * @return true if field name should be translated into column name
098: */
099: public boolean isTranslateField() {
100: return m_translateField;
101: }
102:
103: /**
104: * @param b
105: */
106: void setTranslateField(boolean b) {
107: m_translateField = b;
108: }
109:
110: /* (non-Javadoc)
111: * @see org.apache.ojb.broker.query.SelectionCriteria#getClause()
112: */
113: public String getClause() {
114: return m_clause;
115: }
116: }
|