View Javadoc
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: AtomicCondition.java,v $ 33 * 34 * Author: Jose San Leandro Armend?riz 35 * 36 * Description: Represents undivisible 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: AtomicCondition.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.Condition; 53 import org.acmsl.queryj.Field; 54 55 /*** 56 * Represents indivisible conditions in statements. 57 * @author <a href="mailto:jsanleandro@yahoo.es" 58 >Jose San Leandro</a> 59 * @version $Revision: 1.1 $ 60 */ 61 public abstract class AtomicCondition 62 extends Condition 63 { 64 /*** 65 * The left-side field. 66 */ 67 private Field m__LeftSideField; 68 69 /*** 70 * The operator. 71 */ 72 private ConditionOperator m__Operator; 73 74 /*** 75 * The right-side field. 76 */ 77 private Field m__RightSideField; 78 79 /*** 80 * The right-side value. 81 */ 82 private String m__strRightSideValue; 83 84 /*** 85 * Creates a condition using given information. 86 * @param leftSideField the left-side field. 87 * @param operator the operator. 88 * @param rightSideField the right-side field. 89 */ 90 public AtomicCondition( 91 Field leftSideField, 92 ConditionOperator operator, 93 Field rightSideField) 94 { 95 unmodifiableSetLeftSideField(leftSideField); 96 unmodifiableSetOperator(operator); 97 unmodifiableSetRightSideField(rightSideField); 98 } 99 100 /*** 101 * Creates a condition using given information. 102 * @param leftSideField the left-side field. 103 * @param operator the operator. 104 * @param rightSideField the right-side field. 105 */ 106 protected AtomicCondition( 107 Field leftSideField, 108 ConditionOperator operator, 109 String rightSideValue) 110 { 111 this(leftSideField, operator, (Field) null); 112 unmodifiableSetRightSideValue(rightSideValue); 113 } 114 115 /*** 116 * Creates a condition using given information. 117 * @param leftSideField the left-side field. 118 * @param operator the operator. 119 * @param rightSideField the right-side field. 120 */ 121 public AtomicCondition( 122 Field leftSideField, 123 ConditionOperator operator, 124 int rightSideValue) 125 { 126 this(leftSideField, operator, (Field) null); 127 unmodifiableSetRightSideValue("" + rightSideValue); 128 } 129 130 /*** 131 * Specifies the left-side field. 132 * @param leftSideField such field. 133 */ 134 private void unmodifiableSetLeftSideField(Field leftSideField) 135 { 136 m__LeftSideField = leftSideField; 137 } 138 139 /*** 140 * Specifies the left side field. 141 * @param leftSideField such field. 142 */ 143 protected void setLeftSideField(Field leftSideField) 144 { 145 unmodifiableSetLeftSideField(leftSideField); 146 } 147 148 /*** 149 * Retrieves the left-side field. 150 * @return such reference. 151 */ 152 public Field getLeftSideField() 153 { 154 return m__LeftSideField; 155 } 156 157 /*** 158 * Specifies the operator. 159 * @param operator such operator. 160 */ 161 private void unmodifiableSetOperator(ConditionOperator operator) 162 { 163 m__Operator = operator; 164 } 165 166 /*** 167 * Specifies the operator. 168 * @param operator such operator. 169 */ 170 protected void setOperator(ConditionOperator operator) 171 { 172 unmodifiableSetOperator(operator); 173 } 174 175 /*** 176 * Retrieves the operator. 177 * @return such reference. 178 */ 179 public ConditionOperator getOperator() 180 { 181 return m__Operator; 182 } 183 184 /*** 185 * Specifies the right-side field. 186 * @param rightSideField such field. 187 */ 188 private void unmodifiableSetRightSideField(Field rightSideField) 189 { 190 m__RightSideField = rightSideField; 191 } 192 193 /*** 194 * Specifies the right side field. 195 * @param rightSideField such field. 196 */ 197 protected void setRightSideField(Field rightSideField) 198 { 199 unmodifiableSetRightSideField(rightSideField); 200 } 201 202 /*** 203 * Retrieves the right-side field. 204 * @return such reference. 205 */ 206 public Field getRightSideField() 207 { 208 return m__RightSideField; 209 } 210 211 /*** 212 * Specifies the right-side value. 213 * @param rightSideValue such value. 214 */ 215 private void unmodifiableSetRightSideValue(String rightSideValue) 216 { 217 m__strRightSideValue = rightSideValue; 218 } 219 220 /*** 221 * Specifies the right side value. 222 * @param rightSideValue such value. 223 */ 224 protected void setRightSideValue(String rightSideValue) 225 { 226 unmodifiableSetRightSideValue(rightSideValue); 227 } 228 229 /*** 230 * Retrieves the right-side value. 231 * @return such reference. 232 */ 233 public String getRightSideValue() 234 { 235 return m__strRightSideValue; 236 } 237 238 /*** 239 * Outputs a text version of the condition. 240 * @return the condition. 241 */ 242 public String toString() 243 { 244 StringBuffer t_sbResult = new StringBuffer(); 245 246 t_sbResult.append(getLeftSideField()); 247 t_sbResult.append(" "); 248 t_sbResult.append(getOperator()); 249 250 Field t_RightSideField = getRightSideField(); 251 252 String t_strRightSide = ""; 253 254 if (t_RightSideField != null) 255 { 256 t_strRightSide = t_RightSideField.toString(); 257 } 258 else 259 { 260 t_strRightSide = getRightSideValue(); 261 } 262 263 if (t_strRightSide == null) 264 { 265 t_strRightSide = ""; 266 } 267 else 268 { 269 t_sbResult.append(" "); 270 } 271 272 t_sbResult.append(t_strRightSide); 273 274 return t_sbResult.toString(); 275 } 276 }

This page was automatically generated by Maven