added code to close the netlink socket.
[contrib/iotivity.git] / java / examples-android / fridgegroupserver / src / main / java / org / iotivity / base / examples / Resource.java
1 /*
2  *******************************************************************
3  *
4  * Copyright 2015 Intel Corporation.
5  *
6  *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21  */
22
23 package org.iotivity.base.examples;
24
25 import android.util.Log;
26
27 import org.iotivity.base.OcException;
28 import org.iotivity.base.OcPlatform;
29 import org.iotivity.base.OcRepresentation;
30 import org.iotivity.base.OcResourceHandle;
31
32 /**
33  * Resource
34  * <p/>
35  * Each of the other resource classes (DeviceResource, DoorResource and LightResource extend Resource
36  */
37 public abstract class Resource {
38     protected OcResourceHandle mResourceHandle;
39     protected OcRepresentation mRepresentation;
40
41     Resource() {
42         mResourceHandle = null;
43         mRepresentation = new OcRepresentation();
44     }
45
46     public void bindTo(OcResourceHandle collectionResourceHandle) {
47         try {
48             if (null != mResourceHandle && null != collectionResourceHandle) {
49                 OcPlatform.bindResource(collectionResourceHandle, mResourceHandle);
50             }
51         } catch (OcException e) {
52             Log.e("Resource", e.getMessage());
53         }
54     }
55
56     public static final int SUCCESS = 200;
57     public static final String INTENT = "org.iotivity.base.examples.fridgegroupserver";
58     public static final String MESSAGE = "message";
59 }