Lines Matching refs:host

32  * An immutable representation of a host and port.
57 * host field (if desired) is the caller's responsibility.
68 private final String host;
73 /** True if the parsed host has colons, but no surrounding brackets. */
76 private HostAndPort(String host, int port, boolean hasBracketlessColons) {
77 this.host = host;
90 return host;
118 * Build a HostAndPort instance from separate host and port values.
123 * @param host the host string to parse. Must not contain a port number.
126 * @throws IllegalArgumentException if {@code host} contains a port number,
129 public static HostAndPort fromParts(String host, int port) {
131 HostAndPort parsedHost = fromString(host);
133 return new HostAndPort(parsedHost.host, port, parsedHost.hasBracketlessColons);
139 * Split a freeform string into a host and port, without strict validation.
141 * Note that the host-only formats will leave the port field undefined. You
150 String host;
155 // Parse a bracketed host, typically an IPv6 literal.
157 checkArgument(matcher.matches(), "Invalid bracketed host/port: %s", hostPortString);
158 host = matcher.group(1);
163 // Exactly 1 colon. Split into host:port.
164 host = hostPortString.substring(0, colonPos);
168 host = hostPortString;
186 return new HostAndPort(host, port, hasBracketlessColons);
190 * Provide a default port if the parsed string contained only a host.
204 return new HostAndPort(host, defaultPort, hasBracketlessColons);
208 * Generate an error if the host might be a non-bracketed IPv6 literal.
223 checkArgument(!hasBracketlessColons, "Possible bracketless IPv6 literal: %s", host);
234 return Objects.equal(this.host, that.host)
243 return Objects.hashCode(host, port, hasBracketlessColons);
246 /** Rebuild the host:port string, including brackets if necessary. */
249 StringBuilder builder = new StringBuilder(host.length() + 7);
250 if (host.indexOf(':') >= 0) {
251 builder.append('[').append(host).append(']');
253 builder.append(host);