Class Query<T,F>
- Type Parameters:
T
- bean typeF
- filter type
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
HierarchicalQuery
- Since:
- 1.0
- See Also:
-
Constructor Summary
ConstructorDescriptionQuery()
Constructs a Query for all rows from 0 toInteger.MAX_VALUE
without sorting and filtering.Query
(int offset, int limit, List<QuerySortOrder> sortOrders, Comparator<T> inMemorySorting, F filter) Constructs a new Query object with given offset, limit, sorting and filtering.Constructs a Query for all rows from 0 toInteger.MAX_VALUE
with filtering. -
Method Summary
Modifier and TypeMethodDescriptionGets the filter for items to fetch.Gets the comparator for sorting in-memory data.int
getLimit()
Gets the number of items to fetch.int
Gets the first index of items to fetch.int
getPage()
Returns a zero-based page index to be retrieved.int
Returns the page size that should be returned.int
Gets the requested range end.Gets the optional comparator for sorting data.Gets the sorting for items to fetch.
-
Constructor Details
-
Query
public Query()Constructs a Query for all rows from 0 toInteger.MAX_VALUE
without sorting and filtering. -
Query
Constructs a Query for all rows from 0 toInteger.MAX_VALUE
with filtering.- Parameters:
filter
- back end filter of a suitable type for the data provider; can be null
-
Query
public Query(int offset, int limit, List<QuerySortOrder> sortOrders, Comparator<T> inMemorySorting, F filter) Constructs a new Query object with given offset, limit, sorting and filtering.- Parameters:
offset
- first index to fetchlimit
- fetched item countsortOrders
- sorting order for fetching; used for sorting backendsinMemorySorting
- comparator for sorting in-memory datafilter
- filtering for fetching; can be null
-
-
Method Details
-
getOffset
public int getOffset()Gets the first index of items to fetch. The offset is only used when fetching items, but not when counting the number of available items.- Returns:
- offset for data request
-
getLimit
public int getLimit()Gets the number of items to fetch. The limit is only used when fetching items, but not when counting the number of available items.Note: It is possible that
offset + limit > item count
- Returns:
- number of items to fetch
-
getPage
public int getPage()Returns a zero-based page index to be retrieved.Vaadin asks data from the backend in paged manner. This shorthand calculates the page index for backends using paged data access, such as Spring Data repositories.
- Returns:
- the zero-based page index
-
getPageSize
public int getPageSize()Returns the page size that should be returned. The amount of items can be smaller if there is no more items available in the backend.Vaadin asks data from the backend in paged manner.
This is an alias for
getLimit()
if the page offset can be evenly divided by the limit. Else the page size will be increased to evenly divide offset so the items skip for page will go to the correct item.- Returns:
- the page size used for data access
-
getSortOrders
Gets the sorting for items to fetch. This list of sort orders is used for sorting backends. The sort orders are only used when fetching items, but not when counting the number of available items.Note: Sort orders and in-memory sorting are mutually exclusive. If the
DataProvider
handles one, it should ignore the other.- Returns:
- list of sort orders
-
getFilter
Gets the filter for items to fetch.- Returns:
- optional filter
-
getInMemorySorting
Gets the comparator for sorting in-memory data. The comparator is only used when fetching items, but not when counting the number of available items.Note: Sort orders and in-memory sorting are mutually exclusive. If the
DataProvider
handles one, it should ignore the other.- Returns:
- sorting comparator
-
getSortingComparator
Gets the optional comparator for sorting data. The comparator is only used when fetching items, but not when counting the number of available items.Note: Sort orders and comparator sorting are mutually exclusive. If the
DataProvider
handles one, it should ignore the other.- Returns:
- optional sorting comparator
-
getRequestedRangeEnd
public int getRequestedRangeEnd()Gets the requested range end. This is a shorthand forgetOffset() + getLimit()
where the end is exclusive.- Returns:
- the requested range end
-