Class URLParam
java.lang.Object
org.apache.dubbo.common.url.component.URLParam
- Direct Known Subclasses:
URLPlainParam
A class which store parameters for
Using
URLParam should operate as Copy-On-Write, each modify actions will return a new Object
URL
Using
DynamicParamTable to compress common keys (i.e. side, version)
DynamicParamTable allow to use only two integer value named `key` and
`value-offset` to find a unique string to string key-pair. Also, `value-offset`
is not required if the real value is the default value.
URLParam should operate as Copy-On-Write, each modify actions will return a new Object
NOTE: URLParam is not support serialization! DynamicParamTable is related with
current running environment. If you want to make URL as a parameter, please call
URL.toSerializableURL() to create URLPlainParam instead.
- Since:
- 3.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn embedded Map adapt to URLParam
copy-on-write mode, urlParam reference will be changed after modify actions. -
Method Summary
Modifier and TypeMethodDescriptionaddParameter(String key, String value) Add parameters to a new URLParam.addParameterIfAbsent(String key, String value) Add absent parameters to a new URLParam.addParameters(Map<String, String> parameters) Add parameters to a new URLParam.addParametersIfAbsent(Map<String, String> parameters) Add absent parameters to a new URLParam.remove all of the parameters in URLParambooleanGet any method related parameter which match keygetMethodParameter(String method, String key) Get method related parameter.getMethodParameterStrict(String method, String key) Get method related parameter.getParameter(String key) get value of specified key in URLParamGet a Map like URLParamget raw string like parameterslonginthashCode()booleanhasMethodParameter(String method) Weather there contains some parameter match methodbooleanhasParameter(String key) check if specified key is present in URLParaminitMethodParameters(Map<String, String> parameters) static URLParamParse URLParam Init URLParam by constructor is not allowedstatic URLParamParse URLParam Init URLParam by constructor is not allowedstatic URLParamParse URLParam Init URLParam by constructor is not allowed rawParam field in result will be null whilegetRawParam()will automatically create itstatic URLParamParse URLParam Init URLParam by constructor is not allowedremoveParameters(String... keys) remove specified parameters in URLParamvoidsetTimestamp(long timestamp) toString()
-
Method Details
-
hasMethodParameter
Weather there contains some parameter match method- Parameters:
method- method name- Returns:
- contains or not
-
getMethodParameter
Get method related parameter. If not contains, use getParameter(key) instead. Specially, in some situation like `method1.1.callback=true`, key is `1.callback`.- Parameters:
method- method namekey- key- Returns:
- value
-
getMethodParameterStrict
Get method related parameter. If not contains, return null. Specially, in some situation like `method1.1.callback=true`, key is `1.callback`.- Parameters:
method- method namekey- key- Returns:
- value
-
initMethodParameters
-
getParameters
Get a Map like URLParam- Returns:
- a
URLParam.URLParamMapadapt to URLParam
-
getAnyMethodParameter
Get any method related parameter which match key- Parameters:
key- key- Returns:
- result ( if any, random choose one )
-
addParameter
Add parameters to a new URLParam.- Parameters:
key- keyvalue- value- Returns:
- A new URLParam
-
addParameterIfAbsent
Add absent parameters to a new URLParam.- Parameters:
key- keyvalue- value- Returns:
- A new URLParam
-
addParameters
Add parameters to a new URLParam. If key-pair is present, this will cover it.- Parameters:
parameters- parameters in key-value pairs- Returns:
- A new URLParam
-
addParametersIfAbsent
Add absent parameters to a new URLParam.- Parameters:
parameters- parameters in key-value pairs- Returns:
- A new URL
-
removeParameters
remove specified parameters in URLParam- Parameters:
keys- keys to being removed- Returns:
- A new URLParam
-
clearParameters
remove all of the parameters in URLParam- Returns:
- An empty URLParam
-
hasParameter
check if specified key is present in URLParam- Parameters:
key- specified key- Returns:
- present or not
-
getParameter
get value of specified key in URLParam- Parameters:
key- specified key- Returns:
- value, null if key is absent
-
getRawParam
get raw string like parameters- Returns:
- raw string like parameters
-
getTimestamp
public long getTimestamp() -
setTimestamp
public void setTimestamp(long timestamp) -
equals
-
hashCode
public int hashCode() -
toString
-
parse
Parse URLParam Init URLParam by constructor is not allowed rawParam field in result will be null whilegetRawParam()will automatically create it- Parameters:
params- params map added into URLParam- Returns:
- a new URLParam
-
parse
Parse URLParam Init URLParam by constructor is not allowed- Parameters:
rawParam- original rawParam stringencoded- if parameters are URL encodedextraParameters- extra parameters to add into URLParam- Returns:
- a new URLParam
-
parse
Parse URLParam Init URLParam by constructor is not allowed- Parameters:
rawParam- original rawParam string- Returns:
- a new URLParam
-
parse
Parse URLParam Init URLParam by constructor is not allowed- Parameters:
params- params map added into URLParamrawParam- original rawParam string, directly add to rawParam field, will not affect real key-pairs store in URLParam. Please make sure it can correspond with params or will cause unexpected result when callinggetRawParam()andtoString()()}. If you not sure, you can callparse(String)to init.- Returns:
- a new URLParam
-