1 21 package oracle.toplink.essentials.expressions; 23 24 import oracle.toplink.essentials.internal.helper.ClassConstants; 25 26 36 public class ExpressionMath { 37 38 46 public static Expression abs(Expression expression) { 47 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Abs); 48 return anOperator.expressionFor(expression); 49 } 50 51 55 public static Expression acos(Expression expression) { 56 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Acos); 57 return anOperator.expressionFor(expression); 58 } 59 60 64 public static Expression add(Expression left, int right) { 65 return add(left, new Integer (right)); 66 } 67 68 72 public static Expression add(Expression right, Object left) { 73 ExpressionOperator anOperator = right.getOperator(ExpressionOperator.Add); 74 return anOperator.expressionFor(right, left); 75 } 76 77 81 public static Expression asin(Expression expression) { 82 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Asin); 83 return anOperator.expressionFor(expression); 84 } 85 86 90 public static Expression atan(Expression expression) { 91 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Atan); 92 return anOperator.expressionFor(expression); 93 } 94 95 99 public static Expression atan2(Expression expression, int value) { 100 return atan2(expression, new Integer (value)); 101 } 102 103 107 public static Expression atan2(Expression expression, Object value) { 108 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Atan2); 109 return anOperator.expressionFor(expression, value); 110 } 111 112 116 public static Expression atan2(Expression expression1, Expression expression2) { 117 ExpressionOperator anOperator = expression1.getOperator(ExpressionOperator.Atan2); 118 return anOperator.expressionFor(expression1, expression2); 119 } 120 121 125 public static Expression ceil(Expression expression) { 126 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Ceil); 127 return anOperator.expressionFor(expression); 128 } 129 130 134 public static Expression chr(Expression expression) { 135 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Chr); 136 return anOperator.expressionFor(expression); 137 } 138 139 143 public static Expression cos(Expression expression) { 144 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Cos); 145 return anOperator.expressionFor(expression); 146 } 147 148 153 public static Expression cosh(Expression expression) { 154 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Cosh); 155 return anOperator.expressionFor(expression); 156 } 157 158 162 public static Expression cot(Expression expression) { 163 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Cot); 164 return anOperator.expressionFor(expression); 165 } 166 167 171 public static Expression divide(Expression left, int right) { 172 return divide(left, new Integer (right)); 173 } 174 175 179 public static Expression divide(Expression left, Object right) { 180 ExpressionOperator anOperator = left.getOperator(ExpressionOperator.Divide); 181 return anOperator.expressionFor(left, right); 182 } 183 184 188 public static Expression exp(Expression expression) { 189 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Exp); 190 return anOperator.expressionFor(expression); 191 } 192 193 197 public static Expression floor(Expression expression) { 198 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Floor); 199 return anOperator.expressionFor(expression); 200 } 201 202 206 public static ExpressionOperator getOperator(int selector) { 207 ExpressionOperator result = ExpressionOperator.getOperator(new Integer (selector)); 208 if (result != null) { 209 return result; 210 } 211 212 result = new ExpressionOperator(); 215 result.setSelector(selector); 216 result.setNodeClass(ClassConstants.FunctionExpression_Class); 217 return result; 218 } 219 220 224 public static Expression ln(Expression expression) { 225 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Ln); 226 return anOperator.expressionFor(expression); 227 } 228 229 233 public static Expression log(Expression expression) { 234 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Log); 235 return anOperator.expressionFor(expression); 236 } 237 238 242 public static Expression max(Expression left, int right) { 243 return max(left, new Integer (right)); 244 } 245 246 250 public static Expression max(Expression left, Object right) { 251 ExpressionOperator anOperator = left.getOperator(ExpressionOperator.Greatest); 252 return anOperator.expressionFor(left, right); 253 } 254 255 259 public static Expression min(Expression left, int right) { 260 return min(left, new Integer (right)); 261 } 262 263 267 public static Expression min(Expression left, Object right) { 268 ExpressionOperator anOperator = left.getOperator(ExpressionOperator.Least); 269 return anOperator.expressionFor(left, right); 270 } 271 272 276 public static Expression mod(Expression expression, int base) { 277 return mod(expression, new Integer (base)); 278 } 279 280 284 public static Expression mod(Expression expression, Object base) { 285 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Mod); 286 return anOperator.expressionFor(expression, base); 287 } 288 289 293 public static Expression multiply(Expression left, int right) { 294 return multiply(left, new Integer (right)); 295 } 296 297 301 public static Expression multiply(Expression left, Object right) { 302 ExpressionOperator anOperator = left.getOperator(ExpressionOperator.Multiply); 303 return anOperator.expressionFor(left, right); 304 } 305 306 310 public static Expression power(Expression expression, int raised) { 311 return power(expression, new Integer (raised)); 312 } 313 314 318 public static Expression power(Expression expression, Object raised) { 319 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Power); 320 return anOperator.expressionFor(expression, raised); 321 } 322 323 327 public static Expression round(Expression expression, int decimalPlaces) { 328 return round(expression, new Integer (decimalPlaces)); 329 } 330 331 335 public static Expression round(Expression expression, Object decimalPlaces) { 336 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Round); 337 return anOperator.expressionFor(expression, decimalPlaces); 338 } 339 340 344 public static Expression sign(Expression expression) { 345 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Sign); 346 return anOperator.expressionFor(expression); 347 } 348 349 353 public static Expression sin(Expression expression) { 354 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Sin); 355 return anOperator.expressionFor(expression); 356 } 357 358 362 public static Expression sinh(Expression expression) { 363 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Sinh); 364 return anOperator.expressionFor(expression); 365 } 366 367 371 public static Expression subtract(Expression left, int right) { 372 return subtract(left, new Integer (right)); 373 } 374 375 379 public static Expression subtract(Expression left, Object right) { 380 ExpressionOperator anOperator = left.getOperator(ExpressionOperator.Subtract); 381 return anOperator.expressionFor(left, right); 382 } 383 384 388 public static Expression tan(Expression expression) { 389 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Tan); 390 return anOperator.expressionFor(expression); 391 } 392 393 397 public static Expression tanh(Expression expression) { 398 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Tanh); 399 return anOperator.expressionFor(expression); 400 } 401 402 406 public static Expression trunc(Expression expression, int decimalPlaces) { 407 return trunc(expression, new Integer (decimalPlaces)); 408 } 409 410 414 public static Expression trunc(Expression expression, Object decimalPlaces) { 415 ExpressionOperator anOperator = expression.getOperator(ExpressionOperator.Trunc); 416 return anOperator.expressionFor(expression, decimalPlaces); 417 } 418 } 419 | Popular Tags |