1 19 20 package org.apache.cayenne.exp.parser; 21 22 import org.apache.cayenne.exp.Expression; 23 import org.apache.cayenne.util.ConversionUtil; 24 25 30 public class ASTLike extends PatternMatchNode { 31 ASTLike(int id) { 32 super(id, false); 33 } 34 35 public ASTLike() { 36 super(ExpressionParserTreeConstants.JJTLIKE, false); 37 } 38 39 public ASTLike(ASTPath path, Object pattern) { 40 super(ExpressionParserTreeConstants.JJTLIKE, false); 41 jjtAddChild(path, 0); 42 jjtAddChild(wrapChild(pattern), 1); 43 } 44 45 protected Object evaluateNode(Object o) throws Exception { 46 int len = jjtGetNumChildren(); 47 if (len != 2) { 48 return Boolean.FALSE; 49 } 50 51 String s1 = ConversionUtil.toString(evaluateChild(0, o)); 52 if (s1 == null) { 53 return Boolean.FALSE; 54 } 55 56 return matchPattern(s1) ? Boolean.TRUE : Boolean.FALSE; 57 } 58 59 62 public Expression shallowCopy() { 63 return new ASTLike(id); 64 } 65 66 protected String getExpressionOperator(int index) { 67 return "like"; 68 } 69 70 public int getType() { 71 return Expression.LIKE; 72 } 73 } 74 | Popular Tags |