Class ExtendableProtocolURLStreamHandler

    • Constructor Detail

      • ExtendableProtocolURLStreamHandler

        public ExtendableProtocolURLStreamHandler()
        The default constructor must obey the following conventions:
        • The class must be the top level
        • The simple class name must be "Handler"
        • The class must not be present in the "default" or builtin package("sun.net.www.protocol")
      • ExtendableProtocolURLStreamHandler

        public ExtendableProtocolURLStreamHandler​(java.lang.String protocol)
    • Method Detail

      • getHandlePackages

        public static java.util.Set<java.lang.String> getHandlePackages()
      • getHandlePackagesPropertyValue

        public static java.lang.String getHandlePackagesPropertyValue()
        Get the System property value of the packages of URLStreamHandlers.
        Returns:
        null if absent
      • init

        public void init()
      • openConnection

        protected final java.net.URLConnection openConnection​(java.net.URL u)
                                                       throws java.io.IOException
        Specified by:
        openConnection in class java.net.URLStreamHandler
        Throws:
        java.io.IOException
      • openConnection

        public java.net.URLConnection openConnection​(java.net.URL u,
                                                     java.net.Proxy p)
                                              throws java.io.IOException
        Overrides:
        openConnection in class java.net.URLStreamHandler
        Throws:
        java.io.IOException
      • openFallbackConnection

        protected java.net.URLConnection openFallbackConnection​(java.net.URL url,
                                                                java.net.Proxy proxy)
                                                         throws java.io.IOException
        The subclass can override this method to open the fallback URLConnection if any SubProtocolURLConnectionFactory does not create the URLConnection.
        Parameters:
        url - the URL that this connects to
        proxy - Proxy the proxy through which the connection will be made. If direct connection is desired, Proxy.NO_PROXY should be specified.
        Returns:
        null as default
        Throws:
        java.io.IOException
      • equals

        protected final boolean equals​(java.net.URL u1,
                                       java.net.URL u2)
        Overrides:
        equals in class java.net.URLStreamHandler
      • hashCode

        protected final int hashCode​(java.net.URL u)
        Overrides:
        hashCode in class java.net.URLStreamHandler
      • hostsEqual

        protected final boolean hostsEqual​(java.net.URL u1,
                                           java.net.URL u2)
        Overrides:
        hostsEqual in class java.net.URLStreamHandler
      • toExternalForm

        protected final java.lang.String toExternalForm​(java.net.URL u)
        Reuses the algorithm of URLStreamHandler.toExternalForm(URL) using the StringBuilder to the StringBuilder.
        Overrides:
        toExternalForm in class java.net.URLStreamHandler
        Parameters:
        u - the URL.
        Returns:
        a string representation of the URL argument.
      • parseURL

        protected final void parseURL​(java.net.URL u,
                                      java.lang.String spec,
                                      int start,
                                      int limit)
        Overrides:
        parseURL in class java.net.URLStreamHandler
      • reformSpec

        protected java.lang.String reformSpec​(java.net.URL url,
                                              java.lang.String spec,
                                              int start,
                                              int end,
                                              int limit)
        Reform the string of specified URL if its' scheme presents the sub-protocol, e,g. A string representing the URL is "jdbc:mysql://localhost:3307/mydb?charset=UTF-8#top", its'
        • scheme : "jdbc:mysql"
        • host : "localhost"
        • port : 3307
        • path : "/mydb"
        • query : "charset=UTF-8"
        • ref : "top"

        This scheme contains two parts, the former is "jdbc" as the protocol, the later is "mysql" called sub-protocol which is convenient to extend the fine-grain URLStreamHandler. In this case, the reformed string of specified URL will be "jdbc://localhost:3307/mydb;_sp=mysql?charset=UTF-8#top".

        Parameters:
        url - the URL to receive the result of parsing the spec.
        spec - the String representing the URL that must be parsed.
        start - the character index at which to begin parsing. This is just past the ':' (if there is one) that specifies the determination of the protocol name.
        end - the index of the string "://" present in the URL from the start index, its' value is greater or equal 0.
        limit - the character position to stop parsing at. This is the end of the string or the position of the "#" character, if present. All information after the sharp sign indicates an anchor.
        Returns:
        reformed the string of specified URL if the suffix o
      • resolveSubProtocols

        protected java.util.List<java.lang.String> resolveSubProtocols​(java.net.URL url)
        Get the sub-protocols from the specified URL
        Parameters:
        url - URL
        Returns:
        non-null
      • resolveAuthority

        protected java.lang.String resolveAuthority​(java.net.URL url)
      • resolvePath

        protected java.lang.String resolvePath​(java.net.URL url)
      • getProtocol

        public final java.lang.String getProtocol()
      • toString

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