Coverage report

  %line %branch
org.apache.commons.jelly.tags.dynabean.DynabeanTag
76% 
95% 

 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  
 package org.apache.commons.jelly.tags.dynabean;
 17  
 
 18  
 import org.apache.commons.beanutils.DynaBean;
 19  
 import org.apache.commons.beanutils.DynaClass;
 20  
 import org.apache.commons.jelly.JellyTagException;
 21  
 import org.apache.commons.jelly.MissingAttributeException;
 22  
 import org.apache.commons.jelly.TagSupport;
 23  
 import org.apache.commons.jelly.XMLOutput;
 24  
 
 25  
 
 26  
 /** A tag which conditionally evaluates its body based on some condition
 27  
   *
 28  
   * @author Theo Niemeijer
 29  
   * @version $Revision: 1.5 $
 30  
   */
 31  
 public class DynabeanTag extends TagSupport {
 32  
 
 33  
     private DynaClass dynaClass;
 34  
     private String var;
 35  
 
 36  3
     public DynabeanTag() {
 37  3
     }
 38  
 
 39  
     // Tag interface
 40  
     //-------------------------------------------------------------------------
 41  
     public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException {
 42  
 
 43  3
         if (dynaClass == null) {
 44  0
             throw new MissingAttributeException( "dynaclass" );
 45  
         }
 46  
 
 47  3
         if (var == null) {
 48  0
             throw new MissingAttributeException( "var" );
 49  
         }
 50  
 
 51  
         try {
 52  
             // Create dynabean instance for this dynaclass
 53  3
             DynaBean dynaBean = dynaClass.newInstance();
 54  
 
 55  
             // Place new dynabean in context as a variable
 56  3
             context.setVariable(getVar(), dynaBean);
 57  3
         } catch (IllegalAccessException e) {
 58  0
             throw new JellyTagException(e);
 59  
         } catch (InstantiationException e) {
 60  0
             throw new JellyTagException(e);
 61  
         }
 62  3
     }
 63  
 
 64  
     // Properties
 65  
     //-------------------------------------------------------------------------
 66  
 
 67  
     /**
 68  
      * Sets the DynaClass of the new instance to create
 69  
      */
 70  
     public void setDynaclass(DynaClass dynaClass) {
 71  3
         this.dynaClass = dynaClass;
 72  3
     }
 73  
 
 74  
     public String getVar() {
 75  3
         return var;
 76  
     }
 77  
 
 78  
     /**
 79  
      * Sets the name of the variable to export the new DynaBean instance to
 80  
      */
 81  
     public void setVar(String var) {
 82  3
         this.var = class="keyword">var;
 83  3
     }
 84  
 
 85  
 
 86  
 }

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