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.api;
22  
23  /**
24   * This interface represents a name in the XML document.
25   */
26  public interface Name {
27  
28      /**
29       * The namespace for the <b>xml</b> prefix.
30       */
31      String XML = "http://www.w3.org/XML/1998/namespace";
32  
33      /**
34       * The namespace for the <b>xmlns</b> prefix.
35       */
36      String XMLNS = "http://www.w3.org/2000/xmlns/";
37  
38      /**
39       * Returns <code>true</code> if the specified object is equal to this name.
40       * A Name is equal to any other Name if they have the same namespace and
41       * local name, ignoring any prefix.
42       * <p>
43       * The reasons behind ignoring the prefix derive from the Namespaces in XML
44       * specification, in which the prefix is ignored when comparing qualified
45       * names.
46       * </p>
47       *
48       * @param obj   the object to compare for equality with this name
49       * @return  <code>true</code> if the specified object is equal to this name
50       */
51      boolean equals( Object obj );
52  
53      /**
54       * Returns the local part of this name.
55       *
56       * @return  a <code>String</code> for the local part of this name
57       */
58      String getLocalName();
59  
60      /**
61       * Returns the namespace this name belongs to.
62       *
63       * @return  a <code>String</code> for the namespace this name belongs to
64       */
65      String getNamespace();
66  
67      /**
68       * Returns the prefix part of this name.
69       *
70       * @return  a <code>String</code> for the prefix part of this name
71       */
72      String getPrefix();
73  
74      /**
75       * Returns the qualified name.
76       *
77       * @return  a <code>String</code> for the qualified name
78       */
79      String getQName();
80  
81      /**
82       * Returns the hash code for this name. The hash code of a name is
83       * constructed from the namespace and local name, ignoring any prefix. As
84       * such the hash code a name is defined to be:
85       * <p>
86       * <code>
87       * int result = 37;
88       * result += 37 * result + this.getNamespace().hashCode();
89       * result += 37 * result + this.getLocalName().hashCode();
90       * return result;
91       * </code>
92       * </p>
93       * <p>
94       * The reasons behind ignoring the prefix derive from the Namespaces in XML
95       * specification, in which the prefix is ignored when comparing qualified
96       * names.
97       * </p>
98       *
99       * @return
100      */
101     int hashCode();
102 
103 }