001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.jetspeed.portlet.webcontent;
019:
020: import java.io.Serializable;
021: import java.util.HashMap;
022: import java.util.Iterator;
023: import java.util.Map;
024:
025: import org.apache.commons.lang.ArrayUtils;
026:
027: /**
028: * Information required to re-visit a page in the WebContentPortlet
029: *
030: * @author <a href="mailto:dyoung@phase2systems.com">David L Young</a>
031: * @version $Id: $
032: */
033:
034: public class WebContentHistoryPage extends Object implements
035: Serializable {
036: private String url;
037: private Map params;
038: private boolean is_post;
039:
040: // Constructors
041:
042: public WebContentHistoryPage(String url) {
043: this (url, null, null);
044: }
045:
046: public WebContentHistoryPage(String url, Map params, String method) {
047: super ();
048:
049: // guarantee non-null, so that equals() is well-behaved
050: if (url == null)
051: throw new IllegalArgumentException(
052: "WebContentHistoryPage() - url required");
053:
054: this .url = url;
055: this .params = params != null ? params : new HashMap();
056: this .is_post = method != null
057: && method.equalsIgnoreCase("post");
058: }
059:
060: // Base Class Protocol
061:
062: public boolean equals(Object o) {
063: if (o == null || !(o instanceof WebContentHistoryPage))
064: return false;
065:
066: WebContentHistoryPage page = (WebContentHistoryPage) o;
067:
068: return page.url.equals(this .url)
069: && page.params.equals(this .params)
070: && page.isPost() == this .isPost();
071: }
072:
073: public String toString() {
074: StringBuffer buff = new StringBuffer();
075: buff.append("[").append(isPost() ? "POST: " : "GET: ").append(
076: getUrl()).append(", ").append(getParams().size())
077: .append(" params: {");
078: Iterator iter = getParams().entrySet().iterator();
079: while (iter.hasNext()) {
080: Map.Entry entry = (Map.Entry) iter.next();
081: buff.append("(").append(entry.getKey()).append(" . ")
082: .append(ArrayUtils.toString(entry.getKey()))
083: .append(")");
084: }
085: buff.append("}]");
086: return buff.toString();
087: }
088:
089: // Data Access
090:
091: public String getUrl() {
092: return this .url;
093: }
094:
095: public Map getParams() {
096: return this .params;
097: }
098:
099: public boolean isPost() {
100: return this.is_post;
101: }
102: }
|