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 Selector();
selector.setFields(new String[] {"Id", "LocationName", "CanonicalName", "DisplayType",
"ParentLocations", "Reach", "TargetingStatus"});
selector.setPredicates(new Predicate[] {
// Location names must match exactly, only EQUALS and IN are
// supported.
new Predicate("LocationName", PredicateOperator.IN, locationNames),
// Set the locale of the returned location names.
new Predicate("Locale", PredicateOperator.EQUALS, new String[] {"en"})});
// Make the get request.
LocationCriterion[] locationCriteria = locationCriterionService.get(selector);
// Display the resulting location criteria.
for (LocationCriterion locationCriterion : locationCriteria) {
String parentString =
getParentLocationString(locationCriterion.getLocation().getParentLocations());