java.lang.Object
de.cuioss.tools.net.UrlParameter
- All Implemented Interfaces:
Serializable,Comparable<UrlParameter>
Simple wrapper around an Url Parameter Object.
Depending on the constructor arguments the attributes #getName() and
#getValue() are implicitly encoded properly using
URLEncoder.encode(String, String). This is helpful for reliable
handling of special characters.
- Author:
- Oliver Wolff
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final UrlParameterShortcut constant for faces redirect parameter.static final UrlParameterShortcut constant parameter for includeViewParams. -
Constructor Summary
ConstructorsConstructorDescriptionUrlParameter(String name, String value) Constructor.UrlParameter(String name, String value, boolean encode) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(UrlParameter compareTo) Create a String representation of a name value pair, saying name=valuecreateNameValueString(boolean encode) createParameterMap(List<UrlParameter> urlParameters) Create a parameterMap for a given list ofUrlParameterstatic StringcreateParameterString(boolean encode, UrlParameter... parameters) Create a String-representation of the URL-Parameterstatic StringcreateParameterString(UrlParameter... parameters) Creates a parameter String for a given number ofUrlParameter.static List<UrlParameter>filterParameter(List<UrlParameter> toBeFiltered, ParameterFilter parameterFilter) Filters the given list ofUrlParameterstatic List<UrlParameter>fromQueryString(String queryString) Helper class that create a list ofUrlParameterfrom a given query-Stringstatic final List<UrlParameter>getUrlParameterFromMap(Map<String, List<String>> map, ParameterFilter parameterFilter, boolean encode) Convert a map of raw Url-parameter into a list ofUrlParameterbooleanisEmpty()Returns a boolean indicating whether theUrlParameteris empty, saying has a null value
-
Field Details
-
FACES_REDIRECT
Shortcut constant for faces redirect parameter. -
INCLUDE_VIEW_PARAMETER
Shortcut constant parameter for includeViewParams.
-
-
Constructor Details
-
UrlParameter
Constructor. Name and value are implicitly encoded using UTF-8.- Parameters:
name- must not be null or emptyvalue- may be null.
-
UrlParameter
Constructor.- Parameters:
name- must not be null or emptyvalue- value may be null.encode- indicates whether to encode the parameter name and value as UTF-8
-
-
Method Details
-
isEmpty
Returns a boolean indicating whether theUrlParameteris empty, saying has a null value- Returns:
- boolean flag whether the
UrlParameteris empty
-
createParameterString
Creates a parameter String for a given number ofUrlParameter.- Parameters:
parameters- to be appended, must not be null- Returns:
- the concatenated ParameterString in the form "?parameter1Name=parameter1Value¶meter2Name=parameter2Value"
-
createParameterString
Create a String-representation of the URL-Parameter- Parameters:
encode-parameters-- Returns:
- the created parameter String
-
getUrlParameterFromMap
public static final List<UrlParameter> getUrlParameterFromMap(Map<String, List<String>> map, ParameterFilter parameterFilter, boolean encode) Convert a map of raw Url-parameter into a list ofUrlParameter- Parameters:
map- containing the parameter extracted usually directly from servlet request. From the String[] solely the first element will be extracted. The others will be ignored.parameterFilter- defines the parameter to be filtered. May be null or empty.encode- indicates whether to encode the parameter name and value as UTF-8- Returns:
- the found List of
UrlParameteror empty list if the given map is null or empty. The List is always sorted by #getName()
-
filterParameter
public static List<UrlParameter> filterParameter(List<UrlParameter> toBeFiltered, ParameterFilter parameterFilter) Filters the given list ofUrlParameter- Parameters:
toBeFiltered- may be null or emptyparameterFilter- used for filtering, may be null- Returns:
- the filtered parameter list or empty List if toBeFiltered is null or empty.
-
createParameterMap
Create a parameterMap for a given list ofUrlParameter- Parameters:
urlParameters- may be null or empty- Returns:
- parameter Map, may be empty if urlParameters is empty. The list of String will solely contain one element.
-
fromQueryString
Helper class that create a list ofUrlParameterfrom a given query-String- Parameters:
queryString- if it is null or empty or solely consists of an "?" an emptyList- Returns:
- if queryString is null or empty or solely consists of an "?" an empty
Listwill be returned. An immutableListofUrlParameterotherwise
-
createNameValueString
Create a String representation of a name value pair, saying name=value- Returns:
- String representation of a name value pair, saying name=value
-
createNameValueString
- Parameters:
encode- flag indicate if the result need to be encoded- Returns:
- string representation of name + vale
-
compareTo
- Specified by:
compareToin interfaceComparable<UrlParameter>
-