// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get companies by statement.
CompanyPage page = companyService.getCompaniesByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (Company company : page.getResults()) {
System.out.printf(
"%d) Company with ID \"%d\", name \"%s\", and type \"%s\" was found.\n", i++,
company.getId(), company.getName(), company.getType());
}
}