Class PageParameters
- java.lang.Object
-
- org.apache.wicket.request.mapper.parameter.PageParameters
-
- All Implemented Interfaces:
Serializable
,IIndexedParameters
,INamedParameters
,IClusterable
public class PageParameters extends Object implements IClusterable, IIndexedParameters, INamedParameters
Mutable class that holds parameters of a Page. Page parameters consist of indexed parameters and named parameters. Indexed parameters are URL segments before the query string. Named parameters are usually represented as query string params (i.e. ?arg1=var1&arg2=val)Indexed vs Named Parameters: Suppose we mounted a page on
/user
and the following url was accessed/user/profile/bob?action=view&redirect=false
. In this exampleprofile
andbob
are indexed parameters with respective indexes 0 and 1.action
andredirect
are named parameters.How those parameters are populated depends on the
IRequestMapper
s- Author:
- Matej Knopp
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.wicket.request.mapper.parameter.INamedParameters
INamedParameters.NamedPair, INamedParameters.Type
-
-
Constructor Summary
Constructors Constructor Description PageParameters()
Constructor.PageParameters(PageParameters copy)
Copy constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PageParameters
add(String name, Object value)
Adds a page parameter to these withname
andvalue
PageParameters
add(String name, Object value, int index, INamedParameters.Type type)
Adds named parameter to a specified position.PageParameters
add(String name, Object value, INamedParameters.Type type)
Adds value to named parameter with given name.PageParameters
clearIndexed()
Removes all indexed parameters.PageParameters
clearNamed()
Removes all named parameters.boolean
contains(String name)
Checks if the parameter with the given name existsboolean
equals(Object obj)
static boolean
equals(PageParameters p1, PageParameters p2)
Compares twoPageParameters
objects.StringValue
get(int index)
StringValue
get(String name)
Returns parameter value of named parameter with given nameList<INamedParameters.NamedPair>
getAllNamed()
List<INamedParameters.NamedPair>
getAllNamedByType(INamedParameters.Type type)
int
getIndexedCount()
int
getNamedCount()
Set<String>
getNamedKeys()
Return set of all named parameter names.int
getPosition(String name)
Returns the position of a named parameter.List<StringValue>
getValues(String name)
Return list of all values for named parameter with given nameint
hashCode()
boolean
isEmpty()
PageParameters
mergeWith(PageParameters other)
Merges the page parameters into this, overwriting existing valuesPageParameters
overwriteWith(PageParameters other)
Copy the page parametersPageParameters
remove(int index)
Removes indexed parameter on given indexPageParameters
remove(String name, String... values)
Removes named parameter with given name.PageParameters
set(int index, Object object)
Sets the indexed parameter on given indexPageParameters
set(String name, Object value)
Sets the page parameter withname
andvalue
PageParameters
set(String name, Object value, int index)
Sets the page parameter withname
andvalue
at the givenindex
PageParameters
set(String name, Object value, int index, INamedParameters.Type type)
Sets the named parameter on specified position.PageParameters
set(String name, Object value, INamedParameters.Type type)
Sets the value for named parameter with given name.PageParameters
setLocale(Locale locale)
String
toString()
-
-
-
Constructor Detail
-
PageParameters
public PageParameters()
Constructor.
-
PageParameters
public PageParameters(PageParameters copy)
Copy constructor.- Parameters:
copy
- The parameters to copy from
-
-
Method Detail
-
getIndexedCount
public int getIndexedCount()
- Returns:
- count of indexed parameters
-
getNamedCount
public int getNamedCount()
- Returns:
- count of named parameters
-
set
public PageParameters set(int index, Object object)
Description copied from interface:IIndexedParameters
Sets the indexed parameter on given index- Specified by:
set
in interfaceIIndexedParameters
- Parameters:
index
- The position of the parameterobject
- The parameter at this position- Returns:
- this instance, for chaining
- See Also:
IIndexedParameters.set(int, java.lang.Object)
-
get
public StringValue get(int index)
- Specified by:
get
in interfaceIIndexedParameters
- Parameters:
index
- The position of the parameter- Returns:
- indexed parameter on given index
-
remove
public PageParameters remove(int index)
Description copied from interface:IIndexedParameters
Removes indexed parameter on given index- Specified by:
remove
in interfaceIIndexedParameters
- Parameters:
index
- The position of the parameter- Returns:
- this instance, for chaining
-
getNamedKeys
public Set<String> getNamedKeys()
Description copied from interface:INamedParameters
Return set of all named parameter names.- Specified by:
getNamedKeys
in interfaceINamedParameters
- Returns:
- named parameter names
-
contains
public boolean contains(String name)
Checks if the parameter with the given name exists- Parameters:
name
- the parameter name- Returns:
true
if the parameter exists,false
otherwise
-
get
public StringValue get(String name)
Description copied from interface:INamedParameters
Returns parameter value of named parameter with given name- Specified by:
get
in interfaceINamedParameters
- Returns:
- parameter value
-
getValues
public List<StringValue> getValues(String name)
Description copied from interface:INamedParameters
Return list of all values for named parameter with given name- Specified by:
getValues
in interfaceINamedParameters
- Returns:
- list of parameter values
-
getAllNamed
public List<INamedParameters.NamedPair> getAllNamed()
- Specified by:
getAllNamed
in interfaceINamedParameters
- Returns:
- All named parameters in exact order.
-
getAllNamedByType
public List<INamedParameters.NamedPair> getAllNamedByType(INamedParameters.Type type)
- Specified by:
getAllNamedByType
in interfaceINamedParameters
- Parameters:
type
- The type to filter- Returns:
- All named parameters with the given type. If the type is
null
then returns all named parameters.
-
getPosition
public int getPosition(String name)
Description copied from interface:INamedParameters
Returns the position of a named parameter.- Specified by:
getPosition
in interfaceINamedParameters
- Parameters:
name
- the name of the parameter to look for- Returns:
- the position of the parameter.
-1
if there is no parameter with that name.
-
remove
public PageParameters remove(String name, String... values)
Description copied from interface:INamedParameters
Removes named parameter with given name.- Specified by:
remove
in interfaceINamedParameters
- Parameters:
name
- the name of the parameter to removevalues
- values used as criteria. The parameter will be removed only if its value is equal to any of the criteria.- Returns:
- this
-
add
public PageParameters add(String name, Object value)
Adds a page parameter to these withname
andvalue
- Parameters:
name
-value
-- Returns:
- these
-
add
public PageParameters add(String name, Object value, INamedParameters.Type type)
Description copied from interface:INamedParameters
Adds value to named parameter with given name.- Specified by:
add
in interfaceINamedParameters
- Returns:
- this
-
add
public PageParameters add(String name, Object value, int index, INamedParameters.Type type)
Description copied from interface:INamedParameters
Adds named parameter to a specified position. TheIRequestMapper
s may or may not take the order into account.- Specified by:
add
in interfaceINamedParameters
- Returns:
- this
-
set
public PageParameters set(String name, Object value, int index)
Sets the page parameter withname
andvalue
at the givenindex
- Parameters:
name
-value
-index
-- Returns:
- this
-
set
public PageParameters set(String name, Object value, int index, INamedParameters.Type type)
Description copied from interface:INamedParameters
Sets the named parameter on specified position. TheIRequestMapper
s may or may not take the order into account.- Specified by:
set
in interfaceINamedParameters
- Returns:
- this
-
set
public PageParameters set(String name, Object value)
Sets the page parameter withname
andvalue
- Parameters:
name
-value
-- Returns:
- this
-
set
public PageParameters set(String name, Object value, INamedParameters.Type type)
Description copied from interface:INamedParameters
Sets the value for named parameter with given name.- Specified by:
set
in interfaceINamedParameters
- Returns:
- this
-
clearIndexed
public PageParameters clearIndexed()
Description copied from interface:IIndexedParameters
Removes all indexed parameters.- Specified by:
clearIndexed
in interfaceIIndexedParameters
- Returns:
- this instance, for chaining
-
clearNamed
public PageParameters clearNamed()
Description copied from interface:INamedParameters
Removes all named parameters.- Specified by:
clearNamed
in interfaceINamedParameters
- Returns:
- this
-
overwriteWith
public PageParameters overwriteWith(PageParameters other)
Copy the page parameters- Parameters:
other
- The new parameters- Returns:
- this instance, for chaining
-
mergeWith
public PageParameters mergeWith(PageParameters other)
Merges the page parameters into this, overwriting existing values- Parameters:
other
- The parameters to merge- Returns:
- this instance, for chaining
-
equals
public static boolean equals(PageParameters p1, PageParameters p2)
Compares twoPageParameters
objects.- Parameters:
p1
- The first parametersp2
- The second parameters- Returns:
true
if the objects are equal,false
otherwise.
-
isEmpty
public boolean isEmpty()
- Returns:
true
if the parameters are empty,false
otherwise.
-
setLocale
public PageParameters setLocale(Locale locale)
-
-