Updated the order of imports in the source files of simulator plugins.
[platform/upstream/iotivity.git] / service / simulator / java / eclipse-plugin / ClientControllerPlugin / src / oic / simulator / clientcontroller / remoteresource / SerializedClientController.java
1 /*
2  * Copyright 2015 Samsung Electronics All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package oic.simulator.clientcontroller.remoteresource;
18
19 import java.io.FileInputStream;
20 import java.io.FileOutputStream;
21 import java.io.IOException;
22 import java.io.ObjectInputStream;
23 import java.io.ObjectOutputStream;
24 import java.io.Serializable;
25 import java.util.List;
26
27 public class SerializedClientController implements Serializable {
28
29     public List<String> getResourceTypes() {
30         return m_resourceTypes;
31     }
32
33     public void setResourceTypes(List<String> resourceTypes) {
34         this.m_resourceTypes = resourceTypes;
35     }
36
37     public List<String> getFavorites() {
38         return m_favorites;
39     }
40
41     public void setFavorites(List<String> favorites) {
42         this.m_favorites = favorites;
43     }
44
45     public void serialize(String filePath) throws Exception {
46         try {
47             FileOutputStream fileOut = new FileOutputStream(filePath);
48             ObjectOutputStream out = new ObjectOutputStream(fileOut);
49             out.writeObject(this);
50             out.close();
51             fileOut.close();
52         } catch (IOException i) {
53             throw new Exception("Failed to Serialize data : IOException");
54         }
55     }
56
57     public static SerializedClientController deSerialize(String filePath)
58             throws Exception {
59         SerializedClientController r = null;
60         try {
61             FileInputStream fileIn = new FileInputStream(filePath);
62             ObjectInputStream in = new ObjectInputStream(fileIn);
63             r = (SerializedClientController) in.readObject();
64             in.close();
65             fileIn.close();
66         } catch (IOException i) {
67             throw new Exception("Failed to DeSerialize data : IOException");
68         } catch (ClassNotFoundException c) {
69             throw new Exception("Failed to DeSerialize data : ClassNotFound");
70         }
71         return r;
72     }
73
74     private List<String> m_resourceTypes;
75     private List<String> m_favorites;
76
77 }