SAXRecorder.java
1.16 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
/*
* Decompiled with CFR 0_118.
*/
package com.day.cq.rewriter.xml.helpers;
import com.day.cq.rewriter.xml.helpers.NOPRecorder;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
public final class SAXRecorder
extends NOPRecorder {
private StringBuffer buffer = new StringBuffer();
@Override
public void characters(char[] ary, int start, int length) {
this.buffer.append(ary, start, length);
}
@Override
public void endElement(String namespace, String name, String raw) throws SAXException {
this.buffer.append("</").append(raw).append('>');
}
@Override
public void startElement(String namespace, String name, String raw, Attributes attr) throws SAXException {
this.buffer.append('<').append(raw);
for (int i = 0; i < attr.getLength(); ++i) {
this.buffer.append(' ');
this.buffer.append(attr.getLocalName(i));
this.buffer.append("=\"");
this.buffer.append(attr.getValue(i));
this.buffer.append('\"');
}
this.buffer.append('>');
}
public String getText() {
return this.buffer.toString().trim();
}
}