1 21 package oracle.toplink.essentials.expressions; 23 24 import java.security.AccessController ; 25 import java.security.PrivilegedActionException ; 26 import java.util.*; 27 import java.io.*; 28 import oracle.toplink.essentials.internal.expressions.*; 29 import oracle.toplink.essentials.internal.helper.*; 30 import oracle.toplink.essentials.exceptions.*; 31 import oracle.toplink.essentials.internal.helper.ClassConstants; 32 import oracle.toplink.essentials.internal.security.PrivilegedAccessHelper; 33 import oracle.toplink.essentials.internal.security.PrivilegedNewInstanceFromClass; 34 35 40 public class ExpressionOperator implements Serializable { 41 42 43 static final long serialVersionUID = -7066100204792043980L; 44 protected int selector; 45 protected String [] databaseStrings; 46 protected boolean isPrefix = false; 47 protected boolean isRepeating = false; 48 protected Class nodeClass; 49 protected int type; 50 protected int[] argumentIndices = null; 51 protected static Hashtable allOperators; 52 protected static Hashtable platformOperatorNames; 53 protected String [] javaStrings; 54 55 56 public static final int LogicalOperator = 1; 57 public static final int ComparisonOperator = 2; 58 public static final int AggregateOperator = 3; 59 public static final int OrderOperator = 4; 60 public static final int FunctionOperator = 5; 61 62 63 public static final int And = 1; 64 public static final int Or = 2; 65 public static final int Not = 3; 66 67 68 public static final int Equal = 4; 69 public static final int NotEqual = 5; 70 public static final int EqualOuterJoin = 6; 71 public static final int LessThan = 7; 72 public static final int LessThanEqual = 8; 73 public static final int GreaterThan = 9; 74 public static final int GreaterThanEqual = 10; 75 public static final int Like = 11; 76 public static final int NotLike = 12; 77 public static final int In = 13; 78 public static final int NotIn = 14; 79 public static final int Between = 15; 80 public static final int NotBetween = 16; 81 public static final int IsNull = 17; 82 public static final int NotNull = 18; 83 public static final int Exists = 86; 84 public static final int NotExists = 88; 85 public static final int LikeEscape = 89; 86 public static final int Decode = 105; 87 public static final int Case = 117; 88 89 90 public static final int Count = 19; 91 public static final int Sum = 20; 92 public static final int Average = 21; 93 public static final int Maximum = 22; 94 public static final int Minimum = 23; 95 public static final int StandardDeviation = 24; 96 public static final int Variance = 25; 97 public static final int Distinct = 87; 98 99 100 public static final int Ascending = 26; 101 public static final int Descending = 27; 102 103 104 105 public static final int ToUpperCase = 28; 107 public static final int ToLowerCase = 29; 108 public static final int Chr = 30; 109 public static final int Concat = 31; 110 public static final int HexToRaw = 32; 111 public static final int Initcap = 33; 112 public static final int Instring = 34; 113 public static final int Soundex = 35; 114 public static final int LeftPad = 36; 115 public static final int LeftTrim = 37; 116 public static final int Replace = 38; 117 public static final int RightPad = 39; 118 public static final int RightTrim = 40; 119 public static final int Substring = 41; 120 public static final int ToNumber = 42; 121 public static final int Translate = 43; 122 public static final int Trim = 44; 123 public static final int Ascii = 45; 124 public static final int Length = 46; 125 public static final int CharIndex = 96; 126 public static final int CharLength = 97; 127 public static final int Difference = 98; 128 public static final int Reverse = 99; 129 public static final int Replicate = 100; 130 public static final int Right = 101; 131 public static final int Locate = 112; 132 public static final int Locate2 = 113; 133 public static final int ToChar = 114; 134 public static final int ToCharWithFormat = 115; 135 public static final int RightTrim2 = 116; 136 public static final int Any = 118; 137 public static final int Some = 119; 138 public static final int All = 120; 139 public static final int Trim2 = 121; 140 public static final int LeftTrim2 = 122; 141 142 public static final int AddMonths = 47; 144 public static final int DateToString = 48; 145 public static final int LastDay = 49; 146 public static final int MonthsBetween = 50; 147 public static final int NextDay = 51; 148 public static final int RoundDate = 52; 149 public static final int ToDate = 53; 150 public static final int Today = 54; 151 public static final int AddDate = 90; 152 public static final int DateName = 92; 153 public static final int DatePart = 93; 154 public static final int DateDifference = 94; 155 public static final int TruncateDate = 102; 156 public static final int NewTime = 103; 157 public static final int Nvl = 104; 158 public static final int currentDate = 123; 159 160 public static final int Ceil = 55; 162 public static final int Cos = 56; 163 public static final int Cosh = 57; 164 public static final int Abs = 58; 165 public static final int Acos = 59; 166 public static final int Asin = 60; 167 public static final int Atan = 61; 168 public static final int Exp = 62; 169 public static final int Sqrt = 63; 170 public static final int Floor = 64; 171 public static final int Ln = 65; 172 public static final int Log = 66; 173 public static final int Mod = 67; 174 public static final int Power = 68; 175 public static final int Round = 69; 176 public static final int Sign = 70; 177 public static final int Sin = 71; 178 public static final int Sinh = 72; 179 public static final int Tan = 73; 180 public static final int Tanh = 74; 181 public static final int Trunc = 75; 182 public static final int Greatest = 76; 183 public static final int Least = 77; 184 public static final int Add = 78; 185 public static final int Subtract = 79; 186 public static final int Divide = 80; 187 public static final int Multiply = 81; 188 public static final int Atan2 = 91; 189 public static final int Cot = 95; 190 191 public static final int Deref = 82; 193 public static final int Ref = 83; 194 public static final int RefToHex = 84; 195 public static final int Value = 85; 196 197 public static final int Extract = 106; 199 public static final int ExtractValue = 107; 200 public static final int ExistsNode = 108; 201 public static final int GetStringVal = 109; 202 public static final int GetNumberVal = 110; 203 public static final int IsFragment = 111; 204 205 209 public ExpressionOperator() { 210 this.type = FunctionOperator; 211 setNodeClass(ClassConstants.FunctionExpression_Class); 213 } 214 215 219 public ExpressionOperator(int selector, Vector newDatabaseStrings) { 220 this.type = FunctionOperator; 221 setNodeClass(ClassConstants.FunctionExpression_Class); 223 this.selector = selector; 224 this.printsAs(newDatabaseStrings); 225 } 226 227 231 public static ExpressionOperator abs() { 232 return simpleFunction(Abs, "ABS"); 233 } 234 235 239 public static ExpressionOperator acos() { 240 return simpleFunction(Acos, "ACOS"); 241 } 242 243 247 public static ExpressionOperator addDate() { 248 ExpressionOperator exOperator = simpleThreeArgumentFunction(AddDate, "DATEADD"); 249 int[] indices = new int[3]; 250 indices[0] = 1; 251 indices[1] = 2; 252 indices[2] = 0; 253 254 exOperator.setArgumentIndices(indices); 255 return exOperator; 256 } 257 258 262 public static ExpressionOperator addMonths() { 263 return simpleTwoArgumentFunction(AddMonths, "ADD_MONTHS"); 264 } 265 266 270 public static void addOperator(ExpressionOperator exOperator) { 271 allOperators.put(new Integer (exOperator.getSelector()), exOperator); 272 } 273 274 278 public static ExpressionOperator and() { 279 return simpleLogical(And, "AND", "and"); 280 } 281 282 287 public Object applyFunction(Object source, Vector arguments) { 288 if (source instanceof String ) { 289 if (getSelector() == ToUpperCase) { 290 return ((String )source).toUpperCase(); 291 } else if (getSelector() == ToLowerCase) { 292 return ((String )source).toLowerCase(); 293 } else if ((getSelector() == Concat) && (arguments.size() == 1) && (arguments.elementAt(0) instanceof String )) { 294 return ((String )source).concat((String )arguments.elementAt(0)); 295 } else if ((getSelector() == Substring) && (arguments.size() == 2) && (arguments.elementAt(0) instanceof Number ) && (arguments.elementAt(1) instanceof Number )) { 296 int beginIndexInclusive = ((Number )arguments.elementAt(0)).intValue() - 1; 298 int endIndexExclusive = beginIndexInclusive + ((Number )arguments.elementAt(1)).intValue(); 299 return ((String )source).substring(beginIndexInclusive, endIndexExclusive); 300 } else if (getSelector() == ToNumber) { 301 return new java.math.BigDecimal ((String )source); 302 } else if (getSelector() == Trim) { 303 return ((String )source).trim(); 304 } else if (getSelector() == Length) { 305 return new Integer (((String )source).length()); 306 } 307 } else if (source instanceof Number ) { 308 if (getSelector() == Ceil) { 309 return new Double (Math.ceil(((Number )source).doubleValue())); 310 } else if (getSelector() == Cos) { 311 return new Double (Math.cos(((Number )source).doubleValue())); 312 } else if (getSelector() == Abs) { 313 return new Double (Math.abs(((Number )source).doubleValue())); 314 } else if (getSelector() == Acos) { 315 return new Double (Math.acos(((Number )source).doubleValue())); 316 } else if (getSelector() == Asin) { 317 return new Double (Math.asin(((Number )source).doubleValue())); 318 } else if (getSelector() == Atan) { 319 return new Double (Math.atan(((Number )source).doubleValue())); 320 } else if (getSelector() == Exp) { 321 return new Double (Math.exp(((Number )source).doubleValue())); 322 } else if (getSelector() == Sqrt) { 323 return new Double (Math.sqrt(((Number )source).doubleValue())); 324 } else if (getSelector() == Floor) { 325 return new Double (Math.floor(((Number )source).doubleValue())); 326 } else if (getSelector() == Log) { 327 return new Double (Math.log(((Number )source).doubleValue())); 328 } else if ((getSelector() == Power) && (arguments.size() == 1) && (arguments.elementAt(0) instanceof Number )) { 329 return new Double (Math.pow(((Number )source).doubleValue(), (((Number )arguments.elementAt(0)).doubleValue()))); 330 } else if (getSelector() == Round) { 331 return new Double (Math.round(((Number )source).doubleValue())); 332 } else if (getSelector() == Sin) { 333 return new Double (Math.sin(((Number )source).doubleValue())); 334 } else if (getSelector() == Tan) { 335 return new Double (Math.tan(((Number )source).doubleValue())); 336 } else if ((getSelector() == Greatest) && (arguments.size() == 1) && (arguments.elementAt(0) instanceof Number )) { 337 return new Double (Math.max(((Number )source).doubleValue(), (((Number )arguments.elementAt(0)).doubleValue()))); 338 } else if ((getSelector() == Least) && (arguments.size() == 1) && (arguments.elementAt(0) instanceof Number )) { 339 return new Double (Math.min(((Number )source).doubleValue(), (((Number )arguments.elementAt(0)).doubleValue()))); 340 } else if ((getSelector() == Add) && (arguments.size() == 1) && (arguments.elementAt(0) instanceof Number )) { 341 return new Double (((Number )source).doubleValue() + (((Number )arguments.elementAt(0)).doubleValue())); 342 } else if ((getSelector() == Subtract) && (arguments.size() == 1) && (arguments.elementAt(0) instanceof Number )) { 343 return new Double (((Number )source).doubleValue() - (((Number )arguments.elementAt(0)).doubleValue())); 344 } else if ((getSelector() == Divide) && (arguments.size() == 1) && (arguments.elementAt(0) instanceof Number )) { 345 return new Double (((Number )source).doubleValue() / (((Number )arguments.elementAt(0)).doubleValue())); 346 } else if ((getSelector() == Multiply) && (arguments.size() == 1) && (arguments.elementAt(0) instanceof Number )) { 347 return new Double (((Number )source).doubleValue() * (((Number )arguments.elementAt(0)).doubleValue())); 348 } 349 } 350 351 throw QueryException.cannotConformExpression(); 352 } 353 354 358 public static ExpressionOperator ascending() { 359 return simpleOrdering(Ascending, "ASC", "ascending"); 360 } 361 362 366 public static ExpressionOperator ascii() { 367 return simpleFunction(Ascii, "ASCII"); 368 } 369 370 374 public static ExpressionOperator asin() { 375 return simpleFunction(Asin, "ASIN"); 376 } 377 378 382 public static ExpressionOperator atan() { 383 return simpleFunction(Atan, "ATAN"); 384 } 385 386 390 public static ExpressionOperator average() { 391 return simpleAggregate(Average, "AVG", "average"); 392 } 393 394 399 public void bePostfix() { 400 isPrefix = false; 401 } 402 403 408 public void bePrefix() { 409 isPrefix = true; 410 } 411 412 416 public void beRepeating() { 417 isRepeating = true; 418 } 419 420 424 public static ExpressionOperator between() { 425 ExpressionOperator result = new ExpressionOperator(); 426 result.setSelector(Between); 427 result.setType(ComparisonOperator); 428 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(); 429 v.addElement("("); 430 v.addElement(" BETWEEN "); 431 v.addElement(" AND "); 432 v.addElement(")"); 433 result.printsAs(v); 434 result.bePrefix(); 435 result.setNodeClass(ClassConstants.FunctionExpression_Class); 436 return result; 437 } 438 439 445 public static ExpressionOperator caseStatement() { 446 ExpressionOperator exOperator = new ExpressionOperator(); 447 exOperator.setType(FunctionOperator); 448 exOperator.setSelector(Case); 449 exOperator.bePrefix(); 450 exOperator.setNodeClass(FunctionExpression.class); 451 return exOperator; 452 } 453 454 458 public static ExpressionOperator ceil() { 459 return simpleFunction(Ceil, "CEIL"); 460 } 461 462 466 public static ExpressionOperator charIndex() { 467 return simpleTwoArgumentFunction(CharIndex, "CHARINDEX"); 468 } 469 470 474 public static ExpressionOperator charLength() { 475 return simpleFunction(CharLength, "CHAR_LENGTH"); 476 } 477 478 482 public static ExpressionOperator chr() { 483 return simpleFunction(Chr, "CHR"); 484 } 485 486 490 public static ExpressionOperator concat() { 491 return simpleMath(Concat, "+"); 492 } 493 494 498 public boolean conformBetween(Object left, Object right) { 499 Object start = ((Vector)right).elementAt(0); 500 Object end = ((Vector)right).elementAt(1); 501 if ((left == null) || (start == null) || (end == null)) { 502 return false; 503 } 504 if ((left instanceof Number ) && (start instanceof Number ) && (end instanceof Number )) { 505 return ((((Number )left).doubleValue()) >= (((Number )start).doubleValue())) && ((((Number )left).doubleValue()) <= (((Number )end).doubleValue())); 506 } else if ((left instanceof String ) && (start instanceof String ) && (end instanceof String )) { 507 return ((((String )left).compareTo(((String )start)) > 0) || (((String )left).compareTo(((String )start)) == 0)) && ((((String )left).compareTo(((String )end)) < 0) || (((String )left).compareTo(((String )end)) == 0)); 508 } else if ((left instanceof java.util.Date ) && (start instanceof java.util.Date ) && (end instanceof java.util.Date )) { 509 return (((java.util.Date )left).after(((java.util.Date )start)) || ((java.util.Date )left).equals(((java.util.Date )start))) && (((java.util.Date )left).before(((java.util.Date )end)) || ((java.util.Date )left).equals(((java.util.Date )end))); 510 } 511 512 throw QueryException.cannotConformExpression(); 513 } 514 515 521 public boolean conformLike(Object left, Object right) { 522 if ((right == null) && (left == null)) { 523 return true; 524 } 525 if (!(right instanceof String ) || !(left instanceof String )) { 526 throw QueryException.cannotConformExpression(); 527 } 528 String likeString = (String )right; 529 if (likeString.indexOf("_") != -1) { 530 throw QueryException.cannotConformExpression(); 531 } 532 String value = (String )left; 533 if (likeString.indexOf("%") == -1) { 534 return left.equals(right); 536 } 537 boolean strictStart = !likeString.startsWith("%"); 538 boolean strictEnd = !likeString.endsWith("%"); 539 StringTokenizer tokens = new StringTokenizer(likeString, "%"); 540 int lastPosition = 0; 541 String lastToken = null; 542 if (strictStart) { 543 lastToken = tokens.nextToken(); 544 if (!value.startsWith(lastToken)) { 545 return false; 546 } 547 } 548 while (tokens.hasMoreTokens()) { 549 lastToken = tokens.nextToken(); 550 lastPosition = value.indexOf(lastToken, lastPosition); 551 if (lastPosition < 0) { 552 return false; 553 } 554 } 555 if (strictEnd) { 556 return value.endsWith(lastToken); 557 } 558 return true; 559 } 560 561 565 public static ExpressionOperator cos() { 566 return simpleFunction(Cos, "COS"); 567 } 568 569 573 public static ExpressionOperator cosh() { 574 return simpleFunction(Cosh, "COSH"); 575 } 576 577 581 public static ExpressionOperator cot() { 582 return simpleFunction(Cot, "COT"); 583 } 584 585 589 public static ExpressionOperator count() { 590 return simpleAggregate(Count, "COUNT", "count"); 591 } 592 593 597 public static ExpressionOperator dateDifference() { 598 return simpleThreeArgumentFunction(DateDifference, "DATEDIFF"); 599 } 600 601 605 public static ExpressionOperator dateName() { 606 return simpleTwoArgumentFunction(DateName, "DATENAME"); 607 } 608 609 613 public static ExpressionOperator oracleDateName() { 614 ExpressionOperator exOperator = new ExpressionOperator(); 615 exOperator.setType(FunctionOperator); 616 exOperator.setSelector(DateName); 617 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(3); 618 v.addElement("TO_CHAR("); 619 v.addElement(", '"); 620 v.addElement("')"); 621 exOperator.printsAs(v); 622 exOperator.bePrefix(); 623 int[] indices = { 1, 0 }; 624 exOperator.setArgumentIndices(indices); 625 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 626 return exOperator; 627 } 628 629 633 public static ExpressionOperator datePart() { 634 return simpleTwoArgumentFunction(DatePart, "DATEPART"); 635 } 636 637 641 public static ExpressionOperator dateToString() { 642 return simpleFunction(DateToString, "TO_CHAR"); 643 } 644 645 649 public static ExpressionOperator toChar() { 650 return simpleFunction(ToChar, "TO_CHAR"); 651 } 652 653 657 public static ExpressionOperator toCharWithFormat() { 658 return simpleTwoArgumentFunction(ToCharWithFormat, "TO_CHAR"); 659 } 660 661 667 public static ExpressionOperator decode() { 668 ExpressionOperator exOperator = new ExpressionOperator(); 669 670 exOperator.setSelector(Decode); 671 672 exOperator.setNodeClass(FunctionExpression.class); 673 exOperator.setType(FunctionOperator); 674 exOperator.bePrefix(); 675 return exOperator; 676 } 677 678 682 public static ExpressionOperator deref() { 683 return simpleFunction(Deref, "DEREF"); 684 } 685 686 690 public static ExpressionOperator descending() { 691 return simpleOrdering(Descending, "DESC", "descending"); 692 } 693 694 698 public static ExpressionOperator difference() { 699 return simpleTwoArgumentFunction(Difference, "DIFFERENCE"); 700 } 701 702 706 public static ExpressionOperator distinct() { 707 return simpleFunction(Distinct, "DISTINCT", "distinct"); 708 } 709 710 715 public boolean doesRelationConform(Object left, Object right) { 716 if (getSelector() == Equal) { 721 if ((left == null) && (right == null)) { 722 return true; 723 } else if ((left == null) || (right == null)) { 724 return false; 725 } 726 if (((left instanceof Number ) && (right instanceof Number )) && (left.getClass() != right.getClass())) { 727 return ((Number )left).doubleValue() == ((Number )right).doubleValue(); 728 } 729 return left.equals(right); 730 } else if (getSelector() == NotEqual) { 731 if ((left == null) && (right == null)) { 732 return false; 733 } else if ((left == null) || (right == null)) { 734 return true; 735 } 736 return !left.equals(right); 737 } else if (getSelector() == IsNull) { 738 return (left == null); 739 } 740 if (getSelector() == NotNull) { 741 return (left != null); 742 } 743 else if (getSelector() == LessThan) { if ((left == null) || (right == null)) { 746 return false; 747 } 748 if ((left instanceof Number ) && (right instanceof Number )) { 749 return (((Number )left).doubleValue()) < (((Number )right).doubleValue()); 750 } else if ((left instanceof String ) && (right instanceof String )) { 751 return ((String )left).compareTo(((String )right)) < 0; 752 } else if ((left instanceof java.util.Date ) && (right instanceof java.util.Date )) { 753 return ((java.util.Date )left).before(((java.util.Date )right)); 754 } 755 } else if (getSelector() == LessThanEqual) { 756 if ((left == null) && (right == null)) { 757 return true; 758 } else if ((left == null) || (right == null)) { 759 return false; 760 } 761 if ((left instanceof Number ) && (right instanceof Number )) { 762 return (((Number )left).doubleValue()) <= (((Number )right).doubleValue()); 763 } else if ((left instanceof String ) && (right instanceof String )) { 764 int compareValue = ((String )left).compareTo(((String )right)); 765 return (compareValue < 0) || (compareValue == 0); 766 } else if ((left instanceof java.util.Date ) && (right instanceof java.util.Date )) { 767 return ((java.util.Date )left).equals(((java.util.Date )right)) || ((java.util.Date )left).before(((java.util.Date )right)); 768 } 769 } else if (getSelector() == GreaterThan) { 770 if ((left == null) || (right == null)) { 771 return false; 772 } 773 if ((left instanceof Number ) && (right instanceof Number )) { 774 return (((Number )left).doubleValue()) > (((Number )right).doubleValue()); 775 } else if ((left instanceof String ) && (right instanceof String )) { 776 int compareValue = ((String )left).compareTo(((String )right)); 777 return (compareValue > 0); 778 } else if ((left instanceof java.util.Date ) && (right instanceof java.util.Date )) { 779 return ((java.util.Date )left).after(((java.util.Date )right)); 780 } 781 } else if (getSelector() == GreaterThanEqual) { 782 if ((left == null) && (right == null)) { 783 return true; 784 } else if ((left == null) || (right == null)) { 785 return false; 786 } 787 if ((left instanceof Number ) && (right instanceof Number )) { 788 return (((Number )left).doubleValue()) >= (((Number )right).doubleValue()); 789 } else if ((left instanceof String ) && (right instanceof String )) { 790 int compareValue = ((String )left).compareTo(((String )right)); 791 return (compareValue > 0) || (compareValue == 0); 792 } else if ((left instanceof java.util.Date ) && (right instanceof java.util.Date )) { 793 return ((java.util.Date )left).equals(((java.util.Date )right)) || ((java.util.Date )left).after(((java.util.Date )right)); 794 } 795 } 796 else if ((getSelector() == Between) && (right instanceof Vector) && (((Vector)right).size() == 2)) { 798 return conformBetween(left, right); 799 } else if ((getSelector() == NotBetween) && (right instanceof Vector) && (((Vector)right).size() == 2)) { 800 return !conformBetween(left, right); 801 } 802 else if ((getSelector() == In) && (right instanceof Vector)) { 804 return ((Vector)right).contains(left); 805 } else if ((getSelector() == NotIn) && (right instanceof Vector)) { 806 return !((Vector)right).contains(left); 807 } 808 else if ((getSelector() == Like) || (getSelector() == NotLike)) { 811 int doesLikeConform = JavaPlatform.conformLike(left, right); 814 if (doesLikeConform == JavaPlatform.TRUE) { 815 return getSelector() == Like; } else if (doesLikeConform == JavaPlatform.FALSE) { 817 return getSelector() != Like; } 819 } 820 821 throw QueryException.cannotConformExpression(); 822 } 823 824 832 public static ExpressionOperator equalOuterJoin() { 833 return simpleRelation(EqualOuterJoin, "=*"); 834 } 835 836 840 public boolean equals(Object object) { 841 if (!(object instanceof ExpressionOperator)) { 842 return false; 843 } 844 return getSelector() == ((ExpressionOperator)object).getSelector(); 845 } 846 847 851 public int hashCode() { 852 return getSelector(); 853 } 854 855 859 public static ExpressionOperator exists() { 860 ExpressionOperator exOperator = new ExpressionOperator(); 861 exOperator.setType(FunctionOperator); 862 exOperator.setSelector(Exists); 863 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(2); 864 v.addElement("EXISTS" + " "); 865 v.addElement(" "); 866 exOperator.printsAs(v); 867 exOperator.bePrefix(); 868 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 869 return exOperator; 870 } 871 872 876 public static ExpressionOperator exp() { 877 return simpleFunction(Exp, "EXP"); 878 } 879 880 884 public Expression expressionFor(Expression base) { 885 return expressionForArguments(base, oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(0)); 886 } 887 888 892 public Expression expressionFor(Expression base, Object value) { 893 return newExpressionForArgument(base, value); 894 } 895 896 901 public Expression expressionForWithBaseLast(Expression base, Object value) { 902 return newExpressionForArgumentWithBaseLast(base, value); 903 } 904 905 909 public Expression expressionForArguments(Expression base, Vector arguments) { 910 return newExpressionForArguments(base, arguments); 911 } 912 913 917 public static ExpressionOperator extract() { 918 ExpressionOperator result = new ExpressionOperator(); 919 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(); 920 v.addElement("extract("); 921 v.addElement(","); 922 v.addElement(")"); 923 result.printsAs(v); 924 result.bePrefix(); 925 result.setSelector(Extract); 926 result.setNodeClass(ClassConstants.FunctionExpression_Class); 927 return result; 928 } 929 930 934 public static ExpressionOperator extractValue() { 935 ExpressionOperator result = new ExpressionOperator(); 936 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(); 937 v.addElement("extractValue("); 938 v.addElement(","); 939 v.addElement(")"); 940 result.printsAs(v); 941 result.bePrefix(); 942 result.setSelector(ExtractValue); 943 result.setNodeClass(ClassConstants.FunctionExpression_Class); 944 return result; 945 } 946 947 951 public static ExpressionOperator existsNode() { 952 ExpressionOperator result = new ExpressionOperator(); 953 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(); 954 v.addElement("existsNode("); 955 v.addElement(","); 956 v.addElement(")"); 957 result.printsAs(v); 958 result.bePrefix(); 959 result.setSelector(ExistsNode); 960 result.setNodeClass(ClassConstants.FunctionExpression_Class); 961 return result; 962 } 963 964 public static ExpressionOperator getStringVal() { 965 ExpressionOperator result = new ExpressionOperator(); 966 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(); 967 v.addElement(".getStringVal()"); 968 result.printsAs(v); 969 result.bePostfix(); 970 result.setSelector(GetStringVal); 971 result.setNodeClass(ClassConstants.FunctionExpression_Class); 972 return result; 973 } 974 975 public static ExpressionOperator getNumberVal() { 976 ExpressionOperator result = new ExpressionOperator(); 977 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(); 978 v.addElement(".getNumberVal()"); 979 result.printsAs(v); 980 result.bePostfix(); 981 result.setSelector(GetNumberVal); 982 result.setNodeClass(ClassConstants.FunctionExpression_Class); 983 return result; 984 } 985 986 public static ExpressionOperator isFragment() { 987 ExpressionOperator result = new ExpressionOperator(); 988 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(); 989 v.addElement(".isFragment()"); 990 result.printsAs(v); 991 result.bePostfix(); 992 result.setSelector(IsFragment); 993 result.setNodeClass(ClassConstants.FunctionExpression_Class); 994 return result; 995 } 996 997 1001 public static ExpressionOperator floor() { 1002 return simpleFunction(Floor, "FLOOR"); 1003 } 1004 1005 1009 public static synchronized Hashtable getAllOperators() { 1010 if (allOperators == null) { 1011 initializeOperators(); 1012 } 1013 return allOperators; 1014 } 1015 1016 1019 public String [] getDatabaseStrings() { 1020 return databaseStrings; 1021 } 1022 1023 1026 public String [] getJavaStrings() { 1027 return javaStrings; 1028 } 1029 1030 1033 public Class getNodeClass() { 1034 return nodeClass; 1035 } 1036 1037 1041 public static ExpressionOperator getOperator(Integer selector) { 1042 return (ExpressionOperator)getAllOperators().get(selector); 1043 } 1044 1045 1049 public int getSelector() { 1050 return selector; 1051 } 1052 1053 1058 public int getType() { 1059 return this.type; 1060 } 1061 1062 1066 public static ExpressionOperator greatest() { 1067 return simpleTwoArgumentFunction(Greatest, "GREATEST"); 1068 } 1069 1070 1074 public static ExpressionOperator hexToRaw() { 1075 return simpleFunction(HexToRaw, "HEXTORAW"); 1076 } 1077 1078 1082 public static ExpressionOperator ifNull() { 1083 return simpleTwoArgumentFunction(Nvl, "NVL"); 1084 } 1085 1086 1090 public static ExpressionOperator in() { 1091 ExpressionOperator result = new ExpressionOperator(); 1092 result.setType(ExpressionOperator.FunctionOperator); 1093 result.setSelector(In); 1094 Vector v = new Vector(2); 1095 v.addElement(" IN ("); 1096 v.addElement(")"); 1097 result.printsAs(v); 1098 result.bePostfix(); 1099 result.setNodeClass(ClassConstants.FunctionExpression_Class); 1100 return result; 1101 } 1102 1103 1107 public static ExpressionOperator initcap() { 1108 return simpleFunction(Initcap, "INITCAP"); 1109 } 1110 1111 1114 protected static void initializeAggregateFunctionOperators() { 1115 addOperator(count()); 1116 addOperator(sum()); 1117 addOperator(average()); 1118 addOperator(minimum()); 1119 addOperator(maximum()); 1120 addOperator(variance()); 1121 addOperator(standardDeviation()); 1122 addOperator(distinct()); 1123 } 1124 1125 1128 protected static void initializeFunctionOperators() { 1129 addOperator(notOperator()); 1130 addOperator(ascending()); 1131 addOperator(descending()); 1132 addOperator(any()); 1133 addOperator(some()); 1134 addOperator(all()); 1135 addOperator(in()); 1136 addOperator(notIn()); 1137 } 1138 1139 1142 protected static void initializeLogicalOperators() { 1143 addOperator(and()); 1144 addOperator(or()); 1145 addOperator(isNull()); 1146 addOperator(notNull()); 1147 1148 } 1149 1150 1153 public static Hashtable initializeOperators() { 1154 resetOperators(); 1155 initializeFunctionOperators(); 1156 initializeRelationOperators(); 1157 initializeLogicalOperators(); 1158 initializeAggregateFunctionOperators(); 1159 return allOperators; 1160 } 1161 1162 1166 public static String getPlatformOperatorName(int operator) { 1167 String name = (String )getPlatformOperatorNames().get(new Integer (operator)); 1168 if (name == null) { 1169 name = String.valueOf(operator); 1170 } 1171 return name; 1172 } 1173 1174 1178 public static synchronized Hashtable getPlatformOperatorNames() { 1179 if (platformOperatorNames == null) { 1180 platformOperatorNames = new Hashtable(); 1181 platformOperatorNames.put(new Integer (ToUpperCase), "ToUpperCase"); 1182 platformOperatorNames.put(new Integer (ToLowerCase), "ToLowerCase"); 1183 platformOperatorNames.put(new Integer (Chr), "Chr"); 1184 platformOperatorNames.put(new Integer (Concat), "Concat"); 1185 platformOperatorNames.put(new Integer (HexToRaw), "HexToRaw"); 1186 platformOperatorNames.put(new Integer (Initcap), "Initcap"); 1187 platformOperatorNames.put(new Integer (Instring), "Instring"); 1188 platformOperatorNames.put(new Integer (Soundex), "Soundex"); 1189 platformOperatorNames.put(new Integer (LeftPad), "LeftPad"); 1190 platformOperatorNames.put(new Integer (LeftTrim), "LeftTrim"); 1191 platformOperatorNames.put(new Integer (RightPad), "RightPad"); 1192 platformOperatorNames.put(new Integer (RightTrim), "RightTrim"); 1193 platformOperatorNames.put(new Integer (Substring), "Substring"); 1194 platformOperatorNames.put(new Integer (Translate), "Translate"); 1195 platformOperatorNames.put(new Integer (Ascii), "Ascii"); 1196 platformOperatorNames.put(new Integer (Length), "Length"); 1197 platformOperatorNames.put(new Integer (CharIndex), "CharIndex"); 1198 platformOperatorNames.put(new Integer (CharLength), "CharLength"); 1199 platformOperatorNames.put(new Integer (Difference), "Difference"); 1200 platformOperatorNames.put(new Integer (Reverse), "Reverse"); 1201 platformOperatorNames.put(new Integer (Replicate), "Replicate"); 1202 platformOperatorNames.put(new Integer (Right), "Right"); 1203 platformOperatorNames.put(new Integer (Locate), "Locate"); 1204 platformOperatorNames.put(new Integer (Locate2), "Locate"); 1205 platformOperatorNames.put(new Integer (ToNumber), "ToNumber"); 1206 platformOperatorNames.put(new Integer (ToChar), "ToChar"); 1207 platformOperatorNames.put(new Integer (ToCharWithFormat), "ToChar"); 1208 platformOperatorNames.put(new Integer (AddMonths), "AddMonths"); 1209 platformOperatorNames.put(new Integer (DateToString), "DateToString"); 1210 platformOperatorNames.put(new Integer (MonthsBetween), "MonthsBetween"); 1211 platformOperatorNames.put(new Integer (NextDay), "NextDay"); 1212 platformOperatorNames.put(new Integer (RoundDate), "RoundDate"); 1213 platformOperatorNames.put(new Integer (AddDate), "AddDate"); 1214 platformOperatorNames.put(new Integer (DateName), "DateName"); 1215 platformOperatorNames.put(new Integer (DatePart), "DatePart"); 1216 platformOperatorNames.put(new Integer (DateDifference), "DateDifference"); 1217 platformOperatorNames.put(new Integer (TruncateDate), "TruncateDate"); 1218 platformOperatorNames.put(new Integer (NewTime), "NewTime"); 1219 platformOperatorNames.put(new Integer (Nvl), "Nvl"); 1220 platformOperatorNames.put(new Integer (NewTime), "NewTime"); 1221 platformOperatorNames.put(new Integer (Ceil), "Ceil"); 1222 platformOperatorNames.put(new Integer (Cos), "Cos"); 1223 platformOperatorNames.put(new Integer (Cosh), "Cosh"); 1224 platformOperatorNames.put(new Integer (Abs), "Abs"); 1225 platformOperatorNames.put(new Integer (Acos), "Acos"); 1226 platformOperatorNames.put(new Integer (Asin), "Asin"); 1227 platformOperatorNames.put(new Integer (Atan), "Atan"); 1228 platformOperatorNames.put(new Integer (Exp), "Exp"); 1229 platformOperatorNames.put(new Integer (Sqrt), "Sqrt"); 1230 platformOperatorNames.put(new Integer (Floor), "Floor"); 1231 platformOperatorNames.put(new Integer (Ln), "Ln"); 1232 platformOperatorNames.put(new Integer (Log), "Log"); 1233 platformOperatorNames.put(new Integer (Mod), "Mod"); 1234 platformOperatorNames.put(new Integer (Power), "Power"); 1235 platformOperatorNames.put(new Integer (Round), "Round"); 1236 platformOperatorNames.put(new Integer (Sign), "Sign"); 1237 platformOperatorNames.put(new Integer (Sin), "Sin"); 1238 platformOperatorNames.put(new Integer (Sinh), "Sinh"); 1239 platformOperatorNames.put(new Integer (Tan), "Tan"); 1240 platformOperatorNames.put(new Integer (Tanh), "Tanh"); 1241 platformOperatorNames.put(new Integer (Trunc), "Trunc"); 1242 platformOperatorNames.put(new Integer (Greatest), "Greatest"); 1243 platformOperatorNames.put(new Integer (Least), "Least"); 1244 platformOperatorNames.put(new Integer (Add), "Add"); 1245 platformOperatorNames.put(new Integer (Subtract), "Subtract"); 1246 platformOperatorNames.put(new Integer (Divide), "Divide"); 1247 platformOperatorNames.put(new Integer (Multiply), "Multiply"); 1248 platformOperatorNames.put(new Integer (Atan2), "Atan2"); 1249 platformOperatorNames.put(new Integer (Cot), "Cot"); 1250 platformOperatorNames.put(new Integer (Deref), "Deref"); 1251 platformOperatorNames.put(new Integer (Ref), "Ref"); 1252 platformOperatorNames.put(new Integer (RefToHex), "RefToHex"); 1253 platformOperatorNames.put(new Integer (Value), "Value"); 1254 platformOperatorNames.put(new Integer (Extract), "Extract"); 1255 platformOperatorNames.put(new Integer (ExtractValue), "ExtractValue"); 1256 platformOperatorNames.put(new Integer (ExistsNode), "ExistsNode"); 1257 platformOperatorNames.put(new Integer (GetStringVal), "GetStringVal"); 1258 platformOperatorNames.put(new Integer (GetNumberVal), "GetNumberVal"); 1259 platformOperatorNames.put(new Integer (IsFragment), "IsFragment"); 1260 } 1261 return platformOperatorNames; 1262 } 1263 1264 1267 protected static void initializeRelationOperators() { 1268 addOperator(simpleRelation(Equal, "=", "equal")); 1269 addOperator(simpleRelation(NotEqual, "<>", "notEqual")); 1270 addOperator(simpleRelation(LessThan, "<", "lessThan")); 1271 addOperator(simpleRelation(LessThanEqual, "<=", "lessThanEqual")); 1272 addOperator(simpleRelation(GreaterThan, ">", "greaterThan")); 1273 addOperator(simpleRelation(GreaterThanEqual, ">=", "greaterThanEqual")); 1274 1275 addOperator(like()); 1276 addOperator(likeEscape()); 1277 addOperator(notLike()); 1278 addOperator(between()); 1279 1280 addOperator(exists()); 1281 addOperator(notExists()); 1282 } 1283 1284 1288 public static ExpressionOperator instring() { 1289 return simpleTwoArgumentFunction(Instring, "INSTR"); 1290 } 1291 1292 1295 public boolean isAggregateOperator() { 1296 return getType() == AggregateOperator; 1297 } 1298 1299 1302 public boolean isComparisonOperator() { 1303 return getType() == ComparisonOperator; 1304 } 1305 1306 1312 public boolean isComplete() { 1313 return (databaseStrings != null) && (databaseStrings.length != 0); 1314 } 1315 1316 1319 public boolean isFunctionOperator() { 1320 return getType() == FunctionOperator; 1321 } 1322 1323 1326 public boolean isLogicalOperator() { 1327 return getType() == LogicalOperator; 1328 } 1329 1330 1334 public static ExpressionOperator isNull() { 1335 ExpressionOperator result = new ExpressionOperator(); 1336 result.setType(ComparisonOperator); 1337 result.setSelector(IsNull); 1338 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(); 1339 v.addElement("("); 1340 v.addElement(" IS NULL)"); 1341 result.printsAs(v); 1342 result.bePrefix(); 1343 result.printsJavaAs(".isNull()"); 1344 result.setNodeClass(ClassConstants.FunctionExpression_Class); 1345 return result; 1346 } 1347 1348 1351 public boolean isOrderOperator() { 1352 return getType() == OrderOperator; 1353 } 1354 1355 1359 public boolean isPrefix() { 1360 return isPrefix; 1361 } 1362 1363 1367 public static ExpressionOperator lastDay() { 1368 return simpleFunction(LastDay, "LAST_DAY"); 1369 } 1370 1371 1375 public static ExpressionOperator least() { 1376 return simpleTwoArgumentFunction(Least, "LEAST"); 1377 } 1378 1379 1383 public static ExpressionOperator leftPad() { 1384 return simpleThreeArgumentFunction(LeftPad, "LPAD"); 1385 } 1386 1387 1391 public static ExpressionOperator leftTrim() { 1392 return simpleFunction(LeftTrim, "LTRIM"); 1393 } 1394 1395 1399 public static ExpressionOperator leftTrim2() { 1400 return simpleTwoArgumentFunction(LeftTrim2, "LTRIM"); 1401 } 1402 1403 1407 public static ExpressionOperator length() { 1408 return simpleFunction(Length, "LENGTH"); 1409 } 1410 1411 1415 public static ExpressionOperator like() { 1416 return simpleRelation(Like, "LIKE", "like"); 1417 } 1418 1419 1423 public static ExpressionOperator likeEscape() { 1424 ExpressionOperator result = new ExpressionOperator(); 1425 result.setSelector(LikeEscape); 1426 result.setType(ComparisonOperator); 1427 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(); 1428 v.addElement("("); 1429 v.addElement(" LIKE "); 1430 v.addElement(" ESCAPE "); 1431 v.addElement(")"); 1432 result.printsAs(v); 1433 result.bePrefix(); 1434 result.setNodeClass(ClassConstants.FunctionExpression_Class); 1435 return result; 1436 } 1437 1438 1442 public static ExpressionOperator ln() { 1443 return simpleFunction(Ln, "LN"); 1444 } 1445 1446 1450 public static ExpressionOperator locate() { 1451 ExpressionOperator expOperator = simpleTwoArgumentFunction(Locate, "LOCATE"); 1452 int[] argumentIndices = new int[2]; 1453 argumentIndices[0] = 1; 1454 argumentIndices[1] = 0; 1455 expOperator.setArgumentIndices(argumentIndices); 1456 return expOperator; 1457 } 1458 1459 1464 public static ExpressionOperator locate2() { 1465 ExpressionOperator expOperator = simpleThreeArgumentFunction(Locate2, "LOCATE"); 1466 int[] argumentIndices = new int[3]; 1467 argumentIndices[0] = 1; 1468 argumentIndices[1] = 0; 1469 argumentIndices[2] = 2; 1470 expOperator.setArgumentIndices(argumentIndices); 1471 return expOperator; 1472 } 1473 1474 1478 public static ExpressionOperator log() { 1479 return simpleFunction(Log, "LOG"); 1480 } 1481 1482 1486 public static ExpressionOperator maximum() { 1487 return simpleAggregate(Maximum, "MAX", "maximum"); 1488 } 1489 1490 1494 public static ExpressionOperator minimum() { 1495 return simpleAggregate(Minimum, "MIN", "minimum"); 1496 } 1497 1498 1502 public static ExpressionOperator mod() { 1503 return simpleTwoArgumentFunction(Mod, "MOD"); 1504 } 1505 1506 1510 public static ExpressionOperator monthsBetween() { 1511 return simpleTwoArgumentFunction(MonthsBetween, "MONTHS_BETWEEN"); 1512 } 1513 1514 1518 public Expression newExpressionForArgument(Expression base, Object singleArgument) { 1519 if (representsEqualToNull(singleArgument)) { 1520 return base.isNull(); 1521 } 1522 if (representsNotEqualToNull(singleArgument)) { 1523 return base.notNull(); 1524 } 1525 1526 try { 1527 Expression exp = null; 1528 if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ 1529 try { 1530 exp = (Expression)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(getNodeClass())); 1531 } catch (PrivilegedActionException exception) { 1532 return null; 1533 } 1534 } else { 1535 exp = (Expression)PrivilegedAccessHelper.newInstanceFromClass(getNodeClass()); 1536 } 1537 exp.create(base, singleArgument, this); 1538 return exp; 1539 } catch (InstantiationException e) { 1540 return null; 1541 } catch (IllegalAccessException f) { 1542 return null; 1543 } 1544 } 1545 1546 1550 public Expression newExpressionForArgumentWithBaseLast(Expression base, Object singleArgument) { 1551 if (representsEqualToNull(singleArgument)) { 1552 return base.isNull(); 1553 } 1554 if (representsNotEqualToNull(singleArgument)) { 1555 return base.notNull(); 1556 } 1557 1558 try { 1559 Expression exp = null; 1560 if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ 1561 try { 1562 exp = (Expression)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(getNodeClass())); 1563 } catch (PrivilegedActionException exception) { 1564 return null; 1565 } 1566 } else { 1567 exp = (Expression)PrivilegedAccessHelper.newInstanceFromClass(getNodeClass()); 1568 } 1569 exp.createWithBaseLast(base, singleArgument, this); 1570 return exp; 1571 } catch (InstantiationException e) { 1572 return null; 1573 } catch (IllegalAccessException f) { 1574 return null; 1575 } 1576 } 1577 1578 1582 public Expression newExpressionForArguments(Expression base, Vector arguments) { 1583 if (representsEqualToNull(arguments)) { 1584 return base.isNull(); 1585 } 1586 if (representsNotEqualToNull(arguments)) { 1587 return base.notNull(); 1588 } 1589 1590 try { 1591 Expression exp = null; 1592 if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ 1593 try { 1594 exp = (Expression)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(getNodeClass())); 1595 } catch (PrivilegedActionException exception) { 1596 return null; 1597 } 1598 } else { 1599 exp = (Expression)PrivilegedAccessHelper.newInstanceFromClass(getNodeClass()); 1600 } 1601 exp.create(base, arguments, this); 1602 return exp; 1603 } catch (InstantiationException e) { 1604 return null; 1605 } catch (IllegalAccessException f) { 1606 return null; 1607 } 1608 } 1609 1610 1614 public static ExpressionOperator newTime() { 1615 return simpleThreeArgumentFunction(NewTime, "NEW_TIME"); 1616 } 1617 1618 1622 public static ExpressionOperator nextDay() { 1623 return simpleTwoArgumentFunction(NextDay, "NEXT_DAY"); 1624 } 1625 1626 1630 public static ExpressionOperator notExists() { 1631 ExpressionOperator exOperator = new ExpressionOperator(); 1632 exOperator.setType(FunctionOperator); 1633 exOperator.setSelector(NotExists); 1634 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(2); 1635 v.addElement("NOT EXISTS" + " "); 1636 v.addElement(" "); 1637 exOperator.printsAs(v); 1638 exOperator.bePrefix(); 1639 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 1640 return exOperator; 1641 } 1642 1643 1647 public static ExpressionOperator notIn() { 1648 ExpressionOperator result = new ExpressionOperator(); 1649 result.setType(ExpressionOperator.FunctionOperator); 1650 result.setSelector(NotIn); 1651 Vector v = new Vector(2); 1652 v.addElement(" NOT IN ("); 1653 v.addElement(")"); 1654 result.printsAs(v); 1655 result.bePostfix(); 1656 result.setNodeClass(ClassConstants.FunctionExpression_Class); 1657 return result; 1658 } 1659 1660 1664 public static ExpressionOperator notLike() { 1665 return simpleRelation(NotLike, "NOT LIKE", "notLike"); 1666 } 1667 1668 1672 public static ExpressionOperator notNull() { 1673 ExpressionOperator result = new ExpressionOperator(); 1674 result.setType(ComparisonOperator); 1675 result.setSelector(NotNull); 1676 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(); 1677 v.addElement("("); 1678 v.addElement(" IS NOT NULL)"); 1679 result.printsAs(v); 1680 result.bePrefix(); 1681 result.printsJavaAs(".notNull()"); 1682 result.setNodeClass(ClassConstants.FunctionExpression_Class); 1683 return result; 1684 } 1685 1686 1690 public static ExpressionOperator notOperator() { 1691 ExpressionOperator result = new ExpressionOperator(); 1692 result.setSelector(Not); 1693 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(); 1694 v.addElement("NOT ("); 1695 v.addElement(")"); 1696 result.printsAs(v); 1697 result.bePrefix(); 1698 result.printsJavaAs(".not()"); 1699 result.setNodeClass(ClassConstants.FunctionExpression_Class); 1700 return result; 1701 } 1702 1703 1707 public static ExpressionOperator or() { 1708 return simpleLogical(Or, "OR", "or"); 1709 } 1710 1711 1715 public static ExpressionOperator power() { 1716 return simpleTwoArgumentFunction(Power, "POWER"); 1717 } 1718 1719 1722 public void printCollection(Vector items, ExpressionSQLPrinter printer) { 1723 int dbStringIndex = 0; 1724 try { 1725 if (isPrefix()) { 1726 printer.getWriter().write(getDatabaseStrings()[0]); 1727 dbStringIndex = 1; 1728 } else { 1729 dbStringIndex = 0; 1730 } 1731 } catch (IOException e) { 1732 e.printStackTrace(); 1733 } 1734 1735 for (int i = 0; i < items.size(); i++) { 1736 int index = 0; 1737 if (argumentIndices == null) { 1738 index = i; 1739 } else { 1740 index = argumentIndices[i]; 1741 } 1742 ; 1743 Expression item = (Expression)items.elementAt(index); 1744 if ((getSelector() == Ref) || ((getSelector() == Deref) && (item.isObjectExpression()))) { 1745 DatabaseTable alias = ((ObjectExpression)item).aliasForTable((DatabaseTable)((ObjectExpression)item).getDescriptor().getTables().firstElement()); 1746 printer.printString(alias.getName()); 1747 } else if ((getSelector() == Count) && (item.isExpressionBuilder())) { 1748 printer.printString("*"); 1749 } else if (getType() == FunctionOperator) { 1750 item.printSQLWithoutConversion(printer); 1751 } else { 1752 item.printSQL(printer); 1753 } 1754 if (dbStringIndex < getDatabaseStrings().length) { 1755 printer.printString(getDatabaseStrings()[dbStringIndex++]); 1756 } 1757 } 1758 } 1759 1760 1763 public void printJavaCollection(Vector items, ExpressionJavaPrinter printer) { 1764 int javaStringIndex = 0; 1765 1766 for (int i = 0; i < items.size(); i++) { 1767 Expression item = (Expression)items.elementAt(i); 1768 item.printJava(printer); 1769 if (javaStringIndex < getJavaStrings().length) { 1770 printer.printString(getJavaStrings()[javaStringIndex++]); 1771 } 1772 } 1773 } 1774 1775 1779 public void printDuo(Expression first, Expression second, ExpressionSQLPrinter printer) { 1780 int dbStringIndex; 1781 if (isPrefix()) { 1782 printer.printString(getDatabaseStrings()[0]); 1783 dbStringIndex = 1; 1784 } else { 1785 dbStringIndex = 0; 1786 } 1787 1788 first.printSQL(printer); 1789 if (dbStringIndex < getDatabaseStrings().length) { 1790 printer.printString(getDatabaseStrings()[dbStringIndex++]); 1791 } 1792 if (second != null) { 1793 second.printSQL(printer); 1794 if (dbStringIndex < getDatabaseStrings().length) { 1795 printer.printString(getDatabaseStrings()[dbStringIndex++]); 1796 } 1797 } 1798 } 1799 1800 1804 public void printJavaDuo(Expression first, Expression second, ExpressionJavaPrinter printer) { 1805 int javaStringIndex = 0; 1806 1807 first.printJava(printer); 1808 if (javaStringIndex < getJavaStrings().length) { 1809 printer.printString(getJavaStrings()[javaStringIndex++]); 1810 } 1811 if (second != null) { 1812 second.printJava(printer); 1813 if (javaStringIndex < getJavaStrings().length) { 1814 printer.printString(getJavaStrings()[javaStringIndex]); 1815 } 1816 } 1817 } 1818 1819 1823 public void printsAs(String s) { 1824 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(1); 1825 v.addElement(s); 1826 printsAs(v); 1827 } 1828 1829 1833 public void printsAs(Vector dbStrings) { 1834 this.databaseStrings = new String [dbStrings.size()]; 1835 for (int i = 0; i < dbStrings.size(); i++) { 1836 getDatabaseStrings()[i] = (String )dbStrings.elementAt(i); 1837 } 1838 } 1839 1840 1844 public void printsJavaAs(String s) { 1845 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(1); 1846 v.addElement(s); 1847 printsJavaAs(v); 1848 } 1849 1850 1854 public void printsJavaAs(Vector dbStrings) { 1855 this.javaStrings = new String [dbStrings.size()]; 1856 for (int i = 0; i < dbStrings.size(); i++) { 1857 getJavaStrings()[i] = (String )dbStrings.elementAt(i); 1858 } 1859 } 1860 1861 1865 public static ExpressionOperator ref() { 1866 return simpleFunction(Ref, "REF"); 1867 } 1868 1869 1873 public static ExpressionOperator refToHex() { 1874 return simpleFunction(RefToHex, "REFTOHEX"); 1875 } 1876 1877 1881 public static ExpressionOperator replace() { 1882 return simpleThreeArgumentFunction(Replace, "REPLACE"); 1883 } 1884 1885 1889 public static ExpressionOperator replicate() { 1890 return simpleTwoArgumentFunction(Replicate, "REPLICATE"); 1891 } 1892 1893 1898 public boolean representsEqualToNull(Object singleArgument) { 1899 if (singleArgument instanceof Vector) { 1900 return representsEqualToNull((Vector)singleArgument); 1901 } 1902 return (getSelector() == Equal) && (singleArgument == null); 1903 } 1904 1905 1910 public boolean representsEqualToNull(Vector arguments) { 1911 return (getSelector() == Equal) && (arguments.size() == 1) && (arguments.elementAt(0) == null); 1912 } 1913 1914 1919 public boolean representsNotEqualToNull(Object singleArgument) { 1920 if (singleArgument instanceof Vector) { 1921 return representsNotEqualToNull((Vector)singleArgument); 1922 } 1923 return (getSelector() == NotEqual) && (singleArgument == null); 1924 } 1925 1926 1931 public boolean representsNotEqualToNull(Vector arguments) { 1932 return (getSelector() == NotEqual) && (arguments.size() == 1) && (arguments.elementAt(0) == null); 1933 } 1934 1935 1939 public static void resetOperators() { 1940 allOperators = new Hashtable(); 1941 } 1942 1943 1947 public static ExpressionOperator reverse() { 1948 return simpleFunction(Reverse, "REVERSE"); 1949 } 1950 1951 1955 public static ExpressionOperator right() { 1956 return simpleTwoArgumentFunction(Right, "RIGHT"); 1957 } 1958 1959 1963 public static ExpressionOperator rightPad() { 1964 return simpleThreeArgumentFunction(RightPad, "RPAD"); 1965 } 1966 1967 1971 public static ExpressionOperator rightTrim() { 1972 return simpleFunction(RightTrim, "RTRIM"); 1973 } 1974 1975 1980 public static ExpressionOperator rightTrim2() { 1981 return simpleTwoArgumentFunction(RightTrim2, "RTRIM"); 1982 } 1983 1984 1988 public static ExpressionOperator round() { 1989 return simpleTwoArgumentFunction(Round, "ROUND"); 1990 } 1991 1992 1996 public static ExpressionOperator roundDate() { 1997 return simpleTwoArgumentFunction(RoundDate, "ROUND"); 1998 } 1999 2000 2004 public void setArgumentIndices(int[] indices) { 2005 argumentIndices = indices; 2006 } 2007 2008 2020 public void setNodeClass(Class nodeClass) { 2021 this.nodeClass = nodeClass; 2022 } 2023 2024 2028 public void setSelector(int selector) { 2029 this.selector = selector; 2030 } 2031 2032 2037 public void setType(int type) { 2038 this.type = type; 2039 } 2040 2041 2045 public static ExpressionOperator sign() { 2046 return simpleFunction(Sign, "SIGN"); 2047 } 2048 2049 2054 public static ExpressionOperator simpleAggregate(int selector, String databaseName, String javaName) { 2055 ExpressionOperator exOperator = new ExpressionOperator(); 2056 exOperator.setType(AggregateOperator); 2057 exOperator.setSelector(selector); 2058 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(2); 2059 v.addElement(databaseName + "("); 2060 v.addElement(")"); 2061 exOperator.printsAs(v); 2062 exOperator.bePrefix(); 2063 exOperator.printsJavaAs("." + javaName + "()"); 2064 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 2065 return exOperator; 2066 } 2067 2068 2073 public static ExpressionOperator simpleFunction(int selector, String databaseName) { 2074 ExpressionOperator exOperator = new ExpressionOperator(); 2075 exOperator.setType(FunctionOperator); 2076 exOperator.setSelector(selector); 2077 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(2); 2078 v.addElement(databaseName + "("); 2079 v.addElement(")"); 2080 exOperator.printsAs(v); 2081 exOperator.bePrefix(); 2082 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 2083 return exOperator; 2084 } 2085 2086 2090 public static ExpressionOperator simpleFunctionNoParentheses(int selector, String databaseName) { 2091 ExpressionOperator exOperator = new ExpressionOperator(); 2092 exOperator.setType(FunctionOperator); 2093 exOperator.setSelector(selector); 2094 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(1); 2095 v.addElement(databaseName); 2096 exOperator.printsAs(v); 2097 exOperator.bePrefix(); 2098 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 2099 return exOperator; 2100 } 2101 2102 2103 2108 public static ExpressionOperator simpleFunction(int selector, String databaseName, String javaName) { 2109 ExpressionOperator exOperator = simpleFunction(selector, databaseName); 2110 exOperator.printsJavaAs("." + javaName + "()"); 2111 return exOperator; 2112 } 2113 2114 2119 public static ExpressionOperator simpleLogical(int selector, String databaseName, String javaName) { 2120 ExpressionOperator exOperator = new ExpressionOperator(); 2121 exOperator.setType(LogicalOperator); 2122 exOperator.setSelector(selector); 2123 exOperator.printsAs(" " + databaseName + " "); 2124 exOperator.bePostfix(); 2125 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(2); 2126 v.addElement("." + javaName + "("); 2127 v.addElement(")"); 2128 exOperator.printsJavaAs(v); 2129 exOperator.setNodeClass(ClassConstants.LogicalExpression_Class); 2130 return exOperator; 2131 } 2132 2133 2137 public static ExpressionOperator simpleMath(int selector, String databaseName) { 2138 ExpressionOperator exOperator = new ExpressionOperator(); 2139 exOperator.setType(FunctionOperator); 2140 exOperator.setSelector(selector); 2141 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(3); 2142 v.addElement("("); 2143 v.addElement(" " + databaseName + " "); 2144 v.addElement(")"); 2145 exOperator.printsAs(v); 2146 exOperator.bePrefix(); 2147 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 2148 return exOperator; 2149 } 2150 2151 2156 public static ExpressionOperator simpleOrdering(int selector, String databaseName, String javaName) { 2157 ExpressionOperator exOperator = new ExpressionOperator(); 2158 exOperator.setType(OrderOperator); 2159 exOperator.setSelector(selector); 2160 exOperator.printsAs(" " + databaseName); 2161 exOperator.bePostfix(); 2162 exOperator.printsJavaAs("." + javaName + "()"); 2163 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 2164 return exOperator; 2165 } 2166 2167 2172 public static ExpressionOperator simpleRelation(int selector, String databaseName) { 2173 ExpressionOperator exOperator = new ExpressionOperator(); 2174 exOperator.setType(ComparisonOperator); 2175 exOperator.setSelector(selector); 2176 exOperator.printsAs(" " + databaseName + " "); 2177 exOperator.bePostfix(); 2178 exOperator.setNodeClass(ClassConstants.RelationExpression_Class); 2179 return exOperator; 2180 } 2181 2182 2187 public static ExpressionOperator simpleRelation(int selector, String databaseName, String javaName) { 2188 ExpressionOperator exOperator = simpleRelation(selector, databaseName); 2189 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(2); 2190 v.addElement("." + javaName + "("); 2191 v.addElement(")"); 2192 exOperator.printsJavaAs(v); 2193 return exOperator; 2194 } 2195 2196 2200 public static ExpressionOperator simpleThreeArgumentFunction(int selector, String dbString) { 2201 ExpressionOperator exOperator = new ExpressionOperator(); 2202 exOperator.setType(FunctionOperator); 2203 exOperator.setSelector(selector); 2204 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(4); 2205 v.addElement(dbString + "("); 2206 v.addElement(", "); 2207 v.addElement(", "); 2208 v.addElement(")"); 2209 exOperator.printsAs(v); 2210 exOperator.bePrefix(); 2211 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 2212 return exOperator; 2213 } 2214 2215 2219 public static ExpressionOperator simpleTwoArgumentFunction(int selector, String dbString) { 2220 ExpressionOperator exOperator = new ExpressionOperator(); 2221 exOperator.setType(FunctionOperator); 2222 exOperator.setSelector(selector); 2223 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(5); 2224 v.addElement(dbString + "("); 2225 v.addElement(", "); 2226 v.addElement(")"); 2227 exOperator.printsAs(v); 2228 exOperator.bePrefix(); 2229 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 2230 return exOperator; 2231 } 2232 2233 2238 public static ExpressionOperator simpleLogicalNoParens(int selector, String dbString) { 2239 ExpressionOperator exOperator = new ExpressionOperator(); 2240 exOperator.setType(FunctionOperator); 2241 exOperator.setSelector(selector); 2242 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(5); 2243 v.addElement(""); 2244 v.addElement(" " + dbString + " "); 2245 v.addElement(""); 2246 exOperator.printsAs(v); 2247 exOperator.bePrefix(); 2248 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 2249 return exOperator; 2250 } 2251 2252 2256 public static ExpressionOperator sin() { 2257 return simpleFunction(Sin, "SIN"); 2258 } 2259 2260 2264 public static ExpressionOperator sinh() { 2265 return simpleFunction(Sinh, "SINH"); 2266 } 2267 2268 2272 public static ExpressionOperator soundex() { 2273 return simpleFunction(Soundex, "SOUNDEX"); 2274 } 2275 2276 2280 public static ExpressionOperator sqrt() { 2281 return simpleFunction(Sqrt, "SQRT"); 2282 } 2283 2284 2288 public static ExpressionOperator standardDeviation() { 2289 return simpleAggregate(StandardDeviation, "STDDEV", "standardDeviation"); 2290 } 2291 2292 2296 public static ExpressionOperator substring() { 2297 return simpleThreeArgumentFunction(Substring, "SUBSTR"); 2298 } 2299 2300 2304 public static ExpressionOperator sum() { 2305 return simpleAggregate(Sum, "SUM", "sum"); 2306 } 2307 2308 2312 public static ExpressionOperator sybaseAddMonthsOperator() { 2313 ExpressionOperator exOperator = new ExpressionOperator(); 2314 exOperator.setType(FunctionOperator); 2315 exOperator.setSelector(AddMonths); 2316 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(3); 2317 v.addElement("DATEADD(month, "); 2318 v.addElement(", "); 2319 v.addElement(")"); 2320 exOperator.printsAs(v); 2321 exOperator.bePrefix(); 2322 int[] indices = { 1, 0 }; 2323 exOperator.setArgumentIndices(indices); 2324 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 2325 return exOperator; 2326 2327 } 2328 2329 2333 public static ExpressionOperator sybaseAtan2Operator() { 2334 return ExpressionOperator.simpleTwoArgumentFunction(Atan2, "ATN2"); 2335 } 2336 2337 2341 public static ExpressionOperator sybaseInStringOperator() { 2342 ExpressionOperator exOperator = new ExpressionOperator(); 2343 exOperator.setType(FunctionOperator); 2344 exOperator.setSelector(Instring); 2345 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(3); 2346 v.addElement("CHARINDEX("); 2347 v.addElement(", "); 2348 v.addElement(")"); 2349 exOperator.printsAs(v); 2350 exOperator.bePrefix(); 2351 int[] indices = { 1, 0 }; 2352 exOperator.setArgumentIndices(indices); 2353 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 2354 return exOperator; 2355 2356 } 2357 2358 2362 public static ExpressionOperator sybaseToNumberOperator() { 2363 ExpressionOperator exOperator = new ExpressionOperator(); 2364 exOperator.setType(FunctionOperator); 2365 exOperator.setSelector(ToNumber); 2366 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(2); 2367 v.addElement("CONVERT(NUMERIC, "); 2368 v.addElement(")"); 2369 exOperator.printsAs(v); 2370 exOperator.bePrefix(); 2371 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 2372 return exOperator; 2373 } 2374 2375 2379 public static ExpressionOperator sybaseToDateToStringOperator() { 2380 ExpressionOperator exOperator = new ExpressionOperator(); 2381 exOperator.setType(FunctionOperator); 2382 exOperator.setSelector(DateToString); 2383 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(2); 2384 v.addElement("CONVERT(CHAR, "); 2385 v.addElement(")"); 2386 exOperator.printsAs(v); 2387 exOperator.bePrefix(); 2388 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 2389 return exOperator; 2390 } 2391 2392 2396 public static ExpressionOperator sybaseToDateOperator() { 2397 ExpressionOperator exOperator = new ExpressionOperator(); 2398 exOperator.setType(FunctionOperator); 2399 exOperator.setSelector(ToDate); 2400 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(2); 2401 v.addElement("CONVERT(DATETIME, "); 2402 v.addElement(")"); 2403 exOperator.printsAs(v); 2404 exOperator.bePrefix(); 2405 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 2406 return exOperator; 2407 } 2408 2409 2413 public static ExpressionOperator sybaseToCharOperator() { 2414 ExpressionOperator exOperator = new ExpressionOperator(); 2415 exOperator.setType(FunctionOperator); 2416 exOperator.setSelector(ToChar); 2417 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(2); 2418 v.addElement("CONVERT(CHAR, "); 2419 v.addElement(")"); 2420 exOperator.printsAs(v); 2421 exOperator.bePrefix(); 2422 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 2423 return exOperator; 2424 } 2425 2426 2430 public static ExpressionOperator sybaseToCharWithFormatOperator() { 2431 ExpressionOperator exOperator = new ExpressionOperator(); 2432 exOperator.setType(FunctionOperator); 2433 exOperator.setSelector(ToCharWithFormat); 2434 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(3); 2435 v.addElement("CONVERT(CHAR, "); 2436 v.addElement(","); 2437 v.addElement(")"); 2438 exOperator.printsAs(v); 2439 exOperator.bePrefix(); 2440 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 2441 return exOperator; 2442 } 2443 2444 2448 public static ExpressionOperator sybaseLocateOperator() { 2449 ExpressionOperator result = simpleTwoArgumentFunction(ExpressionOperator.Locate, "CHARINDEX"); 2450 int[] argumentIndices = new int[2]; 2451 argumentIndices[0] = 1; 2452 argumentIndices[1] = 0; 2453 result.setArgumentIndices(argumentIndices); 2454 return result; 2455 } 2456 2457 2458 2462 public static ExpressionOperator tan() { 2463 return simpleFunction(Tan, "TAN"); 2464 } 2465 2466 2470 public static ExpressionOperator tanh() { 2471 return simpleFunction(Tanh, "TANH"); 2472 } 2473 2474 2478 public static ExpressionOperator toDate() { 2479 return simpleFunction(ToDate, "TO_DATE"); 2480 } 2481 2482 2486 public static ExpressionOperator today() { 2487 return simpleFunctionNoParentheses(Today, "SYSDATE"); 2488 } 2489 2490 2494 public static ExpressionOperator currentDate() { 2495 return simpleFunctionNoParentheses(currentDate, "TO_DATE( SYSDATE )"); 2496 } 2497 2498 2502 public static ExpressionOperator toLowerCase() { 2503 return simpleFunction(ToLowerCase, "LOWER", "toLowerCase"); 2504 } 2505 2506 2510 public static ExpressionOperator toNumber() { 2511 return simpleFunction(ToNumber, "TO_NUMBER"); 2512 } 2513 2514 2517 public String toString() { 2518 if ((getDatabaseStrings() == null) || (getDatabaseStrings().length == 0)) { 2519 return "platform operator - " + getPlatformOperatorName(getSelector()); 2521 } else { 2522 return "operator " + getDatabaseStrings()[0]; 2523 } 2524 } 2525 2526 2530 public static ExpressionOperator toUpperCase() { 2531 return simpleFunction(ToUpperCase, "UPPER", "toUpperCase"); 2532 } 2533 2534 2538 public static ExpressionOperator translate() { 2539 return simpleThreeArgumentFunction(Translate, "TRANSLATE"); 2540 } 2541 2542 2546 public static ExpressionOperator trim() { 2547 return simpleFunction(Trim, "TRIM"); 2548 } 2549 2550 2554 public static ExpressionOperator trim2() { 2555 ExpressionOperator exOperator = new ExpressionOperator(); 2556 exOperator.setType(FunctionOperator); 2557 exOperator.setSelector(Trim2); 2558 Vector v = oracle.toplink.essentials.internal.helper.NonSynchronizedVector.newInstance(5); 2559 v.addElement("TRIM("); 2560 v.addElement(" FROM "); 2561 v.addElement(")"); 2562 exOperator.printsAs(v); 2563 exOperator.bePrefix(); 2564 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 2565 return exOperator; 2566 } 2567 2568 2572 public static ExpressionOperator trunc() { 2573 return simpleTwoArgumentFunction(Trunc, "TRUNC"); 2574 } 2575 2576 2580 public static ExpressionOperator truncateDate() { 2581 return simpleTwoArgumentFunction(TruncateDate, "TRUNC"); 2582 } 2583 2584 2588 public static ExpressionOperator value() { 2589 return simpleFunction(Value, "VALUE"); 2590 } 2591 2592 2596 public static ExpressionOperator variance() { 2597 return simpleAggregate(Variance, "VARIANCE", "variance"); 2598 } 2599 2600 2604 public static ExpressionOperator any() { 2605 ExpressionOperator exOperator = new ExpressionOperator(); 2606 exOperator.setType(FunctionOperator); 2607 exOperator.setSelector(Any); 2608 exOperator.printsAs("ANY"); 2609 exOperator.bePostfix(); 2610 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 2611 return exOperator; 2612 } 2613 2614 2618 public static ExpressionOperator some() { 2619 ExpressionOperator exOperator = new ExpressionOperator(); 2620 exOperator.setType(FunctionOperator); 2621 exOperator.setSelector(Some); 2622 exOperator.printsAs("SOME"); 2623 exOperator.bePostfix(); 2624 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 2625 return exOperator; 2626 } 2627 2628 2632 public static ExpressionOperator all() { 2633 ExpressionOperator exOperator = new ExpressionOperator(); 2634 exOperator.setType(FunctionOperator); 2635 exOperator.setSelector(All); 2636 exOperator.printsAs("ALL"); 2637 exOperator.bePostfix(); 2638 exOperator.setNodeClass(ClassConstants.FunctionExpression_Class); 2639 return exOperator; 2640 } 2641 2642 2646 public boolean isAny() { 2647 return selector == ExpressionOperator.Any || 2648 selector == ExpressionOperator.Some; 2649 } 2650 2654 public boolean isAll() { 2655 return selector == ExpressionOperator.All; 2656 } 2657 2661 public boolean isAnyOrAll() { 2662 return isAny() || isAll(); 2663 } 2664} 2665 | Popular Tags |