Coverage report

  %line %branch
org.apache.commons.jelly.tags.util.FileTag
85% 
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.jelly.tags.util;
 18  
 
 19  
 import java.io.File;
 20  
 
 21  
 import org.apache.commons.jelly.JellyTagException;
 22  
 import org.apache.commons.jelly.MissingAttributeException;
 23  
 import org.apache.commons.jelly.TagSupport;
 24  
 import org.apache.commons.jelly.XMLOutput;
 25  
 
 26  
 /**
 27  
  * A tag which creates a {@link File} from a given name.
 28  
  *
 29  
  * @author <a href="mailto:dion@apache.org">dIon Gillard</a>
 30  
  * @version $Revision: 1.6 $
 31  
  */
 32  1
 public class FileTag extends TagSupport {
 33  
 
 34  
     /** The file to place into the context */
 35  
     private String name;
 36  
 
 37  
     /** The variable name to place the file into */
 38  
     private String var;
 39  
 
 40  
     // Tag interface
 41  
     //-------------------------------------------------------------------------
 42  
     public void doTag(final XMLOutput output) throws MissingAttributeException, JellyTagException {
 43  1
         boolean available = false;
 44  
 
 45  1
         if (name == null) {
 46  0
             throw new MissingAttributeException("name must be specified");
 47  
         }
 48  
 
 49  1
         if (var == null) {
 50  0
             throw new MissingAttributeException("var must be specified");
 51  
         }
 52  
 
 53  1
         File newFile = new File(name);
 54  1
         getContext().setVariable(var, newFile);
 55  1
     }
 56  
 
 57  
     /**
 58  
      * Name of the file to be placed into the context
 59  
      * @param name The fileName to set
 60  
      */
 61  
     public void setName(String name) {
 62  1
         this.name = name;
 63  1
     }
 64  
 
 65  
     /**
 66  
      * Name of the variable to contain the file
 67  
      * @param var The var to set
 68  
      */
 69  
     public void setVar(String var) {
 70  1
         this.var = class="keyword">var;
 71  1
     }
 72  
 
 73  
 }

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