DurboUtil.java
3.26 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.PropertyType
*/
package com.day.durbo;
import com.day.durbo.DurboInput;
import com.day.durbo.DurboValue;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import javax.jcr.PropertyType;
public class DurboUtil {
private static final String BLANKS = " ";
private static void dump(DurboInput in, PrintWriter out) throws IOException {
DurboInput.Element elem;
String[] nsp;
int indent = 0;
out.println("DurboSer: Version " + in.getVersion());
out.println("Encoding: " + in.getEncoding());
out.println("ContentType: " + in.getContentType());
while ((elem = in.read()) != null) {
if (elem.isProperty()) {
DurboValue[] values;
DurboInput.Property p = (DurboInput.Property)elem;
out.print(" ".substring(0, indent));
out.print(p.name());
String delim = ": ";
for (DurboValue value : values = p.getValues()) {
out.print(delim);
if (p.getType() == 2) {
out.print("<binary, size=" + value.getLength() + ">");
} else {
out.print(value.getString());
}
delim = ", ";
}
out.print(" (");
out.print(PropertyType.nameFromValue((int)p.getType()));
if (p.isMultiple()) {
out.println("[])");
continue;
}
out.println(")");
continue;
}
if (elem.isNodeStart()) {
out.print(" ".substring(0, indent));
out.println(elem.name());
out.print(" ".substring(0, indent += 2));
out.println("{");
continue;
}
if (!elem.isNodeEnd()) continue;
out.print(" ".substring(0, indent));
out.println("}");
indent -= 2;
}
out.println("used namespaces:");
for (String aNsp : nsp = in.getPrefixes()) {
out.println(" " + aNsp + ":" + in.getURI(aNsp));
}
}
public static void main(String[] args) {
try {
FileInputStream in = new FileInputStream(args[0]);
DurboInput din = new DurboInput(in);
DurboUtil.dump(din, new PrintWriter(System.out, true));
in.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}