2 *******************************************************************
4 * Copyright 2015 Intel Corporation.
6 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
23 package org.iotivity.base;
25 import java.util.List;
28 * OcResourceResponse provides APIs to set the response details
30 public class OcResourceResponse {
33 System.loadLibrary("oc");
34 System.loadLibrary("ocstack-jni");
37 public OcResourceResponse() {
43 private OcResourceResponse(long nativeHandle) {
44 this.mNativeHandle = nativeHandle;
48 * This API sets the error code for this response
50 * @param eCode error code to set
52 public native void setErrorCode(int eCode);
55 * Gets new resource uri
57 * @return new resource uri
59 public native String getNewResourceUri();
62 * Sets new resource uri
64 * @param newResourceUri new resource uri
66 public native void setNewResourceUri(String newResourceUri);
69 * This API allows to set headerOptions in the response
71 * @param headerOptionList List of HeaderOption entries
73 public void setHeaderOptions(List<OcHeaderOption> headerOptionList) {
74 this.setHeaderOptions(headerOptionList.toArray(
75 new OcHeaderOption[headerOptionList.size()])
79 private native void setHeaderOptions(OcHeaderOption[] headerOptionList);
82 * This API allows to set request handle
84 * @param ocRequestHandle request handle
86 public native void setRequestHandle(OcRequestHandle ocRequestHandle);
89 * This API allows to set the resource handle
91 * @param ocResourceHandle resource handle
93 public native void setResourceHandle(OcResourceHandle ocResourceHandle);
96 * This API allows to set the EntityHandler response result
98 * @param responseResult OcEntityHandlerResult type to set the result value
100 public void setResponseResult(EntityHandlerResult responseResult) {
101 this.setResponseResult(responseResult.getValue());
104 private native void setResponseResult(int responseResult);
107 * API to set the entire resource attribute representation
109 * @param ocRepresentation the name value pairs representing the resource's attributes
110 * @param interfaceStr specifies the interface
112 public native void setResourceRepresentation(OcRepresentation ocRepresentation,
113 String interfaceStr);
116 * API to set the entire resource attribute representation
118 * @param representation object containing the name value pairs representing the
119 * resource's attributes
121 public void setResourceRepresentation(OcRepresentation representation) {
122 this.setResourceRepresentation1(representation);
125 private native void setResourceRepresentation1(OcRepresentation representation);
128 protected void finalize() throws Throwable {
134 private native void create();
136 private native void dispose();
138 private long mNativeHandle;