1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.quiotix.html.parser;
17
18 import java.io.OutputStream;
19 import java.io.OutputStreamWriter;
20 import java.io.PrintWriter;
21 import java.io.UnsupportedEncodingException;
22
23
24
25
26
27
28
29
30 public class HtmlDumper extends HtmlVisitor {
31 protected PrintWriter out;
32
33
34 public HtmlDumper(OutputStream os) {
35 out = new PrintWriter(os);
36 }
37
38
39 public HtmlDumper(OutputStream os, String encoding)
40 throws UnsupportedEncodingException {
41 out = new PrintWriter(new OutputStreamWriter(os, encoding));
42 }
43
44 public void finish() {
45 out.flush();
46 }
47
48 public void visit(HtmlDocument.Tag t) {
49 out.print(t);
50 }
51
52 public void visit(HtmlDocument.EndTag t) {
53 out.print(t);
54 }
55
56 public void visit(HtmlDocument.Comment c) {
57 out.print(c);
58 }
59
60 public void visit(HtmlDocument.Text t) {
61 out.print(t);
62 }
63
64 public void visit(HtmlDocument.Newline n) {
65 out.println();
66 }
67
68 public void visit(HtmlDocument.Annotation a) {
69 out.print(a);
70 }
71 }
72