protected List<Location> deserializeSearchResults(InputStream inputStream) throws JAXBException { JAXBContext jaxbContext = JAXBContext.newInstance(SearchData.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); SearchData data = (SearchData) unmarshaller.unmarshal(inputStream); List<Location> locations = new ArrayList<Location>(); for (LocationResult l : data.getResults()) { Location location = new Location(); location.setCity(l.getCity()); location.setLatitude(l.getLatitude()); location.setLongitude(l.getLongitude()); location.setStateOrCountry(l.getRegion() != null ? l.getRegion() : l.getCountry()); StringBuffer code = new StringBuffer(); code.append(l.getCity()); if (l.getRegion() != null && !l.getRegion().contains(", ")) { code.append(", ").append(l.getRegion()); } if (l.getCountry() != null) { code.append(", ").append(l.getCountry()); } location.setLocationCode(code.toString()); locations.add(location); } return locations; }