equal
deleted
inserted
replaced
99 return addr == null; |
99 return addr == null; |
100 } |
100 } |
101 |
101 |
102 @Override |
102 @Override |
103 public String toString() { |
103 public String toString() { |
|
104 |
|
105 String formatted; |
|
106 |
104 if (isUnresolved()) { |
107 if (isUnresolved()) { |
105 return hostname + ":" + port; |
108 formatted = hostname + "/<unresolved>"; |
106 } else { |
109 } else { |
107 return addr.toString() + ":" + port; |
110 formatted = addr.toString(); |
|
111 if (addr instanceof Inet6Address) { |
|
112 int i = formatted.lastIndexOf("/"); |
|
113 formatted = formatted.substring(0, i + 1) |
|
114 + "[" + formatted.substring(i + 1) + "]"; |
|
115 } |
108 } |
116 } |
|
117 return formatted + ":" + port; |
109 } |
118 } |
110 |
119 |
111 @Override |
120 @Override |
112 public final boolean equals(Object obj) { |
121 public final boolean equals(Object obj) { |
113 if (obj == null || !(obj instanceof InetSocketAddressHolder)) |
122 if (obj == null || !(obj instanceof InetSocketAddressHolder)) |
365 |
374 |
366 /** |
375 /** |
367 * Constructs a string representation of this InetSocketAddress. |
376 * Constructs a string representation of this InetSocketAddress. |
368 * This String is constructed by calling toString() on the InetAddress |
377 * This String is constructed by calling toString() on the InetAddress |
369 * and concatenating the port number (with a colon). If the address |
378 * and concatenating the port number (with a colon). If the address |
370 * is unresolved then the part before the colon will only contain the hostname. |
379 * is an IPv6 address, the IPv6 literal is enclosed in square brackets. |
|
380 * If the address is {@linkplain #isUnresolved() unresolved}, |
|
381 * {@code <unresolved>} is displayed in place of the address literal. |
371 * |
382 * |
372 * @return a string representation of this object. |
383 * @return a string representation of this object. |
373 */ |
384 */ |
374 @Override |
385 @Override |
375 public String toString() { |
386 public String toString() { |