01: /******************************************************************************
02: * JBoss, a division of Red Hat *
03: * Copyright 2006, Red Hat Middleware, LLC, and individual *
04: * contributors as indicated by the @authors tag. See the *
05: * copyright.txt in the distribution for a full listing of *
06: * individual contributors. *
07: * *
08: * This is free software; you can redistribute it and/or modify it *
09: * under the terms of the GNU Lesser General Public License as *
10: * published by the Free Software Foundation; either version 2.1 of *
11: * the License, or (at your option) any later version. *
12: * *
13: * This software is distributed in the hope that it will be useful, *
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16: * Lesser General Public License for more details. *
17: * *
18: * You should have received a copy of the GNU Lesser General Public *
19: * License along with this software; if not, write to the Free *
20: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
21: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
22: ******************************************************************************/package org.jboss.portal.server.servlet;
23:
24: /**
25: * The result of a request to a mapper.
26: *
27: * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
28: * @version $Revision: 8784 $
29: */
30: public class PathMappingResult {
31:
32: private final Object target;
33: private final String matchedPath;
34: private final String remainingPath;
35:
36: public PathMappingResult(Object target, String matchedPath,
37: String remainingPath) {
38: this .target = target;
39: this .matchedPath = matchedPath;
40: this .remainingPath = remainingPath;
41: }
42:
43: public Object getTarget() {
44: return target;
45: }
46:
47: public String getMatchedPath() {
48: return matchedPath;
49: }
50:
51: public String getRemainingPath() {
52: return remainingPath;
53: }
54:
55: public int hashCode() {
56: int hashCode = (target != null ? target.hashCode() : 0)
57: + (matchedPath != null ? matchedPath.hashCode() : 0)
58: + (remainingPath != null ? remainingPath.hashCode() : 0);
59: return hashCode;
60: }
61:
62: public boolean equals(Object obj) {
63: if (obj == this ) {
64: return true;
65: }
66: if (obj instanceof PathMappingResult) {
67: PathMappingResult other = (PathMappingResult) obj;
68: return (target == null ? (other.target == null) : target
69: .equals(other.target))
70: && (matchedPath == null ? (other.matchedPath == null)
71: : matchedPath.equals(other.matchedPath))
72: && (remainingPath == null ? (other.remainingPath == null)
73: : remainingPath.equals(other.remainingPath));
74: }
75: return false;
76: }
77:
78: public String toString() {
79: StringBuffer buffer = new StringBuffer("MappingResult[");
80: buffer.append(target == null ? "null" : '\"' + target
81: .toString() + '\"');
82: buffer.append(',');
83: buffer.append(matchedPath == null ? "null"
84: : '\"' + matchedPath + '\"');
85: buffer.append(',');
86: buffer.append(remainingPath == null ? "null"
87: : '\"' + remainingPath + '\"');
88: buffer.append("]");
89: return buffer.toString();
90: }
91: }
|