PageRenderTime 80ms CodeModel.GetById 73ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Java | 76 lines | 42 code | 15 blank | 19 comment | 7 complexity | 175f91f1b698c770a4fd23d108e8c901 MD5 | raw file
 1/*
 2 * HtmlVisitor.java
 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.util.Iterator;
19
20/**
21 * Abstract class implementing Visitor pattern for XmlDocument objects.
22 *
23 * @author Brian Goetz, Quiotix
24 */
25
26public abstract class XmlVisitor {
27    public void visit(XmlDocument.Tag t) {
28    }
29
30    public void visit(XmlDocument.EndTag t) {
31    }
32
33    public void visit(XmlDocument.Comment c) {
34    }
35
36    public void visit(XmlDocument.Text t) {
37    }
38
39    public void visit(XmlDocument.Newline n) {
40    }
41
42    public void visit(XmlDocument.Annotation a) {
43    }
44
45    public void visit(XmlDocument.TagBlock bl) {
46        if (bl == null)
47            return;
48        bl.startTag.accept(this);
49        visit(bl.body);
50        bl.endTag.accept(this);
51    }
52
53    public void visit(XmlDocument.ElementSequence s) {
54        if (s == null)
55            return;
56        for (Iterator iterator = s.iterator(); iterator.hasNext();) {
57            XmlDocument.XmlElement htmlElement = (XmlDocument.XmlElement) iterator.next();
58            htmlElement.accept(this);
59        }
60    }
61
62    public void visit(XmlDocument d) {
63        if (d == null)
64            return;
65        start();
66        visit(d.elements);
67        finish();
68    }
69
70    public void start() {
71    }
72
73    public void finish() {
74    }
75}
76