KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mdarad > framework > expr > Criterion


1 /*
2     Mdarad-Toolobox is a collection of tools for Architected RAD
3     (Rapid Application Development) based on an MDA approach.
4     The toolbox contains frameworks and generators for many environments
5     (JAVA, J2EE, Hibernate, .NET, C++, etc.) which allow to generate
6     applications from a design Model
7     Copyright (C) 2004-2005 Elapse Technologies Inc.
8
9     This library is free software; you can redistribute it and/or
10     modify it under the terms of the GNU General Public
11     License as published by the Free Software Foundation; either
12     version 2.1 of the License, or (at your option) any later version.
13
14     This library is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17     General Public License for more details.
18
19     You should have received a copy of the GNU General Public
20     License along with this library; if not, write to the Free Software
21     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */

23 package org.mdarad.framework.expr;
24
25 import java.io.Serializable JavaDoc;
26 import java.util.Locale JavaDoc;
27
28 /**
29  * Class that represent a search criterion for the MDARAD framework.
30  * The criterion is not associated with a specific query language.
31  * Each criterion must be matched with an entity (class) on wich the
32  * search is to be executed.
33  * @author Philippe Brouillette
34  * @version 1.0
35  */

36 public class Criterion implements Serializable JavaDoc {
37
38     /**
39      * Constructor that takes all the properties except locale as argument
40      * @exception IllegalArgumentException if the entity, property or operator
41      * is or are null.
42      */

43     public Criterion(Class JavaDoc entity, String JavaDoc property, OperatorType operator, Object JavaDoc value) {
44         this(entity, property, operator, value, null);
45     }
46     /**
47      * Constructor that takes all the properties as argument
48      * @exception IllegalArgumentException if the entity, property or operator
49      * is or are null.
50      */

51     public Criterion(Class JavaDoc entity, String JavaDoc property, OperatorType operator, Object JavaDoc value, Locale JavaDoc locale) {
52         if (entity == null || property == null || operator == null) {
53             throw new IllegalArgumentException JavaDoc("The entity, property or " +
54                 "operator cannot be null");
55         }
56         
57         this.entity = entity;
58         this.property = property;
59         this.operator = operator;
60         this.value = value;
61         this.locale = locale;
62     }
63
64     /**
65      * Property that keeeps the entity (class) associated
66      * to the search criterion.
67      */

68     private Class JavaDoc entity;
69     
70     public Class JavaDoc getEntity() {
71         return entity;
72     }
73
74     public void setEntity(Class JavaDoc class1) {
75         entity = class1;
76     }
77
78
79     /**
80      * Property that keeps the property of the entity that
81      * will be used as a query criterion.
82      */

83     private String JavaDoc property;
84     
85     public String JavaDoc getProperty() {
86         return property;
87     }
88
89     public void setProperty(String JavaDoc string) {
90         property = string;
91     }
92     
93
94     /**
95      * Property that keeps the operator type as an enumeration
96      * class ({@link OperatorTypes})
97      */

98     private OperatorType operator;
99     
100     public OperatorType getOperator() {
101         return operator;
102     }
103
104     public void setOperator(OperatorType string) {
105         operator = string;
106     }
107
108     /**
109      * Property that keeps the value used by the query criterion.
110      * The <code>toString()</code> method is used to return the value
111      */

112     private Object JavaDoc value;
113
114     public Object JavaDoc getValue() {
115         return value;
116     }
117
118     public void setValue(Object JavaDoc object) {
119         value = object;
120     }
121
122     /**
123      * Property that keeps the locale used by the query criterion.
124      */

125     private Locale JavaDoc locale;
126
127     public Locale JavaDoc getLocale() {
128         return locale;
129     }
130
131     public void setLocale(Locale JavaDoc locale) {
132         this.locale = locale;
133     }
134
135 }
136
Popular Tags