SAXWriterFactory.java
3.43 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
87
88
89
90
91
92
93
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.Service
* org.apache.sling.rewriter.ProcessingComponentConfiguration
* org.apache.sling.rewriter.ProcessingContext
* org.apache.sling.rewriter.Serializer
* org.apache.sling.rewriter.SerializerFactory
*/
package com.day.cq.rewriter.processor.impl;
import com.day.cq.rewriter.htmlparser.SAXWriter;
import com.day.cq.rewriter.processor.ProcessingComponentConfiguration;
import com.day.cq.rewriter.processor.ProcessingContext;
import com.day.cq.rewriter.processor.impl.ProcessingComponentConfigurationWrapper;
import com.day.cq.rewriter.processor.impl.ProcessingContextWrapper;
import java.io.IOException;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.rewriter.Serializer;
import org.apache.sling.rewriter.SerializerFactory;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
@Component
@Service(value={SerializerFactory.class})
@Property(name="pipeline.type", value={"htmlwriter"})
public class SAXWriterFactory
implements SerializerFactory {
public Serializer createSerializer() {
final SAXWriter writer = new SAXWriter();
return new Serializer(){
public void setDocumentLocator(Locator locator) {
writer.setDocumentLocator(locator);
}
public void startDocument() throws SAXException {
writer.startDocument();
}
public void endDocument() throws SAXException {
writer.endDocument();
}
public void startPrefixMapping(String prefix, String uri) throws SAXException {
writer.startPrefixMapping(prefix, uri);
}
public void endPrefixMapping(String prefix) throws SAXException {
writer.endPrefixMapping(prefix);
}
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
writer.startElement(uri, localName, qName, atts);
}
public void endElement(String uri, String localName, String qName) throws SAXException {
writer.endElement(uri, localName, qName);
}
public void characters(char[] ch, int start, int length) throws SAXException {
writer.characters(ch, start, length);
}
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
writer.ignorableWhitespace(ch, start, length);
}
public void processingInstruction(String target, String data) throws SAXException {
writer.processingInstruction(target, data);
}
public void skippedEntity(String name) throws SAXException {
writer.skippedEntity(name);
}
public void init(org.apache.sling.rewriter.ProcessingContext context, org.apache.sling.rewriter.ProcessingComponentConfiguration config) throws IOException {
writer.init(new ProcessingContextWrapper(context), new ProcessingComponentConfigurationWrapper(config));
}
public void dispose() {
}
};
}
}