Back to project page Android-NetPowerctrl-Shared.
The source code is released under:
Copyright (c) 2014, David Gr?ff All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: *...
If you think the Android project Android-NetPowerctrl-Shared listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package oly.netpowerctrl.device_base.device; /* w w w . ja v a 2s .c o m*/ import android.util.JsonReader; import android.util.JsonWriter; import java.io.IOException; /** * Created by david on 28.07.14. */ public class DeviceFeatureTemperature implements DeviceFeatureInterface { public static final String ID = "Temperature"; public String temp; public DeviceFeatureTemperature() { } public DeviceFeatureTemperature(String temp) { this.temp = temp; } @Override public String getString() { return temp; } public void toJSON(JsonWriter writer) throws IOException { writer.beginObject(); writer.name("feature_id").value(ID); writer.name("temp").value(temp); writer.endObject(); } @Override public boolean fromJSON(JsonReader reader) throws IOException { boolean ok = false; // no beginObject! we are already inside a json object while (reader.hasNext()) { String name = reader.nextName(); assert name != null; switch (name) { case "temp": temp = reader.nextString(); ok = true; break; default: reader.skipValue(); break; } } reader.endObject(); return ok; } }