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: package org.apache.jetspeed.portalsite.view;
018:
019: import org.apache.jetspeed.om.folder.MenuDefinition;
020: import org.apache.jetspeed.page.document.Node;
021:
022: /**
023: * This class represents a menu definition locator that is
024: * comprised of the menu name, (the full definition is saved
025: * here from convenience), and concrete path of the
026: * defining folder or page.
027: *
028: * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
029: * @version $Id: SiteViewMenuDefinitionLocator.java 517121 2007-03-12 07:45:49Z ate $
030: */
031: public class SiteViewMenuDefinitionLocator {
032: /**
033: * locator - locator string defined for menu containing
034: * menu name and concrete path of defining node
035: */
036: private String locator;
037:
038: /**
039: * menuDefinition - menu definition
040: */
041: private MenuDefinition menuDefinition;
042:
043: /**
044: * SiteViewMenuDefinitionLocator - custom menu definition constructor
045: *
046: * @param menuDefinition custom menu definition
047: * @param definingNode defining page or folder
048: */
049: public SiteViewMenuDefinitionLocator(MenuDefinition menuDefinition,
050: Node definingNode) {
051: this .menuDefinition = menuDefinition;
052: this .locator = definingNode.getPath() + "|"
053: + menuDefinition.getName();
054: }
055:
056: /**
057: * SiteViewMenuDefinitionLocator - standard menu definition constructor
058: *
059: * @param menuDefinition standard menu definition
060: */
061: public SiteViewMenuDefinitionLocator(MenuDefinition menuDefinition) {
062: this .menuDefinition = menuDefinition;
063: this .locator = "<standard_menu_definition>|"
064: + menuDefinition.getName();
065: }
066:
067: /**
068: * toString - return locator
069: *
070: * @return search path
071: */
072: public String toString() {
073: return locator;
074: }
075:
076: /**
077: * equals - compare as string to locator
078: *
079: * @return equals result
080: */
081: public boolean equals(Object obj) {
082: if (obj instanceof String) {
083: return locator.equals(obj);
084: }
085: return locator.equals(obj.toString());
086: }
087:
088: /**
089: * hashCode - return search path hash code
090: *
091: * @return hash code
092: */
093: public int hashCode() {
094: return locator.hashCode();
095: }
096:
097: /**
098: * getMenuDefinition - return menu definition
099: *
100: * @return menu definition
101: */
102: public MenuDefinition getMenuDefinition() {
103: return menuDefinition;
104: }
105:
106: /**
107: * getName - return name of menu definition
108: *
109: * @return menu definition name
110: */
111: public String getName() {
112: return menuDefinition.getName();
113: }
114: }
|