Thanks to a question and answer on StackOverflow (http://stackoverflow.com/questions/4812020/get-state-province-from-geonames-data), I've learned that the connection a city has with its Province/State/etc is that the AdminCode1 will match. Using this, I do the following:
Code:
private List<Toponym> getCities(Toponym region)
{
List<Toponym> cities = new ArrayList<Toponym>();
WebService.setUserName(WEBSERVICE_USERNAME);
ToponymSearchCriteria searchCriteria = new ToponymSearchCriteria();
ToponymSearchResult searchResult;
try {
searchCriteria.setCountryCode(region.getCountryCode());
searchCriteria.setStyle(Style.FULL);
searchCriteria.setAdminCode1(region.getAdminCode1()); // AdminCode1 is for top-level Administrative division (Region)
searchCriteria.setFeatureClass(FeatureClass.P); // use the FeatureCode of P (Populated Area)
searchResult = WebService.search(searchCriteria);
searchResult.setStyle(Style.FULL);
for (Toponym t : searchResult.getToponyms())
{
cities.add(new AdtToponym(t));
}
} catch (InvalidParameterException e) {
}
catch (InsufficientStyleException e) {
} catch (Exception e) {
}
return cities;
}
I hope that this can help someone else. There may be a better way to do this, and I hope that there is a proper way to use hierarchy to get this information. If anyone ever learns how, please update this thread with proper instructions, but until then, this works.