List of usage examples for com.google.gwt.json.client JSONValue isString
public JSONString isString()
From source file:lh.api.showcase.client.JsonParserUtils.java
License:Apache License
public static String getAircraftCode(JSONValue jsAircraftCodeVal) { if (jsAircraftCodeVal == null) { return null; }//from ww w. j av a2s . co m JSONString jsAircraftCodeStr = jsAircraftCodeVal.isString(); JSONNumber jsAircraftCodeNum = null; if (jsAircraftCodeStr == null) { jsAircraftCodeNum = jsAircraftCodeVal.isNumber(); } return (jsAircraftCodeStr != null) ? (jsAircraftCodeStr.toString().replace("\"", "")) : ((jsAircraftCodeNum != null) ? (String.valueOf(jsAircraftCodeNum.doubleValue())) : ("")); }
From source file:lh.api.showcase.client.operations.JsonParserFlightUtils.java
License:Apache License
private static JSONString getStringIfExist(JSONObject jsObj, String object, String property) { JSONValue jsObjectVal = jsObj.get(object); JSONString jsStr = null;/* w ww . j av a2s. c o m*/ if (jsObjectVal != null) { JSONValue jsObjectPropVal = jsObjectVal.isObject().get(property); if (jsObjectPropVal != null) { jsStr = jsObjectPropVal.isString(); } } return jsStr; }
From source file:lh.api.showcase.client.operations.JsonParserFlightUtils.java
License:Apache License
private static JSONString getStringIfExist(JSONObject jsObj, String object, String alternativeObject, String property) {/*from ww w .java 2 s .c o m*/ JSONValue jsVal = jsObj.get(object); if (jsVal == null) { jsVal = jsObj.get(alternativeObject); } JSONString jsStr = null; if (jsVal != null) { JSONValue jsObjectPropVal = jsVal.isObject().get(property); if (jsObjectPropVal != null) { jsStr = jsObjectPropVal.isString(); } } return jsStr; }
From source file:lh.api.showcase.client.referencedata.aircraft.AircraftResponseJsonParser.java
License:Apache License
private Aircraft getAircraftInfo(JSONObject jsAircraftSummaryObj) { JSONValue jsAircraftCodeVal = jsAircraftSummaryObj.get("AircraftCode"); JSONValue jsAircraftAirlineEquipCodeVal = jsAircraftSummaryObj.get("AirlineEquipCode"); if (jsAircraftCodeVal == null) { return null; }// w ww. j a v a2 s . c om String aircraftCode = JsonParserUtils.getAircraftCode(jsAircraftCodeVal); JSONString jsAircraftAirlineEquipCodeStr = null; if (jsAircraftAirlineEquipCodeVal != null) { jsAircraftAirlineEquipCodeStr = jsAircraftAirlineEquipCodeVal.isString(); } JSONObject jsNamesObj = jsAircraftSummaryObj.get("Names").isObject(); return new Aircraft(aircraftCode, (jsAircraftAirlineEquipCodeStr == null) ? ("") : (jsAircraftAirlineEquipCodeStr.toString().replace("\"", "")), JsonParserUtils.getNamesMap(jsNamesObj)); }
From source file:lh.api.showcase.client.referencedata.airlines.AirlinesResponseJsonParser.java
License:Apache License
private Airline getAirlineInfo(JSONObject jsAirlineObj) { JSONValue jsAirlineIdVal = jsAirlineObj.get("AirlineID"); JSONValue jsAirlineIdIcaoVal = jsAirlineObj.get("AirlineID_ICAO"); if (jsAirlineIdVal == null || jsAirlineIdIcaoVal == null) { return null; }//w w w . ja va 2 s . c o m JSONString jsAirlineIdStr = jsAirlineIdVal.isString(); JSONString jsAirlineIdIcaoStr = jsAirlineIdIcaoVal.isString(); JSONObject jsNamesObj = jsAirlineObj.get("Names").isObject(); JSONValue jsOtherIdsVal = jsAirlineObj.get("OtherIDs"); JSONObject jsOtherIdsObj = null; if (jsOtherIdsVal != null) { jsOtherIdsObj = jsOtherIdsVal.isObject(); } return new Airline((jsAirlineIdStr == null) ? ("") : (jsAirlineIdStr.toString().replace("\"", "")), (jsAirlineIdIcaoStr == null) ? ("") : (jsAirlineIdIcaoStr.toString().replace("\"", "")), getOtherIDsInfo(jsOtherIdsObj), JsonParserUtils.getNamesMap(jsNamesObj)); }
From source file:lh.api.showcase.client.referencedata.airlines.AirlinesResponseJsonParser.java
License:Apache License
public String getOtherIDInfo(JSONObject jsOtherIdObj) { JSONValue jsDescriptionVal = jsOtherIdObj.get("@Description"); @SuppressWarnings("unused") JSONString jsDescriptionStr = jsDescriptionVal.isString(); JSONValue jsNameVal = jsOtherIdObj.get("$"); JSONString jsNameStr = jsNameVal.isString(); return (jsNameStr == null) ? (null) : (jsNameStr.toString().replace("\"", "")); }
From source file:lh.api.showcase.client.referencedata.cities.CitiesResponseJsonParser.java
License:Apache License
private City getCityInfo(JSONObject jsCityObj) { JSONValue jsCityCodeVal = jsCityObj.get("CityCode"); JSONValue jsCountryCodeVal = jsCityObj.get("CountryCode"); if (jsCityCodeVal == null || jsCountryCodeVal == null) { return null; }/*from www. ja v a 2s . c o m*/ JSONString jsCityCodeStr = jsCityCodeVal.isString(); JSONString jsCountryCodeStr = jsCountryCodeVal.isString(); JSONNumber jsLatitudeNum = null; JSONNumber jsLongitudeNum = null; JSONValue jsCoordinateVal = jsCityObj.get("Position"); if (jsCoordinateVal != null) { JSONObject jsCoordinateObj = jsCoordinateVal.isObject().get("Coordinate").isObject(); jsLatitudeNum = jsCoordinateObj.get("Latitude").isNumber(); jsLongitudeNum = jsCoordinateObj.get("Longitude").isNumber(); } JSONObject jsNamesObj = jsCityObj.get("Names").isObject(); JSONValue jsAirportsVal = jsCityObj.get("Airports"); JSONObject jsAirportsObj = (jsAirportsVal == null) ? (null) : (jsAirportsVal.isObject()); return new City((jsCityCodeStr == null) ? ("") : (jsCityCodeStr.toString().replace("\"", "")), (jsCountryCodeStr == null) ? ("") : (jsCountryCodeStr.toString().replace("\"", "")), (jsLatitudeNum == null) ? (null) : (jsLatitudeNum.doubleValue()), (jsLongitudeNum == null) ? (null) : (jsLongitudeNum.doubleValue()), getAirportInfo(jsAirportsObj), JsonParserUtils.getNamesMap(jsNamesObj)); }
From source file:lh.api.showcase.client.referencedata.cities.CitiesResponseJsonParser.java
License:Apache License
public static Set<String> getAirportInfo(JSONObject jsAirportsObj) { if (jsAirportsObj == null) { return null; }/*from w ww. j av a2s . c o m*/ Set<String> ret = new HashSet<String>(); JSONValue jsAirportCodeVal = jsAirportsObj.get("AirportCode"); JSONString jsjsAirportCodeValStr = jsAirportCodeVal.isString(); if (jsjsAirportCodeValStr == null) { JSONArray jsAirportCodeArray = jsAirportCodeVal.isArray(); if (jsAirportCodeArray != null) { for (int i = 0; i < jsAirportCodeArray.size(); ++i) { JSONString jsCodeStr = jsAirportCodeArray.get(i).isString(); if (jsCodeStr == null) { continue; } ret.add(jsCodeStr.toString().replace("\"", "")); } } } else { ret.add(jsjsAirportCodeValStr.toString().replace("\"", "")); } return ret; }
From source file:lh.api.showcase.client.referencedata.countries.CountriesResponseJsonParser.java
License:Apache License
private void getCountryInfo(JSONObject jsCountryObj, List<Country> countries) { JSONValue jsCountryCodeVal = jsCountryObj.get("CountryCode"); JSONString jsCountryCodeStr = (jsCountryCodeVal == null) ? (null) : (jsCountryCodeVal.isString()); JSONValue jsCountryZoneVal = jsCountryObj.get("ZoneCode"); JSONString jsZoneCodeStr = (jsCountryZoneVal == null) ? (null) : (jsCountryZoneVal.isString()); JSONValue jsNamesVal = jsCountryObj.get("Names"); JSONObject jsNamesObj = jsNamesVal.isObject(); countries.add(/*from w w w .j a v a 2s . c o m*/ new Country((jsCountryCodeStr == null) ? ("") : (jsCountryCodeStr.toString().replace("\"", "")), (jsZoneCodeStr == null) ? ("") : (jsZoneCodeStr.toString().replace("\"", "")), JsonParserUtils.getNamesMap(jsNamesObj))); }
From source file:my.plugin.ide.editor.StringListUnmarshaller.java
License:Open Source License
public List<String> toList(String jsonStr) { JSONValue parsed = JSONParser.parseStrict(jsonStr); JSONArray jsonArray = parsed.isArray(); if (jsonArray == null) { return Collections.emptyList(); }/*from w w w .j a va 2 s. c o m*/ List<String> list = new ArrayList<>(); for (int i = 0; i < jsonArray.size(); i++) { JSONValue jsonValue = jsonArray.get(i); JSONString jsonString = jsonValue.isString(); String stringValue = (jsonString == null) ? jsonValue.toString() : jsonString.stringValue(); list.add(stringValue); } return list; }