E
- the type of object in the pagepublic class Page<E> extends Object
Constructor and Description |
---|
Page() |
Modifier and Type | Method and Description |
---|---|
Page<E> |
addFacet(Facet facet)
Adds a filter facet to this result page.
|
Facet |
addFacet(String field,
String title,
sirius.kernel.cache.ValueComputer<String,String> translator)
Adds a filter facet with the given name, title and translator.
|
Page<E> |
bindToRequest(WebContext ctx)
Binds the page to the request.
|
String |
createNextPageQueryString()
Creates a query string containing all filters, the search query and a start parameter selecting the
next page.
|
String |
createPrevPageQueryString()
Creates a query string containing all filters, the search query and a start parameter selecting the
previous page.
|
String |
createQueryString()
Creates a query string containing all filters and the search query and a start parameter selecting the
current page.
|
String |
createQueryString(String field,
String value,
boolean resetStart)
Creates a query string containing all filters and the search query along with a given custom field.
|
String |
createQueryStringForConfigurableStart()
Creates an incomplete query string to be completed by appending the start index.
|
int |
getCurrentPageNumber()
Calculates the current page number
|
String |
getDuration()
Returns the search duration.
|
int |
getEnd()
Returns the absolute index (1 based) of the last item on this page.
|
List<Facet> |
getFacets()
Returns all filter facets available.
|
List<E> |
getItems()
Returns the items on this page.
|
int |
getNextStart()
Returns the index of the next page.
|
int |
getPageSize()
Returns the total page size.
|
int |
getPreviousStart()
Returns the index of the previous page.
|
String |
getQuery()
Returns the query string which was used to create the result set.
|
String |
getRange()
Returns a string representation naming the first and last index contained on this page.
|
int |
getStart()
Returns the absolute index (1 based) of the first item on this page.
|
int |
getTotal()
Returns the total number of items (if known).
|
boolean |
hasFacets()
Determines if there is at least one filter facet with filter items.
|
boolean |
hasLess()
Determines if there is a previous page.
|
boolean |
hasMore()
Determines if there is a next page.
|
Page<E> |
withDuration(String duration)
Specifies the duration (as string) it took to compute (query) the page items.
|
Page<E> |
withFactes(List<Facet> facets)
Specifies the facets available to further filter the page (or underlying data source).
|
Page<E> |
withFactesSupplier(Supplier<List<Facet>> facetsSupplier)
Specifies the supplier used to compute the facets available to further filter the page (or underlying data
source).
|
Page<E> |
withHasMore(boolean more)
Specifies the flag which indicates if "more" items are available.
|
Page<E> |
withItems(List<E> items)
Specifies the effective items this page contains.
|
Page<E> |
withLimitedItemsSupplier(Function<sirius.kernel.commons.Limit,List<E>> itemsSupplier)
Easy method for supplying items the page contains to avoid boiler code.
|
Page<E> |
withPageSize(int pageSize)
Specifies the number of items shown per page.
|
Page<E> |
withQuery(String query)
Specifies the query used to compute the result list.
|
Page<E> |
withStart(int start)
Specifies the index of the first item.
|
Page<E> |
withTotalItems(int total)
Specifies the number of total items.
|
public Page<E> withQuery(String query)
query
- the query string which was used to create the result setpublic Page<E> withStart(int start)
start
- the index of the first item shown on this page (relative to the overall list).public Page<E> withItems(List<E> items)
items
- the items contained in the page.public Page<E> withLimitedItemsSupplier(Function<sirius.kernel.commons.Limit,List<E>> itemsSupplier)
The supplier provides the Limit
of the current page for easy iteration
over a result set.
This method should be supplied with a List
which size was determined by
the supplied Limit
as this method does also is able to determine whether
this page has more items to show
which are currently
not being displayed.
Using the supplied limit e.g. via Limit.asPredicate()
for slicing the provided list results
in a list of size pageSize
+ 1 for easier handling whether there are more elements to
determine if there is another page.
itemsSupplier
- the supplier to supply items to the current page limited by the provided limitpublic Page<E> withDuration(String duration)
duration
- the duration required to compute the page items.public Page<E> withFactes(List<Facet> facets)
facets
- the facets available for further filteringpublic Facet addFacet(String field, String title, @Nullable sirius.kernel.cache.ValueComputer<String,String> translator)
field
- the name of the field being filteredtitle
- the title of the filter shown to the usertranslator
- the trnanslater used to convert filter values to visual representations for the userpublic Page<E> addFacet(Facet facet)
facet
- the facet to addpublic int getCurrentPageNumber()
public Page<E> bindToRequest(WebContext ctx)
This will read start, query and all facet values from the given request.
ctx
- the request to parsepublic Page<E> withFactesSupplier(Supplier<List<Facet>> facetsSupplier)
facetsSupplier
- the facets supplier computing the facets available for further filteringpublic Page<E> withHasMore(boolean more)
more
- indicates if more items are available or not.public Page<E> withPageSize(int pageSize)
pageSize
- the number of items shown per pagepublic Page<E> withTotalItems(int total)
total
- the number of items in the data source (applying the current filters)public String getQuery()
public int getStart()
public int getEnd()
public List<E> getItems()
public int getPreviousStart()
public int getNextStart()
public boolean hasLess()
public boolean hasMore()
public int getTotal()
public String getRange()
public String getDuration()
public String createPrevPageQueryString()
public String createNextPageQueryString()
public String createQueryString()
public String createQueryString(String field, String value, boolean resetStart)
field
- the additional field to setvalue
- the value of the field to setresetStart
- determines if the start value should be kept (false) or reset to 1 (true)public String createQueryStringForConfigurableStart()
ex.:
var startIndex = "33"; $('a.config-start').attr("href", "@prefix/@baseURL?@page.createQueryStringForConfigurableStart()" + startIndex);
public List<Facet> getFacets()
public boolean hasFacets()
public int getPageSize()
This not the number of items in the page but rather the general paging size currently being used.
DEFAULT_PAGE_SIZE
Copyright © 2018. All rights reserved.