1 /*
2 QueryJ
3
4 Copyright (C) 2002 Jose San Leandro Armend?riz
5 jsanleandro@yahoo.es
6 chousz@yahoo.com
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22 Thanks to ACM S.L. for distributing this library under the GPL license.
23 Contact info: jsanleandro@yahoo.es
24 Postal Address: c/Playa de Lagoa, 1
25 Urb. Valdecaba?as
26 Boadilla del monte
27 28660 Madrid
28 Spain
29
30 ******************************************************************************
31 *
32 * Filename: $RCSfile: Condition.java,v $
33 *
34 * Author: Jose San Leandro Armend?riz
35 *
36 * Description: Represents conditions.
37 *
38 * Last modified by: $Author: chous $ at $Date: 2003/08/29 08:14:58 $
39 *
40 * File version: $Revision: 1.1 $
41 *
42 * Project version: $Name: $
43 *
44 * $Id: Condition.java,v 1.1 2003/08/29 08:14:58 chous Exp $
45 *
46 */
47 package org.acmsl.queryj;
48
49 /*
50 * Importing some ACM-SL classes.
51 */
52 import org.acmsl.queryj.Field;
53
54 /***
55 * Represents conditions.
56 * @author <a href="mailto:jsanleandro@yahoo.es"
57 >Jose San Leandro</a>
58 * @version $Revision: 1.1 $
59 */
60 public abstract class Condition
61 {
62 /***
63 * The inner condition.
64 */
65 private Condition m__InnerCondition;
66
67 /***
68 * Creates a condition.
69 */
70 public Condition() {};
71
72 /***
73 * Specifies a new condition collection.
74 * @param conditions the new conditions.
75 */
76 protected void setInnerCondition(Condition condition)
77 {
78 m__InnerCondition = condition;
79 }
80
81 /***
82 * Retrieves the inner condition.
83 * @return such instance.
84 */
85 protected Condition getInnerCondition()
86 {
87 return m__InnerCondition;
88 }
89
90 /***
91 * Requests OR evaluation with given condition.
92 * @param condition the condition to evaluate.
93 * @return the resulting condition.
94 */
95 public Condition or(Condition condition)
96 {
97 Condition result = condition;
98
99 ConditionFactory t_ConditionFactory = ConditionFactory.getInstance();
100
101 if (result != null)
102 {
103 Condition t_InnerCondition = getInnerCondition();
104
105 if (t_InnerCondition == null)
106 {
107 t_InnerCondition = this;
108 }
109
110 String t_strPrefix = "(" + t_InnerCondition.toString() + ") OR (";
111 String t_strSuffix = ")";
112
113 result =
114 t_ConditionFactory.wrap(condition, t_strPrefix, t_strSuffix);
115
116 setInnerCondition(result);
117 }
118
119 return result;
120 }
121
122 /***
123 * Requests AND evaluation with given condition.
124 * @param condition the condition to evaluate.
125 * @return the resulting condition.
126 */
127 public Condition and(Condition condition)
128 {
129 Condition result = condition;
130
131 ConditionFactory t_ConditionFactory = ConditionFactory.getInstance();
132
133 if (result != null)
134 {
135 Condition t_InnerCondition = getInnerCondition();
136
137 if (t_InnerCondition == null)
138 {
139 t_InnerCondition = this;
140 }
141
142 String t_strPrefix = "(" + t_InnerCondition.toString() + ") AND (";
143 String t_strSuffix = ")";
144
145 result =
146 t_ConditionFactory.wrap(condition, t_strPrefix, t_strSuffix);
147
148 setInnerCondition(result);
149 }
150
151 return result;
152 }
153
154 /***
155 * Outputs a text version of the condition.
156 * @return the condition.
157 */
158 public String toString()
159 {
160 return "" + getInnerCondition();
161 }
162 }
This page was automatically generated by Maven