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; /* ww w. ja v a 2s .c o m*/ import android.util.JsonReader; import android.util.Log; import java.io.IOException; /** * Created by david on 28.07.14. */ public class DeviceFeatureFabric { public static DeviceFeatureInterface fromJSON(JsonReader reader) throws IOException, ClassNotFoundException { reader.beginObject(); if (!reader.hasNext()) { return null; } String name = reader.nextName(); if (!name.equals("feature_id")) { Log.e("DeviceFeatureFabric", "Expected feature_id! " + name); reader.endObject(); return null; } name = reader.nextString(); DeviceFeatureInterface deviceFeature; switch (name) { case DeviceFeatureTemperature.ID: { deviceFeature = new DeviceFeatureTemperature(); break; } default: throw new ClassNotFoundException("Unexpected feature: " + name); } if (!deviceFeature.fromJSON(reader)) { return null; } else return deviceFeature; } }