/// <summary> /// Provides the default hash calculation. May be overidden by handlers for /// other protocols that have different requirements for hashCode /// calculation. </summary> /// <param name="u"> a URL object </param> /// <returns> an {@code int} suitable for hash table indexing /// @since 1.3 </returns> protected internal virtual int HashCode(URL u) { int h = 0; // Generate the protocol part. String protocol = u.Protocol; if (protocol != null) { h += protocol.HashCode(); } // Generate the host part. InetAddress addr = GetHostAddress(u); if (addr != null) { h += addr.HashCode(); } else { String host = u.Host; if (host != null) { h += host.ToLowerCase().HashCode(); } } // Generate the file part. String file = u.File; if (file != null) { h += file.HashCode(); } // Generate the port part. if (u.Port == -1) { h += DefaultPort; } else { h += u.Port; } // Generate the ref part. String @ref = u.Ref; if (@ref != null) { h += @ref.HashCode(); } return(h); }
public override sealed int HashCode() { if (Addr != null) { return(Addr.HashCode() + Port_Renamed); } if (Hostname != null) { return(Hostname.ToLowerCase().HashCode() + Port_Renamed); } return(Port_Renamed); }