com.alibaba.dubbo.common
Class URL

java.lang.Object  extended by com.alibaba.dubbo.common.URL
All Implemented Interfaces:
Serializable

public final class URL
extends Object
implements Serializable

URL - Uniform Resource Locator (Immutable, ThreadSafe)

url example:

  • http://www.facebook.com/friends?param1=value1&param2=value2
  • http://username:password@10.20.130.230:8080/list?version=1.0.0
  • ftp://username:password@192.168.1.7: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 = null, 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

Author:
william.liangf, ding.lid
See Also:
URL, URI, Serialized Form


Constructor Summary
URL(String protocol, String host, int port)
           
URL(String protocol, String host, int port, Map<String,String> parameters)
           
URL(String protocol, String host, int port, String path)
           
URL(String protocol, String host, int port, String[] pairs)
           
URL(String protocol, String host, int port, String path, Map<String,String> parameters)
           
URL(String protocol, String host, int port, String path, String... pairs)
           
URL(String protocol, String username, String password, String host, int port, String path)
           
URL(String protocol, String username, String password, String host, int port, String path, Map<String,String> parameters)
           
URL(String protocol, String username, String password, String host, int port, String path, String... pairs)
           
 
Method Summary
 URLaddParameter(String key, boolean value)
           
 URLaddParameter(String key, byte value)
           
 URLaddParameter(String key, char value)
           
 URLaddParameter(String key, CharSequence value)
           
 URLaddParameter(String key, double value)
           
 URLaddParameter(String key, Enum<?> value)
           
 URLaddParameter(String key, float value)
           
 URLaddParameter(String key, int value)
           
 URLaddParameter(String key, long value)
           
 URLaddParameter(String key, Number value)
           
 URLaddParameter(String key, short value)
           
 URLaddParameter(String key, String value)
           
 URLaddParameterAndEncoded(String key, String value)
           
 URLaddParameterIfAbsent(String key, String value)
           
 URLaddParameters(Map<String,String> parameters)
          Add parameters to a new url.
 URLaddParameters(String... pairs)
           
 URLaddParametersIfAbsent(Map<String,String> parameters)
           
 URLaddParameterString(String query)
           
 URLclearParameters()
           
static Stringdecode(String value)
           
