1 16 package org.apache.commons.jexl.parser; 17 18 import org.apache.commons.jexl.JexlContext; 19 import org.apache.commons.jexl.util.Coercion; 20 21 27 public class ASTNENode extends SimpleNode { 28 33 public ASTNENode(int id) { 34 super(id); 35 } 36 37 43 public ASTNENode(Parser p, int id) { 44 super(p, id); 45 } 46 47 48 public Object jjtAccept(ParserVisitor visitor, Object data) { 49 return visitor.visit(this, data); 50 } 51 52 53 public Object value(JexlContext pc) throws Exception { 54 Object left = ((SimpleNode) jjtGetChild(0)).value(pc); 55 Object right = ((SimpleNode) jjtGetChild(1)).value(pc); 56 57 if (left == null && right == null) { 58 61 62 return Boolean.FALSE; 63 } else if (left == null || right == null) { 64 67 return Boolean.TRUE; 68 } else if (left.getClass().equals(right.getClass())) { 69 return (left.equals(right)) ? Boolean.FALSE : Boolean.TRUE; 70 } else if (left instanceof Float 71 || left instanceof Double 72 || right instanceof Float 73 || right instanceof Double ) { 74 return (Coercion.coerceDouble(left).equals(Coercion.coerceDouble(right))) ? Boolean.FALSE : Boolean.TRUE; 75 } else if (left instanceof Number || right instanceof Number || left instanceof Character 76 || right instanceof Character ) { 77 return (Coercion.coerceLong(left).equals(Coercion.coerceLong(right))) ? Boolean.FALSE : Boolean.TRUE; 78 } else if (left instanceof Boolean || right instanceof Boolean ) { 79 return (Coercion.coerceBoolean(left).equals(Coercion.coerceBoolean(right))) ? Boolean.FALSE : Boolean.TRUE; 80 } else if (left instanceof java.lang.String || right instanceof String ) { 81 return (left.toString().equals(right.toString())) ? Boolean.FALSE : Boolean.TRUE; 82 } 83 84 return (left.equals(right)) ? Boolean.FALSE : Boolean.TRUE; 85 } 86 } 87 | Popular Tags |