Coverage report

  %line %branch
org.apache.commons.jelly.tags.sql.DriverTag
0% 
0% 

 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.sql;
 18  
 
 19  
 import org.apache.commons.jelly.JellyTagException;
 20  
 import org.apache.commons.jelly.TagSupport;
 21  
 import org.apache.commons.jelly.XMLOutput;
 22  
 
 23  
 /**
 24  
  * <p>Tag handler for &lt;Driver&gt; in JSTL, used to create
 25  
  * a simple DataSource for prototyping.</p>
 26  
  *
 27  
  * @author Hans Bergsten
 28  
  */
 29  0
 public class DriverTag extends TagSupport {
 30  
     private static final String DRIVER_CLASS_NAME =
 31  
         "javax.servlet.jsp.jstl.sql.driver";
 32  
     private static final String JDBC_URL = "javax.servlet.jsp.jstl.sql.jdbcURL";
 33  
     private static final String USER_NAME = "javax.servlet.jsp.jstl.sql.userName";
 34  
     private static final String PASSWORD = "javax.servlet.jsp.jstl.sql.password";
 35  
 
 36  
     private String driverClassName;
 37  
     private String jdbcURL;
 38  0
     private String scope = "page";
 39  
     private String userName;
 40  
     private String var;
 41  
 
 42  
     //*********************************************************************
 43  
     // Accessor methods
 44  
 
 45  
     public void setDriver(String driverClassName) {
 46  0
         this.driverClassName = driverClassName;
 47  0
     }
 48  
 
 49  
     public void setJdbcURL(String jdbcURL) {
 50  0
         this.jdbcURL = jdbcURL;
 51  0
     }
 52  
 
 53  
     /**
 54  
      * Sets the scope of the variable to hold the
 55  
      * result.
 56  
      *
 57  
      */
 58  
     public void setScope(String scopeName) {
 59  0
         this.scope = scopeName;
 60  0
     }
 61  
 
 62  
     public void setUserName(String userName) {
 63  0
         this.userName = userName;
 64  0
     }
 65  
 
 66  
     public void setVar(String var) {
 67  0
         this.var = class="keyword">var;
 68  0
     }
 69  
 
 70  
     //*********************************************************************
 71  
     // Tag logic
 72  
 
 73  
     public void doTag(XMLOutput output) throws JellyTagException {
 74  0
         DataSourceWrapper ds = new DataSourceWrapper();
 75  
         try {
 76  0
             ds.setDriverClassName(getDriverClassName());
 77  0
         }
 78  
         catch (Exception e) {
 79  0
             throw new JellyTagException("Invalid driver class name: " + e.getMessage());
 80  
         }
 81  0
         ds.setJdbcURL(getJdbcURL());
 82  0
         ds.setUserName(getUserName());
 83  0
         ds.setPassword(getPassword());
 84  0
         context.setVariable(var, ds);
 85  0
     }
 86  
 
 87  
     //*********************************************************************
 88  
     // Private utility methods
 89  
 
 90  
     private String getDriverClassName() {
 91  0
         if (driverClassName != null) {
 92  0
             return driverClassName;
 93  
         }
 94  0
         return getInitParameter(DRIVER_CLASS_NAME);
 95  
     }
 96  
 
 97  
     private String getJdbcURL() {
 98  0
         if (jdbcURL != null) {
 99  0
             return jdbcURL;
 100  
         }
 101  0
         return getInitParameter(JDBC_URL);
 102  
     }
 103  
 
 104  
     private String getUserName() {
 105  0
         if (userName != null) {
 106  0
             return userName;
 107  
         }
 108  0
         return getInitParameter(USER_NAME);
 109  
     }
 110  
 
 111  
     private String getPassword() {
 112  0
         return getInitParameter(PASSWORD);
 113  
     }
 114  
 
 115  
     protected String getInitParameter(String key) {
 116  0
         return "";
 117  
     }
 118  
 }

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