Class URLWrapper


  • public class URLWrapper
    extends java.lang.Object
    • Constructor Detail

      • URLWrapper

        public URLWrapper()
      • URLWrapper

        public URLWrapper​(java.lang.String url)
                   throws java.net.MalformedURLException
        Throws:
        java.net.MalformedURLException
      • URLWrapper

        public URLWrapper​(java.net.URL url)
      • URLWrapper

        public URLWrapper​(java.net.URI uri)
    • Method Detail

      • empty

        public static URLWrapper empty()
        Create a new empty URLWrapper.
        Returns:
        The URLWrapper
      • of

        public static URLWrapper of​(java.lang.String url)
                             throws java.net.MalformedURLException
        Create a new URLWrapper from a String.
        Parameters:
        url - The URL to wrap
        Returns:
        The URLWrapper
        Throws:
        java.net.MalformedURLException - If the URL is invalid
      • of

        public static URLWrapper of​(java.net.URL url)
        Create a new URLWrapper from an URL.
        Parameters:
        url - The URL to wrap
        Returns:
        The URLWrapper
      • of

        public static URLWrapper of​(java.net.URI uri)
        Create a new URLWrapper from an URI.
        Parameters:
        uri - The URI to wrap
        Returns:
        The URLWrapper
      • getProtocol

        public java.lang.String getProtocol()
        Returns:
        The protocol of the URL. e.g. https
      • setProtocol

        public URLWrapper setProtocol​(java.lang.String protocol)
        Set the protocol of the URL.
        e.g. https
        Parameters:
        protocol - The new protocol
        Returns:
        The URLWrapper
      • getHost

        public java.lang.String getHost()
        Returns:
        The host of the URL. e.g. www.example.com
      • setHost

        public URLWrapper setHost​(java.lang.String host)
        Set the host of the URL.
        e.g. www.example.com
        Parameters:
        host - The new host
        Returns:
        The URLWrapper
      • getPort

        public int getPort()
        Returns:
        The port of the URL. e.g. 443
      • setPort

        public URLWrapper setPort​(int port)
        Set the port of the URL.
        e.g. 443
        Parameters:
        port - The new port
        Returns:
        The URLWrapper
      • getPath

        public java.lang.String getPath()
        Returns:
        The file of the URL. e.g. /search
      • setPath

        public URLWrapper setPath​(java.lang.String path)
        Set the file of the URL.
        e.g. /search
        Parameters:
        path - The new file
        Returns:
        The URLWrapper
      • getQuery

        public java.lang.String getQuery()
        Returns:
        The query of the URL. e.g. q=hello
      • setQuery

        public URLWrapper setQuery​(java.lang.String query)
        Set the query of the URL.
        e.g. q=hello
        Parameters:
        query - The new query
        Returns:
        The URLWrapper
      • wrapQuery

        public URLWrapper.QueryWrapper wrapQuery()
        Get a wrapper for the query parameters.
        Returns:
        The query wrapper
      • getUserInfo

        public java.lang.String getUserInfo()
        Returns:
        The user info of the URL. e.g. user:password
      • setUserInfo

        public URLWrapper setUserInfo​(java.lang.String userInfo)
        Set the user info of the URL.
        e.g. user:password
        Parameters:
        userInfo - The new user info
        Returns:
        The URLWrapper
      • getReference

        public java.lang.String getReference()
        Returns:
        The reference of the URL. e.g. reference
      • setReference

        public URLWrapper setReference​(java.lang.String reference)
        Set the reference of the URL.
        e.g. reference
        Parameters:
        reference - The new reference
        Returns:
        The URLWrapper
      • toURL

        public java.net.URL toURL()
                           throws java.net.MalformedURLException
        Returns:
        The wrapped URL
        Throws:
        java.net.MalformedURLException - If the URL is invalid
      • toURI

        public java.net.URI toURI()
        Returns:
        The wrapped URI
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object