类 URL

  • 所有已实现的接口:

    public final class URL
    extends 
    implements 
    URL - Uniform Resource Locator (Immutable, ThreadSafe)

    url example:

    • http://www.facebook.com/friends?param1=value1&param2=value2
    • http://username:[email protected]:8080/list?version=1.0.0
    • ftp://username:[email protected]:21/1/read.txt
    • registry://192.168.1.7:9090/com.alibaba.service1?param1=value1&param2=value2

    Some strange example below:

    • 192.168.1.3:20880
      for this case, url protocol = null, url host = 192.168.1.3, port = 20880, url path = null
    • file:///home/user1/router.js?type=script
      for this case, url protocol = file, url host = null, url path = home/user1/router.js
    • file://home/user1/router.js?type=script
      for this case, url protocol = file, url host = home, url path = user1/router.js
    • file:///D:/1/router.js?type=script
      for this case, url protocol = file, url host = null, url path = D:/1/router.js
    • file:/D:/1/router.js?type=script
      same as above file:///D:/1/router.js?type=script
    • /home/user1/router.js?type=script
      for this case, url protocol = null, url host = null, url path = home/user1/router.js
    • home/user1/router.js?type=script
      for this case, url protocol = null, url host = home, url path = user1/router.js
    另请参阅:
    , , 序列化表格
    • 构造器概要

      构造器 
      构造器 说明
       protocol,  host, int port)  
       protocol,  host, int port,  path)  
       protocol,  host, int port, [] pairs)  
       protocol,  host, int port,  path, ... pairs)  
       protocol,  host, int port,  path, <,​> parameters)  
       protocol,  host, int port, <,​> parameters)  
       protocol,  username,  password,  host, int port,  path)  
       protocol,  username,  password,  host, int port,  path, ... pairs)  
       protocol,  username,  password,  host, int port,  path, <,​> parameters)  
    • 方法概要

      所有方法 静态方法 实例方法 具体方法 已过时的方法 
      修饰符和类型 方法 说明
      URL  key, boolean value)  
      URL  key, byte value)  
      URL  key, char value)  
      URL  key, double value)  
      URL  key, float value)  
      URL  key, int value)  
      URL  key, long value)  
      URL  key, short value)  
      URL  key,  value)  
      URL  key, <?> value)  
      URL  key,  value)  
      URL  key,  value)  
      URL  key,  value)  
      URL  key,  value)  
      URL ... pairs)  
      URL <,​> parameters)
      Add parameters to a new url.
      URL <,​> parameters)  
      URL  query)  
      URL clearParameters()  
      static  value)  
      static  value)  
      boolean  obj)  
      getAbsolutePath()  
      getAddress()  
      getAuthority()  
      getBackupAddress()  
      getBackupAddress​(int defaultPort)  
      <URL> getBackupUrls()  
      boolean  key)
      已过时。
      Replace to getParameter(String, boolean)
      boolean  key, boolean defaultValue)
      已过时。
      Replace to getParameter(String, boolean)
      getHost()  
      int  key)
      已过时。
      Replace to getParameter(String, int)
      int  key, int defaultValue)
      已过时。
      Replace to getParameter(String, int)
      getIp()
      Fetch IP address for this URL.
      boolean  method,  key)
      已过时。
      Replace to getMethodParameter(String, String, boolean)
      boolean  method,  key, boolean defaultValue)
      已过时。
      Replace to getMethodParameter(String, String, boolean)
      int  method,  key)
      已过时。
      Replace to getMethodParameter(String, String, int)
      int  method,  key, int defaultValue)
      已过时。
      Replace to getMethodParameter(String, String, int)
       method,  key)  
      boolean  method,  key, boolean defaultValue)  
      byte  method,  key, byte defaultValue)  
      char  method,  key, char defaultValue)  
      double  method,  key, double defaultValue)  
      float  method,  key, float defaultValue)  
      int  method,  key, int defaultValue)  
      long  method,  key, long defaultValue)  
      short  method,  key, short defaultValue)  
       method,  key,  defaultValue)  
       method,  key)  
       method,  key,  defaultValue)  
      int  method,  key, int defaultValue)
      已过时。
      Replace to getMethodPositiveParameter(String, String, int)
      byte  method,  key, byte defaultValue)  
      double  method,  key, double defaultValue)  
      float  method,  key, float defaultValue)  
      int  method,  key, int defaultValue)  
      long  method,  key, long defaultValue)  
      short  method,  key, short defaultValue)  
       key)  
      boolean  key, boolean defaultValue)  
      byte  key, byte defaultValue)  
      char  key, char defaultValue)  
      double  key, double defaultValue)  
      float  key, float defaultValue)  
      int  key, int defaultValue)  
      long  key, long defaultValue)  
      short  key, short defaultValue)  
       key,  defaultValue)  
      []  key, [] defaultValue)  
       key)  
       key,  defaultValue)  
      <,​> getParameters()  
      getPassword()  
      getPath()  
      int getPort()  
      int getPort​(int defaultPort)  
      int  key, int defaultValue)
      已过时。
      Replace to getPositiveParameter(String, int)
      byte  key, byte defaultValue)  
      double  key, double defaultValue)  
      float  key, float defaultValue)  
      int  key, int defaultValue)  
      long  key, long defaultValue)  
      short  key, short defaultValue)  
      getProtocol()  
       key)  
      getServiceInterface()  
      getServiceKey()  
      getServiceName()
      已过时。
      URL  key)  
      getUsername()  
      int hashCode()  
      boolean  method,  key)  
      boolean  key)  
      boolean isAnyHost()  
      boolean isLocalHost()  
      URL  key)  
      URL ... keys)  
      URL <> keys)  
      URL  address)  
      URL  host)  
      URL  password)  
      URL  path)  
      URL setPort​(int port)  
      URL  protocol)  
      URL  service)  
      URL  username)  
      toFullString()  
      ... parameters)  
      toIdentityString()  
      ... parameters)  
      toInetSocketAddress()  
      toJavaURL()  
      <,​> toMap()  
      toParameterString()  
      ... parameters)  
      toServiceString()  
      toServiceStringWithoutResolving()  
      toString()  
      ... parameters)  
      static URL  url)
      Parse url string
      • 从类继承的方法 java.lang.

        , , , , ,
    • 构造器详细资料

      • URL

        public URL​( protocol,
                    host,
                   int port)
      • URL

        public URL​( protocol,
                    host,
                   int port,
                   [] pairs)
      • URL

        public URL​( protocol,
                    host,
                   int port,
                   <,​> parameters)
      • URL

        public URL​( protocol,
                    host,
                   int port,
                    path)
      • URL

        public URL​( protocol,
                    host,
                   int port,
                    path,
                   ... pairs)
      • URL

        public URL​( protocol,
                    host,
                   int port,
                    path,
                   <,​> parameters)
      • URL

        public URL​( protocol,
                    username,
                    password,
                    host,
                   int port,
                    path)
      • URL

        public URL​( protocol,
                    username,
                    password,
                    host,
                   int port,
                    path,
                   ... pairs)
      • URL

        public URL​( protocol,
                    username,
                    password,
                    host,
                   int port,
                    path,
                   <,​> parameters)
    • 方法详细资料

      • valueOf

        public static  url)
        Parse url string
        参数:
        url - URL string
        返回:
        URL instance
        另请参阅:
        URL
      • encode

        public static  encode​( value)
      • decode

        public static  decode​( value)
      • getProtocol

        public  getProtocol()
      • setProtocol

        public  protocol)
      • getUsername

        public  getUsername()
      • setUsername

        public  username)
      • getPassword

        public  getPassword()
      • setPassword

        public  password)
      • getAuthority

        public  getAuthority()
      • getHost

        public  getHost()
      • setHost

        public  host)
      • getIp

        public  getIp()
        Fetch IP address for this URL. Pls. note that IP should be used instead of Host when to compare with socket's address or to search in a map which use address as its key.
        返回:
        ip in string format
      • getPort

        public int getPort()
      • setPort

        public URL setPort​(int port)
      • getPort

        public int getPort​(int defaultPort)
      • getAddress

        public  getAddress()
      • setAddress

        public  address)
      • getBackupAddress

        public  getBackupAddress()
      • getBackupAddress

        public  getBackupAddress​(int defaultPort)
      • getBackupUrls

        public <URL> getBackupUrls()
      • getPath

        public  getPath()
      • setPath

        public  path)
      • getAbsolutePath

        public  getAbsolutePath()
      • getParameters

        public <,​> getParameters()
      • getParameterAndDecoded

        public  getParameterAndDecoded​( key)
      • getParameterAndDecoded

        public  getParameterAndDecoded​( key,
                                              defaultValue)
      • getParameter

        public  getParameter​( key)
      • getParameter

        public  getParameter​( key,
                                    defaultValue)
      • getParameter

        public [] getParameter​( key,
                                     [] defaultValue)
      • getUrlParameter

        public  key)
      • getParameter

        public double getParameter​( key,
                                   double defaultValue)
      • getParameter

        public float getParameter​( key,
                                  float defaultValue)
      • getParameter

        public long getParameter​( key,
                                 long defaultValue)
      • getParameter

        public int getParameter​( key,
                                int defaultValue)
      • getParameter

        public short getParameter​( key,
                                  short defaultValue)
      • getParameter

        public byte getParameter​( key,
                                 byte defaultValue)
      • getPositiveParameter

        public float getPositiveParameter​( key,
                                          float defaultValue)
      • getPositiveParameter

        public double getPositiveParameter​( key,
                                           double defaultValue)
      • getPositiveParameter

        public long getPositiveParameter​( key,
                                         long defaultValue)
      • getPositiveParameter

        public int getPositiveParameter​( key,
                                        int defaultValue)
      • getPositiveParameter

        public short getPositiveParameter​( key,
                                          short defaultValue)
      • getPositiveParameter

        public byte getPositiveParameter​( key,
                                         byte defaultValue)
      • getParameter

        public char getParameter​( key,
                                 char defaultValue)
      • getParameter

        public boolean getParameter​( key,
                                    boolean defaultValue)
      • hasParameter

        public boolean hasParameter​( key)
      • getMethodParameterAndDecoded

        public  getMethodParameterAndDecoded​( method,
                                                    key)
      • getMethodParameterAndDecoded

        public  getMethodParameterAndDecoded​( method,
                                                    key,
                                                    defaultValue)
      • getMethodParameter

        public  getMethodParameter​( method,
                                          key)
      • getMethodParameter

        public  getMethodParameter​( method,
                                          key,
                                          defaultValue)
      • getMethodParameter

        public double getMethodParameter​( method,
                                          key,
                                         double defaultValue)
      • getMethodParameter

        public float getMethodParameter​( method,
                                         key,
                                        float defaultValue)
      • getMethodParameter

        public long getMethodParameter​( method,
                                        key,
                                       long defaultValue)
      • getMethodParameter

        public int getMethodParameter​( method,
                                       key,
                                      int defaultValue)
      • getMethodParameter

        public short getMethodParameter​( method,
                                         key,
                                        short defaultValue)
      • getMethodParameter

        public byte getMethodParameter​( method,
                                        key,
                                       byte defaultValue)
      • getMethodPositiveParameter

        public double getMethodPositiveParameter​( method,
                                                  key,
                                                 double defaultValue)
      • getMethodPositiveParameter

        public float getMethodPositiveParameter​( method,
                                                 key,
                                                float defaultValue)
      • getMethodPositiveParameter

        public long getMethodPositiveParameter​( method,
                                                key,
                                               long defaultValue)
      • getMethodPositiveParameter

        public int getMethodPositiveParameter​( method,
                                               key,
                                              int defaultValue)
      • getMethodPositiveParameter

        public short getMethodPositiveParameter​( method,
                                                 key,
                                                short defaultValue)
      • getMethodPositiveParameter

        public byte getMethodPositiveParameter​( method,
                                                key,
                                               byte defaultValue)
      • getMethodParameter

        public char getMethodParameter​( method,
                                        key,
                                       char defaultValue)
      • getMethodParameter

        public boolean getMethodParameter​( method,
                                           key,
                                          boolean defaultValue)
      • hasMethodParameter

        public boolean hasMethodParameter​( method,
                                           key)
      • isLocalHost

        public boolean isLocalHost()
      • isAnyHost

        public boolean isAnyHost()
      • addParameterAndEncoded

        public  key,
                                           value)
      • addParameter

        public  key,
                                boolean value)
      • addParameter

        public  key,
                                char value)
      • addParameter

        public  key,
                                byte value)
      • addParameter

        public  key,
                                short value)
      • addParameter

        public  key,
                                int value)
      • addParameter

        public  key,
                                long value)
      • addParameter

        public  key,
                                float value)
      • addParameter

        public  key,
                                double value)
      • addParameter

        public  key,
                                <?> value)
      • addParameter

        public  key,
                                 value)
      • addParameter

        public  key,
                                 value)
      • addParameter

        public  key,
                                 value)
      • addParameterIfAbsent

        public  key,
                                         value)
      • addParameters

        public <,​> parameters)
        Add parameters to a new url.
        参数:
        parameters - parameters in key-value pairs
        返回:
        A new URL
      • addParametersIfAbsent

        public <,​> parameters)
      • addParameters

        public ... pairs)
      • addParameterString

        public  query)
      • removeParameter

        public  key)
      • removeParameters

        public <> keys)
      • removeParameters

        public ... keys)
      • clearParameters

        public URL clearParameters()
      • getRawParameter

        public  getRawParameter​( key)
      • toMap

        public <,​> toMap()
      • toString

        public  toString()
        覆盖:
         在类中 
      • toString

        public  toString​(... parameters)
      • toIdentityString

        public  toIdentityString()
      • toIdentityString

        public  toIdentityString​(... parameters)
      • toFullString

        public  toFullString()
      • toFullString

        public  toFullString​(... parameters)
      • toParameterString

        public  toParameterString()
      • toParameterString

        public  toParameterString​(... parameters)
      • toJavaURL

        public  toJavaURL()
      • toInetSocketAddress

        public  toInetSocketAddress()
      • getServiceKey

        public  getServiceKey()
      • toServiceStringWithoutResolving

        public  toServiceStringWithoutResolving()
      • toServiceString

        public  toServiceString()
      • getServiceName

        public  getServiceName()
        已过时。
      • getServiceInterface

        public  getServiceInterface()
      • setServiceInterface

        public  service)
      • getIntParameter

        public int getIntParameter​( key)
        已过时。
        Replace to getParameter(String, int)
        另请参阅:
        getParameter(String, int)
      • getIntParameter

        public int getIntParameter​( key,
                                   int defaultValue)
        已过时。
        Replace to getParameter(String, int)
        另请参阅:
        getParameter(String, int)
      • getPositiveIntParameter

        public int getPositiveIntParameter​( key,
                                           int defaultValue)
        已过时。
        Replace to getPositiveParameter(String, int)
        另请参阅:
        getPositiveParameter(String, int)
      • getBooleanParameter

        public boolean getBooleanParameter​( key)
        已过时。
        Replace to getParameter(String, boolean)
        另请参阅:
        getParameter(String, boolean)
      • getBooleanParameter

        public boolean getBooleanParameter​( key,
                                           boolean defaultValue)
        已过时。
        Replace to getParameter(String, boolean)
        另请参阅:
        getParameter(String, boolean)
      • getMethodIntParameter

        public int getMethodIntParameter​( method,
                                          key)
        已过时。
        Replace to getMethodParameter(String, String, int)
        另请参阅:
        getMethodParameter(String, String, int)
      • getMethodIntParameter

        public int getMethodIntParameter​( method,
                                          key,
                                         int defaultValue)
        已过时。
        Replace to getMethodParameter(String, String, int)
        另请参阅:
        getMethodParameter(String, String, int)
      • getMethodPositiveIntParameter

        public int getMethodPositiveIntParameter​( method,
                                                  key,
                                                 int defaultValue)
        已过时。
        Replace to getMethodPositiveParameter(String, String, int)
        另请参阅:
        getMethodPositiveParameter(String, String, int)
      • getMethodBooleanParameter

        public boolean getMethodBooleanParameter​( method,
                                                  key)
        已过时。
        Replace to getMethodParameter(String, String, boolean)
        另请参阅:
        getMethodParameter(String, String, boolean)
      • getMethodBooleanParameter

        public boolean getMethodBooleanParameter​( method,
                                                  key,
                                                 boolean defaultValue)
        已过时。
        Replace to getMethodParameter(String, String, boolean)
        另请参阅:
        getMethodParameter(String, String, boolean)
      • hashCode

        public int hashCode()
        覆盖:
         在类中 
      • equals

        public boolean equals​( obj)
        覆盖:
         在类中