Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: javax/ide/extension/ElementName.java


1   package javax.ide.extension;
2   
3   /**
4    * Represents a qualified element name in XML. A qualified element name
5    * consists of a namespace URI (which may be null) and a local name.
6    */
7   public final class ElementName 
8   {
9     private final String _namespaceURI;
10    private final String _localName;
11  
12    /**
13     * Constructs an ElementName with the specified namespace URI and local
14     * name.
15     * 
16     * @param namespaceURI the namespace uri of the qualified name. May be null.
17     * @param localName the local name of the qualified name. Must not be null.
18     */
19    public ElementName( String namespaceURI, String localName )
20    {
21      if ( localName == null )
22      {
23        throw new NullPointerException( "null localName" );
24      }
25      _namespaceURI = namespaceURI;
26      _localName = localName;
27    }
28    
29    /**
30     * Get the namespace uri of this element name.
31     * 
32     * @return the namespace uri of this element name.
33     */
34    public String getNamespaceURI()
35    {
36      return _namespaceURI;
37    }
38    
39    /**
40     * The local name of this element name.
41     * 
42     * @return the local name of this element name.
43     */
44    public String getLocalName()
45    {
46      return _localName;
47    }
48    
49    /**
50     * Get a string representation of this element name.
51     * 
52     * @return a string representation of this element name.
53     */
54    public String toString()
55    {
56      return ElementName.class.getName() + "[namespaceURI="+
57        String.valueOf( _namespaceURI ) + ", localName="+
58        _localName + "]";
59    }
60    
61    /**
62     * Get a hashcode for this object.
63     * 
64     * @return a hash code.
65     */
66    public int hashCode()
67    {
68      int hash = 42;
69      if ( _namespaceURI != null )
70      {
71        hash = 37 * hash + _namespaceURI.hashCode();
72      }
73      hash = 37 * hash + _localName.hashCode();
74      
75      return hash;
76    }
77    
78    /**
79     * Get whether this element name equals some other object.
80     * 
81     * @param o another object to compare to this one.
82     * @return true if the objects represent the same element name.
83     */
84    public boolean equals( Object o ) 
85    {
86      if ( o == this )
87      {
88        return true;
89      }
90      if ( !(o instanceof ElementName) )
91      {
92        return false;
93      }
94      ElementName that = (ElementName) o;
95      return _localName.equals( that._localName ) &&
96        ( ( _namespaceURI == null && that._namespaceURI == null ) ||
97          ( _namespaceURI != null && _namespaceURI.equals( that._namespaceURI )));
98    }
99    
100   
101 }