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: import java.util.Locale;
021:
022: import org.apache.jetspeed.om.folder.MenuDefinition;
023: import org.apache.jetspeed.om.common.GenericMetadata;
024:
025: /**
026: * This abstract class implements the menu definition interface
027: * in a default manner to allow derived classes to easily describe
028: * standard menu definitions supported natively by the portal site
029: * component.
030: *
031: * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
032: * @version $Id: StandardMenuDefinitionImpl.java 516448 2007-03-09 16:25:47Z ate $
033: */
034: public abstract class StandardMenuDefinitionImpl implements
035: MenuDefinition {
036: /**
037: * StandardMenuDefinitionImpl - constructor
038: */
039: public StandardMenuDefinitionImpl() {
040: }
041:
042: /**
043: * getName - get menu name
044: *
045: * @return menu name
046: */
047: public String getName() {
048: return null;
049: }
050:
051: /**
052: * setName - set menu name
053: *
054: * @param name menu name
055: */
056: public void setName(String name) {
057: throw new RuntimeException(
058: "StandardMenuDefinitionImpl instance immutable");
059: }
060:
061: /**
062: * getOptions - get comma separated menu options if not specified as elements
063: *
064: * @return option paths specification
065: */
066: public String getOptions() {
067: return null;
068: }
069:
070: /**
071: * setOptions - set comma separated menu options if not specified as elements
072: *
073: * @param option option paths specification
074: */
075: public void setOptions(String options) {
076: throw new RuntimeException(
077: "StandardMenuDefinitionImpl instance immutable");
078: }
079:
080: /**
081: * getDepth - get depth of inclusion for folder menu options
082: *
083: * @return inclusion depth
084: */
085: public int getDepth() {
086: return 0;
087: }
088:
089: /**
090: * setDepth - set depth of inclusion for folder menu options
091: *
092: * @param depth inclusion depth
093: */
094: public void setDepth(int depth) {
095: throw new RuntimeException(
096: "StandardMenuDefinitionImpl instance immutable");
097: }
098:
099: /**
100: * isPaths - get generate ordered path options for specified options
101: *
102: * @return paths options flag
103: */
104: public boolean isPaths() {
105: return false;
106: }
107:
108: /**
109: * setPaths - set generate ordered path options for specified options
110: *
111: * @param paths paths options flag
112: */
113: public void setPaths(boolean paths) {
114: throw new RuntimeException(
115: "StandardMenuDefinitionImpl instance immutable");
116: }
117:
118: /**
119: * isRegexp - get regexp flag for interpreting specified options
120: *
121: * @return regexp flag
122: */
123: public boolean isRegexp() {
124: return false;
125: }
126:
127: /**
128: * setRegexp - set regexp flag for interpreting specified options
129: *
130: * @param regexp regexp flag
131: */
132: public void setRegexp(boolean regexp) {
133: throw new RuntimeException(
134: "StandardMenuDefinitionImpl instance immutable");
135: }
136:
137: /**
138: * getProfile - get profile locator used to filter specified options
139: *
140: * @return profile locator name
141: */
142: public String getProfile() {
143: return null;
144: }
145:
146: /**
147: * setProfile - set profile locator used to filter specified options
148: *
149: * @param locatorName profile locator name
150: */
151: public void setProfile(String locatorName) {
152: throw new RuntimeException(
153: "StandardMenuDefinitionImpl instance immutable");
154: }
155:
156: /**
157: * getOrder - get comma separated regexp ordering patterns for options
158: *
159: * @return ordering patterns list
160: */
161: public String getOrder() {
162: return null;
163: }
164:
165: /**
166: * setOrder - set comma separated regexp ordering patterns for options
167: *
168: * @param order ordering patterns list
169: */
170: public void setOrder(String order) {
171: throw new RuntimeException(
172: "StandardMenuDefinitionImpl instance immutable");
173: }
174:
175: /**
176: * getSkin - get skin name for menu
177: *
178: * @return skin name
179: */
180: public String getSkin() {
181: return null;
182: }
183:
184: /**
185: * setSkin - set skin name for menu
186: *
187: * @param name skin name
188: */
189: public void setSkin(String name) {
190: throw new RuntimeException(
191: "StandardMenuDefinitionImpl instance immutable");
192: }
193:
194: /**
195: * getTitle - get default title for menu
196: *
197: * @return title text
198: */
199: public String getTitle() {
200: // fallback to getName()
201: return getName();
202: }
203:
204: /**
205: * setTitle - set default title for menu
206: *
207: * @param title title text
208: */
209: public void setTitle(String title) {
210: throw new RuntimeException(
211: "StandardMenuDefinitionImpl instance immutable");
212: }
213:
214: /**
215: * getShortTitle - get default short title for menu
216: *
217: * @return short title text
218: */
219: public String getShortTitle() {
220: // fallback to getTitle()
221: return getTitle();
222: }
223:
224: /**
225: * setShortTitle - set default short title for menu
226: *
227: * @param title short title text
228: */
229: public void setShortTitle(String title) {
230: throw new RuntimeException(
231: "StandardMenuDefinitionImpl instance immutable");
232: }
233:
234: /**
235: * getTitle - get locale specific title for menu from metadata
236: *
237: * @param locale preferred locale
238: * @return title text
239: */
240: public String getTitle(Locale locale) {
241: // fallback to getTitle()
242: return getTitle(locale, true);
243: }
244:
245: /**
246: * getTitle - get locale specific title for menu from metadata
247: * protocol, with or without falback enabled
248: *
249: * @param locale preferred locale
250: * @param fallback whether to return default title
251: * @return title text
252: */
253: protected String getTitle(Locale locale, boolean fallback) {
254: // fallback to getTitle() if enabled
255: if (fallback) {
256: return getTitle();
257: }
258: return null;
259: }
260:
261: /**
262: * getShortTitle - get locale specific short title for menu from metadata
263: *
264: * @param locale preferred locale
265: * @return short title text
266: */
267: public String getShortTitle(Locale locale) {
268: // fallback to getTitle(Locale)
269: String title = getTitle(locale, false);
270:
271: // fallback to getShortTitle()
272: if (title == null) {
273: title = getShortTitle();
274: }
275: return title;
276: }
277:
278: /**
279: * getMetadata - get generic metadata instance for menu
280: *
281: * @return metadata instance
282: */
283: public GenericMetadata getMetadata() {
284: return null;
285: }
286:
287: /**
288: * getMenuElements - get ordered list of menu options,
289: * nested menus, separators, included
290: * menu, and excluded menu elements
291: *
292: * @return element list
293: */
294: public List getMenuElements() {
295: return null;
296: }
297:
298: /**
299: * setMenuElements - set ordered list of menu options
300: *
301: * @param elements element list
302: */
303: public void setMenuElements(List elements) {
304: throw new RuntimeException(
305: "StandardMenuDefinitionImpl instance immutable");
306: }
307: }
|