You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@ws.apache.org by sn...@apache.org on 2002/11/18 18:36:37 UTC

cvs commit: xml-soap/java/src/org/apache/soap/util/xml QName.java

snichol     2002/11/18 09:36:37

  Modified:    java/src/org/apache/soap/util/xml QName.java
  Log:
  Submitted by: Pavel Ausianik <Pa...@epam.com>
  
  QName changed so it not uses intern() in equals() because the
  number of calls per  object instance was small.
  
  Scott Nichol added javadoc and other comments.
  
  Revision  Changes    Path
  1.9       +44 -6     xml-soap/java/src/org/apache/soap/util/xml/QName.java
  
  Index: QName.java
  ===================================================================
  RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/util/xml/QName.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- QName.java	30 Oct 2002 14:33:02 -0000	1.8
  +++ QName.java	18 Nov 2002 17:36:37 -0000	1.9
  @@ -70,11 +70,19 @@
     private String namespaceURI;
     private String localPart;
   
  +  /**
  +   * No args constructor for use as bean.
  +   */
     public QName()
     {
  -    // no args constructor for use as bean
     }
   
  +  /**
  +   * Constructor that initializes from a Node.
  +   *
  +   * @param The node from which to initialize.
  +   * @exception IllegalArgumentException If the node has no namespace or local part.
  +   */
     public QName(Node node) throws IllegalArgumentException
     {
       String namespaceURI = node.getNamespaceURI();
  @@ -97,44 +105,71 @@
       setLocalPart(localPart);
     }
   
  +  /**
  +   * Constructor that initializes from a local part and URI.
  +   *
  +   * @param namespaceURI The URI for the namespace.
  +   * @param localPart The local part for the element name.
  +   */
     public QName(String namespaceURI, String localPart)
     {
       setNamespaceURI(namespaceURI);
       setLocalPart(localPart);
     }
  -  
  +
  +  /**
  +   * Sets the URI for the namespace.
  +   */  
     public void setNamespaceURI(String namespaceURI)
     {
  -    this.namespaceURI = (namespaceURI == null ? "" : namespaceURI).intern();
  +    this.namespaceURI = (namespaceURI == null ? "" : namespaceURI);
     }
   
  +  /**
  +   * Gets the URI for the namespace.
  +   */
     public String getNamespaceURI()
     {
       return namespaceURI;
     }
   
  +  /**
  +   * Sets the local part for the name.
  +   */
     public void setLocalPart(String localPart)
     {
  -    this.localPart = (localPart == null ? "" : localPart).intern();
  +    this.localPart = (localPart == null ? "" : localPart);
     }
   
  +  /**
  +   * Gets the local part for the name.
  +   */
     public String getLocalPart()
     {
       return localPart;
     }
   
  +  /**
  +   * Gets the hash code.
  +   */
     public int hashCode()
     {
       return namespaceURI.hashCode() + localPart.hashCode();
     }
   
  +  /**
  +   * Gets whether this instance is equal to another.
  +   */
     public boolean equals(Object obj)
     {
       return (obj != null
  -            && namespaceURI == ((QName)obj).getNamespaceURI()
  -            && localPart == ((QName)obj).getLocalPart());
  +            && namespaceURI.equals(((QName)obj).getNamespaceURI())
  +            && localPart.equals(((QName)obj).getLocalPart()));
     }
   
  +  /**
  +   * Gets whether this node matches another.
  +   */
     public boolean matches(Node node)
     {
       return (node != null
  @@ -142,6 +177,9 @@
               && localPart.equals(node.getLocalName()));
     }
   
  +  /**
  +   * Gets a string representation of this instance.
  +   */
     public String toString()
     {
       return new StringBuffer(namespaceURI.length() + 1 + localPart.length())