Android Open Source - Android-NetPowerctrl-Shared Device Connection Fabric






From Project

Back to project page Android-NetPowerctrl-Shared.

License

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.

Java Source Code

package oly.netpowerctrl.device_base.device;
//from   ww  w  .j av  a2 s .  co m
import android.support.annotation.NonNull;
import android.util.JsonReader;
import android.util.Log;

import java.io.IOException;

/**
 * Created by david on 28.07.14.
 */
public class DeviceConnectionFabric {

    public static DeviceConnection fromJSON(@NonNull JsonReader reader, @NonNull Device device)
            throws IOException, ClassNotFoundException {
        reader.beginObject();
        if (!reader.hasNext()) {
            return null;
        }

        String name = reader.nextName();
        if (!name.equals("connection_type")) {
            Log.e("DeviceConnection", "Expected connection_type first! " + name);
            reader.endObject();
            return null;
        }

        name = reader.nextString();

        DeviceConnection deviceConnection;

        switch (name) {
            case DeviceConnectionUDP.ID:
                deviceConnection = new DeviceConnectionUDP(device);
                break;
            case DeviceConnectionHTTP.ID:
                deviceConnection = new DeviceConnectionHTTP(device);
                break;
            case DeviceConnectionAPI.ID:
                deviceConnection = new DeviceConnectionAPI(device);
                break;
            default:
                throw new ClassNotFoundException("Unexpected connection_type: " + name);
        }

        if (!deviceConnection.fromJSON(reader, true)) {
            return null;
        } else
            return deviceConnection;
    }
}




Java Source Code List

oly.netpowerctrl.device_base.ApplicationTest.java
oly.netpowerctrl.device_base.data.JSONHelper.java
oly.netpowerctrl.device_base.data.StorableInterface.java
oly.netpowerctrl.device_base.device.DeviceConnectionAPI.java
oly.netpowerctrl.device_base.device.DeviceConnectionFabric.java
oly.netpowerctrl.device_base.device.DeviceConnectionHTTP.java
oly.netpowerctrl.device_base.device.DeviceConnectionUDP.java
oly.netpowerctrl.device_base.device.DeviceConnection.java
oly.netpowerctrl.device_base.device.DeviceFeatureFabric.java
oly.netpowerctrl.device_base.device.DeviceFeatureInterface.java
oly.netpowerctrl.device_base.device.DeviceFeatureTemperature.java
oly.netpowerctrl.device_base.device.DevicePort.java
oly.netpowerctrl.device_base.device.Device.java
oly.netpowerctrl.device_base.executables.ExecutableReachability.java
oly.netpowerctrl.device_base.executables.ExecutableType.java
oly.netpowerctrl.device_base.executables.Executable.java
oly.netpowerctrl.plugin.App2PluginCommunication.java
oly.netpowerctrl.plugin.App2PluginService.java
oly.netpowerctrl.plugin.DeviceConnectionStateInterface.java
oly.netpowerctrl.plugin.onDeviceStateChange.java
oly.netpowerctrl.plugin.onServiceStateChange.java