The query iterator.
The
Query iterator is the result of the query factory for
Query factories
IndividualEnrollment: |
ProvisioningServiceClient#createIndividualEnrollmentQuery(QuerySpecification,int) |
EnrollmentGroup: |
ProvisioningServiceClient#createEnrollmentGroupQuery(QuerySpecification,int) |
RegistrationStatus: |
ProvisioningServiceClient#createEnrollmentGroupRegistrationStatusQuery(QuerySpecification,String,int) |
On all cases, the QuerySpecification contains a SQL query that must follow the
Query Language
for the Device Provisioning Service.
Optionally, an
Integer with the pageSize, can determine the maximum number of the items in the
QueryResult returned by the
#next(). It must be any positive integer, and if it contains 0,
the Device Provisioning Service will ignore it and use a standard page size.
You can use this Object as a standard Iterator, just using the
#hasNext() and
#next() in a
while loop, up to the point where the
#hasNext() return
false. But, keep in mind
that the
QueryResult can contain a empty list, even if the
#hasNext() returned
true.
For example, image that you have 10 IndividualEnrollment in the Device Provisioning Service and you created
new query with the
pageSize equals 5. The first
hasNext() will return
true, and the
first
next() will return a
QueryResult with 5 items. After that you call the
hasNext,
which will returns
true. Now, before you get the next page, somebody delete all the IndividualEnrollment,
What happened, when you call the
next(), it will return a valid
QueryResult, but the
QueryResult#getItems() will return a empty list.
You can also store a query context (QuerySpecification + ContinuationToken) and restart it in the future, from
the point where you stopped.
Besides the Items, the queryResult contains the continuationToken, the
QueryResult#getContinuationToken()shall return it. In any point in the future, you may recreate the query using the same query factories that you
used for the first time, and call
#next(String) providing the stored continuationToken to get the next page.