1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet;
16  
17  import com.liferay.portal.kernel.language.LanguageUtil;
18  import com.liferay.portal.kernel.util.JavaConstants;
19  import com.liferay.portal.kernel.util.StringPool;
20  
21  import java.util.Enumeration;
22  import java.util.Locale;
23  import java.util.ResourceBundle;
24  
25  /**
26   * <a href="StrutsResourceBundle.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   * @author Eduardo Lundgren
30   */
31  public class StrutsResourceBundle extends ResourceBundle {
32  
33      public StrutsResourceBundle(String portletName, Locale locale) {
34          _portletName = portletName;
35          _locale = locale;
36      }
37  
38      public Enumeration<String> getKeys() {
39          return null;
40      }
41  
42      public Locale getLocale() {
43          return _locale;
44      }
45  
46      protected Object handleGetObject(String key) {
47          if ((key != null) &&
48              (key.equals(JavaConstants.JAVAX_PORTLET_TITLE) ||
49               key.equals(JavaConstants.JAVAX_PORTLET_SHORT_TITLE) ||
50               key.equals(JavaConstants.JAVAX_PORTLET_KEYWORDS) ||
51               key.equals(JavaConstants.JAVAX_PORTLET_DESCRIPTION))) {
52  
53              key = key.concat(StringPool.PERIOD).concat(_portletName);
54          }
55  
56          return LanguageUtil.get(_locale, key);
57      }
58  
59      private String _portletName;
60      private Locale _locale;
61  
62  }