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

Print this page

        

@@ -21,11 +21,11 @@
  * $Id: URI.java,v 1.1.4.1 2005/09/08 11:03:20 suresh_emailid Exp $
  */
 package com.sun.org.apache.xml.internal.serializer.utils;
 
 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

@@ -861,11 +861,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("//");
     }

@@ -953,11 +953,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);

@@ -1319,10 +1319,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)
     {

@@ -1341,19 +1342,33 @@
     }
 
     return false;
   }
 
+  @Override
+  public int hashCode() {
+    int hash = 5;
+    hash = 41 * hash + Objects.hashCode(this.m_scheme);
+    hash = 41 * hash + Objects.hashCode(this.m_userinfo);
+    hash = 41 * hash + Objects.hashCode(this.m_host);
+    hash = 41 * hash + this.m_port;
+    hash = 41 * hash + Objects.hashCode(this.m_path);
+    hash = 41 * hash + Objects.hashCode(this.m_queryString);
+    hash = 41 * 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(':');

@@ -1541,11 +1556,11 @@
   /**
    * Determine whether a character is a hexadecimal character.
    *
    *
    * @param p_char the character to check
-   * @return true if the char is betweeen '0' and '9', 'a' and 'f'
+   * @return true if the char is between '0' and '9', 'a' and 'f'
    *         or 'A' and 'F', false otherwise
    */
   private static boolean isHex(char p_char)
   {
     return (isDigit(p_char) || (p_char >= 'a' && p_char <= 'f')