001: /*
002: * $Id: MockTag.java 471756 2006-11-06 15:01:43Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts2.views.jsp.ui;
022:
023: import java.util.Calendar;
024: import java.util.Date;
025: import java.util.HashMap;
026: import java.util.Map;
027:
028: import javax.servlet.jsp.tagext.BodyTagSupport;
029:
030: /**
031: */
032: public class MockTag extends BodyTagSupport {
033:
034: private static final long serialVersionUID = 2694367759647164641L;
035:
036: private static String s;
037: private static Integer i;
038: private static Double d;
039: private static Long l;
040: private static Float f;
041: private static Date date;
042: private static Calendar cal;
043: private static HashMap params;
044: private static MockTag instance = new MockTag();
045:
046: public static MockTag getInstance() {
047: return instance;
048: }
049:
050: public void setCal(Calendar cal) {
051: MockTag.cal = cal;
052: }
053:
054: public Calendar getCal() {
055: return cal;
056: }
057:
058: public void setDate(Date date) {
059: MockTag.date = date;
060: }
061:
062: public Date getDate() {
063: return date;
064: }
065:
066: public void setDouble(Double d) {
067: MockTag.d = d;
068: }
069:
070: public Double getDouble() {
071: return d;
072: }
073:
074: public void setFloat(Float f) {
075: MockTag.f = f;
076: }
077:
078: public Float getFloat() {
079: return f;
080: }
081:
082: public void setInteger(Integer i) {
083: MockTag.i = i;
084: }
085:
086: public Integer getInteger() {
087: return i;
088: }
089:
090: public void setLong(Long l) {
091: MockTag.l = l;
092: }
093:
094: public Long getLong() {
095: return l;
096: }
097:
098: public Map getParameters() {
099: return MockTag.params;
100: }
101:
102: public void setString(String s) {
103: MockTag.s = s;
104: }
105:
106: public String getString() {
107: return s;
108: }
109:
110: public void addParameter(String key, Object value) {
111: MockTag.params.put(key, value);
112: }
113:
114: /**
115: * resets all the static variables to their initial state. this must be called before each test!
116: */
117: public void reset() {
118: s = null;
119: i = null;
120: l = null;
121: f = null;
122: date = null;
123: cal = null;
124: params = new HashMap();
125: }
126: }
|