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