1
22
23 package com.liferay.util.bridges.jsf.common;
24
25 import com.liferay.portal.kernel.language.LanguageUtil;
26 import com.liferay.portal.kernel.log.Log;
27 import com.liferay.portal.kernel.log.LogFactoryUtil;
28
29 import java.util.Collection;
30 import java.util.Locale;
31 import java.util.Map;
32 import java.util.Set;
33
34 import javax.faces.context.FacesContext;
35
36
46 public class LanguageManagedBean implements Map<String, String> {
47
48 public void clear() {
49 throw new UnsupportedOperationException();
50 }
51
52 public boolean containsKey(Object key) {
53 throw new UnsupportedOperationException();
54 }
55
56 public boolean containsValue(Object value) {
57 throw new UnsupportedOperationException();
58 }
59
60 public boolean isEmpty() {
61 throw new UnsupportedOperationException();
62 }
63
64 public Set<Entry<String, String>> entrySet() {
65 throw new UnsupportedOperationException();
66 }
67
68 public String get(Object key) {
69 String value = null;
70
71 if (key != null) {
72 FacesContext facesContext = FacesContext.getCurrentInstance();
73
74 Locale locale = facesContext.getViewRoot().getLocale();
75
76 if (locale == null) {
77 locale = facesContext.getApplication().getDefaultLocale();
78 }
79
80 value = LanguageUtil.get(locale, key.toString());
81
82 if (_log.isDebugEnabled()) {
83 _log.debug(
84 "{locale=" + locale + ", key=" + key + ", value=" + value);
85 }
86 }
87
88 return value;
89 }
90
91 public Set<String> keySet() {
92 throw new UnsupportedOperationException();
93 }
94
95 public String put(String key, String value) {
96 throw new UnsupportedOperationException();
97 }
98
99 public void putAll(Map<? extends String, ? extends String> map) {
100 throw new UnsupportedOperationException();
101 }
102
103 public String remove(Object key) {
104 throw new UnsupportedOperationException();
105 }
106
107 public int size() {
108 throw new UnsupportedOperationException();
109 }
110
111 public Collection<String> values() {
112 throw new UnsupportedOperationException();
113 }
114
115 private static Log _log = LogFactoryUtil.getLog(LanguageManagedBean.class);
116
117 }