1 56 package org.objectstyle.cayenne.exp.parser; 57 58 import org.objectstyle.cayenne.exp.Expression; 59 import org.objectstyle.cayenne.util.ConversionUtil; 60 61 66 public class ASTLike extends PatternMatchNode { 67 ASTLike(int id) { 68 super(id, false); 69 } 70 71 public ASTLike() { 72 super(ExpressionParserTreeConstants.JJTLIKE, false); 73 } 74 75 public ASTLike(ASTPath path, Object pattern) { 76 super(ExpressionParserTreeConstants.JJTLIKE, false); 77 jjtAddChild(path, 0); 78 jjtAddChild(wrapChild(pattern), 1); 79 } 80 81 protected Object evaluateNode(Object o) throws Exception { 82 int len = jjtGetNumChildren(); 83 if (len != 2) { 84 return Boolean.FALSE; 85 } 86 87 String s1 = ConversionUtil.toString(evaluateChild(0, o)); 88 if (s1 == null) { 89 return Boolean.FALSE; 90 } 91 92 return matchPattern(s1) ? Boolean.TRUE : Boolean.FALSE; 93 } 94 95 98 public Expression shallowCopy() { 99 return new ASTLike(id); 100 } 101 102 protected String getExpressionOperator(int index) { 103 return "like"; 104 } 105 106 public int getType() { 107 return Expression.LIKE; 108 } 109 } 110 | Popular Tags |