1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.tags.core;
17
18 import org.apache.commons.jelly.MissingAttributeException;
19 import org.apache.commons.jelly.TagSupport;
20 import org.apache.commons.jelly.XMLOutput;
21 import org.apache.commons.jelly.expression.Expression;
22
23 /***
24 * A tag which removes the variable of the given name from the current variable scope.
25 *
26 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
27 * @version $Revision: 155420 $
28 */
29 public class RemoveTag extends TagSupport {
30
31 private Expression var;
32
33 public RemoveTag() {
34 }
35
36
37
38 public void doTag(XMLOutput output) throws MissingAttributeException {
39 if (var != null) {
40 context.removeVariable( var.evaluateAsString(context) );
41 }
42 else {
43 throw new MissingAttributeException("var");
44 }
45 }
46
47
48
49
50 /***
51 * Sets the name of the variable which will be removed by this tag..
52 */
53 public void setVar(Expression var) {
54 this.var = var;
55 }
56 }