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.psml;
018:
019: import java.util.ArrayList;
020: import java.util.Iterator;
021: import java.util.List;
022:
023: import org.apache.jetspeed.om.folder.MenuDefinition;
024:
025: /**
026: * This class implements the MenuDefinition
027: * interface in a persistent object form for use by
028: * the page manager component.
029: *
030: * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
031: * @version $Id: MenuDefinitionImpl.java 516448 2007-03-09 16:25:47Z ate $
032: */
033: public class MenuDefinitionImpl extends MenuMetadataImpl implements
034: MenuDefinition {
035: /**
036: * name - name of menu definition
037: */
038: private String name;
039:
040: /**
041: * options - comma separated option paths specification for menu
042: */
043: private String options;
044:
045: /**
046: * depth - depth of inclusion for folder options
047: */
048: private int depth;
049:
050: /**
051: * paths - generate ordered path options for options
052: */
053: private boolean paths;
054:
055: /**
056: * regexp - interpret specified optionsas regexp
057: */
058: private boolean regexp;
059:
060: /**
061: * profile - profile locator name filter for options
062: */
063: private String profile;
064:
065: /**
066: * order - comma separated list of ordering patterns for options
067: */
068: private String order;
069:
070: /**
071: * skin - skin name for menu
072: */
073: private String skin;
074:
075: /**
076: * title - title for menu
077: */
078: private String title;
079:
080: /**
081: * shortTitle - short title for menu
082: */
083: private String shortTitle;
084:
085: /**
086: * menuElements - ordered polymorphic list of menu options nested
087: * menu, separator, include, and exclude definitions
088: */
089: private List menuElements;
090:
091: /**
092: * menuElementImpls - ordered homogeneous list of menu elements
093: */
094: private List menuElementImpls;
095:
096: /**
097: * MenuDefinitionImpl - constructor
098: */
099: public MenuDefinitionImpl() {
100: }
101:
102: /**
103: * getName - get menu name
104: *
105: * @return menu name
106: */
107: public String getName() {
108: return name;
109: }
110:
111: /**
112: * setName - set menu name
113: *
114: * @param name menu name
115: */
116: public void setName(String name) {
117: this .name = name;
118: }
119:
120: /**
121: * getOptions - get comma separated menu options if not specified as elements
122: *
123: * @return option paths specification
124: */
125: public String getOptions() {
126: return options;
127: }
128:
129: /**
130: * setOptions - set comma separated menu options if not specified as elements
131: *
132: * @param options option paths specification
133: */
134: public void setOptions(String options) {
135: this .options = options;
136: }
137:
138: /**
139: * getDepth - get depth of inclusion for folder menu options
140: *
141: * @return inclusion depth
142: */
143: public int getDepth() {
144: return depth;
145: }
146:
147: /**
148: * setDepth - set depth of inclusion for folder menu options
149: *
150: * @param depth inclusion depth
151: */
152: public void setDepth(int depth) {
153: this .depth = depth;
154: }
155:
156: /**
157: * isPaths - get generate ordered path options for specified options
158: *
159: * @return paths options flag
160: */
161: public boolean isPaths() {
162: return paths;
163: }
164:
165: /**
166: * setPaths - set generate ordered path options for specified options
167: *
168: * @param paths paths options flag
169: */
170: public void setPaths(boolean paths) {
171: this .paths = paths;
172: }
173:
174: /**
175: * isRegexp - get regexp flag for interpreting specified options
176: *
177: * @return regexp flag
178: */
179: public boolean isRegexp() {
180: return regexp;
181: }
182:
183: /**
184: * setRegexp - set regexp flag for interpreting specified options
185: *
186: * @param regexp regexp flag
187: */
188: public void setRegexp(boolean regexp) {
189: this .regexp = regexp;
190: }
191:
192: /**
193: * getProfile - get profile locator used to filter specified options
194: *
195: * @return profile locator name
196: */
197: public String getProfile() {
198: return profile;
199: }
200:
201: /**
202: * setProfile - set profile locator used to filter specified options
203: *
204: * @param locatorName profile locator name
205: */
206: public void setProfile(String locatorName) {
207: profile = locatorName;
208: }
209:
210: /**
211: * getOrder - get comma separated regexp ordering patterns for options
212: *
213: * @return ordering patterns list
214: */
215: public String getOrder() {
216: return order;
217: }
218:
219: /**
220: * setOrder - set comma separated regexp ordering patterns for options
221: *
222: * @param order ordering patterns list
223: */
224: public void setOrder(String order) {
225: this .order = order;
226: }
227:
228: /**
229: * getSkin - get skin name for menu
230: *
231: * @return skin name
232: */
233: public String getSkin() {
234: return skin;
235: }
236:
237: /**
238: * setSkin - set skin name for menu
239: *
240: * @param name skin name
241: */
242: public void setSkin(String name) {
243: skin = name;
244: }
245:
246: /**
247: * getTitle - get default title for menu
248: *
249: * @return title text
250: */
251: public String getTitle() {
252: return title;
253: }
254:
255: /**
256: * setTitle - set default title for menu
257: *
258: * @param title title text
259: */
260: public void setTitle(String title) {
261: this .title = title;
262: }
263:
264: /**
265: * getShortTitle - get default short title for menu
266: *
267: * @return short title text
268: */
269: public String getShortTitle() {
270: return shortTitle;
271: }
272:
273: /**
274: * setShortTitle - set default short title for menu
275: *
276: * @param title short title text
277: */
278: public void setShortTitle(String title) {
279: this .shortTitle = title;
280: }
281:
282: /**
283: * getMenuElements - get ordered list of menu options,
284: * nested menus, separators, included
285: * menu, and excluded menu elements
286: *
287: * @return element list
288: */
289: public List getMenuElements() {
290: return menuElements;
291: }
292:
293: /**
294: * setMenuElements - set ordered list of menu elements
295: *
296: * @param elements element list
297: */
298: public void setMenuElements(List elements) {
299: menuElements = elements;
300: }
301:
302: /**
303: * getMenuElementImpls - get ordered list of wrapped menu elements
304: *
305: * @return element list
306: */
307: public List getMenuElementImpls() {
308: return menuElementImpls;
309: }
310:
311: /**
312: * setMenuElementImpls - set ordered list of menu elements using
313: * a list of wrapped menu elements
314: *
315: * @param elements element list
316: */
317: public void setMenuElementImpls(List elements) {
318: menuElementImpls = elements;
319: }
320:
321: /**
322: * unmarshalled - notification that this instance has been
323: * loaded from the persistent store
324: */
325: public void unmarshalled() {
326: // notify super class implementation
327: super .unmarshalled();
328:
329: // unwrap menu elements and propagate
330: // unmarshalled notification
331: if (menuElementImpls != null) {
332: menuElements = new ArrayList(menuElementImpls.size());
333: Iterator menuElementIter = menuElementImpls.iterator();
334: while (menuElementIter.hasNext()) {
335: // unwrap menu element
336: Object menuElement = ((MenuElementImpl) menuElementIter
337: .next()).getElement();
338: menuElements.add(menuElement);
339:
340: // propagate unmarshalled notification
341: if (menuElement instanceof MenuMetadataImpl) {
342: ((MenuMetadataImpl) menuElement).unmarshalled();
343: }
344: }
345: } else {
346: menuElements = null;
347: }
348: }
349:
350: /**
351: * marshalling - notification that this instance is to
352: * be saved to the persistent store
353: */
354: public void marshalling() {
355: // wrap menu elements and propagate
356: // marshalling notification
357: if (menuElements != null) {
358: menuElementImpls = new ArrayList(menuElements.size());
359: Iterator menuElementIter = menuElements.iterator();
360: while (menuElementIter.hasNext()) {
361: // wrap menu element
362: Object menuElement = menuElementIter.next();
363: menuElementImpls.add(new MenuElementImpl(menuElement));
364:
365: // propagate marshalling notification
366: if (menuElement instanceof MenuDefinitionImpl) {
367: ((MenuDefinitionImpl) menuElement).unmarshalled();
368: }
369: }
370: } else {
371: menuElementImpls = null;
372: }
373: }
374: }
|