Class HttpUtil


  • public final class HttpUtil
    extends Object
    HTTP validation / hint water marks utility class.
    Restriction:
    This class is not intended to be sub-classed by clients.
    Restriction:
    This class is not intended to be instantiated by clients.
    • Method Detail

      • isValidUrl

        public static boolean isValidUrl​(String url)
        Validate, whether given URL is in valid format.
        Parameters:
        url - URL to validate, can be null then false will be returned
        Returns:
        whether given URL is in valid format
      • validateUrl

        public static org.eclipse.core.runtime.IStatus validateUrl​(String url)
        Validate, whether given URL is in valid format.
        Parameters:
        url - URL to validate, cannot be null
        Returns:
        OK status if given URL is in valid format, or ERROR status with description of throwable
      • validateUri

        public static org.eclipse.core.runtime.IStatus validateUri​(String uri)
        Validate, whether given URI is in valid format.
        Parameters:
        url - URI to validate, cannot be null
        Returns:
        OK status if given URI is in valid format, or ERROR status with description of throwable
      • findFreePort

        public static int findFreePort()
        Returns a free port number on localhost, or -1 if unable to find a free port.
        Returns:
        a free port number on localhost, or -1 if unable to find a free port
      • isAvailable

        public static boolean isAvailable​(int port)
        Returns whether the given port is available on the current PC.
        Parameters:
        port - the port to check, must be positive and less or equal to 65535
        Returns:
        whether the given port is available on the current PC
      • getHostName

        public static String getHostName()
                                  throws UnknownHostException
        Returns the host name. Can return null if not found or error occurred.
        Returns:
        the host name or null if not found
        Throws:
        UnknownHostException - if the local host name could not be resolved into an address
      • tryGetHostName

        public static String tryGetHostName()
        Try to get and return host name. If cannot get, returns localhost
        Returns:
        host name or localhost if cannot get