1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 }