Coverage report

  %line %branch
org.apache.commons.jexl.parser.ASTEmptyFunction
83% 
100% 

 1  
 /*
 2  
  * Copyright 2002,2004 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  
 
 17  
 package org.apache.commons.jexl.parser;
 18  
 
 19  
 import org.apache.commons.jexl.JexlContext;
 20  
 
 21  
 import java.util.Collection;
 22  
 import java.util.Map;
 23  
 
 24  
 /**
 25  
  *  function to see if reference doesn't exist in context
 26  
  *
 27  
  *  @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
 28  
  *  @author <a href="mailto:tobrien@apache.org">Tim O'Brien</a>
 29  
  *  @version $Id: ASTEmptyFunction.java,v 1.6 2004/08/23 13:30:36 dion Exp $
 30  
  */
 31  
 public class ASTEmptyFunction extends SimpleNode
 32  
 {
 33  
     public ASTEmptyFunction(int id)
 34  
     {
 35  0
         super(id);
 36  0
     }
 37  
 
 38  
     public ASTEmptyFunction(Parser p, int id)
 39  
     {
 40  321
         super(p, id);
 41  321
     }
 42  
 
 43  
     /** Accept the visitor. **/
 44  
     public Object jjtAccept(ParserVisitor visitor, Object data)
 45  
     {
 46  0
         return visitor.visit(this, data);
 47  
     }
 48  
 
 49  
     public Object value(JexlContext jc)
 50  
         throws Exception
 51  
     {
 52  306
         SimpleNode sn = (SimpleNode) jjtGetChild(0);
 53  
 
 54  
         /*
 55  
          * I can't believe this
 56  
          */
 57  
 
 58  306
         Object o = sn.value(jc);
 59  
 
 60  306
         if (o == null)
 61  54
             return Boolean.TRUE;
 62  
 
 63  252
         if (o instanceof String && "".equals((String) o))
 64  126
             return Boolean.TRUE;
 65  
 
 66  126
         if (o.getClass().isArray() && ((Object[])o).length == 0)
 67  15
             return Boolean.TRUE;
 68  
 
 69  111
         if (o instanceof Collection && ((Collection)o).isEmpty())
 70  45
             return Boolean.TRUE;
 71  
 
 72  
         /*
 73  
          *  Map isn't a collection
 74  
          */
 75  66
         if (o instanceof Map && ((Map)o).isEmpty())
 76  15
             return Boolean.TRUE;
 77  
 
 78  51
         return Boolean.FALSE;
 79  
     }
 80  
 }

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