String fieldname = parser.getCurrentName();
if (fieldname != null && fieldname.equals("HotelSummary")) {
if (parser.nextToken() == JsonToken.START_ARRAY) {
while(parser.nextToken() != JsonToken.END_ARRAY){
fieldname = parser.getCurrentName();
EanHotel hotel = new EanHotel();
Place p = new Place();
EanHotelDetail ean = new EanHotelDetail();
p.setCategory("hotel");
while(parser.nextToken() != JsonToken.END_OBJECT) {
String str = fieldname = parser.getCurrentName();
if (str != null) {
switch(str){
case "address1":
p.setAddr(getValue(parser));
break;
case "address2":
p.setAddr(p.getAddr() + " " + getValue(parser));
break;
case "highRate":
ean.setHightRate(Double.parseDouble(getValue(parser)));
break;
case "hotelRating":
ean.setHotelRating(Double.parseDouble(getValue(parser)));
break;
case "latitude":
p.setLat(Double.parseDouble(getValue(parser)));
break;
case "longitude":
p.setLng(Double.parseDouble(getValue(parser)));
break;
case "lowRate":
ean.setLowRate(Double.parseDouble(getValue(parser)));
break;
case "name":
p.setName(getValue(parser));
break;
case "postalCode":
ean.setPostalCode(getValue(parser));
break;
case "rateCurrencyCode":
ean.setRateCurrencyCode(getValue(parser));
break;
case "deepLink":
ean.setDeepLink(getValue(parser).replaceAll("(&cid=)[^&]*(&)","$1455207$2"));
break;
case "airportCode":
ean.setAirportCode(getValue(parser));
break;
case "shortDescription":
ean.setShortDescription(getValue(parser));
break;
}
}
}
PlacesDao d = new PlacesDao(_url);
d.completeRecord(p);
UUID id = (p.getId() == null)? UUIDs.timeBased() : p.getId();
d.insertPlaces(p, id);
d.close();
EanHotelDetailDao ed = new EanHotelDetailDao(_url);
ean.setPlaceId(id);
ed.insertRecord(ean);
ed.close();
hotel.setHotel(p);
hotel.setDetail(ean);
results.add(hotel);
}
}
}
}