01: /*
02: * Copyright 2005-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
05: * in compliance with the License. You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software distributed under the License
10: * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11: * or implied. See the License for the specific language governing permissions and limitations under
12: * the License.
13: */
14:
15: package org.strecks.web;
16:
17: import java.util.HashMap;
18: import java.util.Map;
19:
20: import org.apache.commons.beanutils.ConvertUtils;
21: import org.strecks.constants.InfrastructureKeys;
22:
23: /**
24: * Basic implementation of <code>RedirectHelper</code>
25: * @author Phil Zoio
26: */
27: public class RedirectHelperImpl implements RedirectHelper {
28:
29: private Map<String, String> requestParameters;
30:
31: private Map<String, Object> sessionParameters;
32:
33: public RedirectHelperImpl() {
34: super ();
35: }
36:
37: public void addRequestParameter(String name, Object value) {
38: if (requestParameters == null)
39: requestParameters = new HashMap<String, String>();
40: if (value != null) {
41: String string = ConvertUtils.convert(value);
42: requestParameters.put(name, string);
43: }
44: }
45:
46: public void addSessionParameter(String name, Object value) {
47: if (sessionParameters == null)
48: sessionParameters = new HashMap<String, Object>();
49: if (value != null) {
50: sessionParameters.put(name, value);
51: }
52: }
53:
54: public void setStatusMessage(String statusMessage) {
55: addSessionParameter(InfrastructureKeys.STATUS_MESSAGE,
56: statusMessage);
57: }
58:
59: public Map<String, Object> getSessionParameters() {
60: return sessionParameters;
61: }
62:
63: public Map<String, String> getRequestParameters() {
64: return requestParameters;
65: }
66:
67: @Override
68: public boolean equals(Object obj) {
69: if (obj instanceof RedirectHelperImpl) {
70: RedirectHelper other = (RedirectHelper) obj;
71: boolean equal = other.getRequestParameters() == getRequestParameters();
72: if (equal)
73: equal = other.getSessionParameters() == getSessionParameters();
74: return equal;
75: }
76: return false;
77: }
78:
79: }
|