01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.jetspeed.portalsite.view;
18:
19: import org.apache.jetspeed.om.folder.Folder;
20:
21: /**
22: * This class represents a search path along with a profile
23: * locator name used to construct the logical site view. The
24: * profiler locator name is uses to identify and group
25: * located nodes within the view.
26: *
27: * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
28: * @version $Id: SiteViewSearchPath.java 517121 2007-03-12 07:45:49Z ate $
29: */
30: public class SiteViewSearchPath {
31: /**
32: * locatorName - profile locator name
33: */
34: private String locatorName;
35:
36: /**
37: * searchPath - search path
38: */
39: private String searchPath;
40:
41: /**
42: * SiteViewSearchPath - validating constructor that strips any trailing
43: * folder separator from search path
44: *
45: * @param locatorName profile locator name
46: * @param searchPath search path
47: */
48: public SiteViewSearchPath(String locatorName, String searchPath) {
49: this .locatorName = locatorName;
50: if (searchPath.endsWith(Folder.PATH_SEPARATOR)
51: && !searchPath.equals(Folder.PATH_SEPARATOR)) {
52: this .searchPath = searchPath.substring(0, searchPath
53: .length() - 1);
54: } else {
55: this .searchPath = searchPath;
56: }
57: }
58:
59: /**
60: * toString - return search path
61: *
62: * @return search path
63: */
64: public String toString() {
65: return searchPath;
66: }
67:
68: /**
69: * equals - compare as string to search path
70: *
71: * @return equals result
72: */
73: public boolean equals(Object obj) {
74: if (obj instanceof String) {
75: return searchPath.equals(obj);
76: }
77: return searchPath.equals(obj.toString());
78: }
79:
80: /**
81: * hashCode - return search path hash code
82: *
83: * @return hash code
84: */
85: public int hashCode() {
86: return searchPath.hashCode();
87: }
88:
89: /**
90: * getLocatorName - return profile locator name
91: *
92: * @return profile locator name
93: */
94: public String getLocatorName() {
95: return locatorName;
96: }
97: }
|