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 Set<Entry<String, String>> entrySet() {
051 throw new UnsupportedOperationException();
052 }
053
054 public String get(Object key) {
055 String value = null;
056
057 if (key != null) {
058 FacesContext facesContext = FacesContext.getCurrentInstance();
059
060 Locale locale = facesContext.getViewRoot().getLocale();
061
062 if (locale == null) {
063 locale = facesContext.getApplication().getDefaultLocale();
064 }
065
066 value = LanguageUtil.get(locale, key.toString());
067
068 if (_log.isDebugEnabled()) {
069 _log.debug(
070 "{locale=" + locale + ", key=" + key + ", value=" + value);
071 }
072 }
073
074 return value;
075 }
076
077 public boolean isEmpty() {
078 throw new UnsupportedOperationException();
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 }