1 21 package oracle.toplink.essentials.internal.parsing; 23 24 import oracle.toplink.essentials.expressions.*; 25 26 35 public class LocateNode extends ArithmeticFunctionNode { 36 private Node find = null; 37 private Node findIn = null; 38 private Node startPosition = null; 39 40 43 public LocateNode() { 44 super(); 45 } 46 47 51 public void validate(ParseTreeContext context) { 52 TypeHelper typeHelper = context.getTypeHelper(); 53 if (findIn != null) { 54 findIn.validate(context); 55 findIn.validateParameter(context, typeHelper.getStringType()); 56 } 57 if (find != null) { 58 find.validate(context); 59 find.validateParameter(context, typeHelper.getStringType()); 60 } 61 if (startPosition != null) { 62 startPosition.validate(context); 63 startPosition.validateParameter(context, typeHelper.getIntType()); 64 } 65 setType(typeHelper.getIntType()); 66 } 67 68 72 public Expression generateExpression(GenerationContext context) { 73 Expression whereClause = getFindIn().generateExpression(context); 74 Expression findExpr = getFind().generateExpression(context); 75 if (startPosition != null) { 76 whereClause = whereClause.locate(findExpr, getStartPosition().generateExpression(context)); 77 } else { 78 whereClause = whereClause.locate(findExpr); 79 } 80 return whereClause; 81 } 82 83 public Node getFind() { 85 return find; 86 } 87 88 public Node getFindIn() { 89 return findIn; 90 } 91 92 public void setFind(Node newFind) { 93 find = newFind; 94 } 95 96 public void setFindIn(Node newFindIn) { 97 findIn = newFindIn; 98 } 99 100 public Node getStartPosition() { 101 return startPosition; 102 } 103 104 public void setStartPosition(Node newStartPosition) { 105 startPosition = newStartPosition; 106 } 107 108 } 109 | Popular Tags |