1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.portalsite.view;
18
19 import org.apache.jetspeed.om.folder.MenuDefinition;
20 import org.apache.jetspeed.page.document.Node;
21
22 /***
23 * This class represents a menu definition locator that is
24 * comprised of the menu name, (the full definition is saved
25 * here from convenience), and concrete path of the
26 * defining folder or page.
27 *
28 * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
29 * @version $Id: SiteViewMenuDefinitionLocator.java 517121 2007-03-12 07:45:49Z ate $
30 */
31 public class SiteViewMenuDefinitionLocator
32 {
33 /***
34 * locator - locator string defined for menu containing
35 * menu name and concrete path of defining node
36 */
37 private String locator;
38
39 /***
40 * menuDefinition - menu definition
41 */
42 private MenuDefinition menuDefinition;
43
44 /***
45 * SiteViewMenuDefinitionLocator - custom menu definition constructor
46 *
47 * @param menuDefinition custom menu definition
48 * @param definingNode defining page or folder
49 */
50 public SiteViewMenuDefinitionLocator(MenuDefinition menuDefinition, Node definingNode)
51 {
52 this.menuDefinition = menuDefinition;
53 this.locator = definingNode.getPath() + "|" + menuDefinition.getName();
54 }
55
56 /***
57 * SiteViewMenuDefinitionLocator - standard menu definition constructor
58 *
59 * @param menuDefinition standard menu definition
60 */
61 public SiteViewMenuDefinitionLocator(MenuDefinition menuDefinition)
62 {
63 this.menuDefinition = menuDefinition;
64 this.locator = "<standard_menu_definition>|" + menuDefinition.getName();
65 }
66
67 /***
68 * toString - return locator
69 *
70 * @return search path
71 */
72 public String toString()
73 {
74 return locator;
75 }
76
77 /***
78 * equals - compare as string to locator
79 *
80 * @return equals result
81 */
82 public boolean equals(Object obj)
83 {
84 if (obj instanceof String)
85 {
86 return locator.equals(obj);
87 }
88 return locator.equals(obj.toString());
89 }
90
91 /***
92 * hashCode - return search path hash code
93 *
94 * @return hash code
95 */
96 public int hashCode()
97 {
98 return locator.hashCode();
99 }
100
101 /***
102 * getMenuDefinition - return menu definition
103 *
104 * @return menu definition
105 */
106 public MenuDefinition getMenuDefinition()
107 {
108 return menuDefinition;
109 }
110
111 /***
112 * getName - return name of menu definition
113 *
114 * @return menu definition name
115 */
116 public String getName()
117 {
118 return menuDefinition.getName();
119 }
120 }