| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| HtmlVisitor |
|
| 1.0909090909090908;1.091 |
| 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 | ||
| 16 | package com.quiotix.html.parser; | |
| 17 | ||
| 18 | import java.util.Iterator; | |
| 19 | ||
| 20 | /** | |
| 21 | * Abstract class implementing Visitor pattern for HtmlDocument objects. | |
| 22 | * | |
| 23 | * @author Brian Goetz, Quiotix | |
| 24 | */ | |
| 25 | ||
| 26 | 18 | public abstract class HtmlVisitor { |
| 27 | /** Visit a Tag. */ | |
| 28 | public void visit(HtmlDocument.Tag t) { | |
| 29 | 0 | } |
| 30 | ||
| 31 | /** Visit an EndTag. */ | |
| 32 | public void visit(HtmlDocument.EndTag t) { | |
| 33 | 0 | } |
| 34 | ||
| 35 | /** Visit a Comment. */ | |
| 36 | public void visit(HtmlDocument.Comment c) { | |
| 37 | 0 | } |
| 38 | ||
| 39 | /** Visit Text. */ | |
| 40 | public void visit(HtmlDocument.Text t) { | |
| 41 | 6 | } |
| 42 | ||
| 43 | /** Visit a Newline. */ | |
| 44 | public void visit(HtmlDocument.Newline n) { | |
| 45 | 4 | } |
| 46 | ||
| 47 | /** Visit an Annotation. */ | |
| 48 | public void visit(HtmlDocument.Annotation a) { | |
| 49 | 0 | } |
| 50 | ||
| 51 | /** Visit a TagBlock. */ | |
| 52 | public void visit(HtmlDocument.TagBlock bl) { | |
| 53 | 0 | bl.startTag.accept(this); |
| 54 | 0 | visit(bl.body); |
| 55 | 0 | bl.endTag.accept(this); |
| 56 | 0 | } |
| 57 | ||
| 58 | /** Visit an ElementSequence. */ | |
| 59 | public void visit(HtmlDocument.ElementSequence s) { | |
| 60 | 10 | for (Iterator iterator = s.iterator(); iterator.hasNext();) { |
| 61 | 90 | HtmlDocument.HtmlElement htmlElement = (HtmlDocument.HtmlElement) iterator.next(); |
| 62 | 90 | htmlElement.accept(this); |
| 63 | 90 | } |
| 64 | 10 | } |
| 65 | ||
| 66 | /** Visit an HtmlDocument. */ | |
| 67 | public void visit(HtmlDocument d) { | |
| 68 | 14 | start(); |
| 69 | 14 | visit(d.elements); |
| 70 | 14 | finish(); |
| 71 | 14 | } |
| 72 | ||
| 73 | ||
| 74 | /** Start. */ | |
| 75 | public void start() { | |
| 76 | 6 | } |
| 77 | ||
| 78 | /** Finish. */ | |
| 79 | public void finish() { | |
| 80 | 8 | } |
| 81 | } | |
| 82 |