Coverage report

  %line %branch
net.sf.infrared.web.customtags.ContainsTag
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.util.Set;
 26  
 
 27  
 import javax.servlet.jsp.JspException;
 28  
 import javax.servlet.jsp.tagext.TagSupport;
 29  
 
 30  
 import org.apache.commons.beanutils.PropertyUtils;
 31  
 import org.apache.log4j.Logger;
 32  
 import org.apache.struts.util.RequestUtils;
 33  
 
 34  
 import net.sf.infrared.base.util.LoggingFactory;
 35  
 
 36  0
 public class ContainsTag extends TagSupport {
 37  
     protected String name;
 38  
 
 39  
     protected String property;
 40  
 
 41  
     protected String scope;
 42  
 
 43  
     protected String selectedName;
 44  
 
 45  
     protected String notContains;
 46  
 
 47  0
     protected boolean flag = false;
 48  
 
 49  0
     private static final Logger logger = LoggingFactory.getLogger(ContainsTag.class);
 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 String getScope() {
 68  0
         return scope;
 69  
     }
 70  
 
 71  
     public void setScope(String scope) {
 72  0
         this.scope = scope;
 73  0
     }
 74  
 
 75  
     public String getSelectedName() {
 76  0
         return selectedName;
 77  
     }
 78  
 
 79  
     public void setSelectedName(String instanceName) {
 80  0
         this.selectedName = instanceName;
 81  0
     }
 82  
 
 83  
     public String isNotContains() {
 84  0
         return notContains;
 85  
     }
 86  
 
 87  
     public void setNotContains(String notContains) {
 88  0
         this.notContains = notContains;
 89  0
     }
 90  
 
 91  
     public int doStartTag() throws JspException {
 92  0
         Object formBean = RequestUtils.lookup(pageContext, name, scope);
 93  
 
 94  
         // Able to get an value for instance as Struts creates page context variable
 95  
         // with the same name as the id in the logic:iterate tag. Thus for each iteration
 96  
         // the value of this variable is updated.
 97  
 
 98  0
         String instance = (String) RequestUtils.lookup(pageContext, selectedName, scope);
 99  0
         flag = Boolean.valueOf(notContains).booleanValue();
 100  
 
 101  0
         Set currentInstance = null;
 102  
         try {
 103  0
             currentInstance = (Set) PropertyUtils.getProperty(formBean, property);
 104  
         }
 105  0
         catch (Exception e) {
 106  0
             logger.error("Unable to find the property " + property + " in the bean", e);
 107  0
         }
 108  
 
 109  0
         if ((currentInstance.contains(instance) && !flag)
 110  
                 || (!currentInstance.contains(instance) && flag))
 111  0
             return (EVAL_BODY_INCLUDE);
 112  
         else
 113  0
             return (SKIP_BODY);
 114  
     }
 115  
 
 116  
     public int doEndTag() throws JspException {
 117  0
         release();
 118  0
         return super.doEndTag();
 119  
     }
 120  
 
 121  
     public void release() {
 122  0
         super.release();
 123  0
         name = null;
 124  0
         property = null;
 125  0
         scope = null;
 126  0
         selectedName = null;
 127  0
         notContains = null;
 128  0
     }
 129  
 
 130  
 }

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