类 URLParam

  • 直接已知子类:
    URLPlainParam

    public class URLParam
    extends Object
    A class which store parameters for 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.
    从以下版本开始:
    3.0
    • 方法详细资料

      • hasMethodParameter

        public boolean hasMethodParameter​(String method)
        Weather there contains some parameter match method
        参数:
        method - method name
        返回:
        contains or not
      • getMethodParameter

        public String getMethodParameter​(String method,
                                         String key)
        Get method related parameter. If not contains, use getParameter(key) instead. Specially, in some situation like `method1.1.callback=true`, key is `1.callback`.
        参数:
        method - method name
        key - key
        返回:
        value
      • getMethodParameterStrict

        public String getMethodParameterStrict​(String method,
                                               String key)
        Get method related parameter. If not contains, return null. Specially, in some situation like `method1.1.callback=true`, key is `1.callback`.
        参数:
        method - method name
        key - key
        返回:
        value
      • getAnyMethodParameter

        public String getAnyMethodParameter​(String key)
        Get any method related parameter which match key
        参数:
        key - key
        返回:
        result ( if any, random choose one )
      • addParameter

        public URLParam addParameter​(String key,
                                     String value)
        Add parameters to a new URLParam.
        参数:
        key - key
        value - value
        返回:
        A new URLParam
      • addParameterIfAbsent

        public URLParam addParameterIfAbsent​(String key,
                                             String value)
        Add absent parameters to a new URLParam.
        参数:
        key - key
        value - value
        返回:
        A new URLParam
      • addParameters

        public URLParam addParameters​(Map<String,​String> parameters)
        Add parameters to a new URLParam. If key-pair is present, this will cover it.
        参数:
        parameters - parameters in key-value pairs
        返回:
        A new URLParam
      • addParametersIfAbsent

        public URLParam addParametersIfAbsent​(Map<String,​String> parameters)
        Add absent parameters to a new URLParam.
        参数:
        parameters - parameters in key-value pairs
        返回:
        A new URL
      • removeParameters

        public URLParam removeParameters​(String... keys)
        remove specified parameters in URLParam
        参数:
        keys - keys to being removed
        返回:
        A new URLParam
      • clearParameters

        public URLParam clearParameters()
        remove all of the parameters in URLParam
        返回:
        An empty URLParam
      • hasParameter

        public boolean hasParameter​(String key)
        check if specified key is present in URLParam
        参数:
        key - specified key
        返回:
        present or not
      • getParameter

        public String getParameter​(String key)
        get value of specified key in URLParam
        参数:
        key - specified key
        返回:
        value, null if key is absent
      • getRawParam

        public String getRawParam()
        get raw string like parameters
        返回:
        raw string like parameters
      • getTimestamp

        public long getTimestamp()
      • setTimestamp

        public void setTimestamp​(long timestamp)
      • hashCode

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

        public static URLParam parse​(Map<String,​String> params)
        Parse URLParam Init URLParam by constructor is not allowed rawParam field in result will be null while getRawParam() will automatically create it
        参数:
        params - params map added into URLParam
        返回:
        a new URLParam
      • parse

        public static URLParam parse​(String rawParam,
                                     boolean encoded,
                                     Map<String,​String> extraParameters)
        Parse URLParam Init URLParam by constructor is not allowed
        参数:
        rawParam - original rawParam string
        encoded - if parameters are URL encoded
        extraParameters - extra parameters to add into URLParam
        返回:
        a new URLParam
      • parse

        public static URLParam parse​(String rawParam)
        Parse URLParam Init URLParam by constructor is not allowed
        参数:
        rawParam - original rawParam string
        返回:
        a new URLParam
      • parse

        public static URLParam parse​(Map<String,​String> params,
                                     String rawParam)
        Parse URLParam Init URLParam by constructor is not allowed
        参数:
        params - params map added into URLParam
        rawParam - original rawParam string, directly add to rawParam field, will not effect real key-pairs store in URLParam. Please make sure it can correspond with params or will cause unexpected result when calling getRawParam() and toString() ()}. If you not sure, you can call parse(String) to init.
        返回:
        a new URLParam