Rebuild the host:port string, including brackets if necessary.
()
| 298 | |
| 299 | /** Rebuild the host:port string, including brackets if necessary. */ |
| 300 | @Override |
| 301 | public String toString() { |
| 302 | // "[]:12345" requires 8 extra bytes. |
| 303 | StringBuilder builder = new StringBuilder(host.length() + 8); |
| 304 | if (host.indexOf(':') >= 0) { |
| 305 | builder.append('[').append(host).append(']'); |
| 306 | } else { |
| 307 | builder.append(host); |
| 308 | } |
| 309 | if (hasPort()) { |
| 310 | builder.append(':').append(port); |
| 311 | } |
| 312 | return builder.toString(); |
| 313 | } |
| 314 | |
| 315 | /** Return true for valid port numbers. */ |
| 316 | private static boolean isValidPort(int port) { |