1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.universAAL.middleware.rdf;
21
22 import java.util.ArrayList;
23 import java.util.Enumeration;
24 import java.util.Hashtable;
25 import java.util.List;
26
27 import org.universAAL.middleware.container.utils.LogUtils;
28 import org.universAAL.middleware.datarep.SharedResources;
29
30
31
32
33
34
35 public final class UnmodifiableResource extends Resource {
36
37 private Resource res;
38
39 public UnmodifiableResource(Resource r) {
40 res = r;
41 }
42
43
44
45
46
47
48
49
50
51
52
53
54 public static Object getUnmodifiable(Object o) {
55 if (o instanceof Resource)
56 return new UnmodifiableResource((Resource) o);
57 else if (o instanceof List)
58 return new UnmodifiableResourceList((List) o);
59
60 return o;
61 }
62
63
64 public boolean changeProperty(String propURI, Object value) {
65 LogUtils.logDebug(SharedResources.moduleContext,
66 UnmodifiableResource.class, "changeProperty",
67 new String[] { "Can not change an unmodifiable resource." },
68 null);
69 return false;
70 }
71
72
73 public final Object getProperty(String propURI) {
74 Object o = res.getProperty(propURI);
75 return getUnmodifiable(o);
76 }
77
78
79 public boolean setProperty(String propURI, Object value) {
80 LogUtils.logDebug(SharedResources.moduleContext,
81 UnmodifiableResource.class, "setProperty",
82 new String[] { "Can not change an unmodifiable resource." },
83 null);
84 return false;
85 }
86
87
88
89
90
91 public boolean setPropertyPath(String[] propPath, Object value,
92 boolean force) {
93 LogUtils.logDebug(SharedResources.moduleContext,
94 UnmodifiableResource.class, "setPropertyPath",
95 new String[] { "Can not change an unmodifiable resource." },
96 null);
97 return false;
98 }
99
100
101
102
103
104 public boolean setPropertyPath(String[] propPath, Object value) {
105 LogUtils.logDebug(SharedResources.moduleContext,
106 UnmodifiableResource.class, "setPropertyPath",
107 new String[] { "Can not change an unmodifiable resource." },
108 null);
109 return false;
110 }
111
112
113
114
115
116 public boolean setPropertyPathFromOffset(String[] propPath, int fromIndex,
117 Object value, boolean force) {
118 LogUtils.logDebug(SharedResources.moduleContext,
119 UnmodifiableResource.class, "setPropertyPathFromOffset",
120 new String[] { "Can not change an unmodifiable resource." },
121 null);
122 return false;
123 }
124
125 public List asList() {
126 return new UnmodifiableResourceList(res.asList());
127 }
128
129 public void asList(List l) {
130 ArrayList l2 = new ArrayList();
131 res.asList(l2);
132 for (int i = 0; i < l2.size(); i++) {
133 Object o = l2.get(i);
134 l.add(getUnmodifiable(o));
135 }
136 }
137
138 public Resource copy(boolean isXMLLitera) {
139 return new UnmodifiableResource(res.copy(isXMLLitera));
140 }
141
142 public Resource deepCopy() {
143 return res.deepCopy();
144 }
145
146 public boolean equals(Object other) {
147 if (this == other)
148 return true;
149 if (getURI().equals(((Resource) other).getURI()))
150 return true;
151 return res.equals(other);
152 }
153
154 public String getOrConstructLabel(String type) {
155 return res.getOrConstructLabel(type);
156 }
157
158 public int getPropSerializationType(String propURI) {
159 return res.getPropSerializationType(propURI);
160 }
161
162 public String getResourceComment() {
163 return res.getResourceComment();
164 }
165
166 public String getResourceLabel() {
167 return res.getResourceLabel();
168 }
169
170 public Object getStaticFieldValue(String fieldName, Object defaultValue) {
171
172 return res.getStaticFieldValue(fieldName, defaultValue);
173 }
174
175 public int hashCode() {
176 return res.hashCode();
177 }
178
179 public boolean hasProperty(String propURI) {
180 return res.hasProperty(propURI);
181 }
182
183 public boolean isClosedCollection(String propURI) {
184 return res.isClosedCollection(propURI);
185 }
186
187 public boolean isWellFormed() {
188 return res.isWellFormed();
189 }
190
191 public boolean representsQualifiedURI() {
192 return res.representsQualifiedURI();
193 }
194
195 public boolean serializesAsXMLLiteral() {
196 return res.serializesAsXMLLiteral();
197 }
198
199 public void setResourceComment(String comment) {
200 }
201
202 public void setResourceLabel(String label) {
203 }
204
205 public String toString() {
206 return res.toString();
207 }
208
209 public String toStringRecursive() {
210 return res.toStringRecursive();
211 }
212
213 public String toStringRecursive(String prefix, boolean prefixAtStart,
214 Hashtable visitedElements) {
215 return res.toStringRecursive(prefix, prefixAtStart, visitedElements);
216 }
217
218 public int numberOfProperties() {
219 return res.numberOfProperties();
220 }
221
222
223 public boolean isAnon() {
224 return res.isAnon();
225 }
226
227
228 public final boolean hasQualifiedName() {
229 return res.hasQualifiedName();
230 }
231
232
233 public final String getURI() {
234 return res.getURI();
235 }
236
237
238 public final Enumeration getPropertyURIs() {
239 return res.getPropertyURIs();
240 }
241
242
243 public final boolean addType(String typeURI, boolean blockFurtherTypes) {
244 return false;
245 }
246
247
248 public final String getLocalName() {
249 return res.getLocalName();
250 }
251
252
253 public final String getNamespace() {
254 return res.getNamespace();
255 }
256
257
258 public final String getType() {
259 return res.getType();
260 }
261
262
263 public final String[] getTypes() {
264 return res.getTypes();
265 }
266
267 public final Class getClassOfUnmodifiable() {
268 return res.getClass();
269 }
270
271 public final boolean instanceOf(Class c) {
272 return c.isAssignableFrom(res.getClass());
273 }
274 }