src/share/classes/java/net/InetSocketAddress.java

Print this page




 372      * This String is constructed by calling toString() on the InetAddress
 373      * and concatenating the port number (with a colon). If the address
 374      * is unresolved then the part before the colon will only contain the hostname.
 375      *
 376      * @return  a string representation of this object.
 377      */
 378     @Override
 379     public String toString() {
 380         return holder.toString();
 381     }
 382 
 383     /**
 384      * Compares this object against the specified object.
 385      * The result is <code>true</code> if and only if the argument is
 386      * not <code>null</code> and it represents the same address as
 387      * this object.
 388      * <p>
 389      * Two instances of <code>InetSocketAddress</code> represent the same
 390      * address if both the InetAddresses (or hostnames if it is unresolved) and port
 391      * numbers are equal.
 392      * If both addresses are unresolved, then the hostname & the port number
 393      * are compared.
 394      *
 395      * Note: Hostnames are case insensitive. e.g. "FooBar" and "foobar" are
 396      * considered equal.
 397      *
 398      * @param   obj   the object to compare against.
 399      * @return  <code>true</code> if the objects are the same;
 400      *          <code>false</code> otherwise.
 401      * @see java.net.InetAddress#equals(java.lang.Object)
 402      */
 403     @Override
 404     public final boolean equals(Object obj) {
 405         if (obj == null || !(obj instanceof InetSocketAddress))
 406             return false;
 407         return holder.equals(((InetSocketAddress) obj).holder);
 408     }
 409 
 410     /**
 411      * Returns a hashcode for this socket address.
 412      *


 372      * This String is constructed by calling toString() on the InetAddress
 373      * and concatenating the port number (with a colon). If the address
 374      * is unresolved then the part before the colon will only contain the hostname.
 375      *
 376      * @return  a string representation of this object.
 377      */
 378     @Override
 379     public String toString() {
 380         return holder.toString();
 381     }
 382 
 383     /**
 384      * Compares this object against the specified object.
 385      * The result is <code>true</code> if and only if the argument is
 386      * not <code>null</code> and it represents the same address as
 387      * this object.
 388      * <p>
 389      * Two instances of <code>InetSocketAddress</code> represent the same
 390      * address if both the InetAddresses (or hostnames if it is unresolved) and port
 391      * numbers are equal.
 392      * If both addresses are unresolved, then the hostname and the port number
 393      * are compared.
 394      *
 395      * Note: Hostnames are case insensitive. e.g. "FooBar" and "foobar" are
 396      * considered equal.
 397      *
 398      * @param   obj   the object to compare against.
 399      * @return  <code>true</code> if the objects are the same;
 400      *          <code>false</code> otherwise.
 401      * @see java.net.InetAddress#equals(java.lang.Object)
 402      */
 403     @Override
 404     public final boolean equals(Object obj) {
 405         if (obj == null || !(obj instanceof InetSocketAddress))
 406             return false;
 407         return holder.equals(((InetSocketAddress) obj).holder);
 408     }
 409 
 410     /**
 411      * Returns a hashcode for this socket address.
 412      *