Parse an authority string (in the form host:port) into
host and port, handling IPv4 and IPv6 host formats
as defined in RFC 2732
| Modifier and Type | Field and Description |
|---|---|
| private final String | |
| private final int | |
| private static final int | |
| private static final Logger |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| private |
| Modifier and Type | Method and Description |
|---|---|
| public String | |
| public int | |
| public int | Returns: the portthe default port to return if a port is not specified defaultPort)Get the port or the given default port. |
| public boolean | |
| public boolean | |
| protected boolean | |
| protected boolean | |
| public static String | Returns: a host name or an IPv4 address or an IPv6 literal (not an IPv6 address)a host name, IPv4 address, IPv6 address or IPv6 literal host)Normalizes IPv6 address as per RFC 2732 and RFC 6874, surrounding with square brackets if they are absent. |
| public static int | |
| private int | Returns: the portthe raw port string to parse rawPort, boolean true to always return a port in the range 0 to 65535 (or -1 for undefined if rawPort is horribly bad), false to return
the provided port (or unsafe)IllegalArgumentException if it is horribly bad)Parse a potential port. |
| public String | |
| public static HostPort |
| _host | back to summary |
|---|---|
| private final String _host | |
| _port | back to summary |
|---|---|
| private final int _port | |
| BAD_PORT | back to summary |
|---|---|
| private static final int BAD_PORT | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| HostPort | back to summary |
|---|---|
| public HostPort(String host, int port) | |
| HostPort | back to summary |
|---|---|
| public HostPort(String authority) throws IllegalArgumentException | |
| HostPort | back to summary |
|---|---|
private HostPort(String authority, boolean unsafe)
| |
| getHost | back to summary |
|---|---|
| public String getHost() Get the host.
| |
| getPort | back to summary |
|---|---|
| public int getPort() Get the port.
| |
| getPort | back to summary |
|---|---|
| public int getPort(int defaultPort) Get the port or the given default port.
| |
| hasHost | back to summary |
|---|---|
| public boolean hasHost() | |
| hasPort | back to summary |
|---|---|
| public boolean hasPort() | |
| isValidHostName | back to summary |
|---|---|
| protected boolean isValidHostName(String name) | |
| isValidIpAddress | back to summary |
|---|---|
| protected boolean isValidIpAddress(String ip) | |
| normalizeHost | back to summary |
|---|---|
| public static String normalizeHost(String host) Normalizes IPv6 address as per RFC 2732 and RFC 6874, surrounding with square brackets if they are absent. | |
| parsePort | back to summary |
|---|---|
| public static int parsePort(String rawPort) throws IllegalArgumentException Parse a string representing a port validating it is a valid port value.
| |
| parsePort | back to summary |
|---|---|
| private int parsePort(String rawPort, boolean unsafe) Parse a potential port.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| unsafe | back to summary |
|---|---|
| public static HostPort unsafe(String authority) Create a HostPort from an unsafe (and not validated) authority. There are no validations performed against the provided authority. It is quite possible to end up with HostPort that cannot be used to generate valid URL, URI, InetSocketAddress, Location header, etc. | |