1
22
23 package com.liferay.util.bridges.jsf.common;
24
25 import com.liferay.portal.kernel.language.LanguageUtil;
26
27 import java.util.Collection;
28 import java.util.Locale;
29 import java.util.Map;
30 import java.util.Set;
31
32 import javax.faces.context.FacesContext;
33
34 import org.apache.commons.logging.Log;
35 import org.apache.commons.logging.LogFactory;
36
37
48 public class LanguageManagedBean implements Map {
49
50 public LanguageManagedBean() {
51
52
54 FacesContext facesContext = FacesContext.getCurrentInstance();
55
56 _companyId = JSFPortletUtil.getCompanyId(facesContext);
57
58 if (_companyId == 0) {
59 _log.error("Unable to determine company id from facesContext");
60 }
61 }
62
63 public void clear() {
64 throw new UnsupportedOperationException();
65 }
66
67 public boolean containsKey(Object key) {
68 throw new UnsupportedOperationException();
69 }
70
71 public boolean containsValue(Object value) {
72 throw new UnsupportedOperationException();
73 }
74
75 public boolean isEmpty() {
76 throw new UnsupportedOperationException();
77 }
78
79 public Set entrySet() {
80 throw new UnsupportedOperationException();
81 }
82
83 public Object get(Object key) {
84 Object value = null;
85
86 if (key != null) {
87 FacesContext facesContext = FacesContext.getCurrentInstance();
88
89 Locale locale = facesContext.getViewRoot().getLocale();
90
91 if (locale == null) {
92 locale = facesContext.getApplication().getDefaultLocale();
93 }
94
95 value = LanguageUtil.get(_companyId, locale, key.toString());
96
97 if (_log.isDebugEnabled()) {
98 _log.debug(
99 "{companyId=" + _companyId + ", locale=" + locale +
100 ", key=" + key + ", value=" + value);
101 }
102 }
103
104 return value;
105 }
106
107 public Set keySet() {
108 throw new UnsupportedOperationException();
109 }
110
111 public Object put(Object key, Object value) {
112 throw new UnsupportedOperationException();
113 }
114
115 public void putAll(Map map) {
116 throw new UnsupportedOperationException();
117 }
118
119 public Object remove(Object key) {
120 throw new UnsupportedOperationException();
121 }
122
123 public int size() {
124 throw new UnsupportedOperationException();
125 }
126
127 public Collection values() {
128 throw new UnsupportedOperationException();
129 }
130
131 private static Log _log = LogFactory.getLog(LanguageManagedBean.class);
132
133 private long _companyId = 0;
134
135 }