Coverage report

  %line %branch
org.apache.commons.jexl.parser.ASTNENode
86% 
100% 

 1  
 /*
 2  
  * Copyright 2002-2006 The Apache Software Foundation.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 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  
 /**
 22  
  * Not equal to. Use '!=' or 'ne', do not use <>.
 23  
  * 
 24  
  * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
 25  
  * @version $Id: ASTNENode.java 398270 2006-04-30 03:02:58Z dion $
 26  
  */
 27  
 public class ASTNENode extends SimpleNode {
 28  
     /**
 29  
      * Create the node given an id.
 30  
      * 
 31  
      * @param id node id.
 32  
      */
 33  
     public ASTNENode(int id) {
 34  0
         super(id);
 35  0
     }
 36  
 
 37  
     /**
 38  
      * Create a node with the given parser and id.
 39  
      * 
 40  
      * @param p a parser.
 41  
      * @param id node id.
 42  
      */
 43  
     public ASTNENode(Parser p, int id) {
 44  23
         super(p, id);
 45  23
     }
 46  
 
 47  
     /** {@inheritDoc} */
 48  
     public Object jjtAccept(ParserVisitor visitor, Object data) {
 49  0
         return visitor.visit(this, data);
 50  
     }
 51  
 
 52  
     /** {@inheritDoc} */
 53  
     public Object value(JexlContext pc) throws Exception {
 54  19
         Object left = ((SimpleNode) jjtGetChild(0)).value(pc);
 55  19
         Object right = ((SimpleNode) jjtGetChild(1)).value(pc);
 56  
 
 57  19
         if (left == null && right == class="keyword">null) {
 58  
             /*
 59  
              * first, the possibility that both *are* null
 60  
              */
 61  
 
 62  1
             return Boolean.FALSE;
 63  18
         } else if (left == null || right == class="keyword">null) {
 64  
             /*
 65  
              * otherwise, both aren't, so it's clear L != R
 66  
              */
 67  7
             return Boolean.TRUE;
 68  11
         } else if (left.getClass().equals(right.getClass())) {
 69  5
             return (left.equals(right)) ? Boolean.FALSE : Boolean.TRUE;
 70  6
         } else if (left instanceof Float 
 71  
             || left instanceof Double 
 72  
             || right instanceof Float 
 73  
             || right instanceof Double) {
 74  2
             return (Coercion.coerceDouble(left).equals(Coercion.coerceDouble(right))) ? Boolean.FALSE : Boolean.TRUE;
 75  4
         } else if (left instanceof Number || right instanceof Number || left instanceof Character
 76  
             || right instanceof Character) {
 77  1
             return (Coercion.coerceLong(left).equals(Coercion.coerceLong(right))) ? Boolean.FALSE : Boolean.TRUE;
 78  3
         } else if (left instanceof Boolean || right instanceof Boolean) {
 79  1
             return (Coercion.coerceBoolean(left).equals(Coercion.coerceBoolean(right))) ? Boolean.FALSE : Boolean.TRUE;
 80  2
         } else if (left instanceof java.lang.String || right instanceof String) {
 81  1
             return (left.toString().equals(right.toString())) ? Boolean.FALSE : Boolean.TRUE;
 82  
         }
 83  
 
 84  1
         return (left.equals(right)) ? Boolean.FALSE : Boolean.TRUE;
 85  
     }
 86  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.