// Get the CompanyService.
CompanyServiceInterface companyService =
user.getService(DfpService.V201208.COMPANY_SERVICE);
// Set defaults for page and filterStatement.
CompanyPage page = new CompanyPage();
Statement filterStatement = new Statement();
int offset = 0;
do {
// Create a statement to get all companies.
filterStatement.setQuery("LIMIT 500 OFFSET " + offset);
// Get companies by statement.
page = companyService.getCompaniesByStatement(filterStatement);
if (page.getResults() != null) {
int i = page.getStartIndex();
for (Company company : page.getResults()) {
System.out.println(i + ") Company with ID \"" + company.getId()
+ "\", name \"" + company.getName()
+ "\", and type \"" + company.getType() + "\" was found.");
i++;
}
}
offset += 500;
} while (offset < page.getTotalResultSetSize());
System.out.println("Number of results found: " + page.getTotalResultSetSize());
} catch (Exception e) {
e.printStackTrace();
}
}