static Stringencode(String value)
           
 booleanequals(Object obj)
           
 StringgetAbsolutePath()
           
 StringgetAddress()
           
 StringgetAuthority()
           
 StringgetBackupAddress()
           
 StringgetBackupAddress(int defaultPort)
           
 List<URL>getBackupUrls()
           
 booleangetBooleanParameter(String key)
          Deprecated. Replace to getParameter(String, boolean)
 booleangetBooleanParameter(String key, boolean defaultValue)
          Deprecated. Replace to getParameter(String, boolean)
 StringgetHost()
           
 intgetIntParameter(String key)
          Deprecated. Replace to getParameter(String, int)
 intgetIntParameter(String key, int defaultValue)
          Deprecated. Replace to getParameter(String, int)
 StringgetIp()
          ??IP??.
 booleangetMethodBooleanParameter(String method, String key)
          Deprecated. Replace to getMethodParameter(String, String, boolean)
 booleangetMethodBooleanParameter(String method, String key, boolean defaultValue)
          Deprecated. Replace to getMethodParameter(String, String, boolean)
 intgetMethodIntParameter(String method, String key)
          Deprecated. Replace to getMethodParameter(String, String, int)
 intgetMethodIntParameter(String method, String key, int defaultValue)
          Deprecated. Replace to getMethodParameter(String, String, int)
 StringgetMethodParameter(String method, String key)
           
 booleangetMethodParameter(String method, String key, boolean defaultValue)
           
 bytegetMethodParameter(String method, String key, byte defaultValue)
           
 chargetMethodParameter(String method, String key, char defaultValue)
           
 doublegetMethodParameter(String method, String key, double defaultValue)
           
 floatgetMethodParameter(String method, String key, float defaultValue)
           
 intgetMethodParameter(String method, String key, int defaultValue)
           
 longgetMethodParameter(String method, String key, long defaultValue)
           
 shortgetMethodParameter(String method, String key, short defaultValue)
           
 StringgetMethodParameter(String method, String key, String defaultValue)
           
 StringgetMethodParameterAndDecoded(String method, String key)
           
 StringgetMethodParameterAndDecoded(String method, String key, String defaultValue)
           
 intgetMethodPositiveIntParameter(String method, String key, int defaultValue)
          Deprecated. Replace to getMethodPositiveParameter(String, String, int)
 bytegetMethodPositiveParameter(String method, String key, byte defaultValue)
           
 doublegetMethodPositiveParameter(String method, String key, double defaultValue)
           
 floatgetMethodPositiveParameter(String method, String key, float defaultValue)
           
 intgetMethodPositiveParameter(String method, String key, int defaultValue)
           
 longgetMethodPositiveParameter(String method, String key, long defaultValue)
           
 shortgetMethodPositiveParameter(String method, String key, short defaultValue)
           
 StringgetParameter(String key)
           
 booleangetParameter(String key, boolean defaultValue)
           
 bytegetParameter(String key, byte defaultValue)
           
 chargetParameter(String key, char defaultValue)
           
 doublegetParameter(String key, double defaultValue)
           
 floatgetParameter(String key, float defaultValue)
           
 intgetParameter(String key, int defaultValue)
           
 longgetParameter(String key, long defaultValue)
           
 shortgetParameter(String key, short defaultValue)
           
 StringgetParameter(String key, String defaultValue)
           
 String[]getParameter(String key, String[] defaultValue)
           
 StringgetParameterAndDecoded(String key)
           
 StringgetParameterAndDecoded(String key, String defaultValue)
           
 Map<String,String>getParameters()
           
 StringgetPassword()
           
 StringgetPath()
           
 intgetPort()
           
 intgetPort(int defaultPort)
           
 intgetPositiveIntParameter(String key, int defaultValue)
          Deprecated. Replace to getPositiveParameter(String, int)
 bytegetPositiveParameter(String key, byte defaultValue)
           
 doublegetPositiveParameter(String key, double defaultValue)
           
 floatgetPositiveParameter(String key, float defaultValue)
           
 intgetPositiveParameter(String key, int defaultValue)
           
 longgetPositiveParameter(String key, long defaultValue)
           
 shortgetPositiveParameter(String key, short defaultValue)
           
 StringgetProtocol()
           
 StringgetRawParameter(String key)
           
 StringgetServiceInterface()
           
 StringgetServiceKey()
           
 StringgetServiceName()
          Deprecated. 
 URLgetUrlParameter(String key)
           
 StringgetUsername()
           
 inthashCode()
           
 booleanhasMethodParameter(String method, String key)
           
 booleanhasParameter(String key)
           
 booleanisAnyHost()
           
 booleanisLocalHost()
           
 URLremoveParameter(String key)
           
 URLremoveParameters(Collection<String> keys)
           
 URLremoveParameters(String... keys)
           
 URLsetAddress(String address)
           
 URLsetHost(String host)
           
 URLsetPassword(String password)
           
 URLsetPath(String path)
           
 URLsetPort(int port)
           
 URLsetProtocol(String protocol)
           
 URLsetServiceInterface(String service)
           
 URLsetUsername(String username)
           
 StringtoFullString()
           
 StringtoFullString(String... parameters)
           
 StringtoIdentityString()
           
 StringtoIdentityString(String... parameters)
           
 InetSocketAddresstoInetSocketAddress()
           
 URLtoJavaURL()
           
 Map<String,String>toMap()
           
 StringtoParameterString()
           
 StringtoParameterString(String... parameters)
           
 StringtoServiceString()
           
 StringtoString()
           
 StringtoString(String... parameters)
           
static URLvalueOf(String url)
          Parse url string
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

URL

public URL(String protocol,           String host,           int port)

URL

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

URL

public URL(String protocol,           String host,           int port,           Map<String,String> parameters)

URL

public URL(String protocol,           String host,           int port,           String path)

URL

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

URL

public URL(String protocol,           String host,           int port,           String path,           Map<String,String> parameters)

URL

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

URL

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

URL

public URL(String protocol,           String username,           String password,           String host,           int port,           String path,           Map<String,String> parameters)
Method Detail

valueOf

public static URL valueOf(String url)
Parse url string

Parameters:
url - URL string
Returns:
URL instance
See Also:
URL

getProtocol

public String getProtocol()

getUsername

public String getUsername()

getPassword

public String getPassword()

getAuthority

public String getAuthority()

getHost

public String getHost()

getIp

public String getIp()
??IP??. ???? ???Socket?????? ??????Map?Key??? ???IP???Host? ??????????

Returns:
ip

getPort

public int getPort()

getPort

public int getPort(int defaultPort)

getAddress

