/ org.htmlparser / src / org / htmlparser / scanners / TagScanner.java
TagScanner.java
 1  // HTMLParser Library $Name: v1_6_20060319 $ - A java-based parser for HTML
 2  // http://sourceforge.org/projects/htmlparser
 3  // Copyright (C) 2003 Somik Raha
 4  //
 5  // Revision Control Information
 6  //
 7  // $Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/scanners/TagScanner.java,v $
 8  // $Author: derrickoswald $
 9  // $Date: 2004/07/02 00:49:28 $
10  // $Revision: 1.54 $
11  //
12  // This library is free software; you can redistribute it and/or
13  // modify it under the terms of the GNU Lesser General Public
14  // License as published by the Free Software Foundation; either
15  // version 2.1 of the License, or (at your option) any later version.
16  //
17  // This library is distributed in the hope that it will be useful,
18  // but WITHOUT ANY WARRANTY; without even the implied warranty of
19  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  // Lesser General Public License for more details.
21  //
22  // You should have received a copy of the GNU Lesser General Public
23  // License along with this library; if not, write to the Free Software
24  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  //
26  
27  package org.htmlparser.scanners;
28  
29  import java.io.Serializable;
30  
31  import org.htmlparser.Tag;
32  import org.htmlparser.lexer.Lexer;
33  import org.htmlparser.util.NodeList;
34  import org.htmlparser.util.ParserException;
35  
36  /**
37   * TagScanner is an abstract superclass, subclassed to create specific scanners.
38   * When asked to scan the tag, this class does nothing other than perform the
39   * tag's semantic action.
40   * Use TagScanner when you have a meta task to do like setting the BASE url for
41   * the page when a BASE tag is encountered.
42   * If you want to match end tags and handle special syntax between tags,
43   * then you'll probably want to subclass {@link CompositeTagScanner} instead.
44   */
45  public class TagScanner
46      implements
47          Scanner,
48          Serializable
49  {
50      /**
51       * Create a (non-composite) tag scanner.
52       */
53      public TagScanner ()
54      {
55      }
56  
57      /**
58       * Scan the tag.
59       * For this implementation, the only operation is to perform the tag's
60       * semantic action.
61       * @param tag The tag to scan.
62       * @param lexer Provides html page access.
63       * @param stack The parse stack. May contain pending tags that enclose
64       * this tag.
65       * @return The resultant tag (may be unchanged).
66       */
67      public Tag scan (Tag tag, Lexer lexer, NodeList stack) throws ParserException
68      {
69          tag.doSemanticAction ();
70  
71          return (tag);
72      }
73  }