1
2
3
4
5
6
7
8
9
10
11
12
13
14
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: 155420 $
26 */
27 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 public ParamTag() {
37 }
38
39
40
41 public void doTag(XMLOutput output) throws JellyTagException {
42 TransformTag tag = (TransformTag) this.findAncestorWithClass( TransformTag.class );
43 if ( tag == null ) {
44 throw new JellyTagException( "<param> tag must be enclosed inside a <transform> tag" );
45 }
46 Object value = this.getValue();
47 if (value == null) {
48 value = getBodyText();
49 }
50
51 tag.setParameterValue( getName(), value );
52 }
53
54
55
56
57 /***
58 * @return the name of the attribute.
59 */
60 public String getName() {
61 return name;
62 }
63 /***
64 * Sets the name of the attribute
65 */
66 public void setName(String name) {
67 this.name = name;
68 }
69
70 /***
71 * @return the value of the attribute.
72 */
73 public Object getValue() {
74 return value;
75 }
76 /***
77 * Sets the value of the attribute
78 */
79 public void setValue(Object value) {
80 this.value = value;
81 }
82 }