Rebuild the host:port string, including brackets if necessary.
()
| 306 | /** Rebuild the host:port string, including brackets if necessary. */ |
| 307 | |
| 308 | @Override |
| 309 | public String toString() { |
| 310 | // "[]:12345" requires 8 extra bytes. |
| 311 | StringBuilder builder = new StringBuilder(host.length() + 8); |
| 312 | if (host.indexOf(':') >= 0) { |
| 313 | builder.append('[').append(host).append(']'); |
| 314 | } else { |
| 315 | builder.append(host); |
| 316 | } |
| 317 | if (hasPort()) { |
| 318 | builder.append(':').append(port); |
| 319 | } |
| 320 | return builder.toString(); |
| 321 | } |
| 322 | |
| 323 | /** Return true for valid port numbers. */ |
| 324 |