1 21 package oracle.toplink.essentials.internal.parsing; 23 24 import oracle.toplink.essentials.expressions.*; 25 26 35 public class SubstringNode extends StringFunctionNode { 36 private Node startPosition = null; 37 private Node stringLength = null; 38 39 42 public SubstringNode() { 43 super(); 44 } 45 46 50 public void validate(ParseTreeContext context) { 51 TypeHelper typeHelper = context.getTypeHelper(); 52 if (startPosition != null) { 53 startPosition.validate(context); 54 startPosition.validateParameter(context, typeHelper.getIntType()); 55 } 56 if (stringLength != null) { 57 stringLength.validate(context); 58 stringLength.validateParameter(context, typeHelper.getIntType()); 59 } 60 setType(typeHelper.getStringType()); 61 } 62 63 67 public Expression generateExpression(GenerationContext context) { 68 Expression whereClause = getLeft().generateExpression(context); 69 Expression startPosition = getStartPosition().generateExpression(context); 70 Expression stringLength = getStringLength().generateExpression(context); 71 whereClause = whereClause.substring(startPosition, stringLength); 72 return whereClause; 73 } 74 75 78 private Node getStartPosition() { 79 return startPosition; 80 } 81 82 85 private Node getStringLength() { 86 return stringLength; 87 } 88 89 94 public void setStartPosition(Node newStartPosition) { 95 startPosition = newStartPosition; 96 } 97 98 103 public void setStringLength(Node newStringLength) { 104 stringLength = newStringLength; 105 } 106 } 107 | Popular Tags |