NormalizedResource.java
1.56 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.Node
* org.apache.commons.lang.builder.ToStringBuilder
* org.apache.sling.api.resource.Resource
* org.apache.sling.api.resource.ValueMap
*/
package com.day.cq.mcm.util;
import javax.jcr.Node;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
public class NormalizedResource {
private Resource resource;
private Resource contentResource;
public void setResource(Resource resource) {
if (resource != null && resource.getChild("jcr:content") != null) {
this.resource = resource;
this.contentResource = resource.getChild("jcr:content");
} else if (resource != null && "jcr:content".equals(resource.getName())) {
this.resource = resource.getParent();
this.contentResource = resource;
}
}
public Resource getResource() {
return this.resource;
}
public ValueMap getContentVals() {
if (this.contentResource != null) {
return (ValueMap)this.contentResource.adaptTo(ValueMap.class);
}
return null;
}
public Node getContentNode() {
return (Node)this.contentResource.adaptTo(Node.class);
}
public String toString() {
return new ToStringBuilder((Object)this).append("resource", (Object)this.getResource()).append("contentVals", (Object)this.getContentVals()).append("contentNode", (Object)this.getContentNode()).toString();
}
}