TidyJsonItemWriter.java
2.55 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
76
77
78
79
80
81
82
83
84
85
86
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.Node
* javax.jcr.NodeIterator
* 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.day.cq.commons;
import com.day.cq.commons.TidyJSONWriter;
import java.io.Writer;
import java.util.Set;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
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 TidyJsonItemWriter
extends JsonItemWriter {
private boolean tidy;
public TidyJsonItemWriter(Set<String> propertyNamesToIgnore) {
super(propertyNamesToIgnore);
}
public boolean isTidy() {
return this.tidy;
}
public void setTidy(boolean tidy) {
this.tidy = tidy;
}
public void dump(Node node, JSONWriter w, int maxRecursionLevels) throws RepositoryException, JSONException {
this.dump(node, w, 0, maxRecursionLevels);
}
public void dump(Node node, Writer w, int maxRecursionLevels) throws RepositoryException, JSONException {
TidyJSONWriter jw = new TidyJSONWriter(w);
jw.setTidy(this.tidy);
this.dump(node, (JSONWriter)jw, 0, maxRecursionLevels);
}
public void dump(NodeIterator it, JSONWriter w) throws RepositoryException, JSONException {
w.array();
while (it.hasNext()) {
this.dumpSingleNode(it.nextNode(), w, 1, 0);
}
w.endArray();
}
public void dump(NodeIterator it, Writer out) throws RepositoryException, JSONException {
TidyJSONWriter w = new TidyJSONWriter(out);
w.setTidy(this.tidy);
w.array();
while (it.hasNext()) {
this.dumpSingleNode(it.nextNode(), (JSONWriter)w, 1, 0);
}
w.endArray();
}
public void dump(Property p, JSONWriter w) throws JSONException, RepositoryException {
w.object();
this.writeProperty(w, p);
w.endObject();
}
public void dump(Property p, Writer w) throws JSONException, ValueFormatException, RepositoryException {
TidyJSONWriter jw = new TidyJSONWriter(w);
jw.setTidy(this.tidy);
jw.object();
this.writeProperty((JSONWriter)jw, p);
jw.endObject();
}
}