Coverage report

  %line %branch
org.apache.commons.jexl.parser.ASTGTNode
77% 
92% 

 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  
  * GT : a > b.
 23  
  * 
 24  
  * Follows A.3.6.1 of the JSTL 1.0 specification
 25  
  * 
 26  
  * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
 27  
  * @author <a href="mailto:proyal@apache.org">Peter Royal</a>
 28  
  * @version $Id: ASTGTNode.java 398197 2006-04-29 16:18:04Z dion $
 29  
  */
 30  
 public class ASTGTNode extends SimpleNode {
 31  
     /**
 32  
      * Create the node given an id.
 33  
      * 
 34  
      * @param id node id.
 35  
      */
 36  
     public ASTGTNode(int id) {
 37  0
         super(id);
 38  0
     }
 39  
 
 40  
     /**
 41  
      * Create a node with the given parser and id.
 42  
      * 
 43  
      * @param p a parser.
 44  
      * @param id node id.
 45  
      */
 46  
     public ASTGTNode(Parser p, int id) {
 47  9
         super(p, id);
 48  9
     }
 49  
 
 50  
     /** {@inheritDoc} */
 51  
     public Object jjtAccept(ParserVisitor visitor, Object data) {
 52  0
         return visitor.visit(this, data);
 53  
     }
 54  
 
 55  
     /** {@inheritDoc} */
 56  
     public Object value(JexlContext jc) throws Exception {
 57  
         /*
 58  
          * now get the values
 59  
          */
 60  
 
 61  9
         Object left = ((SimpleNode) jjtGetChild(0)).value(jc);
 62  9
         Object right = ((SimpleNode) jjtGetChild(1)).value(jc);
 63  
 
 64  9
         if ((left == right) || (left == null) || (right == class="keyword">null)) {
 65  2
             return Boolean.FALSE;
 66  7
         } else if (Coercion.isFloatingPoint(left)
 67  
                 || Coercion.isFloatingPoint(right)) {
 68  1
             double leftDouble = Coercion.coerceDouble(left).class="keyword">doubleValue();
 69  1
             double rightDouble = Coercion.coerceDouble(right).class="keyword">doubleValue();
 70  
 
 71  1
             return leftDouble > rightDouble ? Boolean.TRUE : Boolean.FALSE;
 72  6
         } else if (Coercion.isNumberable(left) || Coercion.isNumberable(right)) {
 73  4
             long leftLong = Coercion.coerceLong(left).class="keyword">longValue();
 74  4
             long rightLong = Coercion.coerceLong(right).class="keyword">longValue();
 75  
 
 76  4
             return leftLong > rightLong ? Boolean.TRUE : Boolean.FALSE;
 77  2
         } else if (left instanceof String || right instanceof String) {
 78  1
             String leftString = left.toString();
 79  1
             String rightString = right.toString();
 80  
 
 81  1
             return leftString.compareTo(rightString) > 0 ? Boolean.TRUE
 82  
                     : Boolean.FALSE;
 83  1
         } else if (left instanceof Comparable) {
 84  1
             return ((Comparable) left).compareTo(right) > 0 ? Boolean.TRUE
 85  
                     : Boolean.FALSE;
 86  0
         } else if (right instanceof Comparable) {
 87  0
             return ((Comparable) right).compareTo(left) < 0 ? Boolean.TRUE
 88  
                     : Boolean.FALSE;
 89  
         }
 90  
 
 91  0
         throw new Exception("Invalid comparison : GT ");
 92  
     }
 93  
 }

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