/** * Get an optional string associated with a key. It returns an empty string if * there is no such key. If the value is not a string and is not null, then it * is coverted to a string. * * @param key * A key string. * @return A string which is the value. */ public String optString(String key) { return optString(key, ""); }
/** * Get an optional string associated with a key. It returns an empty string if * there is no such key. If the value is not a string and is not null, then it * is coverted to a string. * * @param key * A key string. * @return A string which is the value. */ public String optString(String key) { return optString(key, ""); }
public GUIState(JSONObject source) { super(source); distanceUnits = source.optString("gui_distance_units"); temperatureUnits = source.optString("gui_temperature_units"); chargeRateUnits = source.optString("gui_charge_rate_units"); use24HrTime = source.optBoolean("gui_24_hour_time"); rangeDisplay = source.optString("gui_range_display"); }
/** * Get an optional string associated with a key. It returns an empty string if * there is no such key. If the value is not a string and is not null, then it * is coverted to a string. * * @param key * A key string. * @return A string which is the value. */ public String optString(Enum<?> key) { return optString(key.name()); }
/** * Get an optional string associated with a key. It returns the defaultValue * if there is no such key. * * @param key * A key string. * @param defaultValue * The default. * @return A string which is the value. */ public String optString(Enum<?> key, String defaultValue) { return optString(key.name(), defaultValue); }
/** * Get an optional string associated with a key. It returns the defaultValue * if there is no such key. * * @param key * A key string. * @param defaultValue * The default. * @return A string which is the value. */ public String optString(Enum<?> key, String defaultValue) { return optString(key.name(), defaultValue); }
/** * Get an optional string associated with a key. It returns an empty string if * there is no such key. If the value is not a string and is not null, then it * is coverted to a string. * * @param key * A key string. * @return A string which is the value. */ public String optString(Enum<?> key) { return optString(key.name()); }
public Result(JSONObject response) { if (response == null) { success = false; explanation = ""; } else { success = response.optBoolean("result", false); explanation = response.optString("reason"); } }
public Result setChargePercent(int percent) { if (percent < 1 || percent > 100) return new Result(false, "value out of range"); JSONObject response = tesla.invokeCommand( Charge_SetPct, String.format("{'percent' : '%d'}", percent)); if (response.optString("reason").equals("already_set")) { try { response.put("result", true); } catch (JSONException e) { Tesla.logger.severe("Can't Happen!"); } } return new Result(response); }
public VehicleState(JSONObject source) { super(source); isDFOpen = source.optInt("df") != 0; isPFOpen = source.optInt("pf") != 0; isDROpen = source.optInt("dr") != 0; isPROpen = source.optInt("pr") != 0; isFTOpen = source.optInt("ft") != 0; isRTOpen = source.optInt("rt") != 0; locked = source.optBoolean("locked"); hasPano = source.optInt("sun_roof_installed") != 0; panoPercent = source.optInt("sun_roof_percent_open"); panoState = Utils.stringToEnum( VehicleState.PanoPosition.class, source.optString("sun_roof_state")); version = source.optString("car_version"); hasDarkRims = source.optBoolean("dark_rims"); wheelType = source.optString("wheel_type"); hasSpoiler = source.optBoolean("has_spoiler"); roofColor = source.optString("roof_color"); perfConfig = source.optString("perf_config"); remoteStart = source.optBoolean("remote_start"); }
k = keys.next().toString(); XML.noSpace(k); v = jo.optString(k); if (v != null) { sb.append(' ');
k = keys.next().toString(); XML.noSpace(k); v = jo.optString(k); if (v != null) { sb.append(' ');
ElevationEndpoint+locs.toString()+"&sensor=true").object(); GoogleElevationStatus status = GoogleElevationStatus.valueOf( result.optString("status")); if (status != GoogleElevationStatus.OK) { Tesla.logger.warning(
this.baseValues = description.toString(); color = description.optString("color"); displayName = description.optString("display_name"); vehicleID = description.optString("id"); userID = description.optString("user_id"); streamingVID = description.optString("vehicle_id"); vin = description.optString("vin"); uuid = DigestUtils.sha256Hex(vin); status = description.optString("state"); remoteStartEnabled = description.optBoolean("remote_start_enabled"); notificationsEnabled = description.optBoolean("notifications_enabled"); options = new Options(description.optString("option_codes")); streamer = new Streamer(this);
fastChargerPresent = source.optBoolean("fast_charger_present"); chargerPower = source.optInt("charger_power"); chargingState = Utils.stringToEnum(ChargeState.Status.class, source.optString("charging_state")); if (chargingState == ChargeState.Status.Unknown && valid) Tesla.logger.fine("Raw charge state: " + source.toString()); chargeStartingRange = source.optString("charge_starting_range"); chargeStartingSOC = source.optString("charge_starting_soc"); userChargeEnableRequest = source.optString("user_charge_enable_request"); fastChargerType = source.optString("fast_charger_type"); usableBatteryLevel = source.optInt("usable_battery_level"); energyAdded = source.optDouble("charge_energy_added");
public StreamState(JSONObject source) { super(source); vehicleTimestamp = source.optLong(Streamer.Keys.timestamp); speed = source.optDouble(Streamer.Keys.speed); if (Double.isNaN(speed)) speed = 0.0; odometer = source.optDouble(Streamer.Keys.odometer); soc = source.optInt(Streamer.Keys.soc); elevation = source.optInt(Streamer.Keys.elevation); estHeading = source.optInt(Streamer.Keys.est_heading); heading = source.optInt(Streamer.Keys.heading); estLat = source.optDouble(Streamer.Keys.est_lat); estLng = source.optDouble(Streamer.Keys.est_lng); power = source.optInt(Streamer.Keys.power); shiftState = source.optString(Streamer.Keys.shift_state); range = source.optInt(Streamer.Keys.range); estRange = source.optInt(Streamer.Keys.est_range); }