001: /*
002: * $Id: RequestParameters.java 4507 2006-02-16 14:51:20 -0800 (Thu, 16 Feb 2006)
003: * jonathanlocke $ $Revision: 460725 $ $Date: 2006-02-16 14:51:20 -0800 (Thu, 16
004: * Feb 2006) $
005: *
006: * ==============================================================================
007: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
008: * use this file except in compliance with the License. You may obtain a copy of
009: * the License at
010: *
011: * http://www.apache.org/licenses/LICENSE-2.0
012: *
013: * Unless required by applicable law or agreed to in writing, software
014: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
015: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
016: * License for the specific language governing permissions and limitations under
017: * the License.
018: */
019: package wicket.request;
020:
021: import java.io.Serializable;
022: import java.util.Map;
023:
024: import wicket.RequestListenerInterface;
025: import wicket.markup.html.link.ILinkListener;
026:
027: /**
028: * <p>
029: * Object that abstracts common request parameters. It consists of possible
030: * optional parameters that can be translated from e.g. servlet request
031: * parameters and serves of a strongly typed variant of these that is to be
032: * created by the {@link wicket.request.IRequestCycleProcessor}'s
033: * {@link wicket.request.IRequestCodingStrategy}.
034: * </p>
035: * <p>
036: * Though this object can be extended and hence more parameter options can be
037: * used, anything other than in this implementation must be supported by
038: * specific {@link wicket.request.IRequestCycleProcessor} implementations and
039: * thus are not supported by default implementations.
040: * </p>
041: *
042: * @author Eelco Hillenius
043: */
044: public class RequestParameters implements Serializable {
045: private static final long serialVersionUID = 1L;
046:
047: /** the full path to a component (might be just the page). */
048: private String componentPath;
049:
050: /** any name of the page map. */
051: private String pageMapName;
052:
053: /** any version number; 0 for no version. */
054: private int versionNumber;
055:
056: /**
057: * tells wicket this request should only be processed if the page + version
058: * specified are pointing to the last page the user accessed
059: */
060: private boolean onlyProcessIfPathActive = false;
061:
062: /** any callable interface name (e.g. {@link ILinkListener}). */
063: private String interfaceName;
064:
065: /**
066: * in case this request points to a dispatched call to a behavior that is
067: * coupled to a component, this is the registration id of the behavior.
068: */
069: private String behaviorId;
070:
071: /** any id of a non-page target component. */
072: private String componentId;
073:
074: /** any bookmarkable page class. */
075: private String bookmarkablePageClass;
076:
077: /** free-to-use map of non-reserved parameters. */
078: private Map parameters;
079:
080: /** any resource key. */
081: private String resourceKey;
082:
083: /** the path info. */
084: private String path;
085:
086: /**
087: * Construct.
088: */
089: public RequestParameters() {
090:
091: }
092:
093: /**
094: * Gets any bookmarkable page class.
095: *
096: * @return any bookmarkable page class
097: */
098: public String getBookmarkablePageClass() {
099: return bookmarkablePageClass;
100: }
101:
102: /**
103: * Sets any bookmarkable page class.
104: *
105: * @param bookmarkablePageClass
106: * any bookmarkable page class
107: */
108: public void setBookmarkablePageClass(String bookmarkablePageClass) {
109: this .bookmarkablePageClass = bookmarkablePageClass;
110: }
111:
112: /**
113: * Gets any id of a non-page target component.
114: *
115: * @return any id of a non-page target component
116: */
117: public String getComponentId() {
118: return componentId;
119: }
120:
121: /**
122: * Sets any id of a non-page target component.
123: *
124: * @param componentId
125: * any id of a non-page target component
126: */
127: public void setComponentId(String componentId) {
128: this .componentId = componentId;
129: }
130:
131: /**
132: * Gets the full path to a component (might be just the page)..
133: *
134: * @return the full path to a component (might be just the page).
135: */
136: public String getComponentPath() {
137: return componentPath;
138: }
139:
140: /**
141: * Sets the full path to a component (might be just the page)..
142: *
143: * @param componentPath
144: * the full path to a component (might be just the page).
145: */
146: public void setComponentPath(String componentPath) {
147: this .componentPath = componentPath;
148: }
149:
150: /**
151: * @return The interface named by these request parameters
152: */
153: public RequestListenerInterface getInterface() {
154: return RequestListenerInterface.forName(getInterfaceName());
155: }
156:
157: /**
158: * Gets any callable interface name (e.g. {@link ILinkListener}).
159: *
160: * @return any callable interface name (e.g. {@link ILinkListener})
161: */
162: public String getInterfaceName() {
163: return interfaceName;
164: }
165:
166: /**
167: * Sets any callable interface name (e.g. {@link ILinkListener}).
168: *
169: * @param interfaceName
170: * any callable interface name (e.g. {@link ILinkListener})
171: */
172: public void setInterfaceName(String interfaceName) {
173: this .interfaceName = interfaceName;
174: }
175:
176: /**
177: * Gets any name of the page map.
178: *
179: * @return any name of the page map
180: */
181: public String getPageMapName() {
182: return pageMapName;
183: }
184:
185: /**
186: * Sets any name of the page map.
187: *
188: * @param pageMapName
189: * any name of the page map
190: */
191: public void setPageMapName(String pageMapName) {
192: this .pageMapName = pageMapName;
193: }
194:
195: /**
196: * Gets free-to-use map of non-reserved parameters.
197: *
198: * @return free-to-use map of non-reserved parameters
199: */
200: public Map getParameters() {
201: return parameters;
202: }
203:
204: /**
205: * Sets free-to-use map of non-reserved parameters.
206: *
207: * @param parameters
208: * free-to-use map of non-reserved parameters
209: */
210: public void setParameters(Map parameters) {
211: this .parameters = parameters;
212: }
213:
214: /**
215: * Gets any resource key.
216: *
217: * @return any resource key
218: */
219: public String getResourceKey() {
220: return resourceKey;
221: }
222:
223: /**
224: * Sets any resource key.
225: *
226: * @param resourceKey
227: * any resource key
228: */
229: public void setResourceKey(String resourceKey) {
230: this .resourceKey = resourceKey;
231: }
232:
233: /**
234: * Gets any version information string.
235: *
236: * @return any version information string
237: */
238: public int getVersionNumber() {
239: return versionNumber;
240: }
241:
242: /**
243: * Sets any version information string.
244: *
245: * @param versionNumber
246: * any version information string
247: */
248: public void setVersionNumber(int versionNumber) {
249: this .versionNumber = versionNumber;
250: }
251:
252: /**
253: * Gets path info.
254: *
255: * @return path info
256: */
257: public String getPath() {
258: return path;
259: }
260:
261: /**
262: * Sets path info.
263: *
264: * @param pathInfo
265: * path info
266: */
267: public void setPath(String pathInfo) {
268: this .path = pathInfo;
269: }
270:
271: /**
272: * Gets the component registration id of any behavior.
273: *
274: * @return behaviorId the id
275: */
276: public String getBehaviorId() {
277: return behaviorId;
278: }
279:
280: /**
281: * Sets the component registration id of any behavior.
282: *
283: * @param behaviorId
284: * the id
285: */
286: public void setBehaviorId(String behaviorId) {
287: this .behaviorId = behaviorId;
288: }
289:
290: /**
291: * Gets the only-process-if-path-active flag
292: *
293: * @see #onlyProcessIfPathActive
294: *
295: * @return the only-process-if-path-active flag
296: */
297: public boolean isOnlyProcessIfPathActive() {
298: return onlyProcessIfPathActive;
299: }
300:
301: /**
302: * Sets the only-process-if-path-active flag
303: *
304: * @param onlyProcessIfPathActive
305: *
306: * @see #onlyProcessIfPathActive
307: *
308: */
309: public void setOnlyProcessIfPathActive(
310: boolean onlyProcessIfPathActive) {
311: this .onlyProcessIfPathActive = onlyProcessIfPathActive;
312: }
313:
314: /**
315: * @see java.lang.Object#toString()
316: */
317: public String toString() {
318: StringBuffer b = new StringBuffer("[RequestParameters ");
319: if (getComponentPath() != null) {
320: b.append(" componentPath=").append(getComponentPath());
321: b.append(" pageMapName=").append(getPageMapName());
322: b.append(" versionNumber=").append(getVersionNumber());
323: b.append(" interfaceName=").append(getInterfaceName());
324: b.append(" componentId=").append(getComponentId());
325: b.append(" behaviorId=").append(getBehaviorId());
326: }
327: if (getBookmarkablePageClass() != null) {
328: b.append(" bookmarkablePageClass=").append(
329: getBookmarkablePageClass());
330: }
331: if (getParameters() != null) {
332: b.append(" parameters=").append(getParameters());
333: }
334: if (getResourceKey() != null) {
335: b.append(" resourceKey=").append(getResourceKey());
336: }
337: b.append(" onlyProcessIfPathActive=").append(
338: isOnlyProcessIfPathActive());
339:
340: b.append("]");
341: return b.toString();
342: }
343: }
|