Class TokenizedPagingParams

java.lang.Object
org.pipservices3.commons.data.TokenizedPagingParams

public class TokenizedPagingParams extends Object
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 Details

    • token

      public String token
      The start token
    • take

      public Integer take
      The number of items to return.
    • total

      public Boolean total
      The flag to return the total number of items.
  • Constructor Details

    • TokenizedPagingParams

      public TokenizedPagingParams(String token, Integer take, Boolean total)
      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

      public static TokenizedPagingParams fromValue(Object value)
      Converts specified value into TokenizedPagingParams.
      Parameters:
      value - value to be converted
      Returns:
      a newly created PagingParams.
    • fromTuples

      public static TokenizedPagingParams fromTuples(Object... tuples)
      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

      public static TokenizedPagingParams fromMap(Object map)
      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.