public String getAddress()

getBackupAddress

public String getBackupAddress()

getBackupAddress

public String getBackupAddress(int defaultPort)

getBackupUrls

public List<URL> getBackupUrls()

getPath

public String getPath()

getAbsolutePath

public String getAbsolutePath()

setProtocol

public URL setProtocol(String protocol)

setUsername

public URL setUsername(String username)

setPassword

public URL setPassword(String password)

setAddress

public URL setAddress(String address)

setHost

public URL setHost(String host)

setPort

public URL setPort(int port)

setPath

public URL setPath(String path)

getParameters

public Map<String,String> getParameters()

getParameterAndDecoded

public String getParameterAndDecoded(String key)

getParameterAndDecoded

public String getParameterAndDecoded(String key,                                     String defaultValue)

getParameter

public String getParameter(String key)

getParameter

public String getParameter(String key,                           String defaultValue)

getParameter

public String[] getParameter(String key,                             String[] defaultValue)

getUrlParameter

public URL getUrlParameter(String key)

getParameter

public double getParameter(String key,                           double defaultValue)

getParameter

public float getParameter(String key,                          float defaultValue)

getParameter

public long getParameter(String key,                         long defaultValue)

getParameter

public int getParameter(String key,                        int defaultValue)

getParameter

public short getParameter(String key,                          short defaultValue)

getParameter

public byte getParameter(String key,                         byte defaultValue)

getPositiveParameter

public float getPositiveParameter(String key,                                  float defaultValue)

getPositiveParameter

public double getPositiveParameter(String key,                                   double defaultValue)

getPositiveParameter

public long getPositiveParameter(String key,                                 long defaultValue)

getPositiveParameter

public int getPositiveParameter(String key,                                int defaultValue)

getPositiveParameter

public short getPositiveParameter(String key,                                  short defaultValue)

getPositiveParameter

public byte getPositiveParameter(String key,                                 byte defaultValue)

getParameter

public char getParameter(String key,                         char defaultValue)

getParameter

public boolean getParameter(String key,                            boolean defaultValue)

hasParameter

public boolean hasParameter(String key)

getMethodParameterAndDecoded

public String getMethodParameterAndDecoded(String method,                                           String key)

getMethodParameterAndDecoded

public String getMethodParameterAndDecoded(String method,                                           String key,                                           String defaultValue)

getMethodParameter

public String getMethodParameter(String method,                                 String key)

getMethodParameter

public String getMethodParameter(String method,                                 String key,                                 String defaultValue)

getMethodParameter

public double getMethodParameter(String method,                                 String key,                                 double defaultValue)

getMethodParameter

public float getMethodParameter(String method,                                String key,                                float defaultValue)

getMethodParameter

public long getMethodParameter(String method,                               String key,                               long defaultValue)

getMethodParameter

public int getMethodParameter(String method,                              String key,                              int defaultValue)

getMethodParameter

public short getMethodParameter(String method,                                String key,                                short defaultValue)

getMethodParameter

public byte getMethodParameter(String method,                               String key,                               byte defaultValue)

getMethodPositiveParameter

public double getMethodPositiveParameter(String method,                                         String key,                                         double defaultValue)

getMethodPositiveParameter

public float getMethodPositiveParameter(String method,                                        String key,                                        float defaultValue)

getMethodPositiveParameter

public long getMethodPositiveParameter(String method,                                       String key,                                       long defaultValue)

getMethodPositiveParameter

public int getMethodPositiveParameter(String method,                                      String key,                                      int defaultValue)

getMethodPositiveParameter

public short getMethodPositiveParameter(String method,                                        String key,                                        short defaultValue)

getMethodPositiveParameter

public byte getMethodPositiveParameter(String method,                                       String key,                                       byte defaultValue)

getMethodParameter

public char getMethodParameter(String method,                               String key,                               char defaultValue)

getMethodParameter

public boolean getMethodParameter(String method,                                  String key,                                  boolean defaultValue)

hasMethodParameter

public boolean hasMethodParameter(String method,                                  String key)

isLocalHost

public boolean isLocalHost()

isAnyHost

public boolean isAnyHost()

addParameterAndEncoded

public URL addParameterAndEncoded(String key,                                  String value)

addParameter

public URL addParameter(String key,                        boolean value)

addParameter

public URL addParameter(String key,                        char value)

addParameter

public URL addParameter(String key,                        byte value)

addParameter

public URL addParameter(String key,                        short value)

