View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      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.om.folder.psml;
18  
19  import java.util.ArrayList;
20  import java.util.Iterator;
21  import java.util.List;
22  
23  import org.apache.jetspeed.om.folder.MenuDefinition;
24  
25  /***
26   * This class implements the MenuDefinition
27   * interface in a persistent object form for use by
28   * the page manager component.
29   * 
30   * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
31   * @version $Id: MenuDefinitionImpl.java 516448 2007-03-09 16:25:47Z ate $
32   */
33  public class MenuDefinitionImpl extends MenuMetadataImpl implements MenuDefinition
34  {
35      /***
36       * name - name of menu definition
37       */
38      private String name;
39  
40      /***
41       * options - comma separated option paths specification for menu
42       */
43      private String options;
44  
45      /***
46       * depth - depth of inclusion for folder options
47       */
48      private int depth;
49  
50      /***
51       * paths - generate ordered path options for options
52       */
53      private boolean paths;
54  
55      /***
56       * regexp - interpret specified optionsas regexp
57       */
58      private boolean regexp;
59  
60      /***
61       * profile - profile locator name filter for options
62       */
63      private String profile;
64      
65      /***
66       * order - comma separated list of ordering patterns for options
67       */
68      private String order;
69      
70      /***
71       * skin - skin name for menu
72       */
73      private String skin;
74      
75      /***
76       * title - title for menu
77       */
78      private String title;
79  
80      /***
81       * shortTitle - short title for menu
82       */
83      private String shortTitle;
84  
85      /***
86       * menuElements - ordered polymorphic list of menu options nested
87       *                menu, separator, include, and exclude definitions
88       */
89      private List menuElements;
90  
91      /***
92       * menuElementImpls - ordered homogeneous list of menu elements
93       */
94      private List menuElementImpls;
95  
96      /***
97       * MenuDefinitionImpl - constructor
98       */
99      public MenuDefinitionImpl()
100     {
101     }
102 
103     /***
104      * getName - get menu name
105      *
106      * @return menu name
107      */
108     public String getName()
109     {
110         return name;
111     }
112 
113     /***
114      * setName - set menu name
115      *
116      * @param name menu name
117      */
118     public void setName(String name)
119     {
120         this.name = name;
121     }
122 
123     /***
124      * getOptions - get comma separated menu options if not specified as elements
125      *
126      * @return option paths specification
127      */
128     public String getOptions()
129     {
130         return options;
131     }
132 
133     /***
134      * setOptions - set comma separated menu options if not specified as elements
135      *
136      * @param options option paths specification
137      */
138     public void setOptions(String options)
139     {
140         this.options = options;
141     }
142 
143     /***
144      * getDepth - get depth of inclusion for folder menu options
145      *
146      * @return inclusion depth
147      */
148     public int getDepth()
149     {
150         return depth;
151     }
152 
153     /***
154      * setDepth - set depth of inclusion for folder menu options
155      *
156      * @param depth inclusion depth
157      */
158     public void setDepth(int depth)
159     {
160         this.depth = depth;
161     }
162 
163     /***
164      * isPaths - get generate ordered path options for specified options
165      *
166      * @return paths options flag
167      */
168     public boolean isPaths()
169     {
170         return paths;
171     }
172     
173     /***
174      * setPaths - set generate ordered path options for specified options
175      *
176      * @param paths paths options flag
177      */
178     public void setPaths(boolean paths)
179     {
180         this.paths = paths;
181     }
182     
183     /***
184      * isRegexp - get regexp flag for interpreting specified options
185      *
186      * @return regexp flag
187      */
188     public boolean isRegexp()
189     {
190         return regexp;
191     }
192 
193     /***
194      * setRegexp - set regexp flag for interpreting specified options
195      *
196      * @param regexp regexp flag
197      */
198     public void setRegexp(boolean regexp)
199     {
200         this.regexp = regexp;
201     }
202 
203     /***
204      * getProfile - get profile locator used to filter specified options
205      *
206      * @return profile locator name
207      */
208     public String getProfile()
209     {
210         return profile;
211     }
212 
213     /***
214      * setProfile - set profile locator used to filter specified options
215      *
216      * @param locatorName profile locator name
217      */
218     public void setProfile(String locatorName)
219     {
220         profile = locatorName;
221     }
222 
223     /***
224      * getOrder - get comma separated regexp ordering patterns for options
225      *
226      * @return ordering patterns list
227      */
228     public String getOrder()
229     {
230         return order;
231     }
232 
233     /***
234      * setOrder - set comma separated regexp ordering patterns for options
235      *
236      * @param order ordering patterns list
237      */
238     public void setOrder(String order)
239     {
240         this.order = order;
241     }
242 
243     /***
244      * getSkin - get skin name for menu
245      *
246      * @return skin name
247      */
248     public String getSkin()
249     {
250         return skin;
251     }
252 
253     /***
254      * setSkin - set skin name for menu
255      *
256      * @param name skin name
257      */
258     public void setSkin(String name)
259     {
260         skin = name;
261     }
262 
263     /***
264      * getTitle - get default title for menu
265      *
266      * @return title text
267      */
268     public String getTitle()
269     {
270         return title;
271     }
272 
273     /***
274      * setTitle - set default title for menu
275      *
276      * @param title title text
277      */
278     public void setTitle(String title)
279     {
280         this.title = title;
281     }
282 
283     /***
284      * getShortTitle - get default short title for menu
285      *
286      * @return short title text
287      */
288     public String getShortTitle()
289     {
290         return shortTitle; 
291     }
292 
293     /***
294      * setShortTitle - set default short title for menu
295      *
296      * @param title short title text
297      */
298     public void setShortTitle(String title)
299     {
300         this.shortTitle = title;
301     }
302 
303     /***
304      * getMenuElements - get ordered list of menu options,
305      *                   nested menus, separators, included
306      *                   menu, and excluded menu elements
307      *
308      * @return element list
309      */
310     public List getMenuElements()
311     {
312         return menuElements;
313     }
314 
315     /***
316      * setMenuElements - set ordered list of menu elements
317      *
318      * @param elements element list
319      */
320     public void setMenuElements(List elements)
321     {
322         menuElements = elements;
323     }
324 
325     /***
326      * getMenuElementImpls - get ordered list of wrapped menu elements
327      *
328      * @return element list
329      */
330     public List getMenuElementImpls()
331     {
332         return menuElementImpls;
333     }
334 
335     /***
336      * setMenuElementImpls - set ordered list of menu elements using
337      *                       a list of wrapped menu elements
338      *
339      * @param elements element list
340      */
341     public void setMenuElementImpls(List elements)
342     {
343         menuElementImpls = elements;
344     }
345 
346     /***
347      * unmarshalled - notification that this instance has been
348      *                loaded from the persistent store
349      */
350     public void unmarshalled()
351     {
352         // notify super class implementation
353         super.unmarshalled();
354 
355         // unwrap menu elements and propagate
356         // unmarshalled notification
357         if (menuElementImpls != null)
358         {
359             menuElements = new ArrayList(menuElementImpls.size());
360             Iterator menuElementIter = menuElementImpls.iterator();
361             while (menuElementIter.hasNext())
362             {
363                 // unwrap menu element
364                 Object menuElement = ((MenuElementImpl)menuElementIter.next()).getElement();
365                 menuElements.add(menuElement);
366 
367                 // propagate unmarshalled notification
368                 if (menuElement instanceof MenuMetadataImpl)
369                 {
370                     ((MenuMetadataImpl)menuElement).unmarshalled();
371                 }
372             }
373         }
374         else
375         {
376             menuElements = null;            
377         }
378     }
379 
380     /***
381      * marshalling - notification that this instance is to
382      *               be saved to the persistent store
383      */
384     public void marshalling()
385     {
386         // wrap menu elements and propagate
387         // marshalling notification
388         if (menuElements != null)
389         {
390             menuElementImpls = new ArrayList(menuElements.size());
391             Iterator menuElementIter = menuElements.iterator();
392             while (menuElementIter.hasNext())
393             {
394                 // wrap menu element
395                 Object menuElement = menuElementIter.next();
396                 menuElementImpls.add(new MenuElementImpl(menuElement));
397 
398                 // propagate marshalling notification
399                 if (menuElement instanceof MenuDefinitionImpl)
400                 {
401                     ((MenuDefinitionImpl)menuElement).unmarshalled();
402                 }
403             }
404         }
405         else
406         {
407             menuElementImpls = null;            
408         }
409     }
410 }