序列化"驱动程序"

时间:2016-10-12 18:44:06

标签: java serialization

我有一个类是#34;通用网络设备"。我想支持驱动程序的概念。我写了一个" Driver"接口有一套特定的方法。

鉴于用户已输入"通用网络设备"的信息,我希望他们能够下载Serialized" Drivers"我写的那将然后投射"通用网络设备"进入某个特定的网络设备"。

我努力理解的是如何打开已保存的"驱动程序"并能够将其应用于"通用网络设备"。例如,如果我扩展"驱动程序",当我的应用程序反序列化我的新扩展驱动程序时,它将如何知道将其转换为什么?

public abstract class Driver<N extends DefaultDevice, D extends DefaultDevice, R> implements ReturnInterface<R>,Serializable {

N userSuppliedDevice;
protected static String NAME="Driver";
public Driver(N n) {
    this.userSuppliedDevice = n;
}

public Driver() {

}

public void setDefaultDevice(N n) {
    this.userSuppliedDevice = n;
}

/**
 * Gets the Generic Device before the driver is applied.
 *
 * @return
 */
public N getDefaultDevice() {
    return this.userSuppliedDevice;
}

public abstract Double getVersion();

public abstract String getName();

/**
 * Gets the Specific Device after the driver is applied.
 *
 * @return
 */
public abstract D getReturnedDevice();

public abstract String getSnapShotCommands();


public static void SAVE(Object o, String fileName) throws IOException{
    String path=System.getProperty("user.home")+File.separator+"Documents"+File.separator+fileName;
    System.out.println("Path= "+path);
    Serializer.serialize(new File(path), o);

}

 }

0 个答案:

没有答案