1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.kernel.portlet;
16  
17  import java.util.HashMap;
18  import java.util.Map;
19  
20  import javax.portlet.PortletMode;
21  
22  /**
23   * <a href="PortletModeFactory.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Brian Wing Shun Chan
26   */
27  public class PortletModeFactory {
28  
29      public static PortletMode getPortletMode(String name) {
30          return _instance._getPortletMode(name);
31      }
32  
33      private PortletModeFactory() {
34          _portletModes = new HashMap<String, PortletMode>();
35  
36          _portletModes.put(_EDIT, LiferayPortletMode.EDIT);
37          _portletModes.put(_HELP, LiferayPortletMode.HELP);
38          _portletModes.put(_VIEW, LiferayPortletMode.VIEW);
39          _portletModes.put(_ABOUT, LiferayPortletMode.ABOUT);
40          _portletModes.put(_CONFIG, LiferayPortletMode.CONFIG);
41          _portletModes.put(_EDIT_DEFAULTS, LiferayPortletMode.EDIT_DEFAULTS);
42          _portletModes.put(_EDIT_GUEST, LiferayPortletMode.EDIT_GUEST);
43          _portletModes.put(_PREVIEW, LiferayPortletMode.PREVIEW);
44          _portletModes.put(_PRINT, LiferayPortletMode.PRINT);
45      }
46  
47      private PortletMode _getPortletMode(String name) {
48          PortletMode portletMode = _portletModes.get(name);
49  
50          if (portletMode == null) {
51              portletMode = new PortletMode(name);
52          }
53  
54          return portletMode;
55      }
56  
57      private static final String _EDIT = PortletMode.EDIT.toString();
58  
59      private static final String _HELP = PortletMode.HELP.toString();
60  
61      private static final String _VIEW = PortletMode.VIEW.toString();
62  
63      private static final String _ABOUT = LiferayPortletMode.ABOUT.toString();
64  
65      private static final String _CONFIG = LiferayPortletMode.CONFIG.toString();
66  
67      private static final String _EDIT_DEFAULTS =
68          LiferayPortletMode.EDIT_DEFAULTS.toString();
69  
70      private static final String _EDIT_GUEST =
71          LiferayPortletMode.EDIT_GUEST.toString();
72  
73      private static final String _PREVIEW =
74          LiferayPortletMode.PREVIEW.toString();
75  
76      private static final String _PRINT = LiferayPortletMode.PRINT.toString();
77  
78      private static PortletModeFactory _instance = new PortletModeFactory();
79  
80      private Map<String, PortletMode> _portletModes;
81  
82  }