类 URL
- java.lang.Object
-
- com.alibaba.dubbo.common.URL
-
- 所有已实现的接口:
Serializable
public final class URL extends Object implements Serializable
URL - Uniform Resource Locator (Immutable, ThreadSafe)url example:
- http://www.facebook.com/friends?param1=value1¶m2=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¶m2=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
-
-
构造器概要
构造器 构造器 说明 URL(String protocol, String host, int port)
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, String... pairs)
URL(String protocol, String host, int port, String path, Map<String,String> parameters)
URL(String protocol, String host, int port, Map<String,String> parameters)
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, String... pairs)
URL(String protocol, String username, String password, String host, int port, String path, Map<String,String> parameters)
-
方法概要
所有方法 静态方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 URL
addParameter(String key, boolean value)
URL
addParameter(String key, byte value)
URL
addParameter(String key, char value)
URL
addParameter(String key, double value)
URL
addParameter(String key, float value)
URL
addParameter(String key, int value)
URL
addParameter(String key, long value)
URL
addParameter(String key, short value)
URL
addParameter(String key, CharSequence value)
URL
addParameter(String key, Enum<?> value)
URL
addParameter(String key, Number value)
URL
addParameter(String key, String value)
URL
addParameterAndEncoded(String key, String value)
URL
addParameterIfAbsent(String key, String value)
URL
addParameters(String... pairs)
URL
addParameters(Map<String,String> parameters)
Add parameters to a new url.URL
addParametersIfAbsent(Map<String,String> parameters)
URL
addParameterString(String query)
URL
clearParameters()
static String
decode(String value)
static String
encode(String value)
boolean
equals(Object obj)
String
getAbsolutePath()
String
getAddress()
String
getAuthority()
String
getBackupAddress()
String
getBackupAddress(int defaultPort)
List<URL>
getBackupUrls()
boolean
getBooleanParameter(String key)
已过时。Replace togetParameter(String, boolean)
boolean
getBooleanParameter(String key, boolean defaultValue)
已过时。Replace togetParameter(String, boolean)
String
getHost()
int
getIntParameter(String key)
已过时。Replace togetParameter(String, int)
int
getIntParameter(String key, int defaultValue)
已过时。Replace togetParameter(String, int)
String
getIp()
Fetch IP address for this URL.boolean
getMethodBooleanParameter(String method, String key)
已过时。Replace togetMethodParameter(String, String, boolean)
boolean
getMethodBooleanParameter(String method, String key, boolean defaultValue)
已过时。Replace togetMethodParameter(String, String, boolean)
int
getMethodIntParameter(String method, String key)
已过时。Replace togetMethodParameter(String, String, int)
int
getMethodIntParameter(String method, String key, int defaultValue)
已过时。Replace togetMethodParameter(String, String, int)
String
getMethodParameter(String method, String key)
boolean
getMethodParameter(String method, String key, boolean defaultValue)
byte
getMethodParameter(String method, String key, byte defaultValue)
char
getMethodParameter(String method, String key, char defaultValue)
double
getMethodParameter(String method, String key, double defaultValue)
float
getMethodParameter(String method, String key, float defaultValue)
int
getMethodParameter(String method, String key, int defaultValue)
long
getMethodParameter(String method, String key, long defaultValue)
short
getMethodParameter(String method, String key, short defaultValue)
String
getMethodParameter(String method, String key, String defaultValue)
String
getMethodParameterAndDecoded(String method, String key)
String
getMethodParameterAndDecoded(String method, String key, String defaultValue)
int
getMethodPositiveIntParameter(String method, String key, int defaultValue)
已过时。Replace togetMethodPositiveParameter(String, String, int)
byte
getMethodPositiveParameter(String method, String key, byte defaultValue)
double
getMethodPositiveParameter(String method, String key, double defaultValue)
float
getMethodPositiveParameter(String method, String key, float defaultValue)
int
getMethodPositiveParameter(String method, String key, int defaultValue)
long
getMethodPositiveParameter(String method, String key, long defaultValue)
short
getMethodPositiveParameter(String method, String key, short defaultValue)
String
getParameter(String key)
boolean
getParameter(String key, boolean defaultValue)
byte
getParameter(String key, byte defaultValue)
char
getParameter(String key, char defaultValue)
double
getParameter(String key, double defaultValue)
float
getParameter(String key, float defaultValue)
int
getParameter(String key, int defaultValue)
long
getParameter(String key, long defaultValue)
short
getParameter(String key, short defaultValue)
String
getParameter(String key, String defaultValue)
String[]
getParameter(String key, String[] defaultValue)
String
getParameterAndDecoded(String key)
String
getParameterAndDecoded(String key, String defaultValue)
Map<String,String>
getParameters()
String
getPassword()
String
getPath()
int
getPort()
int
getPort(int defaultPort)
int
getPositiveIntParameter(String key, int defaultValue)
已过时。Replace togetPositiveParameter(String, int)
byte
getPositiveParameter(String key, byte defaultValue)
double
getPositiveParameter(String key, double defaultValue)
float
getPositiveParameter(String key, float defaultValue)
int
getPositiveParameter(String key, int defaultValue)
long
getPositiveParameter(String key, long defaultValue)
short
getPositiveParameter(String key, short defaultValue)
String
getProtocol()
String
getRawParameter(String key)
String
getServiceInterface()
String
getServiceKey()
String
getServiceName()
已过时。URL
getUrlParameter(String key)
String
getUsername()
int
hashCode()
boolean
hasMethodParameter(String method, String key)
boolean
hasParameter(String key)
boolean
isAnyHost()
boolean
isLocalHost()
URL
removeParameter(String key)
URL
removeParameters(String... keys)
URL
removeParameters(Collection<String> keys)
URL
setAddress(String address)
URL
setHost(String host)
URL
setPassword(String password)
URL
setPath(String path)
URL
setPort(int port)
URL
setProtocol(String protocol)
URL
setServiceInterface(String service)
URL
setUsername(String username)
String
toFullString()
String
toFullString(String... parameters)
String
toIdentityString()
String
toIdentityString(String... parameters)
InetSocketAddress
toInetSocketAddress()
URL
toJavaURL()
Map<String,String>
toMap()
String
toParameterString()
String
toParameterString(String... parameters)
String
toServiceString()
String
toServiceStringWithoutResolving()
String
toString()
String
toString(String... parameters)
static URL
valueOf(String url)
Parse url string
-
-
-
方法详细资料
-
valueOf
public static URL valueOf(String url)
Parse url string- 参数:
url
- URL string- 返回:
- URL instance
- 另请参阅:
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()
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 String getAddress()
-
getBackupAddress
public String getBackupAddress()
-
getBackupAddress
public String getBackupAddress(int defaultPort)
-
getPath
public String getPath()
-
getAbsolutePath
public String getAbsolutePath()
-
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, String 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 boolean getMethodParameter(String method, String key, boolean defaultValue)
-
isLocalHost
public boolean isLocalHost()
-
isAnyHost
public boolean isAnyHost()
-
addParameter
public URL addParameter(String key, CharSequence value)
-
addParameters
public URL addParameters(Map<String,String> parameters)
Add parameters to a new url.- 参数:
parameters
- parameters in key-value pairs- 返回:
- A new URL
-
removeParameters
public URL removeParameters(Collection<String> keys)
-
clearParameters
public URL clearParameters()
-
toIdentityString
public String toIdentityString()
-
toFullString
public String toFullString()
-
toParameterString
public String toParameterString()
-
toJavaURL
public URL toJavaURL()
-
toInetSocketAddress
public InetSocketAddress toInetSocketAddress()
-
getServiceKey
public String getServiceKey()
-
toServiceStringWithoutResolving
public String toServiceStringWithoutResolving()
-
toServiceString
public String toServiceString()
-
getServiceName
@Deprecated public String getServiceName()
已过时。
-
getServiceInterface
public String getServiceInterface()
-
getIntParameter
@Deprecated public int getIntParameter(String key)
已过时。Replace togetParameter(String, int)
-
getIntParameter
@Deprecated public int getIntParameter(String key, int defaultValue)
已过时。Replace togetParameter(String, int)
-
getPositiveIntParameter
@Deprecated public int getPositiveIntParameter(String key, int defaultValue)
已过时。Replace togetPositiveParameter(String, int)
-
getBooleanParameter
@Deprecated public boolean getBooleanParameter(String key)
已过时。Replace togetParameter(String, boolean)
-
getBooleanParameter
@Deprecated public boolean getBooleanParameter(String key, boolean defaultValue)
已过时。Replace togetParameter(String, boolean)
-
getMethodIntParameter
@Deprecated public int getMethodIntParameter(String method, String key)
已过时。Replace togetMethodParameter(String, String, int)
-
getMethodIntParameter
@Deprecated public int getMethodIntParameter(String method, String key, int defaultValue)
已过时。Replace togetMethodParameter(String, String, int)
-
getMethodPositiveIntParameter
@Deprecated public int getMethodPositiveIntParameter(String method, String key, int defaultValue)
已过时。Replace togetMethodPositiveParameter(String, String, int)
-
getMethodBooleanParameter
@Deprecated public boolean getMethodBooleanParameter(String method, String key)
已过时。Replace togetMethodParameter(String, String, boolean)
-
getMethodBooleanParameter
@Deprecated public boolean getMethodBooleanParameter(String method, String key, boolean defaultValue)
已过时。Replace togetMethodParameter(String, String, boolean)
-
-