Package org.eclipse.jetty.util
Class HostPort
- java.lang.Object
-
- org.eclipse.jetty.util.HostPort
-
public class HostPort extends java.lang.ObjectParse an authority string into Host and PortParse a string in the form "host:port", handling IPv4 an IPv6 hosts
The System property "org.eclipse.jetty.util.HostPort.STRIP_IPV6" can be set to a boolean value to control of the square brackets are stripped off IPv6 addresses (default false).
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetHost()Get the host.intgetPort()Get the port.intgetPort(int defaultPort)Get the port.static java.lang.StringnormalizeHost(java.lang.String host)Normalize IPv6 address as per https://www.ietf.org/rfc/rfc2732.txtstatic intparsePort(java.lang.String rawPort)Parse a string representing a port validating it is a valid port value.java.lang.StringtoString()
-
-
-
Method Detail
-
getHost
public java.lang.String getHost()
Get the host.- Returns:
- the host
-
getPort
public int getPort()
Get the port.- Returns:
- the port
-
getPort
public int getPort(int defaultPort)
Get the port.- Parameters:
defaultPort- , the default port to return if a port is not specified- Returns:
- the port
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
normalizeHost
public static java.lang.String normalizeHost(java.lang.String host)
Normalize IPv6 address as per https://www.ietf.org/rfc/rfc2732.txt- Parameters:
host- A host name- Returns:
- Host name surrounded by '[' and ']' as needed.
-
parsePort
public static int parsePort(java.lang.String rawPort) throws java.lang.IllegalArgumentExceptionParse a string representing a port validating it is a valid port value.- Parameters:
rawPort- the port string.- Returns:
- the integer value for the port.
- Throws:
java.lang.IllegalArgumentException
-
-