NormalizedResource.java 1.56 KB
/*
 * 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();
    }
}