1 56 package org.objectstyle.cayenne.exp.parser; 57 58 import java.io.PrintWriter ; 59 60 import org.objectstyle.cayenne.exp.Expression; 61 import org.objectstyle.cayenne.util.ConversionUtil; 62 63 69 public class ASTNot extends AggregateConditionNode { 70 71 ASTNot(int id) { 72 super(id); 73 } 74 75 public ASTNot() { 76 super(ExpressionParserTreeConstants.JJTNOT); 77 } 78 79 public ASTNot(Node expression) { 80 super(ExpressionParserTreeConstants.JJTNOT); 81 jjtAddChild(expression, 0); 82 } 83 84 protected Object evaluateNode(Object o) throws Exception { 85 int len = jjtGetNumChildren(); 86 if (len == 0) { 87 return Boolean.FALSE; 88 } 89 90 return ConversionUtil.toBoolean(evaluateChild(0, o)) 91 ? Boolean.FALSE 92 : Boolean.TRUE; 93 } 94 95 98 public Expression shallowCopy() { 99 return new ASTNot(id); 100 } 101 102 public int getType() { 103 return Expression.NOT; 104 } 105 106 public void encodeAsString(PrintWriter pw) { 107 pw.print("not "); 108 super.encodeAsString(pw); 109 } 110 111 protected String getExpressionOperator(int index) { 112 throw new UnsupportedOperationException ( 113 "No operator for '" + ExpressionParserTreeConstants.jjtNodeName[id] + "'"); 114 } 115 } 116 | Popular Tags |