addParameter

public URL addParameter(String key,                        int value)

addParameter

public URL addParameter(String key,                        long value)

addParameter

public URL addParameter(String key,                        float value)

addParameter

public URL addParameter(String key,                        double value)

addParameter

public URL addParameter(String key,                        Enum<?> value)

addParameter

public URL addParameter(String key,                        Number value)

addParameter

public URL addParameter(String key,                        CharSequence value)

addParameter

public URL addParameter(String key,                        String value)

addParameterIfAbsent

public URL addParameterIfAbsent(String key,                                String value)

addParameters

public URL addParameters(Map<String,String> parameters)
Add parameters to a new url.

Parameters:
parameters -
Returns:
A new URL

addParametersIfAbsent

public URL addParametersIfAbsent(Map<String,String> parameters)

addParameters

public URL addParameters(String... pairs)

addParameterString

public URL addParameterString(String query)

removeParameter

public URL removeParameter(String key)

removeParameters

public URL removeParameters(Collection<String> keys)

removeParameters

public URL removeParameters(String... keys)

clearParameters

public URL clearParameters()

getRawParameter

public String getRawParameter(String key)

toMap

public Map<String,String> toMap()

toString

public String toString()
Overrides:
toString in class Object

toString

public String toString(String... parameters)

toIdentityString

public String toIdentityString()

toIdentityString

public String toIdentityString(String... parameters)

toFullString

public String toFullString()

toFullString

public String toFullString(String... parameters)

toParameterString

public String toParameterString()

toParameterString

public String toParameterString(String... parameters)

toJavaURL

public URL toJavaURL()

toInetSocketAddress

public InetSocketAddress toInetSocketAddress()

getServiceKey

public String getServiceKey()

toServiceString

public String toServiceString()

getServiceName

@Deprecatedpublic String getServiceName()
Deprecated. 


getServiceInterface

public String getServiceInterface()

setServiceInterface

public URL setServiceInterface(String service)

getIntParameter

@Deprecatedpublic int getIntParameter(String key)
Deprecated. Replace to getParameter(String, int)

See Also:
getParameter(String, int)

getIntParameter

@Deprecatedpublic int getIntParameter(String key,                                      int defaultValue)
Deprecated. Replace to getParameter(String, int)

See Also:
getParameter(String, int)

getPositiveIntParameter

@Deprecatedpublic int getPositiveIntParameter(String key,                                              int defaultValue)
Deprecated. Replace to getPositiveParameter(String, int)

See Also:
getPositiveParameter(String, int)

getBooleanParameter

@Deprecatedpublic boolean getBooleanParameter(String key)
Deprecated. Replace to getParameter(String, boolean)

See Also:
getParameter(String, boolean)

getBooleanParameter

@Deprecatedpublic boolean getBooleanParameter(String key,                                              boolean defaultValue)
Deprecated. Replace to getParameter(String, boolean)

See Also:
getParameter(String, boolean)

getMethodIntParameter

@Deprecatedpublic int getMethodIntParameter(String method,                                            String key)
Deprecated. Replace to getMethodParameter(String, String, int)

See Also:
getMethodParameter(String, String, int)

getMethodIntParameter

@Deprecatedpublic int getMethodIntParameter(String method,                                            String key,                                            int defaultValue)
Deprecated. Replace to getMethodParameter(String, String, int)

See Also:
getMethodParameter(String, String, int)

getMethodPositiveIntParameter

@Deprecatedpublic int getMethodPositiveIntParameter(String method,                                                    String key,                                                    int defaultValue)
Deprecated. Replace to getMethodPositiveParameter(String, String, int)

See Also:
getMethodPositiveParameter(String, String, int)

getMethodBooleanParameter

@Deprecatedpublic boolean getMethodBooleanParameter(String method,                                                    String key)
Deprecated. Replace to getMethodParameter(String, String, boolean)

See Also:
getMethodParameter(String, String, boolean)

getMethodBooleanParameter

@Deprecatedpublic boolean getMethodBooleanParameter(String method,                                                    String key,                                                    boolean defaultValue)
Deprecated. Replace to getMethodParameter(String, String, boolean)

See Also:
getMethodParameter(String, String, boolean)

encode

public static String encode(String value)

decode

public static String decode(String value)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2012
Alibaba. All Rights Reserved.


NOTHING
NOTHING
Add the Maven Dependecy to your project: maven dependecy for com.amazonaws : aws-java-sdk : 1.3.14