View Javadoc

1   /*
2    * $Id: MockTag.java 454565 2006-10-10 00:02:56Z jmitchell $
3    *
4    * Copyright 2006 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.struts2.views.jsp.ui;
19  
20  import java.util.Calendar;
21  import java.util.Date;
22  import java.util.HashMap;
23  import java.util.Map;
24  
25  import javax.servlet.jsp.tagext.BodyTagSupport;
26  
27  
28  /***
29   */
30  public class MockTag extends BodyTagSupport {
31  
32  	private static final long serialVersionUID = 2694367759647164641L;
33  	
34  	private static String s;
35      private static Integer i;
36      private static Double d;
37      private static Long l;
38      private static Float f;
39      private static Date date;
40      private static Calendar cal;
41      private static HashMap params;
42      private static MockTag instance = new MockTag();
43  
44  
45      public static MockTag getInstance() {
46          return instance;
47      }
48  
49      public void setCal(Calendar cal) {
50          MockTag.cal = cal;
51      }
52  
53      public Calendar getCal() {
54          return cal;
55      }
56  
57      public void setDate(Date date) {
58          MockTag.date = date;
59      }
60  
61      public Date getDate() {
62          return date;
63      }
64  
65      public void setDouble(Double d) {
66          MockTag.d = d;
67      }
68  
69      public Double getDouble() {
70          return d;
71      }
72  
73      public void setFloat(Float f) {
74          MockTag.f = f;
75      }
76  
77      public Float getFloat() {
78          return f;
79      }
80  
81      public void setInteger(Integer i) {
82          MockTag.i = i;
83      }
84  
85      public Integer getInteger() {
86          return i;
87      }
88  
89      public void setLong(Long l) {
90          MockTag.l = l;
91      }
92  
93      public Long getLong() {
94          return l;
95      }
96  
97      public Map getParameters() {
98          return MockTag.params;
99      }
100 
101     public void setString(String s) {
102         MockTag.s = s;
103     }
104 
105     public String getString() {
106         return s;
107     }
108 
109     public void addParameter(String key, Object value) {
110         MockTag.params.put(key, value);
111     }
112 
113     /***
114      * resets all the static variables to their initial state.  this must be called before each test!
115      */
116     public void reset() {
117         s = null;
118         i = null;
119         l = null;
120         f = null;
121         date = null;
122         cal = null;
123         params = new HashMap();
124     }
125 }