Integrated resource model related changes with eclipse plug-ins.
[platform/upstream/iotivity.git] / service / simulator / java / eclipse-plugin / ServiceProviderPlugin / src / oic / simulator / serviceprovider / model / SerializedServiceProvider.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.serviceprovider.model;
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 import java.util.Map;
27
28 public class SerializedServiceProvider implements Serializable {
29
30     public class SerializedAttribute implements Serializable {
31
32         public String getName() {
33             return m_name;
34         }
35
36         public void setName(String name) {
37             this.m_name = name;
38         }
39
40         public Object getValue() {
41             return m_value;
42         }
43
44         public void setValue(Object value) {
45             this.m_value = value;
46         }
47
48         public String getType() {
49             return m_type;
50         }
51
52         public void setType(String type) {
53             this.m_type = type;
54         }
55
56         public int getMin() {
57             return m_min;
58         }
59
60         public void setMin(int min) {
61             this.m_min = min;
62         }
63
64         public int getMax() {
65             return m_max;
66         }
67
68         public void setMax(int max) {
69             this.m_max = max;
70         }
71
72         public Object getAllowedValues() {
73             return m_AllowedValues;
74         }
75
76         public void setAllowedValues(Object allowedValues) {
77             this.m_AllowedValues = allowedValues;
78         }
79
80         private String m_name          = null;
81         private Object m_value         = null;
82         private String m_type          = null;
83         private int    m_min           = 0;
84         private int    m_max           = 0;
85         private Object m_AllowedValues = null;
86     }
87
88     public String getResourceName() {
89         return m_resourceName;
90     }
91
92     public void setResourceName(String resourceName) {
93         this.m_resourceName = resourceName;
94     }
95
96     public String getUri() {
97         return m_uri;
98     }
99
100     public void setUri(String uri) {
101         this.m_uri = uri;
102     }
103
104     public String getResourceType() {
105         return m_resourceType;
106     }
107
108     public void setResourceType(String resourceType) {
109         this.m_resourceType = resourceType;
110     }
111
112     public List<String> getInterfaceType() {
113         return m_interfaceType;
114     }
115
116     public void setInterfaceType(List<String> interfaceType) {
117         this.m_interfaceType = interfaceType;
118     }
119
120     public Map<String, SerializedAttribute> getResourceAttributesMap() {
121         return m_resourceAttributesMap;
122     }
123
124     public void setResourceAttributesMap(
125             Map<String, SerializedAttribute> resourceAttributesMap) {
126         this.m_resourceAttributesMap = resourceAttributesMap;
127     }
128
129     public void serialize(String filePath) throws IOException {
130         FileOutputStream fileOut = new FileOutputStream(filePath);
131         ObjectOutputStream out = new ObjectOutputStream(fileOut);
132         out.writeObject(this);
133         out.close();
134         fileOut.close();
135     }
136
137     public static SerializedServiceProvider deSerialize(String filePath)
138             throws Exception {
139         SerializedServiceProvider r = null;
140         FileInputStream fileIn = new FileInputStream(filePath);
141         ObjectInputStream in = new ObjectInputStream(fileIn);
142         r = (SerializedServiceProvider) in.readObject();
143         in.close();
144         fileIn.close();
145         return r;
146     }
147
148     private String                           m_resourceName;
149     private String                           m_uri;
150     private String                           m_resourceType;
151     private List<String>                     m_interfaceType;
152     private Map<String, SerializedAttribute> m_resourceAttributesMap;
153
154 }