类 URLUtils

    • 构造器概要

      构造器 
      构造器 说明
      URLUtils()  
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      static void attachURLStreamHandlerFactory​(java.net.URLStreamHandlerFactory factory)
      Set the specified URLStreamHandlerFactory for URL's if not set before, otherwise, add it into CompositeURLStreamHandlerFactory that will be set.
      static java.lang.String buildMatrixString​(java.lang.String name, java.lang.String... values)
      Build the Matrix String
      static java.lang.String buildMatrixString​(java.util.Map<java.lang.String,​java.util.List<java.lang.String>> matrixParameters)
      Build the Matrix String
      protected static java.lang.String buildString​(java.lang.String name, java.lang.String[] values, char separator, char joiner)  
      static java.lang.String buildURI​(java.lang.String... paths)
      Build multiple paths to URI
      protected static void clearURLStreamHandlerFactory()  
      static java.lang.String decode​(java.lang.String value)
      decode(String, String) with "UTF-8" encoding
      static java.lang.String decode​(java.lang.String value, java.lang.String encoding)
      Decodes a application/x-www-form-urlencoded string using a specific encoding scheme.
      protected static java.lang.String doResolveArchiveEntryPath​(java.lang.String path)  
      protected static java.io.File doResolveArchiveFile​(java.net.URL url)  
      protected static java.lang.String doResolveBasePath​(java.lang.String path)  
      static java.lang.String encode​(java.lang.String value)
      encode(String, String) with "UTF-8" encoding
      static java.lang.String encode​(java.lang.String value, java.lang.String encoding)
      Translates a string into application/x-www-form-urlencoded format using a specific encoding scheme.
      protected static java.lang.String getFirst​(java.util.Map<java.lang.String,​java.util.List<java.lang.String>> parameters, java.lang.String name)  
      protected static MutableURLStreamHandlerFactory getMutableURLStreamHandlerFactory()  
      protected static MutableURLStreamHandlerFactory getMutableURLStreamHandlerFactory​(boolean createIfAbsent)  
      static java.lang.String getSubProtocol​(java.lang.String url)  
      static java.net.URLStreamHandlerFactory getURLStreamHandlerFactory()  
      protected static int indexOfMatrixString​(java.lang.String value)  
      static boolean isArchiveURL​(java.net.URL url)
      Is an archive URL?
      static boolean isDirectoryURL​(java.net.URL url)
      Is directory URL?
      static boolean isJarURL​(java.net.URL url)
      Is Jar URL?
      static java.lang.String normalizePath​(java.lang.String path)
      Normalize Path(maybe from File or URL), will remove duplicated slash or backslash from path.
      protected static java.lang.String reformProtocol​(java.lang.String protocol, java.lang.String spec)  
      protected static java.lang.String reformProtocol​(java.lang.String protocol, java.util.List<java.lang.String> subProtocols)  
      static void registerURLStreamHandler​(ExtendableProtocolURLStreamHandler handler)
      Register an instance of ExtendableProtocolURLStreamHandler
      static void registerURLStreamHandler​(java.lang.String protocol, java.net.URLStreamHandler handler)
      Register an instance of URLStreamHandler with the specified protocol
      protected static java.io.File resolveArchiveDirectory​(java.net.URL resourceURL)  
      static java.lang.String resolveArchiveEntryPath​(java.net.URL archiveFileURL)
      Resolve the entry path from Archive File URL
      static java.io.File resolveArchiveFile​(java.net.URL resourceURL)
      Resolve archive file
      static java.lang.String resolveAuthority​(java.lang.String authority)  
      static java.lang.String resolveAuthority​(java.net.URL url)  
      static java.lang.String resolveBasePath​(java.net.URL url)
      Resolve base path from the specified URL
      static java.util.Map<java.lang.String,​java.util.List<java.lang.String>> resolveMatrixParameters​(java.lang.String url)
      Resolve the matrix parameters Map from specified URL,The parameter name as key ,parameter value list as key
      protected static java.util.Map<java.lang.String,​java.util.List<java.lang.String>> resolveParameters​(java.lang.String paramsString, char separatorChar)  
      static java.lang.String resolvePath​(java.lang.String value)  
      static java.lang.String resolvePath​(java.lang.String value, int indexOfMatrixString)  
      static java.lang.String resolvePath​(java.net.URL url)  
      static java.util.Map<java.lang.String,​java.util.List<java.lang.String>> resolveQueryParameters​(java.lang.String url)
      Resolve the query parameters Map from specified URL,The parameter name as key ,parameter value list as key
      static java.util.List<java.lang.String> resolveSubProtocols​(java.lang.String url)  
      static java.util.List<java.lang.String> resolveSubProtocols​(java.net.URL url)  
      static java.lang.String toExternalForm​(java.net.URL url)
      Converts a URL of a specific protocol to a String.
      static java.lang.String toString​(java.net.URL url)
      Converts a URL of a specific protocol to a String.
      protected static java.lang.String truncateMatrixString​(java.lang.String value)  
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细资料

      • DEFAULT_ENCODING

        public static final java.lang.String DEFAULT_ENCODING
        The default encoding : "UTF-8"
      • EMPTY_URL_ARRAY

        public static final java.net.URL[] EMPTY_URL_ARRAY
        The empty array of URL
      • HANDLER_PACKAGES_PROPERTY_NAME

        public static final java.lang.String HANDLER_PACKAGES_PROPERTY_NAME
        The property which specifies the package prefix list to be scanned for protocol handlers. The value of this property (if any) should be a vertical bar delimited list of package names to search through for a protocol handler to load. The policy of this class is that all protocol handlers will be in a class called .Handler, and each package in the list is examined in turn for a matching handler. If none are found (or the property is not specified), the default package prefix, sun.net.www.protocol, is used. The search proceeds from the first package in the list to the last and stops when a match is found.
        另请参阅:
        常量字段值
      • DEFAULT_HANDLER_PACKAGE_PREFIX

        public static final java.lang.String DEFAULT_HANDLER_PACKAGE_PREFIX
        The prefix of package for Handlers
        另请参阅:
        常量字段值
      • HANDLER_PACKAGES_SEPARATOR_CHAR

        public static final char HANDLER_PACKAGES_SEPARATOR_CHAR
        The separator character of Handlers' packages.
        另请参阅:
        常量字段值
      • HANDLER_CONVENTION_CLASS_NAME

        public static final java.lang.String HANDLER_CONVENTION_CLASS_NAME
        The convention class name of Handler.
        另请参阅:
        常量字段值
      • SUB_PROTOCOL_MATRIX_NAME

        public static final java.lang.String SUB_PROTOCOL_MATRIX_NAME
        The matrix name for the URLs' sub-protocol
        另请参阅:
        常量字段值
    • 构造器详细资料

      • URLUtils

        public URLUtils()
    • 方法详细资料

      • resolveArchiveEntryPath

        public static java.lang.String resolveArchiveEntryPath​(java.net.URL archiveFileURL)
                                                        throws java.lang.NullPointerException
        Resolve the entry path from Archive File URL
        参数:
        archiveFileURL - Archive File URL
        返回:
        Relative path in archive
        抛出:
        java.lang.NullPointerException - archiveFileURL is null
      • doResolveArchiveEntryPath

        protected static java.lang.String doResolveArchiveEntryPath​(java.lang.String path)
      • resolveBasePath

        public static java.lang.String resolveBasePath​(java.net.URL url)
                                                throws java.lang.NullPointerException
        Resolve base path from the specified URL
        参数:
        url - the specified URL
        返回:
        base path
        抛出:
        java.lang.NullPointerException - if url is null
      • doResolveBasePath

        protected static java.lang.String doResolveBasePath​(java.lang.String path)
      • resolveArchiveFile

        public static java.io.File resolveArchiveFile​(java.net.URL resourceURL)
                                               throws java.lang.NullPointerException
        Resolve archive file
        参数:
        resourceURL - the URL of resource
        返回:
        Resolve archive file If exists
        抛出:
        java.lang.NullPointerException
      • doResolveArchiveFile

        protected static java.io.File doResolveArchiveFile​(java.net.URL url)
                                                    throws java.lang.NullPointerException
        抛出:
        java.lang.NullPointerException
      • resolveArchiveDirectory

        protected static java.io.File resolveArchiveDirectory​(java.net.URL resourceURL)
      • resolveQueryParameters

        @Nonnull
        public static java.util.Map<java.lang.String,​java.util.List<java.lang.String>> resolveQueryParameters​(java.lang.String url)
        Resolve the query parameters Map from specified URL,The parameter name as key ,parameter value list as key
        参数:
        url - URL
        返回:
        Non-null and Read-only Map , the order of parameters is determined by query string
      • resolveMatrixParameters

        @Nonnull
        public static java.util.Map<java.lang.String,​java.util.List<java.lang.String>> resolveMatrixParameters​(java.lang.String url)
        Resolve the matrix parameters Map from specified URL,The parameter name as key ,parameter value list as key
        参数:
        url - URL
        返回:
        Non-null and Read-only Map , the order of parameters is determined by matrix string
      • normalizePath

        public static java.lang.String normalizePath​(java.lang.String path)
        Normalize Path(maybe from File or URL), will remove duplicated slash or backslash from path. For example,

        resolvePath("C:\\Windows\\\\temp") == "C:/Windows/temp"; resolvePath("C:\\\\\Windows\\/temp") == "C:/Windows/temp"; resolvePath("/home/////index.html") == "/home/index.html";

        参数:
        path - Path
        返回:
        a newly resolved path
      • encode

        public static java.lang.String encode​(java.lang.String value,
                                              java.lang.String encoding)
                                       throws java.lang.IllegalArgumentException
        Translates a string into application/x-www-form-urlencoded format using a specific encoding scheme. This method uses the supplied encoding scheme to obtain the bytes for unsafe characters.

        Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilites.

        参数:
        value - String to be translated.
        encoding - The name of a supported character encoding.
        返回:
        the translated String.
        抛出:
        java.lang.IllegalArgumentException - If the named encoding is not supported
        另请参阅:
        URLDecoder.decode(String, String)
      • encode

        public static java.lang.String encode​(java.lang.String value)
        encode(String, String) with "UTF-8" encoding
        参数:
        value - the String to decode
        返回:
        the newly encoded String
      • decode

        public static java.lang.String decode​(java.lang.String value)
        decode(String, String) with "UTF-8" encoding
        参数:
        value - the String to decode
        返回:
        the newly decoded String
      • decode

        public static java.lang.String decode​(java.lang.String value,
                                              java.lang.String encoding)
                                       throws java.lang.IllegalArgumentException
        Decodes a application/x-www-form-urlencoded string using a specific encoding scheme. The supplied encoding is used to determine what characters are represented by any consecutive sequences of the form "%xy".

        Note: The World Wide Web Consortium Recommendation states that UTF-8 should be used. Not doing so may introduce incompatibilites.

        参数:
        value - the String to decode
        encoding - The name of a supported encoding
        返回:
        the newly decoded String
        抛出:
        java.lang.IllegalArgumentException - If character encoding needs to be consulted, but named character encoding is not supported
      • isDirectoryURL

        public static boolean isDirectoryURL​(java.net.URL url)
        Is directory URL?
        参数:
        url - URL
        返回:
        if directory , return true
      • isJarURL

        public static boolean isJarURL​(java.net.URL url)
        Is Jar URL?
        参数:
        url - URL
        返回:
        If jar , return true
      • isArchiveURL

        public static boolean isArchiveURL​(java.net.URL url)
        Is an archive URL?
        参数:
        url - URL
        返回:
        If an archive , return true
      • buildURI

        public static java.lang.String buildURI​(java.lang.String... paths)
        Build multiple paths to URI
        参数:
        paths - multiple paths
        返回:
        URI
      • buildMatrixString

        public static java.lang.String buildMatrixString​(java.util.Map<java.lang.String,​java.util.List<java.lang.String>> matrixParameters)
        Build the Matrix String
        参数:
        matrixParameters - the Map of matrix parameters
        返回:
        the Matrix String
      • buildMatrixString

        public static java.lang.String buildMatrixString​(java.lang.String name,
                                                         java.lang.String... values)
        Build the Matrix String
        参数:
        name - the name of matrix parameter
        values - the values of matrix parameter
        返回:
        the Matrix String
      • toString

        public static java.lang.String toString​(java.net.URL url)
                                         throws java.lang.NullPointerException
        Converts a URL of a specific protocol to a String.
        参数:
        url - URL
        返回:
        non-null
        抛出:
        java.lang.NullPointerException - If url is null
      • toExternalForm

        public static java.lang.String toExternalForm​(java.net.URL url)
                                               throws java.lang.NullPointerException
        Converts a URL of a specific protocol to a String.
        参数:
        url - URL
        返回:
        non-null
        抛出:
        java.lang.NullPointerException - If url is null
      • getSubProtocol

        public static java.lang.String getSubProtocol​(java.lang.String url)
      • resolveSubProtocols

        public static java.util.List<java.lang.String> resolveSubProtocols​(java.net.URL url)
      • resolveSubProtocols

        public static java.util.List<java.lang.String> resolveSubProtocols​(java.lang.String url)
      • resolveAuthority

        public static java.lang.String resolveAuthority​(java.net.URL url)
      • resolveAuthority

        public static java.lang.String resolveAuthority​(java.lang.String authority)
      • resolvePath

        public static java.lang.String resolvePath​(java.net.URL url)
      • resolvePath

        public static java.lang.String resolvePath​(java.lang.String value)
      • resolvePath

        public static java.lang.String resolvePath​(java.lang.String value,
                                                   int indexOfMatrixString)
      • truncateMatrixString

        protected static java.lang.String truncateMatrixString​(java.lang.String value)
      • indexOfMatrixString

        protected static int indexOfMatrixString​(java.lang.String value)
      • attachURLStreamHandlerFactory

        public static void attachURLStreamHandlerFactory​(java.net.URLStreamHandlerFactory factory)
        Set the specified URLStreamHandlerFactory for URL's if not set before, otherwise, add it into CompositeURLStreamHandlerFactory that will be set.
        参数:
        factory - URLStreamHandlerFactory
      • getURLStreamHandlerFactory

        public static java.net.URLStreamHandlerFactory getURLStreamHandlerFactory()
      • registerURLStreamHandler

        public static void registerURLStreamHandler​(java.lang.String protocol,
                                                    java.net.URLStreamHandler handler)
        Register an instance of URLStreamHandler with the specified protocol
        参数:
        protocol - the specified protocol of URL
        handler - URLStreamHandler
      • clearURLStreamHandlerFactory

        protected static void clearURLStreamHandlerFactory()
      • reformProtocol

        protected static java.lang.String reformProtocol​(java.lang.String protocol,
                                                         java.lang.String spec)
      • reformProtocol

        protected static java.lang.String reformProtocol​(java.lang.String protocol,
                                                         java.util.List<java.lang.String> subProtocols)
      • resolveParameters

        protected static java.util.Map<java.lang.String,​java.util.List<java.lang.String>> resolveParameters​(java.lang.String paramsString,
                                                                                                                  char separatorChar)
      • buildString

        protected static java.lang.String buildString​(java.lang.String name,
                                                      java.lang.String[] values,
                                                      char separator,
                                                      char joiner)
      • getFirst

        protected static java.lang.String getFirst​(java.util.Map<java.lang.String,​java.util.List<java.lang.String>> parameters,
                                                   java.lang.String name)