001: /*
002: Mdarad-Toolobox is a collection of tools for Architected RAD
003: (Rapid Application Development) based on an MDA approach.
004: The toolbox contains frameworks and generators for many environments
005: (JAVA, J2EE, Hibernate, .NET, C++, etc.) which allow to generate
006: applications from a design Model
007: Copyright (C) 2004-2005 Elapse Technologies Inc.
008:
009: This library is free software; you can redistribute it and/or
010: modify it under the terms of the GNU General Public
011: License as published by the Free Software Foundation; either
012: version 2.1 of the License, or (at your option) any later version.
013:
014: This library is distributed in the hope that it will be useful,
015: but WITHOUT ANY WARRANTY; without even the implied warranty of
016: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: General Public License for more details.
018:
019: You should have received a copy of the GNU General Public
020: License along with this library; if not, write to the Free Software
021: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
022: */
023: package org.mdarad.framework.expr;
024:
025: import java.io.Serializable;
026: import java.util.Locale;
027:
028: /**
029: * Class that represent a search criterion for the MDARAD framework.
030: * The criterion is not associated with a specific query language.
031: * Each criterion must be matched with an entity (class) on wich the
032: * search is to be executed.
033: * @author Philippe Brouillette
034: * @version 1.0
035: */
036: public class Criterion implements Serializable {
037:
038: /**
039: * Constructor that takes all the properties except locale as argument
040: * @exception IllegalArgumentException if the entity, property or operator
041: * is or are null.
042: */
043: public Criterion(Class entity, String property,
044: OperatorType operator, Object value) {
045: this (entity, property, operator, value, null);
046: }
047:
048: /**
049: * Constructor that takes all the properties as argument
050: * @exception IllegalArgumentException if the entity, property or operator
051: * is or are null.
052: */
053: public Criterion(Class entity, String property,
054: OperatorType operator, Object value, Locale locale) {
055: if (entity == null || property == null || operator == null) {
056: throw new IllegalArgumentException(
057: "The entity, property or "
058: + "operator cannot be null");
059: }
060:
061: this .entity = entity;
062: this .property = property;
063: this .operator = operator;
064: this .value = value;
065: this .locale = locale;
066: }
067:
068: /**
069: * Property that keeeps the entity (class) associated
070: * to the search criterion.
071: */
072: private Class entity;
073:
074: public Class getEntity() {
075: return entity;
076: }
077:
078: public void setEntity(Class class1) {
079: entity = class1;
080: }
081:
082: /**
083: * Property that keeps the property of the entity that
084: * will be used as a query criterion.
085: */
086: private String property;
087:
088: public String getProperty() {
089: return property;
090: }
091:
092: public void setProperty(String string) {
093: property = string;
094: }
095:
096: /**
097: * Property that keeps the operator type as an enumeration
098: * class ({@link OperatorTypes})
099: */
100: private OperatorType operator;
101:
102: public OperatorType getOperator() {
103: return operator;
104: }
105:
106: public void setOperator(OperatorType string) {
107: operator = string;
108: }
109:
110: /**
111: * Property that keeps the value used by the query criterion.
112: * The <code>toString()</code> method is used to return the value
113: */
114: private Object value;
115:
116: public Object getValue() {
117: return value;
118: }
119:
120: public void setValue(Object object) {
121: value = object;
122: }
123:
124: /**
125: * Property that keeps the locale used by the query criterion.
126: */
127: private Locale locale;
128:
129: public Locale getLocale() {
130: return locale;
131: }
132:
133: public void setLocale(Locale locale) {
134: this.locale = locale;
135: }
136:
137: }
|