Coverage details for org.chwf.taglib.jutil.NewTag

LineHitsSource
1 /*
2 Chrysalis Web Framework [http://chrysalis.sourceforge.net]
3 Copyright (c) 2002, 2003, 2004, Paul Strack
4  
5 All rights reserved.
6  
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9  
10 1. Redistributions of source code must retain the above copyright notice, this
11 list of conditions and the following disclaimer.
12  
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16  
17 3. Neither the name of the copyright holder nor the names of its contributors
18 may be used to endorse or promote products derived from this software without
19 specific prior written permission.
20  
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
25 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32  
33 package org.chwf.taglib.jutil;
34  
35 import javax.servlet.jsp.JspException;
36  
37 import org.chwf.filter.BeanFilter;
38 import org.chwf.servlet.ServletUtils;
39 import org.chwf.taglib.base.LifeCycleTagSupport;
40 import org.chwf.taglib.base.ObjectTagSupport;
41 import org.chwf.taglib.base.TagException;
42  
43 /**
44  * Tag handler for the <code>&lt;new&gt;</code> tag.
45  *
46  * @author <a href="mailto:pfstrack@users.sourceforge.net">Paul Strack</a>
47  */
486public class NewTag extends LifeCycleTagSupport {
49  
50   /** The variable name. */
51   private String var;
52  
53   /** The class name of the new object. */
54   private String type;
55  
56   /**
57    * The variable name.
58    *
59    * @param var The variable name.
60    */
61   public void setVar(String var) {
623    this.var = var;
633  }
64  
65   /**
66    * The variable name.
67    *
68    * @return The variable name.
69    */
70   public String getVar() {
713    return this.var;
72   }
73  
74   /**
75    * The class name of the new object.
76    *
77    * @param type The class name of the new object.
78    */
79   public void setType(String type) {
803    this.type = type;
813  }
82  
83   /**
84    * The class name of the new object.
85    *
86    * @return The class name of the new object.
87    */
88   public String getType() {
893    return this.type;
90   }
91  
92   /**
93    * Clean up data for tag handler reuse and pooling. Should be overridden in
94    * tag handler. Subclasses should always invoke their superclass's cleanup
95    * method: <code>super.cleanup()</code>
96    */
97   public void cleanup() {
981    super.cleanup();
991    this.var = null;
1001    this.type = null;
1011  }
102  
103   /**
104    * Creates the object.
105    *
106    * @return SKIP_BODY
107    * @throws JspException For IO exceptions.
108    */
109   public int doStart() throws JspException {
110     try {
1111      BeanFilter filter = BeanFilter.findFilter(getType());
1121      Object object = filter.create();
1131      ServletUtils.setPageAttribute(pageContext, getVar(), object);
1141      ServletUtils.setPageAttribute(
115         pageContext,
116         ObjectTagSupport.DEFAULT_OBJECT,
117         object);
1181    } catch (Exception ex) {
1190      throw new TagException(ex);
120     }
1211    return SKIP_BODY;
122   }
123 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.