001
014
015 package com.liferay.util.bridges.jsf.common;
016
017 import com.liferay.portal.kernel.language.LanguageUtil;
018 import com.liferay.portal.kernel.log.Log;
019 import com.liferay.portal.kernel.log.LogFactoryUtil;
020
021 import java.util.Collection;
022 import java.util.Locale;
023 import java.util.Map;
024 import java.util.Set;
025
026 import javax.faces.context.FacesContext;
027
028
036 public class LanguageManagedBean implements Map<String, String> {
037
038 public void clear() {
039 throw new UnsupportedOperationException();
040 }
041
042 public boolean containsKey(Object key) {
043 throw new UnsupportedOperationException();
044 }
045
046 public boolean containsValue(Object value) {
047 throw new UnsupportedOperationException();
048 }
049
050 public boolean isEmpty() {
051 throw new UnsupportedOperationException();
052 }
053
054 public Set<Entry<String, String>> entrySet() {
055 throw new UnsupportedOperationException();
056 }
057
058 public String get(Object key) {
059 String value = null;
060
061 if (key != null) {
062 FacesContext facesContext = FacesContext.getCurrentInstance();
063
064 Locale locale = facesContext.getViewRoot().getLocale();
065
066 if (locale == null) {
067 locale = facesContext.getApplication().getDefaultLocale();
068 }
069
070 value = LanguageUtil.get(locale, key.toString());
071
072 if (_log.isDebugEnabled()) {
073 _log.debug(
074 "{locale=" + locale + ", key=" + key + ", value=" + value);
075 }
076 }
077
078 return value;
079 }
080
081 public Set<String> keySet() {
082 throw new UnsupportedOperationException();
083 }
084
085 public String put(String key, String value) {
086 throw new UnsupportedOperationException();
087 }
088
089 public void putAll(Map<? extends String, ? extends String> map) {
090 throw new UnsupportedOperationException();
091 }
092
093 public String remove(Object key) {
094 throw new UnsupportedOperationException();
095 }
096
097 public int size() {
098 throw new UnsupportedOperationException();
099 }
100
101 public Collection<String> values() {
102 throw new UnsupportedOperationException();
103 }
104
105 private static Log _log = LogFactoryUtil.getLog(LanguageManagedBean.class);
106
107 }