Coverage report

  %line %branch
net.sf.infrared.web.customtags.ColorThresholdTag
0% 
0% 

 1  
 /*
 2  
  *
 3  
  * Copyright 2005 Tavant Technologies and Contributors
 4  
  * 
 5  
  * Licensed under the Apache License, Version 2.0 (the "License")
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  *     http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  *
 17  
  *
 18  
  *
 19  
  * Original Author:  prashant.nair (Tavant Technologies)
 20  
  * Contributor(s):   -;
 21  
  *
 22  
  */
 23  
 package net.sf.infrared.web.customtags;
 24  
 
 25  
 import java.lang.reflect.InvocationTargetException;
 26  
 
 27  
 import javax.servlet.jsp.JspException;
 28  
 import javax.servlet.jsp.tagext.TagSupport;
 29  
 
 30  
 import net.sf.infrared.web.util.WebConfig;
 31  
 
 32  
 import org.apache.commons.beanutils.PropertyUtils;
 33  
 import org.apache.struts.util.RequestUtils;
 34  
 
 35  0
 public class ColorThresholdTag extends TagSupport {
 36  0
     private static final int COLOR_THRESHOLD = WebConfig.getColorThreshold();
 37  
     protected String name;
 38  
 
 39  
     protected String property;
 40  
 
 41  
     protected String scope;
 42  
 
 43  
     public String getScope() {
 44  0
         return scope;
 45  
     }
 46  
 
 47  
     public void setScope(String scope) {
 48  0
         this.scope = scope;
 49  0
     }
 50  
 
 51  
     public String getName() {
 52  0
         return name;
 53  
     }
 54  
 
 55  
     public void setName(String name) {
 56  0
         this.name = name;
 57  0
     }
 58  
 
 59  
     public String getProperty() {
 60  0
         return property;
 61  
     }
 62  
 
 63  
     public void setProperty(String property) {
 64  0
         this.property = property;
 65  0
     }
 66  
 
 67  
     public int doStartTag() throws JspException {
 68  0
         Object formBean = RequestUtils.lookup(pageContext, name, scope);
 69  
 
 70  0
         String beanProperty = null;
 71  
         try {
 72  0
             beanProperty = (String) PropertyUtils.getProperty(formBean, property);
 73  
         }
 74  0
         catch (IllegalAccessException e) {
 75  0
             throw new JspException("Unable to find the property " + property + " in the bean", e);
 76  
         }
 77  0
         catch (InvocationTargetException e) {
 78  0
             throw new JspException("Unable to find the property " + property + " in the bean", e);
 79  
         }
 80  0
         catch (NoSuchMethodException e) {
 81  0
             throw new JspException("Unable to find the property " + property + " in the bean", e);
 82  0
         }
 83  0
         double value = Double.parseDouble(beanProperty);
 84  
 
 85  0
         if (value > COLOR_THRESHOLD)
 86  0
             return (EVAL_BODY_INCLUDE);
 87  
         else
 88  0
             return (SKIP_BODY);
 89  
     }
 90  
 
 91  
     public int doEndTag() throws JspException {
 92  0
         release();
 93  0
         return super.doEndTag();
 94  
     }
 95  
 
 96  
     public void release() {
 97  0
         super.release();
 98  0
         name = null;
 99  0
         property = null;
 100  0
         scope = null;
 101  0
     }
 102  
 
 103  
 }

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