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  import org.millscript.commons.alert.Alert;
24  import org.millscript.commons.util.IMap;
25  
26  /**
27   * This class provides a <code>Name</code> implementation for use when
28   * documents are processed wihtout namespace support.
29   */
30  public class NoNamespacesName extends AbstractName {
31  
32      /**
33       * This is the ID from the release 0.3.0 for future compatibility.
34       */
35      private static final long serialVersionUID = 7762757201196265287L;
36  
37      /**
38       * The full name.
39       */
40      private final String name;
41  
42      /**
43       * Constructs a new no namespace name, with the specified element name.
44       *
45       * @param n the name
46       */
47      public NoNamespacesName( final String n ) {
48          // If the following changes such that name could be null, the equals
49          // and hashCode methods will need updating.
50          if ( n == null ) {
51              throw new NullPointerException( "name cannot be null" );
52          }
53          this.name = n;
54      }
55  
56      /**
57       * @see org.millscript.commons.alert.AlertDecorator#decorate(org.millscript.commons.alert.Alert)
58       */
59      public Alert decorate( final Alert alert ) {
60          return alert.culprit( "xml name", this.getQName() );
61      }
62  
63      /**
64       * @see org.millscript.commons.xml.api.Name#getLocalName()
65       */
66      public String getLocalName() {
67          return this.name;
68      }
69  
70      /**
71       * @see org.millscript.commons.xml.api.Name#getNamespace()
72       */
73      public String getNamespace() {
74          return "";
75      }
76  
77      /**
78       * @see org.millscript.commons.xml.api.Name#getPrefix()
79       */
80      public String getPrefix() {
81          return "";
82      }
83  
84      /**
85       * @see org.millscript.commons.xml.api.Name#getQName()
86       */
87      public String getQName() {
88          return this.name;
89      }
90  
91      /**
92       * @see org.millscript.commons.xml.tokenizer.ProtoName#setNamespace(IMap)
93       */
94      @Override
95      public AbstractName setNamespace( final IMap< String, String > scope ) {
96          return this;
97      }
98  
99      /**
100      * @see java.lang.Object#toString()
101      */
102     @Override
103     public String toString() {
104         return this.name;
105     }
106 
107 }