1 19 20 package org.apache.cayenne.exp.parser; 21 22 import java.io.PrintWriter ; 23 24 import org.apache.cayenne.exp.Expression; 25 import org.apache.cayenne.util.ConversionUtil; 26 27 33 public class ASTNot extends AggregateConditionNode { 34 35 ASTNot(int id) { 36 super(id); 37 } 38 39 public ASTNot() { 40 super(ExpressionParserTreeConstants.JJTNOT); 41 } 42 43 public ASTNot(Node expression) { 44 super(ExpressionParserTreeConstants.JJTNOT); 45 jjtAddChild(expression, 0); 46 } 47 48 protected Object evaluateNode(Object o) throws Exception { 49 int len = jjtGetNumChildren(); 50 if (len == 0) { 51 return Boolean.FALSE; 52 } 53 54 return ConversionUtil.toBoolean(evaluateChild(0, o)) 55 ? Boolean.FALSE 56 : Boolean.TRUE; 57 } 58 59 62 public Expression shallowCopy() { 63 return new ASTNot(id); 64 } 65 66 public int getType() { 67 return Expression.NOT; 68 } 69 70 public void encodeAsString(PrintWriter pw) { 71 pw.print("not "); 72 super.encodeAsString(pw); 73 } 74 75 protected String getExpressionOperator(int index) { 76 throw new UnsupportedOperationException ( 77 "No operator for '" + ExpressionParserTreeConstants.jjtNodeName[id] + "'"); 78 } 79 } 80 | Popular Tags |