Package org.pipservices3.commons.data
Class TokenizedPagingParams
java.lang.Object
org.pipservices3.commons.data.TokenizedPagingParams
Data transfer object to pass tokenized paging parameters for queries.
It can be used for complex paging scenarios, like paging across multiple databases
where the previous state is encoded in a token. The token is usually retrieved from
the previous response. The initial request shall go with token ==
null
The page is defined by two parameters:
- the token
token that defines a starting point for the search.
- the take
parameter sets how many items to return in a page.
- additionally, the optional total
parameter tells to return total number of items in the query.
Remember: not all implementations support the total
parameter
because its generation may lead to severe performance implications.
var filter = FilterParams.fromTuples("type", "Type1");
var paging = new TokenizedPagingParams(null, 100);
var page = myDataClient.getDataByFilter(filter, paging);
-
Field Summary
-
Constructor Summary
ConstructorDescriptionTokenizedPagingParams
(String token, Integer take, Boolean total) Creates a new instance and sets its values. -
Method Summary
Modifier and TypeMethodDescriptionstatic TokenizedPagingParams
Creates a new TokenizedPagingParams and sets it parameters from the specified mapstatic TokenizedPagingParams
fromTuples
(Object... tuples) Creates a new TokenizedPagingParams from a list of key-value pairs called tuples.static TokenizedPagingParams
Converts specified value into TokenizedPagingParams.int
getTake
(int maxTake) Gets the number of items to return in a page.
-
Field Details
-
token
The start token -
take
The number of items to return. -
total
The flag to return the total number of items.
-
-
Constructor Details
-
TokenizedPagingParams
Creates a new instance and sets its values.- Parameters:
token
- token that defines a starting point for the search.take
- the number of items to return.total
- true to return the total number of items.
-
TokenizedPagingParams
public TokenizedPagingParams()
-
-
Method Details
-
getTake
public int getTake(int maxTake) Gets the number of items to return in a page.- Parameters:
maxTake
- the maximum number of items to return.- Returns:
- the number of items to return.
-
fromValue
Converts specified value into TokenizedPagingParams.- Parameters:
value
- value to be converted- Returns:
- a newly created PagingParams.
-
fromTuples
Creates a new TokenizedPagingParams from a list of key-value pairs called tuples.- Parameters:
tuples
- a list of values where odd elements are keys and the following even elements are values- Returns:
- a newly created TokenizedPagingParams.
-
fromMap
Creates a new TokenizedPagingParams and sets it parameters from the specified map- Parameters:
map
- a AnyValueMap or StringValueMap to initialize this TokenizedPagingParams- Returns:
- a newly created PagingParams.
-