jaxp/src/com/sun/org/apache/xml/internal/utils/URI.java

Print this page

        

@@ -25,10 +25,11 @@
 import java.io.IOException;
 import java.io.Serializable;
 
 import com.sun.org.apache.xml.internal.res.XMLErrorResources;
 import com.sun.org.apache.xml.internal.res.XMLMessages;
+import java.util.Objects;
 
 /**
  * A class to represent a Uniform Resource Identifier (URI). This class
  * is designed to handle the parsing of URIs and provide access to
  * the various components (scheme, host, port, userinfo, path, query

@@ -881,11 +882,11 @@
    * @return the scheme-specific part for this URI
    */
   public String getSchemeSpecificPart()
   {
 
-    StringBuffer schemespec = new StringBuffer();
+    final StringBuilder schemespec = new StringBuilder();
 
     if (m_userinfo != null || m_host != null || m_port != -1)
     {
       schemespec.append("//");
     }

@@ -973,11 +974,11 @@
    */
   public String getPath(boolean p_includeQueryString,
                         boolean p_includeFragment)
   {
 
-    StringBuffer pathString = new StringBuffer(m_path);
+    final StringBuilder pathString = new StringBuilder(m_path);
 
     if (p_includeQueryString && m_queryString != null)
     {
       pathString.append('?');
       pathString.append(m_queryString);

@@ -1339,10 +1340,11 @@
    * @param p_test the Object to test for equality.
    *
    * @return true if p_test is a URI with all values equal to this
    *         URI, false otherwise
    */
+  @Override
   public boolean equals(Object p_test)
   {
 
     if (p_test instanceof URI)
     {

@@ -1361,19 +1363,33 @@
     }
 
     return false;
   }
 
+  @Override
+  public int hashCode() {
+    int hash = 7;
+    hash = 59 * hash + Objects.hashCode(this.m_scheme);
+    hash = 59 * hash + Objects.hashCode(this.m_userinfo);
+    hash = 59 * hash + Objects.hashCode(this.m_host);
+    hash = 59 * hash + this.m_port;
+    hash = 59 * hash + Objects.hashCode(this.m_path);
+    hash = 59 * hash + Objects.hashCode(this.m_queryString);
+    hash = 59 * hash + Objects.hashCode(this.m_fragment);
+    return hash;
+  }
+
   /**
    * Get the URI as a string specification. See RFC 2396 Section 5.2.
    *
    * @return the URI string specification
    */
+  @Override
   public String toString()
   {
 
-    StringBuffer uriSpecString = new StringBuffer();
+    final StringBuilder uriSpecString = new StringBuilder();
 
     if (m_scheme != null)
     {
       uriSpecString.append(m_scheme);
       uriSpecString.append(':');