public static void runExample(
AdWordsServices adWordsServices, AdWordsSession session, String[] locationNames)
throws Exception {
// Get the LocationCriterionService.
LocationCriterionServiceInterface locationCriterionService =
adWordsServices.get(session, LocationCriterionServiceInterface.class);
Selector selector = new SelectorBuilder()
.fields(
"Id",
"LocationName",
"CanonicalName",
"DisplayType",
"ParentLocations",
"Reach",
"TargetingStatus")
// Location names must match exactly, only EQUALS and IN are supported.
.in("LocationName", locationNames)
// Set the locale of the returned location names.
.equals("Locale", "en")
.build();
// Make the get request.
LocationCriterion[] locationCriteria = locationCriterionService.get(selector);
// Display the resulting location criteria.
for (LocationCriterion locationCriterion : locationCriteria) {
String parentString =
getParentLocationString(locationCriterion.getLocation().getParentLocations());