001
014
015 package com.liferay.portlet;
016
017 import com.liferay.portal.kernel.language.LanguageUtil;
018 import com.liferay.portal.kernel.util.JavaConstants;
019 import com.liferay.portal.kernel.util.ResourceBundleThreadLocal;
020 import com.liferay.portal.kernel.util.ResourceBundleUtil;
021 import com.liferay.portal.kernel.util.StringPool;
022
023 import java.util.Enumeration;
024 import java.util.Locale;
025 import java.util.ResourceBundle;
026
027
031 public class StrutsResourceBundle extends ResourceBundle {
032
033 public StrutsResourceBundle(String portletName, Locale locale) {
034 _portletName = portletName;
035 _locale = locale;
036 }
037
038 @Override
039 public Enumeration<String> getKeys() {
040 return null;
041 }
042
043 @Override
044 public Locale getLocale() {
045 return _locale;
046 }
047
048 @Override
049 protected Object handleGetObject(String key) {
050 if (key == null) {
051 throw new NullPointerException();
052 }
053
054 if (key.equals(JavaConstants.JAVAX_PORTLET_DESCRIPTION) ||
055 key.equals(JavaConstants.JAVAX_PORTLET_KEYWORDS) ||
056 key.equals(JavaConstants.JAVAX_PORTLET_LONG_TITLE) ||
057 key.equals(JavaConstants.JAVAX_PORTLET_SHORT_TITLE) ||
058 key.equals(JavaConstants.JAVAX_PORTLET_TITLE)) {
059
060 key = key.concat(StringPool.PERIOD).concat(_portletName);
061 }
062
063 String value = LanguageUtil.get(_locale, key);
064
065 if ((value == null) && ResourceBundleThreadLocal.isReplace()) {
066 value = ResourceBundleUtil.NULL_VALUE;
067 }
068
069 return value;
070 }
071
072 private Locale _locale;
073 private String _portletName;
074
075 }