%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.commons.jelly.tags.fmt.SetTimeZoneTag |
|
|
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.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: 1.5 $ |
|
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 | 0 | public SetTimeZoneTag() { |
42 | 0 | } |
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 | 0 | TimeZone timeZone = null; |
50 | ||
51 | 0 | Object valueInput = null; |
52 | 0 | if (this.value != null) { |
53 | 0 | valueInput = this.value.evaluate(context); |
54 | } |
|
55 | ||
56 | ||
57 | 0 | if (valueInput == null) { |
58 | 0 | timeZone = TimeZone.getTimeZone("GMT"); |
59 | } |
|
60 | 0 | else if (valueInput instanceof String) { |
61 | 0 | if (((String) valueInput).trim().equals("")) { |
62 | 0 | timeZone = TimeZone.getTimeZone("GMT"); |
63 | } else { |
|
64 | 0 | timeZone = TimeZone.getTimeZone((String) valueInput); |
65 | } |
|
66 | } else { |
|
67 | 0 | timeZone = (TimeZone) valueInput; |
68 | } |
|
69 | ||
70 | 0 | if (scope != null) { |
71 | 0 | context.setVariable(Config.FMT_TIME_ZONE, scope, timeZone); |
72 | } |
|
73 | else { |
|
74 | 0 | context.setVariable(Config.FMT_TIME_ZONE, timeZone); |
75 | } |
|
76 | 0 | } |
77 | ||
78 | public void setValue(Expression value) { |
|
79 | 0 | this.value = value; |
80 | 0 | } |
81 | ||
82 | public void setVar(String var) { |
|
83 | 0 | this.var = class="keyword">var; |
84 | 0 | } |
85 | ||
86 | public void setScope(String scope) { |
|
87 | 0 | this.scope = scope; |
88 | 0 | } |
89 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |