| Line | Hits | Source |
|---|---|---|
| 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><new></code> tag. | |
| 45 | * | |
| 46 | * @author <a href="mailto:pfstrack@users.sourceforge.net">Paul Strack</a> | |
| 47 | */ | |
| 48 | 6 | public 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) { | |
| 62 | 3 | this.var = var; |
| 63 | 3 | } |
| 64 | ||
| 65 | /** | |
| 66 | * The variable name. | |
| 67 | * | |
| 68 | * @return The variable name. | |
| 69 | */ | |
| 70 | public String getVar() { | |
| 71 | 3 | 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) { | |
| 80 | 3 | this.type = type; |
| 81 | 3 | } |
| 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() { | |
| 89 | 3 | 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() { | |
| 98 | 1 | super.cleanup(); |
| 99 | 1 | this.var = null; |
| 100 | 1 | this.type = null; |
| 101 | 1 | } |
| 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 { | |
| 111 | 1 | BeanFilter filter = BeanFilter.findFilter(getType()); |
| 112 | 1 | Object object = filter.create(); |
| 113 | 1 | ServletUtils.setPageAttribute(pageContext, getVar(), object); |
| 114 | 1 | ServletUtils.setPageAttribute( |
| 115 | pageContext, | |
| 116 | ObjectTagSupport.DEFAULT_OBJECT, | |
| 117 | object); | |
| 118 | 1 | } catch (Exception ex) { |
| 119 | 0 | throw new TagException(ex); |
| 120 | } | |
| 121 | 1 | return SKIP_BODY; |
| 122 | } | |
| 123 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |