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.om.folder.impl;
018:
019: import java.util.List;
020:
021: import org.apache.jetspeed.om.folder.MenuDefinition;
022: import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
023:
024: /**
025: * BaseMenuDefinitionImpl
026: *
027: * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
028: * @version $Id:$
029: */
030: public abstract class BaseMenuDefinitionImpl extends
031: BaseMenuDefinitionMetadata implements MenuDefinition {
032: private String name;
033: private String options;
034: private int depth;
035: private boolean paths;
036: private boolean regexp;
037: private String profile;
038: private String order;
039: private String skin;
040: private String title;
041: private String shortTitle;
042: private List elements;
043:
044: /**
045: * accessElements
046: *
047: * Access mutable persistent collection member for List wrappers.
048: *
049: * @return persistent collection
050: */
051: public List accessElements() {
052: // create initial collection if necessary
053: if (elements == null) {
054: elements = DatabasePageManagerUtils.createList();
055: }
056: return elements;
057: }
058:
059: /* (non-Javadoc)
060: * @see org.apache.jetspeed.om.folder.MenuDefinition#getName()
061: */
062: public String getName() {
063: return name;
064: }
065:
066: /* (non-Javadoc)
067: * @see org.apache.jetspeed.om.folder.MenuDefinition#setName(java.lang.String)
068: */
069: public void setName(String name) {
070: this .name = name;
071: }
072:
073: /* (non-Javadoc)
074: * @see org.apache.jetspeed.om.folder.MenuDefinition#getOptions()
075: */
076: public String getOptions() {
077: return options;
078: }
079:
080: /* (non-Javadoc)
081: * @see org.apache.jetspeed.om.folder.MenuDefinition#setOptions(java.lang.String)
082: */
083: public void setOptions(String options) {
084: this .options = options;
085: }
086:
087: /* (non-Javadoc)
088: * @see org.apache.jetspeed.om.folder.MenuDefinition#getDepth()
089: */
090: public int getDepth() {
091: return depth;
092: }
093:
094: /* (non-Javadoc)
095: * @see org.apache.jetspeed.om.folder.MenuDefinition#setDepth(int)
096: */
097: public void setDepth(int depth) {
098: this .depth = depth;
099: }
100:
101: /* (non-Javadoc)
102: * @see org.apache.jetspeed.om.folder.MenuDefinition#getPaths()
103: */
104: public boolean isPaths() {
105: return paths;
106: }
107:
108: /* (non-Javadoc)
109: * @see org.apache.jetspeed.om.folder.MenuDefinition#setPaths(boolean)
110: */
111: public void setPaths(boolean paths) {
112: this .paths = paths;
113: }
114:
115: /* (non-Javadoc)
116: * @see org.apache.jetspeed.om.folder.MenuDefinition#getRegexp()
117: */
118: public boolean isRegexp() {
119: return regexp;
120: }
121:
122: /* (non-Javadoc)
123: * @see org.apache.jetspeed.om.folder.MenuDefinition#setRegexp(boolean)
124: */
125: public void setRegexp(boolean regexp) {
126: this .regexp = regexp;
127: }
128:
129: /* (non-Javadoc)
130: * @see org.apache.jetspeed.om.folder.MenuDefinition#getProfile()
131: */
132: public String getProfile() {
133: return profile;
134: }
135:
136: /* (non-Javadoc)
137: * @see org.apache.jetspeed.om.folder.MenuDefinition#setProfile(java.lang.String)
138: */
139: public void setProfile(String locatorName) {
140: profile = locatorName;
141: }
142:
143: /* (non-Javadoc)
144: * @see org.apache.jetspeed.om.folder.MenuDefinition#getOrder()
145: */
146: public String getOrder() {
147: return order;
148: }
149:
150: /* (non-Javadoc)
151: * @see org.apache.jetspeed.om.folder.MenuDefinition#setOrder(java.lang.String)
152: */
153: public void setOrder(String order) {
154: this .order = order;
155: }
156:
157: /* (non-Javadoc)
158: * @see org.apache.jetspeed.om.folder.MenuDefinition#getSkin()
159: */
160: public String getSkin() {
161: return skin;
162: }
163:
164: /* (non-Javadoc)
165: * @see org.apache.jetspeed.om.folder.MenuDefinition#setSkin(java.lang.String)
166: */
167: public void setSkin(String name) {
168: skin = name;
169: }
170:
171: /* (non-Javadoc)
172: * @see org.apache.jetspeed.om.folder.MenuDefinition#getTitle()
173: */
174: public String getTitle() {
175: return title;
176: }
177:
178: /* (non-Javadoc)
179: * @see org.apache.jetspeed.om.folder.MenuDefinition#setTitle(java.lang.String)
180: */
181: public void setTitle(String title) {
182: this .title = title;
183: }
184:
185: /* (non-Javadoc)
186: * @see org.apache.jetspeed.om.folder.MenuDefinition#getShortTitle()
187: */
188: public String getShortTitle() {
189: return shortTitle;
190: }
191:
192: /* (non-Javadoc)
193: * @see org.apache.jetspeed.om.folder.MenuDefinition#setShortTitle(java.lang.String)
194: */
195: public void setShortTitle(String title) {
196: this .shortTitle = title;
197: }
198:
199: /* (non-Javadoc)
200: * @see org.apache.jetspeed.om.folder.MenuDefinition#getMenuElements()
201: */
202: public abstract List getMenuElements();
203:
204: /* (non-Javadoc)
205: * @see org.apache.jetspeed.om.folder.MenuDefinition#setMenuElements(java.util.List)
206: */
207: public void setMenuElements(List elements) {
208: // set menu elements by replacing
209: // existing entries with new elements if
210: // new collection is specified
211: List menuElements = getMenuElements();
212: if (elements != menuElements) {
213: // replace all menu elements
214: menuElements.clear();
215: if (elements != null) {
216: menuElements.addAll(elements);
217: }
218: }
219: }
220:
221: /* (non-Javadoc)
222: * @see java.lang.Object#equals(java.lang.Object)
223: */
224: public boolean equals(Object o) {
225: if (o instanceof BaseMenuDefinitionImpl) {
226: if (name != null) {
227: return name.equals(((BaseMenuDefinitionImpl) o)
228: .getName());
229: } else {
230: return (((BaseMenuDefinitionImpl) o).getName() == null);
231: }
232: }
233: return false;
234: }
235:
236: /* (non-Javadoc)
237: * @see java.lang.Object#hashCode()
238: */
239: public int hashCode() {
240: if (name != null) {
241: return name.hashCode();
242: }
243: return 0;
244: }
245: }
|