Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / android / android_api / base / src / main / java / org / iotivity / base / OcResourceResponse.java
1 /*\r
2  * //******************************************************************\r
3  * //\r
4  * // Copyright 2015 Intel Corporation.\r
5  * //\r
6  * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
7  * //\r
8  * // Licensed under the Apache License, Version 2.0 (the "License");\r
9  * // you may not use this file except in compliance with the License.\r
10  * // You may obtain a copy of the License at\r
11  * //\r
12  * //      http://www.apache.org/licenses/LICENSE-2.0\r
13  * //\r
14  * // Unless required by applicable law or agreed to in writing, software\r
15  * // distributed under the License is distributed on an "AS IS" BASIS,\r
16  * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
17  * // See the License for the specific language governing permissions and\r
18  * // limitations under the License.\r
19  * //\r
20  * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
21  */\r
22 \r
23 package org.iotivity.base;\r
24 \r
25 import java.util.List;\r
26 \r
27 /**\r
28  * OcResourceResponse provides APIs to set the response details\r
29  */\r
30 public class OcResourceResponse {\r
31 \r
32     static {\r
33         System.loadLibrary("oc");\r
34         System.loadLibrary("ocstack-jni");\r
35     }\r
36 \r
37     public OcResourceResponse() {\r
38         super();\r
39 \r
40         create();\r
41     }\r
42 \r
43     private OcResourceResponse(long nativeHandle) {\r
44         this.mNativeHandle = nativeHandle;\r
45     }\r
46 \r
47     /**\r
48      * This API sets the error code for this response\r
49      *\r
50      * @param eCode error code to set\r
51      */\r
52     public native void setErrorCode(int eCode);\r
53 \r
54     /**\r
55      * Gets new resource uri\r
56      *\r
57      * @return new resource uri\r
58      */\r
59     public native String getNewResourceUri();\r
60 \r
61     /**\r
62      * Sets new resource uri\r
63      *\r
64      * @param newResourceUri new resource uri\r
65      */\r
66     public native void setNewResourceUri(String newResourceUri);\r
67 \r
68     /**\r
69      * This API allows to set headerOptions in the response\r
70      *\r
71      * @param headerOptionList List of HeaderOption entries\r
72      */\r
73     public void setHeaderOptions(List<OcHeaderOption> headerOptionList) {\r
74         this.setHeaderOptions(headerOptionList.toArray(\r
75                         new OcHeaderOption[headerOptionList.size()])\r
76         );\r
77     }\r
78 \r
79     private native void setHeaderOptions(OcHeaderOption[] headerOptionList);\r
80 \r
81     /**\r
82      * This API allows to set request handle\r
83      *\r
84      * @param ocRequestHandle request handle\r
85      */\r
86     public native void setRequestHandle(OcRequestHandle ocRequestHandle);\r
87 \r
88     /**\r
89      * This API allows to set the resource handle\r
90      *\r
91      * @param ocResourceHandle resource handle\r
92      */\r
93     public native void setResourceHandle(OcResourceHandle ocResourceHandle);\r
94 \r
95     /**\r
96      * This API allows to set the EntityHandler response result\r
97      *\r
98      * @param responseResult OcEntityHandlerResult type to set the result value\r
99      */\r
100     public void setResponseResult(EntityHandlerResult responseResult) {\r
101         this.setResponseResult(responseResult.getValue());\r
102     }\r
103 \r
104     private native void setResponseResult(int responseResult);\r
105 \r
106     /**\r
107      * API to set the entire resource attribute representation\r
108      *\r
109      * @param ocRepresentation the name value pairs representing the resource's attributes\r
110      * @param interfaceStr     specifies the interface\r
111      */\r
112     public native void setResourceRepresentation(OcRepresentation ocRepresentation,\r
113                                                  String interfaceStr);\r
114 \r
115     /**\r
116      * API to set the entire resource attribute representation\r
117      *\r
118      * @param representation object containing the name value pairs representing the\r
119      *                       resource's attributes\r
120      */\r
121     public void setResourceRepresentation(OcRepresentation representation) {\r
122         this.setResourceRepresentation1(representation);\r
123     }\r
124 \r
125     private native void setResourceRepresentation1(OcRepresentation representation);\r
126 \r
127     @Override\r
128     protected void finalize() throws Throwable {\r
129         super.finalize();\r
130 \r
131         dispose();\r
132     }\r
133 \r
134     private native void create();\r
135 \r
136     private native void dispose();\r
137 \r
138     private long mNativeHandle;\r
139 }\r