1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.util;
21
22 import org.apache.myfaces.tobago.context.ResourceManagerUtils;
23
24 import javax.faces.context.FacesContext;
25 import java.io.Serializable;
26 import java.util.Collection;
27 import java.util.Map;
28 import java.util.Set;
29
30 public class BundleMapWrapper implements Map, Serializable {
31
32 private String basename;
33
34 public BundleMapWrapper(String basename) {
35 this.basename = basename;
36 }
37
38 public void clear() {
39 throw new UnsupportedOperationException();
40 }
41
42 public boolean containsKey(Object key) {
43 if (null == key) {
44 return false;
45 }
46 String value = ResourceManagerUtils.getPropertyNotNull(
47 FacesContext.getCurrentInstance(), basename, key.toString());
48 return value != null;
49 }
50
51 public boolean containsValue(Object value) {
52 throw new UnsupportedOperationException();
53 }
54
55 public Set entrySet() {
56 throw new UnsupportedOperationException();
57 }
58
59 public Object get(Object key) {
60 if (null == key) {
61 return null;
62 }
63 return ResourceManagerUtils.getPropertyNotNull(
64 FacesContext.getCurrentInstance(), basename, key.toString());
65 }
66
67 public int hashCode() {
68 return basename.hashCode();
69 }
70
71 public boolean equals(Object o) {
72 if (this == o) {
73 return true;
74 }
75 if (o == null || getClass() != o.getClass()) {
76 return false;
77 }
78 BundleMapWrapper that = (BundleMapWrapper) o;
79 return basename.equals(that.basename);
80 }
81
82 public boolean isEmpty() {
83 throw new UnsupportedOperationException();
84 }
85
86 public Set keySet() {
87 throw new UnsupportedOperationException();
88 }
89
90 public Object put(Object k, Object v) {
91 throw new UnsupportedOperationException();
92 }
93
94 public void putAll(Map t) {
95 throw new UnsupportedOperationException();
96 }
97
98 public Object remove(Object k) {
99 throw new UnsupportedOperationException();
100 }
101
102 public int size() {
103 throw new UnsupportedOperationException();
104 }
105
106 public Collection values() {
107 throw new UnsupportedOperationException();
108 }
109 }