Class URISupport


  • @ThreadSafe
    public final class URISupport
    extends Object
    URL support class.
    • Constructor Detail

      • URISupport

        private URISupport()
        Private constructor.
    • Method Detail

      • buildURIIgnoreDefaultPorts

        @Nonnull
        public static final URI buildURIIgnoreDefaultPorts​(@Nonnull
                                                           String scheme,
                                                           @Nonnull
                                                           String host,
                                                           @Nonnull
                                                           int port,
                                                           @Nonnull
                                                           String path)
                                                    throws URISyntaxException
        Build a URI from the given parameters. If the scheme is either 'http' or 'https' with their respective default port, the port is set to -1.
        Parameters:
        scheme - the scheme
        host - the hostname
        port - the port
        path - the path
        Returns:
        a fully built URI from the given parameters.
        Throws:
        URISyntaxException - if the URI can not be constructed.
      • buildOrigin

        @Nonnull
        public static String buildOrigin​(@Nonnull
                                         URI uri)
                                  throws URISyntaxException
        Builds the 'origin' (see RFC 6454) from given URI. Omits default or unknown ports.
        Parameters:
        uri - the URI to build the origin from
        Returns:
        the origin
        Throws:
        URISyntaxException - if there is an error getting information from the URI.