Imported Upstream version 1.0.0
[platform/upstream/iotivity.git] / service / things-manager / sdk / java / jni / tm / inc / jni_things_manager_util.h
1 /******************************************************************
2  *
3  * Copyright 2015 Samsung Electronics All Rights Reserved.
4  *
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  ******************************************************************/
20
21 /**
22   * @file
23   * This file contains the utility functions for conversions from java to CPP
24   * and viceversa.
25   */
26
27 #ifndef JNI_THINGS_MANAGER_UTILS_H_
28 #define JNI_THINGS_MANAGER_UTILS_H_
29
30 #include <vector>
31 #include <map>
32 #include "JniOcResource.h"
33 #include "jni_things_manager_jvm.h"
34
35 /**
36   * Utility function for converting a Java Vector of Strings to CPP Vector of Strings.
37   *
38   * @param env           - Default JNI Environment pointer
39   * @param jVectorString - Java Vector of Strings
40   */
41 std::vector<std::string> convertStringVector(JNIEnv *env, jobject jVectorString);
42
43 /**
44   * Utility function for converting a Hash Map of Strings to CPP Map of Strings.
45   *
46   * @param env        - Default JNI Environment pointer
47   * @param jMapString - Java Map of Strings
48   */
49 std::map<std::string, std::string> convertStringMap(JNIEnv *env, jobject jMapString);
50
51 /**
52   * Utility function for converting ocResource Handle to java.
53   * @param env            - Default JNI Environment pointer
54   * @param resourceHandle -  Resource Handle
55   */
56 jobject ocResourceHandleToJava(JNIEnv *env, jlong resourceHandle);
57
58 /**
59   * Utility function for converting native ocResource to java ocResource.
60   * @param env      - Default JNI Environment pointer
61   * @param resource - Native Resource
62   */
63 jobject OcResourceToJava(JNIEnv *env, jlong resource);
64
65 /**
66   * Utility function for converting native ocHeaderOption to java ocHeaderOption.
67   * @param env          - Default JNI Environment pointer
68   * @param headerOption - Native headerOption
69   */
70 jobject OcHeaderOptionToJava(JNIEnv *env, OC::HeaderOption::OCHeaderOption headerOption);
71
72 /**
73   * Utility function for converting native ocRepresentation  to java ocRepresentation.
74   * @param env              - Default JNI Environment pointer
75   * @param ocRepresentation - Native ocRepresentation
76   */
77 jobject OcRepresentationToJava(JNIEnv *env, jlong ocRepresentation);
78
79 #endif //JNI_THINGS_MANAGER_UTILS_H_
80