Class QueryParameters
- All Implemented Interfaces:
Serializable
- Since:
- 1.0.
- Author:
- Vaadin Ltd
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionQueryParameters(Map<String, List<String>> parameters) Creates query parameters from parameter map. -
Method Summary
Modifier and TypeMethodDescriptionstatic QueryParametersempty()Creates an empty query parameters information.booleanReturn new QueryParameters excluding given parameters by names.static QueryParametersfromString(String queryString) Creates parameters from a query string.static QueryParametersCreates parameters from full representation, where each parameter name may correspond to multiple values.Returns query parameters information with support for multiple values corresponding to single parameter name.getParameters(String key) Returns query parameter values mapped with the given key.Returns a UTF-8 encoded query string containing all parameter names and values suitable for appending to a URL after the?character.getSingleParameter(String key) Returns the first query parameter values mapped with the given key.inthashCode()Return new QueryParameters including only the given parameters.Return new QueryParameters adding given parameter to the existing ones.mergingAll(Map<String, List<String>> parameters) Return new QueryParameters including given parameters and the existing ones.static QueryParametersCreates parameters from given key-value pair.static QueryParametersCreates parameters from simple representation, where each parameter name corresponds to a single value.toString()
-
Constructor Details
-
QueryParameters
Creates query parameters from parameter map.The parameters keep the iteration order of the given map, so use an ordered map such as
LinkedHashMapto control the order in which they appear ingetQueryString(). Maps without a defined order, such as the ones created byMap.of, may give a different order in each JVM run.- Parameters:
parameters- the parameter map
-
-
Method Details
-
empty
Creates an empty query parameters information.- Returns:
- query parameters information
-
full
Creates parameters from full representation, where each parameter name may correspond to multiple values.The parameters keep the iteration order of the given map, so use an ordered map such as
LinkedHashMapto control the order in which they appear ingetQueryString(). Maps without a defined order, such as the ones created byMap.of, may give a different order in each JVM run.- Parameters:
parameters- query parameters map- Returns:
- query parameters information
-
simple
Creates parameters from simple representation, where each parameter name corresponds to a single value.The parameters keep the iteration order of the given map, so use an ordered map such as
LinkedHashMapto control the order in which they appear ingetQueryString(). Maps without a defined order, such as the ones created byMap.of, may give a different order in each JVM run.- Parameters:
parameters- query parameters map- Returns:
- query parameters information
-
of
Creates parameters from given key-value pair.- Parameters:
key- the name of the parametervalue- the value- Returns:
- query parameters information
- Since:
- 23.2
-
fromString
Creates parameters from a query string.Note that no length checking is done for the string. It is the responsibility of the caller (or the server) to limit the length of the query string.
- Parameters:
queryString- the query string- Returns:
- query parameters information
- Since:
- 7.0
-
getParameters
Returns query parameters information with support for multiple values corresponding to single parameter name.Example:
https://example.com/?one=1&two=2&one=3will result in the corresponding map:{"one" : [1, 3], "two": [2]}- Returns:
- query parameters information
-
getParameters
Returns query parameter values mapped with the given key.Example: Calling the method with key "one" for a parameters like
https://example.com/?one=1&two=2&one=3will result in the corresponding list:[1, 3]- Parameters:
key- the key of query parameters to fetch- Returns:
- query parameters or an empty list if there are no parameters with the given key
- Since:
- 24.2
-
getSingleParameter
Returns the first query parameter values mapped with the given key.Example: Calling with key value "one" with
https://example.com/?one=1&two=2&one=3will return1- Parameters:
key- the key of query parameters to fetch- Returns:
- query parameter value or empty if there are no parameters with the given key
- Since:
- 24.2
-
getQueryString
Returns a UTF-8 encoded query string containing all parameter names and values suitable for appending to a URL after the?character. Parameters appear in the order they were given in: the order of the query string they were parsed from, or the iteration order of the map they were created from. All values of a parameter are written together at the position of its first occurrence, and values may be differently encoded (for example, if a space was encoded as+in the initial URL it will be encoded as%20in the result).- Returns:
- query string suitable for appending to a URL
- See Also:
-
excluding
Return new QueryParameters excluding given parameters by names.- Parameters:
keys- Names of the parameters to be excluded- Returns:
- QueryParameters
- Since:
- 24.2
-
including
Return new QueryParameters including only the given parameters.- Parameters:
keys- Names of the parameters to be included- Returns:
- QueryParameters.
- Since:
- 24.2
-
merging
Return new QueryParameters adding given parameter to the existing ones. If a parameter with the same name is already present, its values will be replaced with the provided ones, keeping its position; otherwise it is added after the existing ones.- Parameters:
key- Parameter name as Stringvalues- Values for the parameter as Strings- Returns:
- QueryParameters.
- Since:
- 24.2
-
mergingAll
Return new QueryParameters including given parameters and the existing ones. Existing parameters will be replaced by the provided ones, keeping their position; new ones are added after the existing ones.- Parameters:
parameters- Map of new parameters to be included- Returns:
- QueryParameters
- Since:
- 24.2
-
toString
-
equals
-
hashCode
public int hashCode()
-