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_TITLE) ||
055 key.equals(JavaConstants.JAVAX_PORTLET_SHORT_TITLE) ||
056 key.equals(JavaConstants.JAVAX_PORTLET_KEYWORDS) ||
057 key.equals(JavaConstants.JAVAX_PORTLET_DESCRIPTION))) {
058
059 key = key.concat(StringPool.PERIOD).concat(_portletName);
060 }
061
062 String value = LanguageUtil.get(_locale, key);
063
064 if ((value == null) && ResourceBundleThreadLocal.isReplace()) {
065 value = ResourceBundleUtil.NULL_VALUE;
066 }
067
068 return value;
069 }
070
071 private String _portletName;
072 private Locale _locale;
073
074 }