1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.tags.fmt;
17
18 import org.apache.commons.jelly.JellyTagException;
19 import org.apache.commons.jelly.XMLOutput;
20 import org.apache.commons.jelly.Tag;
21 import org.apache.commons.jelly.TagSupport;
22 import org.apache.commons.jelly.expression.Expression;
23 import java.util.TimeZone;
24
25 /***
26 * Support for tag handlers for <setTimeZone>, the time zone setting
27 * tag in JSTL.
28 * @author <a href="mailto:willievu@yahoo.com">Willie Vu</a>
29 * @version $Revision: 155420 $
30 *
31 */
32 public class SetTimeZoneTag extends TagSupport {
33
34 private Expression value;
35
36 private String var;
37
38 private String scope;
39
40 /*** Creates a new instance of SetLocaleTag */
41 public SetTimeZoneTag() {
42 }
43
44 /***
45 * Evaluates this tag after all the tags properties have been initialized.
46 *
47 */
48 public void doTag(XMLOutput output) throws JellyTagException {
49 TimeZone timeZone = null;
50
51 Object valueInput = null;
52 if (this.value != null) {
53 valueInput = this.value.evaluate(context);
54 }
55
56
57 if (valueInput == null) {
58 timeZone = TimeZone.getTimeZone("GMT");
59 }
60 else if (valueInput instanceof String) {
61 if (((String) valueInput).trim().equals("")) {
62 timeZone = TimeZone.getTimeZone("GMT");
63 } else {
64 timeZone = TimeZone.getTimeZone((String) valueInput);
65 }
66 } else {
67 timeZone = (TimeZone) valueInput;
68 }
69
70 if (scope != null) {
71 context.setVariable(Config.FMT_TIME_ZONE, scope, timeZone);
72 }
73 else {
74 context.setVariable(Config.FMT_TIME_ZONE, timeZone);
75 }
76 }
77
78 public void setValue(Expression value) {
79 this.value = value;
80 }
81
82 public void setVar(String var) {
83 this.var = var;
84 }
85
86 public void setScope(String scope) {
87 this.scope = scope;
88 }
89 }