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.impl;
18  
19  import java.util.List;
20  import java.util.Locale;
21  
22  import org.apache.jetspeed.om.folder.MenuDefinition;
23  import org.apache.jetspeed.om.common.GenericMetadata;
24  
25  /***
26   * This abstract class implements the menu definition interface
27   * in a default manner to allow derived classes to easily describe
28   * standard menu definitions supported natively by the portal site
29   * component.
30   * 
31   * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
32   * @version $Id: StandardMenuDefinitionImpl.java 516448 2007-03-09 16:25:47Z ate $
33   */
34  public abstract class StandardMenuDefinitionImpl implements MenuDefinition
35  {
36      /***
37       * StandardMenuDefinitionImpl - constructor
38       */
39      public StandardMenuDefinitionImpl()
40      {
41      }
42  
43      /***
44       * getName - get menu name
45       *
46       * @return menu name
47       */
48      public String getName()
49      {
50          return null;
51      }
52  
53      /***
54       * setName - set menu name
55       *
56       * @param name menu name
57       */
58      public void setName(String name)
59      {
60          throw new RuntimeException("StandardMenuDefinitionImpl instance immutable");
61      }
62  
63      /***
64       * getOptions - get comma separated menu options if not specified as elements
65       *
66       * @return option paths specification
67       */
68      public String getOptions()
69      {
70          return null;
71      }
72  
73      /***
74       * setOptions - set comma separated menu options if not specified as elements
75       *
76       * @param option option paths specification
77       */
78      public void setOptions(String options)
79      {
80          throw new RuntimeException("StandardMenuDefinitionImpl instance immutable");
81      }
82  
83      /***
84       * getDepth - get depth of inclusion for folder menu options
85       *
86       * @return inclusion depth
87       */
88      public int getDepth()
89      {
90          return 0;
91      }
92  
93      /***
94       * setDepth - set depth of inclusion for folder menu options
95       *
96       * @param depth inclusion depth
97       */
98      public void setDepth(int depth)
99      {
100         throw new RuntimeException("StandardMenuDefinitionImpl instance immutable");
101     }
102 
103     /***
104      * isPaths - get generate ordered path options for specified options
105      *
106      * @return paths options flag
107      */
108     public boolean isPaths()
109     {
110         return false;
111     }
112     
113     /***
114      * setPaths - set generate ordered path options for specified options
115      *
116      * @param paths paths options flag
117      */
118     public void setPaths(boolean paths)
119     {
120         throw new RuntimeException("StandardMenuDefinitionImpl instance immutable");
121     }
122     
123     /***
124      * isRegexp - get regexp flag for interpreting specified options
125      *
126      * @return regexp flag
127      */
128     public boolean isRegexp()
129     {
130         return false;
131     }
132 
133     /***
134      * setRegexp - set regexp flag for interpreting specified options
135      *
136      * @param regexp regexp flag
137      */
138     public void setRegexp(boolean regexp)
139     {
140         throw new RuntimeException("StandardMenuDefinitionImpl instance immutable");
141     }
142 
143     /***
144      * getProfile - get profile locator used to filter specified options
145      *
146      * @return profile locator name
147      */
148     public String getProfile()
149     {
150         return null;
151     }
152 
153     /***
154      * setProfile - set profile locator used to filter specified options
155      *
156      * @param locatorName profile locator name
157      */
158     public void setProfile(String locatorName)
159     {
160         throw new RuntimeException("StandardMenuDefinitionImpl instance immutable");
161     }
162 
163     /***
164      * getOrder - get comma separated regexp ordering patterns for options
165      *
166      * @return ordering patterns list
167      */
168     public String getOrder()
169     {
170         return null;
171     }
172 
173     /***
174      * setOrder - set comma separated regexp ordering patterns for options
175      *
176      * @param order ordering patterns list
177      */
178     public void setOrder(String order)
179     {
180         throw new RuntimeException("StandardMenuDefinitionImpl instance immutable");
181     }
182 
183     /***
184      * getSkin - get skin name for menu
185      *
186      * @return skin name
187      */
188     public String getSkin()
189     {
190         return null;
191     }
192 
193     /***
194      * setSkin - set skin name for menu
195      *
196      * @param name skin name
197      */
198     public void setSkin(String name)
199     {
200         throw new RuntimeException("StandardMenuDefinitionImpl instance immutable");
201     }
202 
203     /***
204      * getTitle - get default title for menu
205      *
206      * @return title text
207      */
208     public String getTitle()
209     {
210         // fallback to getName()
211         return getName();
212     }
213 
214     /***
215      * setTitle - set default title for menu
216      *
217      * @param title title text
218      */
219     public void setTitle(String title)
220     {
221         throw new RuntimeException("StandardMenuDefinitionImpl instance immutable");
222     }
223 
224     /***
225      * getShortTitle - get default short title for menu
226      *
227      * @return short title text
228      */
229     public String getShortTitle()
230     {
231         // fallback to getTitle()
232         return getTitle();
233     }
234 
235     /***
236      * setShortTitle - set default short title for menu
237      *
238      * @param title short title text
239      */
240     public void setShortTitle(String title)
241     {
242         throw new RuntimeException("StandardMenuDefinitionImpl instance immutable");
243     }
244 
245     /***
246      * getTitle - get locale specific title for menu from metadata
247      *
248      * @param locale preferred locale
249      * @return title text
250      */
251     public String getTitle(Locale locale)
252     {
253         // fallback to getTitle()
254         return getTitle(locale, true);
255     }
256 
257     /***
258      * getTitle - get locale specific title for menu from metadata
259      *            protocol, with or without falback enabled
260      *
261      * @param locale preferred locale
262      * @param fallback whether to return default title
263      * @return title text
264      */
265     protected String getTitle(Locale locale, boolean fallback)
266     {
267         // fallback to getTitle() if enabled
268         if (fallback)
269         {
270             return getTitle();
271         }
272         return null;
273     }
274 
275     /***
276      * getShortTitle - get locale specific short title for menu from metadata
277      *
278      * @param locale preferred locale
279      * @return short title text
280      */
281     public String getShortTitle(Locale locale)
282     {
283         // fallback to getTitle(Locale)
284         String title = getTitle(locale, false);
285 
286         // fallback to getShortTitle()
287         if (title == null)
288         {
289             title = getShortTitle();
290         }
291         return title;
292     }
293 
294     /***
295      * getMetadata - get generic metadata instance for menu
296      *
297      * @return metadata instance
298      */
299     public GenericMetadata getMetadata()
300     {
301         return null;
302     }
303 
304     /***
305      * getMenuElements - get ordered list of menu options,
306      *                   nested menus, separators, included
307      *                   menu, and excluded menu elements
308      *
309      * @return element list
310      */
311     public List getMenuElements()
312     {
313         return null;
314     }
315 
316     /***
317      * setMenuElements - set ordered list of menu options
318      *
319      * @param elements element list
320      */
321     public void setMenuElements(List elements)
322     {
323         throw new RuntimeException("StandardMenuDefinitionImpl instance immutable");
324     }
325 }