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