1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 ******************************************************************/
20 #include "simulator_resource_jni_util.h"
22 std::vector<int> convertIntegerVector(JNIEnv *env, jobject jVectorInt)
24 std::vector<int> vectorInt;
26 jclass vectorClass = env->FindClass("java/util/Vector");
32 jmethodID size = env->GetMethodID(vectorClass, "size", "()I");
38 jmethodID get = env->GetMethodID(vectorClass, "get", "(I)""Ljava/lang/Object;");
44 jint jSize = env->CallIntMethod(jVectorInt, size);
45 int sizeOfVector = jSize;
47 for (int index = 0; index < sizeOfVector; index++)
50 jint jValue = env->CallIntMethod(jVectorInt, get, jIndex);
51 vectorInt.push_back((int)jValue);
57 std::vector<double> convertDoubleVector(JNIEnv *env, jobject jVectorDouble)
59 std::vector<double> vectorDouble;
61 jclass vectorClass = env->FindClass("java/util/Vector");
67 jmethodID size = env->GetMethodID(vectorClass, "size", "()I");
73 jmethodID get = env->GetMethodID(vectorClass, "get", "(I)""Ljava/lang/Object;");
79 jint jSize = env->CallIntMethod(jVectorDouble, size);
80 int sizeOfVector = jSize;
82 for (int index = 0; index < sizeOfVector; index++)
85 jdouble jValue = env->CallDoubleMethod(jVectorDouble, get, jIndex);
86 vectorDouble.push_back((double)jValue);
92 std::vector<std::string> convertStringVector(JNIEnv *env, jobject jVectorString)
94 std::vector<std::string> vectorString;
96 jclass vectorClass = env->FindClass("java/util/Vector");
102 jmethodID size = env->GetMethodID(vectorClass, "size", "()I");
108 jmethodID get = env->GetMethodID(vectorClass, "get", "(I)""Ljava/lang/Object;");
114 jint jSize = env->CallIntMethod(jVectorString, size);
115 int sizeOfVector = jSize;
117 for (int index = 0; index < sizeOfVector; index++)
120 jstring jContactInfoObj = (jstring)env->CallObjectMethod(jVectorString, get, jIndex);
121 if (jContactInfoObj == NULL)
125 const char *buff = env->GetStringUTFChars(jContactInfoObj, 0);
128 std::string tempString = buff;
129 vectorString.push_back(tempString);
132 env->ReleaseStringUTFChars(jContactInfoObj, buff);