PacketWriter.java
1.63 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xmp.core.serializer.impl;
import com.adobe.xmp.core.impl.Utils;
import com.adobe.xmp.core.serializer.SerializeOptions;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
class PacketWriter
extends OutputStreamWriter {
private SerializeOptions options;
public PacketWriter(OutputStream out, SerializeOptions options) throws UnsupportedEncodingException {
super(out, options.getEncoding());
this.options = options;
}
public void indent(int times) throws IOException {
StringBuilder bldr = new StringBuilder();
for (int i = this.options.getBaseIndent() + times; i > 0; --i) {
bldr.append(this.options.getIndent());
}
this.write(bldr.toString());
}
public void newline() throws IOException {
this.write(this.options.getNewline());
}
public void fillWithChar(int number, char c) throws IOException {
while (number > 0) {
this.write(c);
--number;
}
}
public void writeAttribute(String attrName, String attrValue) throws IOException {
StringBuilder bldr = new StringBuilder();
bldr.append(attrName);
bldr.append("=\"");
if (attrValue == null) {
attrValue = "";
}
bldr.append(Utils.escapeXML(attrValue, true, true));
bldr.append('\"');
this.write(bldr.toString());
}
public void writeTagBody(String value) throws IOException {
this.write(Utils.escapeXML(value, false, true));
}
}