1 21 package oracle.toplink.essentials.internal.parsing; 23 24 import oracle.toplink.essentials.expressions.*; 25 26 35 public class LikeNode extends SimpleConditionalExpressionNode { 36 private EscapeNode escape = null; 37 38 41 public LikeNode() { 42 super(); 43 } 44 45 49 public void validate(ParseTreeContext context) { 50 TypeHelper typeHelper = context.getTypeHelper(); 51 if (left != null) { 52 left.validate(context); 53 left.validateParameter(context, typeHelper.getStringType()); 54 } 55 if (right != null) { 56 right.validate(context); 57 right.validateParameter(context, typeHelper.getStringType()); 58 } 59 60 if (escape != null) { 61 escape.validate(context); 62 } 63 64 setType(typeHelper.getBooleanType()); 65 } 66 67 71 public Expression generateExpression(GenerationContext context) { 72 Expression whereClause = getLeft().generateExpression(context); 73 if (!hasEscape()) { 74 whereClause = whereClause.like(getRight().generateExpression(context)); 75 } else { 76 whereClause = whereClause.like(getRight().generateExpression(context), getEscapeNode().generateExpression(context)); 77 } 78 return whereClause; 79 } 80 81 public boolean hasEscape() { 82 return getEscapeNode() != null; 83 } 84 85 public EscapeNode getEscapeNode() { 87 return escape; 88 } 89 90 public void setEscapeNode(EscapeNode node) { 91 escape = node; 92 } 93 } 94 | Popular Tags |