jaxp/src/com/sun/org/apache/xerces/internal/util/URI.java

Print this page

        

@@ -20,10 +20,11 @@
 
 package com.sun.org.apache.xerces.internal.util;
 
 import java.io.IOException;
 import java.io.Serializable;
+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

@@ -1210,11 +1211,11 @@
   * scheme and the first colon). See RFC 2396 Section 5.2 for spec.
   *
   * @return the scheme-specific part for this URI
   */
   public String getSchemeSpecificPart() {
-    StringBuffer schemespec = new StringBuffer();
+    final StringBuilder schemespec = new StringBuilder();
 
     if (m_host != null || m_regAuthority != null) {
       schemespec.append("//");
 
       // Server based authority.

@@ -1295,11 +1296,11 @@
    * Get the authority for this URI.
    *
    * @return the authority
    */
   public String getAuthority() {
-      StringBuffer authority = new StringBuffer();
+      final StringBuilder authority = new StringBuilder();
       if (m_host != null || m_regAuthority != null) {
           authority.append("//");
 
           // Server based authority.
           if (m_host != null) {

@@ -1338,11 +1339,11 @@
   * @return the path for this URI possibly including the query string
   *         and fragment
   */
   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);
     }

@@ -1681,10 +1682,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) {
       URI testURI = (URI) p_test;
       if (((m_scheme == null && testURI.m_scheme == null) ||
            (m_scheme != null && testURI.m_scheme != null &&

@@ -1709,17 +1711,31 @@
       }
     }
     return false;
   }
 
+    @Override
+    public int hashCode() {
+        int hash = 5;
+        hash = 47 * hash + Objects.hashCode(this.m_scheme);
+        hash = 47 * hash + Objects.hashCode(this.m_userinfo);
+        hash = 47 * hash + Objects.hashCode(this.m_host);
+        hash = 47 * hash + this.m_port;
+        hash = 47 * hash + Objects.hashCode(this.m_path);
+        hash = 47 * hash + Objects.hashCode(this.m_queryString);
+        hash = 47 * 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(':');
     }