%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.commons.jelly.tags.xml.ParamTag |
|
|
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.xml; |
|
17 | ||
18 | import org.apache.commons.jelly.JellyTagException; |
|
19 | import org.apache.commons.jelly.TagSupport; |
|
20 | import org.apache.commons.jelly.XMLOutput; |
|
21 | ||
22 | /** Sets a parameter in the parent transform tag |
|
23 | * |
|
24 | * @author Robert Leftwich |
|
25 | * @version $Revision: 1.5 $ |
|
26 | */ |
|
27 | 2 | public class ParamTag extends TagSupport { |
28 | ||
29 | /** the name of the attribute. */ |
|
30 | private String name; |
|
31 | ||
32 | /** the value of the attribute. */ |
|
33 | private Object value; |
|
34 | ||
35 | ||
36 | 17 | public ParamTag() { |
37 | 17 | } |
38 | ||
39 | // Tag interface |
|
40 | //------------------------------------------------------------------------- |
|
41 | public void doTag(XMLOutput output) throws JellyTagException { |
|
42 | 11 | TransformTag tag = (TransformTag) this.findAncestorWithClass( TransformTag.class ); |
43 | 11 | if ( tag == null ) { |
44 | 0 | throw new JellyTagException( "<param> tag must be enclosed inside a <transform> tag" ); |
45 | } |
|
46 | 11 | Object value = this.getValue(); |
47 | 11 | if (value == null) { |
48 | 2 | value = getBodyText(); |
49 | } |
|
50 | ||
51 | 11 | tag.setParameterValue( getName(), value ); |
52 | 11 | } |
53 | ||
54 | // Properties |
|
55 | //------------------------------------------------------------------------- |
|
56 | ||
57 | /** |
|
58 | * @return the name of the attribute. |
|
59 | */ |
|
60 | public String getName() { |
|
61 | 11 | return name; |
62 | } |
|
63 | /** |
|
64 | * Sets the name of the attribute |
|
65 | */ |
|
66 | public void setName(String name) { |
|
67 | 11 | this.name = name; |
68 | 11 | } |
69 | ||
70 | /** |
|
71 | * @return the value of the attribute. |
|
72 | */ |
|
73 | public Object getValue() { |
|
74 | 11 | return value; |
75 | } |
|
76 | /** |
|
77 | * Sets the value of the attribute |
|
78 | */ |
|
79 | public void setValue(Object value) { |
|
80 | 9 | this.value = value; |
81 | 9 | } |
82 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |