View Javadoc

1   ////////////////////////////////////////////////////////////////////////////////
2   // MillScript-XML: an Open Spice interpreter and batch website creation tool
3   // Copyright (C) 2005 Kevin Rogers
4   //
5   // This file is part of MillScript-XML.
6   //
7   // MillScript-XML is free software; you can redistribute it and/or modify it under
8   // the terms of the GNU General Public License as published by the Free
9   // Software Foundation; either version 2 of the License, or (at your option)
10  // any later version.
11  //
12  // MillScript-XML is distributed in the hope that it will be useful, but WITHOUT
13  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  // more details.
16  //
17  // You should have received a copy of the GNU General Public License along with
18  // MillScript-XML; if not, write to the Free Software Foundation, Inc., 59 Temple
19  // Place, Suite 330, Boston, MA  02111-1307  USA
20  ////////////////////////////////////////////////////////////////////////////////
21  package org.millscript.commons.xml.tokenizer.wellformed;
22  
23  import org.millscript.commons.xml.api.token.CharDataToken;
24  import org.millscript.commons.xml.api.token.CommentToken;
25  import org.millscript.commons.xml.api.token.DTDToken;
26  import org.millscript.commons.xml.api.token.EmptyElementToken;
27  import org.millscript.commons.xml.api.token.EndTagToken;
28  import org.millscript.commons.xml.api.token.PIToken;
29  import org.millscript.commons.xml.api.token.StartTagToken;
30  import org.millscript.commons.xml.api.token.XmlDeclToken;
31  
32  /**
33   * This class provides a token visitor the for XML declaration part of an XML
34   * document. This is the first token visitor in a chain that provides the well
35   * formedness checks required of an XML processor.
36   */
37  public class XmlDeclTokenVisitor extends AbsTokenVisitor {
38  
39      /**
40       * Constructs a new XML declaration token visitor, with the specified
41       * token visitor.
42       *
43       * @param xt    the well-formed XML tokenizer our tokens come from
44       */
45      public XmlDeclTokenVisitor( final WellFormedXmlTokenizer xt ) {
46          super( xt, new Misc1TokenVisitor( xt ) );
47      }
48  
49      /**
50       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.CharDataToken)
51       */
52      public void visit( final CharDataToken token ) {
53          // not valid in this section, check it in the next one
54          this.wellFormed.tokenVisitor = this.nextTokenVisitor;
55          token.visit( this.nextTokenVisitor );
56      }
57  
58      /**
59       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.CommentToken)
60       */
61      public void visit( final CommentToken token ) {
62          // not valid in this section, check it in the next one
63          this.wellFormed.tokenVisitor = this.nextTokenVisitor;
64          token.visit( this.nextTokenVisitor );
65      }
66  
67      /**
68       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.DTDToken)
69       */
70      public void visit( final DTDToken token ) {
71          // not valid in this section, check it in the next one
72          this.wellFormed.tokenVisitor = this.nextTokenVisitor;
73          token.visit( this.nextTokenVisitor );
74      }
75  
76      /**
77       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.EmptyElementToken)
78       */
79      public void visit( final EmptyElementToken token ) {
80          // not valid in this section, check it in the next one
81          this.wellFormed.tokenVisitor = this.nextTokenVisitor;
82          token.visit( this.nextTokenVisitor );
83      }
84  
85      /**
86       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.EndTagToken)
87       */
88      public void visit( final EndTagToken token ) {
89          // not valid in this section, check it in the next one
90          this.wellFormed.tokenVisitor = this.nextTokenVisitor;
91          token.visit( this.nextTokenVisitor );
92      }
93  
94      /**
95       * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.PIToken)
96       */
97      public void visit( final PIToken token ) {
98          // not valid in this section, check it in the next one
99          this.wellFormed.tokenVisitor = this.nextTokenVisitor;
100         token.visit( this.nextTokenVisitor );
101     }
102 
103     /**
104      * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.StartTagToken)
105      */
106     public void visit( final StartTagToken token ) {
107         // not valid in this section, check it in the next one
108         this.wellFormed.tokenVisitor = this.nextTokenVisitor;
109         token.visit( this.nextTokenVisitor );
110     }
111 
112     /**
113      * @see org.millscript.commons.xml.api.token.TokenVisitor#visit(org.millscript.commons.xml.api.token.XmlDeclToken)
114      */
115     @Override
116     public void visit( final XmlDeclToken token ) {
117         // this token is valid in this section
118         this.wellFormed.nextToken = token;
119     }
120 
121 }