PageRenderTime 81ms CodeModel.GetById 77ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 1ms

/bundles/plugins-trunk/XML/xml/parser/javacc/XmlDumper.java

#
Java | 70 lines | 36 code | 14 blank | 20 comment | 0 complexity | 3444f4ac535784da9b85edf542e93515 MD5 | raw file
 1/*
 2 * XmlDumper.java -- Dumps an HTML document tree. 
 3 * Copyright (C) 1999 Quiotix Corporation.  
 4 *
 5 * This program is free software; you can redistribute it and/or modify
 6 * it under the terms of the GNU General Public License, version 2, as 
 7 * published by the Free Software Foundation.  
 8 *
 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License (http://www.gnu.org/copyleft/gpl.txt)
13 * for more details.
14 */
15
16package xml.parser.javacc;
17
18import java.io.OutputStream;
19import java.io.OutputStreamWriter;
20import java.io.PrintWriter;
21import java.io.UnsupportedEncodingException;
22
23/**
24 * Simple XmlVisitor which dumps out the document to the specified
25 * output stream.
26 *
27 * @author Brian Goetz, Quiotix
28 */
29
30public class XmlDumper extends XmlVisitor {
31    protected PrintWriter out;
32
33    public XmlDumper(OutputStream os) {
34        out = new PrintWriter(os);
35    }
36
37    public XmlDumper(OutputStream os, String encoding)
38            throws UnsupportedEncodingException {
39        out = new PrintWriter(new OutputStreamWriter(os, encoding));
40    }
41
42    public void finish() {
43        out.flush();
44    }
45
46    public void visit(XmlDocument.Tag t) {
47        out.print(t);
48    }
49
50    public void visit(XmlDocument.EndTag t) {
51        out.print(t);
52    }
53
54    public void visit(XmlDocument.Comment c) {
55        out.print(c);
56    }
57
58    public void visit(XmlDocument.Text t) {
59        out.print(t);
60    }
61
62    public void visit(XmlDocument.Newline n) {
63        out.println();
64    }
65
66    public void visit(XmlDocument.Annotation a) {
67        out.print(a);
68    }
69}
70