JcrJSONWriter.java 1.95 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  javax.jcr.Node
 *  javax.jcr.Property
 *  javax.jcr.RepositoryException
 *  javax.jcr.ValueFormatException
 *  org.apache.sling.commons.json.JSONException
 *  org.apache.sling.commons.json.io.JSONWriter
 *  org.apache.sling.commons.json.jcr.JsonItemWriter
 */
package com.adobe.cq.screens.impl;

import java.util.HashSet;
import java.util.Set;
import javax.jcr.Node;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
import javax.jcr.ValueFormatException;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.io.JSONWriter;
import org.apache.sling.commons.json.jcr.JsonItemWriter;

public class JcrJSONWriter
extends JsonItemWriter {
    private final JSONWriter writer;
    private final Set<String> propertyNamesToIgnore;

    public JcrJSONWriter(JSONWriter writer) {
        this(writer, new HashSet<String>());
    }

    public JcrJSONWriter(JSONWriter writer, Set<String> propertyNamesToIgnore) {
        super(propertyNamesToIgnore);
        this.writer = writer;
        this.propertyNamesToIgnore = propertyNamesToIgnore;
    }

    public JcrJSONWriter dump(Node node, int currentRecursionLevel, int maxRecursionLevels) throws RepositoryException, JSONException {
        super.dump(node, this.writer, currentRecursionLevel, maxRecursionLevels);
        return this;
    }

    protected JcrJSONWriter dumpSingleNode(Node n, int currentRecursionLevel, int maxRecursionLevels) throws RepositoryException, JSONException {
        super.dumpSingleNode(n, this.writer, currentRecursionLevel, maxRecursionLevels);
        return this;
    }

    public JcrJSONWriter writeProperty(Property p) throws ValueFormatException, RepositoryException, JSONException {
        super.writeProperty(this.writer, p);
        return this;
    }

    public JcrJSONWriter ignore(String name) {
        this.propertyNamesToIgnore.add(name);
        return this;
    }
}