ModifiableMappedValueMapDecorator.java
2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.sling.api.resource.ValueMap
* org.apache.sling.api.wrappers.ModifiableValueMapDecorator
*/
package com.adobe.granite.rest.utils;
import java.util.AbstractMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.api.wrappers.ModifiableValueMapDecorator;
public class ModifiableMappedValueMapDecorator
extends ModifiableValueMapDecorator {
public ModifiableMappedValueMapDecorator(Map<String, Object> base) {
super(base);
}
public ModifiableMappedValueMapDecorator(ValueMap base) {
super((Map)base);
}
public Object get(Object key) {
return super.get((Object)ModifiableMappedValueMapDecorator.unmapProperty((String)key));
}
public Object put(String key, Object value) {
return super.put(ModifiableMappedValueMapDecorator.unmapProperty(key), value);
}
public void putAll(Map<? extends String, ?> t) {
for (String key : t.keySet()) {
this.put(key, t.get(key));
}
}
public boolean containsKey(Object key) {
return super.containsKey((Object)ModifiableMappedValueMapDecorator.unmapProperty((String)key));
}
public Set<String> keySet() {
HashSet<String> mapped = new HashSet<String>();
for (String key : super.keySet()) {
mapped.add(ModifiableMappedValueMapDecorator.mapProperty(key));
}
return mapped;
}
public Set<Map.Entry<String, Object>> entrySet() {
HashSet<Map.Entry<String, Object>> set = new HashSet<Map.Entry<String, Object>>();
for (Map.Entry e : super.entrySet()) {
set.add(new AbstractMap.SimpleEntry(ModifiableMappedValueMapDecorator.mapProperty((String)e.getKey()), e.getValue()));
}
return set;
}
public static String mapProperty(String unmappedName) {
if (unmappedName.matches("^jcr:(title|description|language)$")) {
return unmappedName.replaceFirst("jcr:", "dc:");
}
return unmappedName;
}
public static String unmapProperty(String mappedName) {
if (mappedName.matches("^dc:(title|description|language)$")) {
return mappedName.replaceFirst("dc:", "jcr:");
}
return mappedName;
}
}