Author: dion
Date: Mon Mar 20 23:10:33 2006
New Revision: 387445

URL: http://svn.apache.org/viewcvs?rev=387445&view=rev
Log:
Basic Implementation of bitwise and

Modified:
    
jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTBitwiseAndNode.java

Modified: 
jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTBitwiseAndNode.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTBitwiseAndNode.java?rev=387445&r1=387444&r2=387445&view=diff
==============================================================================
--- 
jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTBitwiseAndNode.java
 (original)
+++ 
jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/ASTBitwiseAndNode.java
 Mon Mar 20 23:10:33 2006
@@ -2,6 +2,16 @@
 
 package org.apache.commons.jexl.parser;
 
+import org.apache.commons.jexl.JexlContext;
+import org.apache.commons.jexl.util.Coercion;
+
+/**
+ * Bitwise And. Syntax:
+ *      a & b
+ * Result is a Long
+ * @author Dion Gillard
+ * @since 1.0.1
+ */
 public class ASTBitwiseAndNode extends SimpleNode {
   public ASTBitwiseAndNode(int id) {
     super(id);
@@ -15,5 +25,18 @@
   /** Accept the visitor. **/
   public Object jjtAccept(ParserVisitor visitor, Object data) {
     return visitor.visit(this, data);
+  }
+  
+  /**
+   * @return a [EMAIL PROTECTED] Long} which is the bitwise and of the two 
operands.
+   */
+  public Object value(JexlContext context) throws Exception
+  {
+      Object left = ((SimpleNode) jjtGetChild(0)).value(context);
+      Object right = ((SimpleNode) jjtGetChild(1)).value(context);
+    
+      Long l = left == null ? new Long(0) : Coercion.coerceLong(left);
+      Long r = right == null ? new Long(0) : Coercion.coerceLong(right);
+      return new Long(l.longValue() & r.longValue());
   }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to