// Get the CompanyService.
CompanyServiceInterface companyService =
dfpServices.get(session, CompanyServiceInterface.class);
// Create a statement to only select companies that are advertisers.
StatementBuilder statementBuilder = new StatementBuilder()
.where("type = :type")
.orderBy("id ASC")
.limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
.withBindVariableValue("type", CompanyType.ADVERTISER.toString());
// 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());
}
}
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.getOffset() < totalResultSetSize);
System.out.printf("Number of results found: %d\n", totalResultSetSize);
}