Class HostPort

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String _host  
      private int _port  
      private static boolean STRIP_IPV6  
    • Constructor Summary

      Constructors 
      Constructor Description
      HostPort​(java.lang.String authority)  
      HostPort​(java.lang.String host, int port)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getHost()
      Get the host.
      int getPort()
      Get the port.
      int getPort​(int defaultPort)
      Get the port.
      static java.lang.String normalizeHost​(java.lang.String host)
      Normalize IPv6 address as per https://www.ietf.org/rfc/rfc2732.txt
      static int parsePort​(java.lang.String rawPort)
      Parse a string representing a port validating it is a valid port value.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • STRIP_IPV6

        private static final boolean STRIP_IPV6
      • _host

        private final java.lang.String _host
      • _port

        private final int _port
    • Constructor Detail

      • HostPort

        public HostPort​(java.lang.String host,
                        int port)
      • HostPort

        public HostPort​(java.lang.String authority)
                 throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
    • 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:
        toString in class java.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.IllegalArgumentException
        Parse 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