Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / android / android_api / base / src / main / java / org / iotivity / base / OcResourceRequest.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.EnumSet;\r
26 import java.util.List;\r
27 import java.util.Map;\r
28 \r
29 /**\r
30  * OcResourceRequest provides APIs to extract details from a request\r
31  */\r
32 public class OcResourceRequest {\r
33 \r
34     private OcResourceRequest(long nativeHandle) {\r
35         this.mNativeHandle = nativeHandle;\r
36     }\r
37 \r
38     /**\r
39      * Retrieves the type of request for the entity handler function to operate\r
40      *\r
41      * @return request type. This could be 'GET'/'PUT'/'POST'/'DELETE'\r
42      */\r
43     public RequestType getRequestType() {\r
44         return RequestType.get(getRequestTypeNative());\r
45     }\r
46 \r
47     private native String getRequestTypeNative();\r
48 \r
49     /**\r
50      * Retrieves the query parameters from the request\r
51      *\r
52      * @return parameters in the request\r
53      */\r
54     public native Map<String, String> getQueryParameters();\r
55 \r
56     /**\r
57      * Retrieves the request handler flag set. This can be INIT flag and/or REQUEST flag and/or\r
58      * OBSERVE flag.\r
59      * NOTE:\r
60      * INIT indicates that the vendor's entity handler should go and perform\r
61      * initialization operations\r
62      * REQUEST indicates that it is a request of certain type (GET/PUT/POST/DELETE) and entity\r
63      * handler needs to perform corresponding operations\r
64      * OBSERVE indicates that the request is of type Observe and entity handler needs to perform\r
65      * corresponding operations\r
66      *\r
67      * @return Set of handler flags\r
68      */\r
69     public EnumSet<RequestHandlerFlag> getRequestHandlerFlagSet() {\r
70         return RequestHandlerFlag.convertToEnumSet(getRequestHandlerFlagNative());\r
71     }\r
72 \r
73     private native int getRequestHandlerFlagNative();\r
74 \r
75     /**\r
76      * Provides the entire resource attribute representation\r
77      *\r
78      * @return OcRepresentation object containing the name value pairs representing\r
79      * the resource's attributes\r
80      */\r
81     public native OcRepresentation getResourceRepresentation();\r
82 \r
83     /**\r
84      * Object provides observation information\r
85      *\r
86      * @return observation information\r
87      */\r
88     public native ObservationInfo getObservationInfo();\r
89 \r
90     /**\r
91      * Specifies the resource uri\r
92      *\r
93      * @param resourceUri resource uri\r
94      */\r
95     public native void setResourceUri(String resourceUri);\r
96 \r
97     /**\r
98      * Gets the resource URI\r
99      *\r
100      * @return resource URI\r
101      */\r
102     public native String getResourceUri();\r
103 \r
104     /**\r
105      * This API retrieves a list of headerOptions which was sent from a client\r
106      *\r
107      * @return List of header options\r
108      */\r
109     public native List<OcHeaderOption> getHeaderOptions();\r
110 \r
111     /**\r
112      * This API retrieves the request handle\r
113      *\r
114      * @return request handle\r
115      */\r
116     public native OcRequestHandle getRequestHandle();\r
117 \r
118     /**\r
119      * This API retrieves the resource handle\r
120      *\r
121      * @return resource handle\r
122      */\r
123     public native OcResourceHandle getResourceHandle();\r
124 \r
125     @Override\r
126     protected void finalize() throws Throwable {\r
127         super.finalize();\r
128 \r
129         dispose();\r
130     }\r
131 \r
132     private native void dispose();\r
133 \r
134     private long mNativeHandle;\r
135 }\r