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;
22  
23  /**
24   * This class provides a base for tokenizing XML names, depending on whether
25   * namespaces are supported by the application or not.
26   */
27  public abstract class NameTokenizer {
28  
29      /**
30       * The tokenizer we can use to fetch tokens that make up the name.
31       */
32      final AbstractXmlTokenizerImpl xmlTokenizer;
33  
34      /**
35       * Constructs a new name tokenizer to tokenize a name from the specified
36       * tokenizer.
37       *
38       * @param xt    the tokenizer to tokenize a name from
39       */
40      public NameTokenizer( final AbstractXmlTokenizerImpl xt ) {
41          this.xmlTokenizer = xt;
42      }
43  
44      /**
45       * Returns a name for an attribute, read from the underlying tokenizer.
46       * This method is provided for reading an attribute name and nothing else,
47       * as it only allows qualified names to have a namespace.
48       *
49       * @return  a <code>ProtoName</code> for the attribute, read from the
50       * underlying tokenizer
51       */
52      public abstract AbstractName readAttributeName();
53  
54      /**
55       * Returns a name for a tag, read from the underlying tokenizer. This
56       * method is provided for reading a tag name and nothing else, as it allows
57       * tag names to use the default namespace declaration.
58       *
59       * @return  a <code>ProtoName</code> for the tag, read from the underlying
60       * tokenizer
61       */
62      public abstract AbstractName readTagName();
63  
64  }