-/*\r
-* //******************************************************************\r
-* //\r
-* // Copyright 2015 Intel Corporation.\r
-* //\r
-* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
-* //\r
-* // Licensed under the Apache License, Version 2.0 (the "License");\r
-* // you may not use this file except in compliance with the License.\r
-* // You may obtain a copy of the License at\r
-* //\r
-* // http://www.apache.org/licenses/LICENSE-2.0\r
-* //\r
-* // Unless required by applicable law or agreed to in writing, software\r
-* // distributed under the License is distributed on an "AS IS" BASIS,\r
-* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-* // See the License for the specific language governing permissions and\r
-* // limitations under the License.\r
-* //\r
-* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r
-*/\r
-#include "JniOcRepresentation.h"\r
-#include "JniUtils.h"\r
-\r
-using namespace OC;\r
-\r
-OCRepresentation* JniOcRepresentation::getOCRepresentationPtr(JNIEnv *env, jobject thiz)\r
-{\r
- OCRepresentation *rep = GetHandle<OCRepresentation>(env, thiz);\r
- if (env->ExceptionCheck())\r
- {\r
- LOGE("Failed to get native handle from OcRepresentation");\r
- }\r
- if (!rep)\r
- {\r
- ThrowOcException(JNI_NO_NATIVE_POINTER, "");\r
- }\r
- return rep;\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: getValueN\r
-* Signature: (Ljava/lang/String;)Ljava/lang/Object;\r
-*/\r
-JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getValueN\r
-(JNIEnv *env, jobject thiz, jstring jKey)\r
-{\r
- LOGD("OcRepresentation_getValue");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null");\r
- return nullptr;\r
- }\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return nullptr;\r
-\r
- std::string key = env->GetStringUTFChars(jKey, NULL);\r
-\r
- AttributeValue attrValue;\r
- if (!rep->getAttributeValue(key.c_str(), attrValue))\r
- {\r
- ThrowOcException(JNI_NO_SUCH_KEY, " attribute key does not exist");\r
- return nullptr;\r
- }\r
- return boost::apply_visitor(JObjectConverter(env), attrValue);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueInteger\r
-* Signature: (Ljava/lang/String;I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger\r
-(JNIEnv *env, jobject thiz, jstring jKey, jint jValue)\r
-{\r
- LOGD("OcRepresentation_setValueInteger");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string str = env->GetStringUTFChars(jKey, NULL);\r
- rep->setValue(str, static_cast<int>(jValue));\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueDouble\r
-* Signature: (Ljava/lang/String;D)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble\r
-(JNIEnv *env, jobject thiz, jstring jKey, jdouble jValue)\r
-{\r
- LOGD("OcRepresentation_setValueDouble");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string str = env->GetStringUTFChars(jKey, NULL);\r
- rep->setValue(str, static_cast<double>(jValue));\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueBoolean\r
-* Signature: (Ljava/lang/String;Z)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean\r
-(JNIEnv *env, jobject thiz, jstring jKey, jboolean jValue)\r
-{\r
- LOGD("OcRepresentation_setValueBoolean");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string str = env->GetStringUTFChars(jKey, NULL);\r
- rep->setValue(str, static_cast<bool>(jValue));\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueStringN\r
-* Signature: (Ljava/lang/String;Ljava/lang/String;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueStringN\r
-(JNIEnv *env, jobject thiz, jstring jKey, jstring jValue)\r
-{\r
- LOGD("OcRepresentation_setValueString");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string key = env->GetStringUTFChars(jKey, NULL);\r
- std::string value = env->GetStringUTFChars(jValue, NULL);\r
-\r
- rep->setValue(key, value);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueRepresentation\r
-* Signature: (Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation\r
-(JNIEnv *env, jobject thiz, jstring jKey, jobject jValue)\r
-{\r
- LOGD("OcRepresentation_setValueRepresentation");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string key = env->GetStringUTFChars(jKey, NULL);\r
- OCRepresentation *value = JniOcRepresentation::getOCRepresentationPtr(env, jValue);\r
- if (!value) return;\r
-\r
- rep->setValue(key, *value);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueIntegerArray\r
-* Signature: (Ljava/lang/String;[I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueIntegerArray\r
-(JNIEnv *env, jobject thiz, jstring jKey, jintArray jValue)\r
-{\r
- LOGD("OcRepresentation_setValueIntegerArray");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
-\r
- const jsize len = env->GetArrayLength(jValue);\r
- jint* ints = env->GetIntArrayElements(jValue, NULL);\r
-\r
- std::vector<int> value;\r
- for (jsize i = 0; i < len; ++i)\r
- {\r
- value.push_back(static_cast<int>(ints[i]));\r
- }\r
- env->ReleaseIntArrayElements(jValue, ints, JNI_ABORT);\r
-\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string key = env->GetStringUTFChars(jKey, NULL);\r
- rep->setValue(key, value);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueInteger2DArray\r
-* Signature: (Ljava/lang/String;[[I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger2DArray\r
-(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
-{\r
- LOGD("OcRepresentation__setValueInteger2DArray");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
- std::vector<std::vector<int>> value;\r
- const jsize lenOuter = env->GetArrayLength(jValue);\r
- for (jsize j = 0; j < lenOuter; ++j)\r
- {\r
- jintArray jInnerArray = static_cast<jintArray>(env->GetObjectArrayElement(jValue, j));\r
- jint* ints = env->GetIntArrayElements(jInnerArray, NULL);\r
- std::vector<int> innerVector;\r
- const jsize lenInner = env->GetArrayLength(jInnerArray);\r
- for (jsize i = 0; i < lenInner; ++i)\r
- {\r
- innerVector.push_back(static_cast<int>(ints[i]));\r
- }\r
- env->ReleaseIntArrayElements(jInnerArray, ints, JNI_ABORT);\r
- env->DeleteLocalRef(jInnerArray);\r
- value.push_back(innerVector);\r
- }\r
-\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string key = env->GetStringUTFChars(jKey, NULL);\r
- rep->setValue(key, value);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueInteger3DArray\r
-* Signature: (Ljava/lang/String;[[[I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger3DArray\r
-(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
-{\r
- LOGD("OcRepresentation_setValueInteger3DArray");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
- std::vector<std::vector<std::vector<int>>> value;\r
- const jsize lenOuter = env->GetArrayLength(jValue);\r
- for (jsize k = 0; k < lenOuter; ++k)\r
- {\r
- jobjectArray jMiddleArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, k));\r
- const jsize lenMiddle = env->GetArrayLength(jMiddleArray);\r
- std::vector<std::vector<int>> middleArray;\r
- for (jsize j = 0; j < lenMiddle; ++j)\r
- {\r
- jintArray jInnerArray = static_cast<jintArray>(env->GetObjectArrayElement(jMiddleArray, j));\r
- jint* ints = env->GetIntArrayElements(jInnerArray, NULL);\r
- std::vector<int> innerVector;\r
- const jsize lenInner = env->GetArrayLength(jInnerArray);\r
- for (jsize i = 0; i < lenInner; ++i)\r
- {\r
- innerVector.push_back(static_cast<int>(ints[i]));\r
- }\r
- env->ReleaseIntArrayElements(jInnerArray, ints, JNI_ABORT);\r
- env->DeleteLocalRef(jInnerArray);\r
- middleArray.push_back(innerVector);\r
- }\r
- env->DeleteLocalRef(jMiddleArray);\r
- value.push_back(middleArray);\r
- }\r
-\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string key = env->GetStringUTFChars(jKey, NULL);\r
- rep->setValue(key, value);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueDoubleArray\r
-* Signature: (Ljava/lang/String;[D)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDoubleArray\r
-(JNIEnv *env, jobject thiz, jstring jKey, jdoubleArray jValue)\r
-{\r
- LOGD("OcRepresentation_setValueDoubleArray");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
-\r
- const jsize len = env->GetArrayLength(jValue);\r
- jdouble* doubles = env->GetDoubleArrayElements(jValue, NULL);\r
-\r
- std::vector<double> value;\r
- for (jsize i = 0; i < len; ++i)\r
- {\r
- value.push_back(static_cast<double>(doubles[i]));\r
- }\r
- env->ReleaseDoubleArrayElements(jValue, doubles, JNI_ABORT);\r
-\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string key = env->GetStringUTFChars(jKey, NULL);\r
- rep->setValue(key, value);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueDouble2DArray\r
-* Signature: (Ljava/lang/String;[[D)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble2DArray\r
-(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
-{\r
- LOGD("OcRepresentation_setValueDouble2DArray");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
- std::vector<std::vector<double>> value;\r
- const jsize lenOuter = env->GetArrayLength(jValue);\r
- for (jsize j = 0; j < lenOuter; ++j)\r
- {\r
- jdoubleArray jInnerArray = static_cast<jdoubleArray>(env->GetObjectArrayElement(jValue, j));\r
- jdouble* doubles = env->GetDoubleArrayElements(jInnerArray, NULL);\r
- std::vector<double> innerVector;\r
- const jsize lenInner = env->GetArrayLength(jInnerArray);\r
- for (jsize i = 0; i < lenInner; ++i)\r
- {\r
- innerVector.push_back(static_cast<double>(doubles[i]));\r
- }\r
- env->ReleaseDoubleArrayElements(jInnerArray, doubles, JNI_ABORT);\r
- env->DeleteLocalRef(jInnerArray);\r
- value.push_back(innerVector);\r
- }\r
-\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string key = env->GetStringUTFChars(jKey, NULL);\r
- rep->setValue(key, value);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueDouble3DArray\r
-* Signature: (Ljava/lang/String;[[[D)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble3DArray\r
-(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
-{\r
- LOGD("OcRepresentation_setValueDouble3DArray");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
- std::vector<std::vector<std::vector<double>>> value;\r
- const jsize lenOuter = env->GetArrayLength(jValue);\r
- for (jsize k = 0; k < lenOuter; ++k)\r
- {\r
- jobjectArray jMiddleArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, k));\r
- const jsize lenMiddle = env->GetArrayLength(jMiddleArray);\r
- std::vector<std::vector<double>> middleArray;\r
- for (jsize j = 0; j < lenMiddle; ++j)\r
- {\r
- jdoubleArray jInnerArray = static_cast<jdoubleArray>(env->GetObjectArrayElement(jMiddleArray, j));\r
- jdouble* doubles = env->GetDoubleArrayElements(jInnerArray, NULL);\r
- std::vector<double> innerVector;\r
- const jsize lenInner = env->GetArrayLength(jInnerArray);\r
- for (jsize i = 0; i < lenInner; ++i)\r
- {\r
- innerVector.push_back(static_cast<double>(doubles[i]));\r
- }\r
- env->ReleaseDoubleArrayElements(jInnerArray, doubles, JNI_ABORT);\r
- env->DeleteLocalRef(jInnerArray);\r
- middleArray.push_back(innerVector);\r
- }\r
- env->DeleteLocalRef(jMiddleArray);\r
- value.push_back(middleArray);\r
- }\r
-\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string key = env->GetStringUTFChars(jKey, NULL);\r
- rep->setValue(key, value);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueBooleanArray\r
-* Signature: (Ljava/lang/String;[Z)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBooleanArray\r
-(JNIEnv *env, jobject thiz, jstring jKey, jbooleanArray jValue)\r
-{\r
- LOGD("OcRepresentation_setValueBooleanArray");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
-\r
- const jsize len = env->GetArrayLength(jValue);\r
- jboolean* booleans = env->GetBooleanArrayElements(jValue, NULL);\r
-\r
- std::vector<bool> value;\r
- for (jsize i = 0; i < len; ++i)\r
- {\r
- value.push_back(static_cast<bool>(booleans[i]));\r
- }\r
- env->ReleaseBooleanArrayElements(jValue, booleans, JNI_ABORT);\r
-\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string key = env->GetStringUTFChars(jKey, NULL);\r
- rep->setValue(key, value);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueBoolean2DArray\r
-* Signature: (Ljava/lang/String;[[Z)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean2DArray\r
-(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
-{\r
- LOGD("OcRepresentation_setValueBoolean2DArray");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
- std::vector<std::vector<bool>> value;\r
- const jsize lenOuter = env->GetArrayLength(jValue);\r
- for (jsize j = 0; j < lenOuter; ++j)\r
- {\r
- jbooleanArray jInnerArray = static_cast<jbooleanArray>(env->GetObjectArrayElement(jValue, j));\r
- const jsize lenInner = env->GetArrayLength(jInnerArray);\r
- jboolean* booleans = env->GetBooleanArrayElements(jInnerArray, NULL);\r
-\r
- std::vector<bool> innerVector;\r
- for (jsize i = 0; i < lenInner; ++i)\r
- {\r
- innerVector.push_back(static_cast<bool>(booleans[i]));\r
- }\r
- env->ReleaseBooleanArrayElements(jInnerArray, booleans, JNI_ABORT);\r
- env->DeleteLocalRef(jInnerArray);\r
- value.push_back(innerVector);\r
- }\r
-\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string key = env->GetStringUTFChars(jKey, NULL);\r
- rep->setValue(key, value);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueBoolean3DArray\r
-* Signature: (Ljava/lang/String;[[[Z)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean3DArray\r
-(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
-{\r
- LOGD("OcRepresentation_setValueBoolean3DArray");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
- std::vector<std::vector<std::vector<bool>>> value;\r
- const jsize lenOuter = env->GetArrayLength(jValue);\r
- for (jsize k = 0; k < lenOuter; ++k)\r
- {\r
- jobjectArray jMiddleArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, k));\r
- const jsize lenMiddle = env->GetArrayLength(jMiddleArray);\r
- std::vector<std::vector<bool>> middleArray;\r
- for (jsize j = 0; j < lenMiddle; ++j)\r
- {\r
- jbooleanArray jInnerArray = static_cast<jbooleanArray>(env->GetObjectArrayElement(jMiddleArray, j));\r
- const jsize lenInner = env->GetArrayLength(jInnerArray);\r
- jboolean* booleans = env->GetBooleanArrayElements(jInnerArray, NULL);\r
-\r
- std::vector<bool> innerVector;\r
- for (jsize i = 0; i < lenInner; ++i)\r
- {\r
- innerVector.push_back(static_cast<bool>(booleans[i]));\r
- }\r
- env->ReleaseBooleanArrayElements(jInnerArray, booleans, JNI_ABORT);\r
- env->DeleteLocalRef(jInnerArray);\r
- middleArray.push_back(innerVector);\r
- }\r
- env->DeleteLocalRef(jMiddleArray);\r
- value.push_back(middleArray);\r
- }\r
-\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string key = env->GetStringUTFChars(jKey, NULL);\r
- rep->setValue(key, value);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueStringArray\r
-* Signature: (Ljava/lang/String;[Ljava/lang/String;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueStringArray\r
-(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
-{\r
- LOGD("OcRepresentation_setValueStringArray");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
-\r
- std::vector<std::string> value;\r
- JniUtils::convertJavaStrArrToStrVector(env, jValue, value);\r
-\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string key = env->GetStringUTFChars(jKey, NULL);\r
- rep->setValue(key, value);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueString2DArray\r
-* Signature: (Ljava/lang/String;[[Ljava/lang/String;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueString2DArray\r
-(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
-{\r
- LOGD("OcRepresentation_setValueString2DArray");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
- std::vector<std::vector<std::string>> value;\r
- const jsize lenOuter = env->GetArrayLength(jValue);\r
- for (jsize j = 0; j < lenOuter; ++j)\r
- {\r
- jobjectArray jInnerArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, j));\r
- std::vector<std::string> innerVector;\r
- JniUtils::convertJavaStrArrToStrVector(env, jInnerArray, innerVector);\r
- env->DeleteLocalRef(jInnerArray);\r
- value.push_back(innerVector);\r
- }\r
-\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string key = env->GetStringUTFChars(jKey, NULL);\r
- rep->setValue(key, value);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueString3DArray\r
-* Signature: (Ljava/lang/String;[[[Ljava/lang/String;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueString3DArray\r
-(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
-{\r
- LOGD("OcRepresentation_setValueString3DArray");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
- std::vector<std::vector<std::vector<std::string>>> value;\r
- const jsize lenOuter = env->GetArrayLength(jValue);\r
- for (jsize k = 0; k < lenOuter; ++k)\r
- {\r
- jobjectArray jMiddleArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, k));\r
- const jsize lenMiddle = env->GetArrayLength(jMiddleArray);\r
- std::vector<std::vector<std::string>> middleArray;\r
- for (jsize j = 0; j < lenMiddle; ++j)\r
- {\r
- jobjectArray jInnerArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jMiddleArray, j));\r
- std::vector<std::string> innerVector;\r
- JniUtils::convertJavaStrArrToStrVector(env, jInnerArray, innerVector);\r
- env->DeleteLocalRef(jInnerArray);\r
- middleArray.push_back(innerVector);\r
- }\r
- env->DeleteLocalRef(jMiddleArray);\r
- value.push_back(middleArray);\r
- }\r
-\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string key = env->GetStringUTFChars(jKey, NULL);\r
- rep->setValue(key, value);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueRepresentationArray\r
-* Signature: (Ljava/lang/String;[Lorg/iotivity/base/OcRepresentation;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentationArray\r
-(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
-{\r
- LOGD("OcRepresentation_setValueRepresentationArray");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
-\r
- std::vector<OCRepresentation> value;\r
- JniUtils::convertJavaRepresentationArrToVector(env, jValue, value);\r
-\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string key = env->GetStringUTFChars(jKey, NULL);\r
- rep->setValue(key, value);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueRepresentation2DArray\r
-* Signature: (Ljava/lang/String;[[Lorg/iotivity/base/OcRepresentation;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation2DArray\r
-(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
-{\r
- LOGD("OcRepresentation_setValueRepresentation2DArray");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
- std::vector<std::vector<OCRepresentation>> value;\r
- const jsize lenOuter = env->GetArrayLength(jValue);\r
- for (jsize j = 0; j < lenOuter; ++j)\r
- {\r
- jobjectArray jInnerArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, j));\r
- std::vector<OCRepresentation> innerVector;\r
- JniUtils::convertJavaRepresentationArrToVector(env, jInnerArray, innerVector);\r
- env->DeleteLocalRef(jInnerArray);\r
- value.push_back(innerVector);\r
- }\r
-\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string key = env->GetStringUTFChars(jKey, NULL);\r
- rep->setValue(key, value);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setValueRepresentation3DArray\r
-* Signature: (Ljava/lang/String;[[[Lorg/iotivity/base/OcRepresentation;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation3DArray\r
-(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)\r
-{\r
- LOGD("OcRepresentation_setValueRepresentation3DArray");\r
- if (!jKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");\r
- return;\r
- }\r
- std::vector<std::vector<std::vector<OCRepresentation>>> value;\r
- const jsize lenOuter = env->GetArrayLength(jValue);\r
- for (jsize k = 0; k < lenOuter; ++k)\r
- {\r
- jobjectArray jMiddleArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, k));\r
- const jsize lenMiddle = env->GetArrayLength(jMiddleArray);\r
- std::vector<std::vector<OCRepresentation>> middleArray;\r
- for (jsize j = 0; j < lenMiddle; ++j)\r
- {\r
- jobjectArray jInnerArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jMiddleArray, j));\r
- std::vector<OCRepresentation> innerVector;\r
- JniUtils::convertJavaRepresentationArrToVector(env, jInnerArray, innerVector);\r
- env->DeleteLocalRef(jInnerArray);\r
- middleArray.push_back(innerVector);\r
- }\r
- env->DeleteLocalRef(jMiddleArray);\r
- value.push_back(middleArray);\r
- }\r
-\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string key = env->GetStringUTFChars(jKey, NULL);\r
- rep->setValue(key, value);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: addChild\r
-* Signature: (Lorg/iotivity/base/OcRepresentation;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_addChild\r
-(JNIEnv *env, jobject thiz, jobject jOcRepresentation)\r
-{\r
- LOGD("OcRepresentation_addChild");\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- OCRepresentation *child = JniOcRepresentation::getOCRepresentationPtr(env, jOcRepresentation);\r
- if (!child) return;\r
-\r
- rep->addChild(*child);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: clearChildren\r
-* Signature: ()V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_clearChildren\r
-(JNIEnv *env, jobject thiz)\r
-{\r
- LOGD("OcRepresentation_clearChildren");\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- rep->clearChildren();\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: getChildrenArray\r
-* Signature: ()[Lorg/iotivity/base/OcRepresentation;\r
-*/\r
-JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcRepresentation_getChildrenArray\r
-(JNIEnv *env, jobject thiz)\r
-{\r
- LOGD("OcRepresentation_getChildrenArray");\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return nullptr;\r
-\r
- return JniUtils::convertRepresentationVectorToJavaArray(env, rep->getChildren());\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: getUri\r
-* Signature: ()Ljava/lang/String;\r
-*/\r
-JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcRepresentation_getUri\r
-(JNIEnv *env, jobject thiz)\r
-{\r
- LOGD("OcRepresentation_getUri");\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return nullptr;\r
-\r
- std::string uri(rep->getUri());\r
- return env->NewStringUTF(uri.c_str());\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setUri\r
-* Signature: (Ljava/lang/String;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setUri\r
-(JNIEnv *env, jobject thiz, jstring jUri)\r
-{\r
- LOGD("OcRepresentation_setUri");\r
- if (!jUri)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "uri cannot be null");\r
- return;\r
- }\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- rep->setUri(env->GetStringUTFChars(jUri, NULL));\r
-}\r
-\r
-JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_hasAttribute\r
-(JNIEnv *env, jobject thiz, jstring jstr)\r
-{\r
- LOGD("OcRepresentation_hasAttribute");\r
- if (!jstr)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null");\r
- return false;\r
- }\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return false;\r
-\r
- std::string str = env->GetStringUTFChars(jstr, NULL);\r
- return rep->hasAttribute(str);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: getResourceTypes\r
-* Signature: ()Ljava/util/List;\r
-*/\r
-JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getResourceTypes\r
-(JNIEnv *env, jobject thiz)\r
-{\r
- LOGD("OcRepresentation_getResourceTypes");\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return nullptr;\r
-\r
- std::vector<std::string> resourceTypes = rep->getResourceTypes();\r
- return JniUtils::convertStrVectorToJavaStrList(env, resourceTypes);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setResourceTypeArray\r
-* Signature: ([Ljava/lang/String;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setResourceTypeArray\r
-(JNIEnv *env, jobject thiz, jobjectArray jResourceTypeArray)\r
-{\r
- LOGD("OcRepresentation_setResourceTypeArray");\r
- if (!jResourceTypeArray)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "resourceTypeList cannot be null");\r
- return;\r
- }\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::vector<std::string> resourceTypes;\r
- JniUtils::convertJavaStrArrToStrVector(env, jResourceTypeArray, resourceTypes);\r
- rep->setResourceTypes(resourceTypes);\r
-}\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: getResourceInterfaces\r
-* Signature: ()Ljava/util/List;\r
-*/\r
-JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getResourceInterfaces\r
-(JNIEnv *env, jobject thiz)\r
-{\r
- LOGD("OcRepresentation_getResourceInterfaces");\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return nullptr;\r
-\r
- std::vector<std::string> resourceInterfaces = rep->getResourceInterfaces();\r
- return JniUtils::convertStrVectorToJavaStrList(env, resourceInterfaces);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setResourceInterfaceArray\r
-* Signature: ([Ljava/lang/String;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setResourceInterfaceArray\r
-(JNIEnv *env, jobject thiz, jobjectArray jResourceInterfaceArray)\r
-{\r
- LOGD("OcRepresentation_setResourceInterfaceArray");\r
- if (!jResourceInterfaceArray)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "resourceInterfaceList cannot be null");\r
- return;\r
- }\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::vector<std::string> resourceInterfaces;\r
- JniUtils::convertJavaStrArrToStrVector(env, jResourceInterfaceArray, resourceInterfaces);\r
- rep->setResourceInterfaces(resourceInterfaces);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: isEmpty\r
-* Signature: ()Z\r
-*/\r
-JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_isEmpty\r
-(JNIEnv *env, jobject thiz)\r
-{\r
- LOGD("OcRepresentation_isEmpty");\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return false;\r
-\r
- return static_cast<jboolean>(rep->empty());\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: size\r
-* Signature: ()I\r
-*/\r
-JNIEXPORT jint JNICALL Java_org_iotivity_base_OcRepresentation_size\r
-(JNIEnv *env, jobject thiz)\r
-{\r
- LOGD("OcRepresentation_size");\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return -1;\r
-\r
- return static_cast<jint>(rep->numberOfAttributes());\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: remove\r
-* Signature: (Ljava/lang/String;)Z\r
-*/\r
-JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_remove\r
-(JNIEnv *env, jobject thiz, jstring jAttributeKey)\r
-{\r
- LOGD("OcRepresentation_remove");\r
- if (!jAttributeKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null");\r
- return false;\r
- }\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return false;\r
-\r
- std::string attributeKey = env->GetStringUTFChars(jAttributeKey, NULL);\r
- return static_cast<jboolean>(rep->erase(attributeKey));\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: setNull\r
-* Signature: (Ljava/lang/String;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setNull\r
-(JNIEnv *env, jobject thiz, jstring jAttributeKey)\r
-{\r
- LOGD("OcRepresentation_setNull");\r
- if (!jAttributeKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null");\r
- return;\r
- }\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return;\r
-\r
- std::string attributeKey = env->GetStringUTFChars(jAttributeKey, NULL);\r
- rep->setNULL(attributeKey);\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: isNull\r
-* Signature: (Ljava/lang/String;)Z\r
-*/\r
-JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_isNull\r
-(JNIEnv *env, jobject thiz, jstring jAttributeKey)\r
-{\r
- LOGD("OcRepresentation_isNull");\r
- if (!jAttributeKey)\r
- {\r
- ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null");\r
- return false;\r
- }\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
- if (!rep) return false;\r
-\r
- std::string attributeKey = env->GetStringUTFChars(jAttributeKey, NULL);\r
- return static_cast<jboolean>(rep->isNULL(attributeKey));\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: create\r
-* Signature: ()V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_create\r
-(JNIEnv *env, jobject thiz)\r
-{\r
- LOGD("OcRepresentation_create");\r
- OCRepresentation *rep = new OCRepresentation();\r
- SetHandle<OCRepresentation>(env, thiz, rep);\r
- if (env->ExceptionCheck())\r
- {\r
- LOGE("Failed to set native handle for OcRepresentation");\r
- delete rep;\r
- }\r
-}\r
-\r
-/*\r
-* Class: org_iotivity_base_OcRepresentation\r
-* Method: dispose\r
-* Signature: ()V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_dispose\r
-(JNIEnv *env, jobject thiz, jboolean jNeedsDelete)\r
-{\r
- LOGD("OcRepresentation_dispose");\r
- OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);\r
-\r
- if (jNeedsDelete)\r
- {\r
- delete rep;\r
- }\r
-}\r
+/*
+* //******************************************************************
+* //
+* // Copyright 2015 Intel Corporation.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+* //
+* // Licensed under the Apache License, Version 2.0 (the "License");
+* // you may not use this file except in compliance with the License.
+* // You may obtain a copy of the License at
+* //
+* // http://www.apache.org/licenses/LICENSE-2.0
+* //
+* // Unless required by applicable law or agreed to in writing, software
+* // distributed under the License is distributed on an "AS IS" BASIS,
+* // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* // See the License for the specific language governing permissions and
+* // limitations under the License.
+* //
+* //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+*/
+#include "JniOcRepresentation.h"
+#include "JniUtils.h"
+
+using namespace OC;
+
+OCRepresentation* JniOcRepresentation::getOCRepresentationPtr(JNIEnv *env, jobject thiz)
+{
+ OCRepresentation *rep = GetHandle<OCRepresentation>(env, thiz);
+ if (env->ExceptionCheck())
+ {
+ LOGE("Failed to get native handle from OcRepresentation");
+ }
+ if (!rep)
+ {
+ ThrowOcException(JNI_NO_NATIVE_POINTER, "");
+ }
+ return rep;
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: getValueN
+* Signature: (Ljava/lang/String;)Ljava/lang/Object;
+*/
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getValueN
+(JNIEnv *env, jobject thiz, jstring jKey)
+{
+ LOGD("OcRepresentation_getValue");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null");
+ return nullptr;
+ }
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return nullptr;
+
+ std::string key = env->GetStringUTFChars(jKey, nullptr);
+
+ AttributeValue attrValue;
+ if (!rep->getAttributeValue(key.c_str(), attrValue))
+ {
+ ThrowOcException(JNI_NO_SUCH_KEY, " attribute key does not exist");
+ return nullptr;
+ }
+ return boost::apply_visitor(JObjectConverter(env), attrValue);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueInteger
+* Signature: (Ljava/lang/String;I)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger
+(JNIEnv *env, jobject thiz, jstring jKey, jint jValue)
+{
+ LOGD("OcRepresentation_setValueInteger");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string str = env->GetStringUTFChars(jKey, nullptr);
+ rep->setValue(str, static_cast<int>(jValue));
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueDouble
+* Signature: (Ljava/lang/String;D)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble
+(JNIEnv *env, jobject thiz, jstring jKey, jdouble jValue)
+{
+ LOGD("OcRepresentation_setValueDouble");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string str = env->GetStringUTFChars(jKey, nullptr);
+ rep->setValue(str, static_cast<double>(jValue));
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueBoolean
+* Signature: (Ljava/lang/String;Z)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean
+(JNIEnv *env, jobject thiz, jstring jKey, jboolean jValue)
+{
+ LOGD("OcRepresentation_setValueBoolean");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string str = env->GetStringUTFChars(jKey, nullptr);
+ rep->setValue(str, static_cast<bool>(jValue));
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueStringN
+* Signature: (Ljava/lang/String;Ljava/lang/String;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueStringN
+(JNIEnv *env, jobject thiz, jstring jKey, jstring jValue)
+{
+ LOGD("OcRepresentation_setValueString");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string key = env->GetStringUTFChars(jKey, nullptr);
+ std::string value = env->GetStringUTFChars(jValue, nullptr);
+
+ rep->setValue(key, value);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueRepresentation
+* Signature: (Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation
+(JNIEnv *env, jobject thiz, jstring jKey, jobject jValue)
+{
+ LOGD("OcRepresentation_setValueRepresentation");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string key = env->GetStringUTFChars(jKey, nullptr);
+
+ if (jValue)
+ {
+ OCRepresentation *value = JniOcRepresentation::getOCRepresentationPtr(env, jValue);
+ if (!value) return;
+ rep->setValue(key, *value);
+ }
+ else
+ {
+ rep->setNULL(key);
+ }
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueIntegerArray
+* Signature: (Ljava/lang/String;[I)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueIntegerArray
+(JNIEnv *env, jobject thiz, jstring jKey, jintArray jValue)
+{
+ LOGD("OcRepresentation_setValueIntegerArray");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+
+ const jsize len = env->GetArrayLength(jValue);
+ jint* ints = env->GetIntArrayElements(jValue, nullptr);
+
+ std::vector<int> value;
+ for (jsize i = 0; i < len; ++i)
+ {
+ value.push_back(static_cast<int>(ints[i]));
+ }
+ env->ReleaseIntArrayElements(jValue, ints, JNI_ABORT);
+
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string key = env->GetStringUTFChars(jKey, nullptr);
+ rep->setValue(key, value);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueInteger2DArray
+* Signature: (Ljava/lang/String;[[I)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger2DArray
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)
+{
+ LOGD("OcRepresentation__setValueInteger2DArray");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+ std::vector<std::vector<int>> value;
+ const jsize lenOuter = env->GetArrayLength(jValue);
+ for (jsize j = 0; j < lenOuter; ++j)
+ {
+ jintArray jInnerArray = static_cast<jintArray>(env->GetObjectArrayElement(jValue, j));
+ jint* ints = env->GetIntArrayElements(jInnerArray, nullptr);
+ std::vector<int> innerVector;
+ const jsize lenInner = env->GetArrayLength(jInnerArray);
+ for (jsize i = 0; i < lenInner; ++i)
+ {
+ innerVector.push_back(static_cast<int>(ints[i]));
+ }
+ env->ReleaseIntArrayElements(jInnerArray, ints, JNI_ABORT);
+ env->DeleteLocalRef(jInnerArray);
+ value.push_back(innerVector);
+ }
+
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string key = env->GetStringUTFChars(jKey, nullptr);
+ rep->setValue(key, value);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueInteger3DArray
+* Signature: (Ljava/lang/String;[[[I)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger3DArray
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)
+{
+ LOGD("OcRepresentation_setValueInteger3DArray");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+ std::vector<std::vector<std::vector<int>>> value;
+ const jsize lenOuter = env->GetArrayLength(jValue);
+ for (jsize k = 0; k < lenOuter; ++k)
+ {
+ jobjectArray jMiddleArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, k));
+ const jsize lenMiddle = env->GetArrayLength(jMiddleArray);
+ std::vector<std::vector<int>> middleArray;
+ for (jsize j = 0; j < lenMiddle; ++j)
+ {
+ jintArray jInnerArray = static_cast<jintArray>(env->GetObjectArrayElement(jMiddleArray, j));
+ jint* ints = env->GetIntArrayElements(jInnerArray, nullptr);
+ std::vector<int> innerVector;
+ const jsize lenInner = env->GetArrayLength(jInnerArray);
+ for (jsize i = 0; i < lenInner; ++i)
+ {
+ innerVector.push_back(static_cast<int>(ints[i]));
+ }
+ env->ReleaseIntArrayElements(jInnerArray, ints, JNI_ABORT);
+ env->DeleteLocalRef(jInnerArray);
+ middleArray.push_back(innerVector);
+ }
+ env->DeleteLocalRef(jMiddleArray);
+ value.push_back(middleArray);
+ }
+
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string key = env->GetStringUTFChars(jKey, nullptr);
+ rep->setValue(key, value);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueDoubleArray
+* Signature: (Ljava/lang/String;[D)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDoubleArray
+(JNIEnv *env, jobject thiz, jstring jKey, jdoubleArray jValue)
+{
+ LOGD("OcRepresentation_setValueDoubleArray");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+
+ const jsize len = env->GetArrayLength(jValue);
+ jdouble* doubles = env->GetDoubleArrayElements(jValue, nullptr);
+
+ std::vector<double> value;
+ for (jsize i = 0; i < len; ++i)
+ {
+ value.push_back(static_cast<double>(doubles[i]));
+ }
+ env->ReleaseDoubleArrayElements(jValue, doubles, JNI_ABORT);
+
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string key = env->GetStringUTFChars(jKey, nullptr);
+ rep->setValue(key, value);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueDouble2DArray
+* Signature: (Ljava/lang/String;[[D)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble2DArray
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)
+{
+ LOGD("OcRepresentation_setValueDouble2DArray");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+ std::vector<std::vector<double>> value;
+ const jsize lenOuter = env->GetArrayLength(jValue);
+ for (jsize j = 0; j < lenOuter; ++j)
+ {
+ jdoubleArray jInnerArray = static_cast<jdoubleArray>(env->GetObjectArrayElement(jValue, j));
+ jdouble* doubles = env->GetDoubleArrayElements(jInnerArray, nullptr);
+ std::vector<double> innerVector;
+ const jsize lenInner = env->GetArrayLength(jInnerArray);
+ for (jsize i = 0; i < lenInner; ++i)
+ {
+ innerVector.push_back(static_cast<double>(doubles[i]));
+ }
+ env->ReleaseDoubleArrayElements(jInnerArray, doubles, JNI_ABORT);
+ env->DeleteLocalRef(jInnerArray);
+ value.push_back(innerVector);
+ }
+
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string key = env->GetStringUTFChars(jKey, nullptr);
+ rep->setValue(key, value);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueDouble3DArray
+* Signature: (Ljava/lang/String;[[[D)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble3DArray
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)
+{
+ LOGD("OcRepresentation_setValueDouble3DArray");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+ std::vector<std::vector<std::vector<double>>> value;
+ const jsize lenOuter = env->GetArrayLength(jValue);
+ for (jsize k = 0; k < lenOuter; ++k)
+ {
+ jobjectArray jMiddleArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, k));
+ const jsize lenMiddle = env->GetArrayLength(jMiddleArray);
+ std::vector<std::vector<double>> middleArray;
+ for (jsize j = 0; j < lenMiddle; ++j)
+ {
+ jdoubleArray jInnerArray = static_cast<jdoubleArray>(env->GetObjectArrayElement(jMiddleArray, j));
+ jdouble* doubles = env->GetDoubleArrayElements(jInnerArray, nullptr);
+ std::vector<double> innerVector;
+ const jsize lenInner = env->GetArrayLength(jInnerArray);
+ for (jsize i = 0; i < lenInner; ++i)
+ {
+ innerVector.push_back(static_cast<double>(doubles[i]));
+ }
+ env->ReleaseDoubleArrayElements(jInnerArray, doubles, JNI_ABORT);
+ env->DeleteLocalRef(jInnerArray);
+ middleArray.push_back(innerVector);
+ }
+ env->DeleteLocalRef(jMiddleArray);
+ value.push_back(middleArray);
+ }
+
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string key = env->GetStringUTFChars(jKey, nullptr);
+ rep->setValue(key, value);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueBooleanArray
+* Signature: (Ljava/lang/String;[Z)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBooleanArray
+(JNIEnv *env, jobject thiz, jstring jKey, jbooleanArray jValue)
+{
+ LOGD("OcRepresentation_setValueBooleanArray");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+
+ const jsize len = env->GetArrayLength(jValue);
+ jboolean* booleans = env->GetBooleanArrayElements(jValue, nullptr);
+
+ std::vector<bool> value;
+ for (jsize i = 0; i < len; ++i)
+ {
+ value.push_back(static_cast<bool>(booleans[i]));
+ }
+ env->ReleaseBooleanArrayElements(jValue, booleans, JNI_ABORT);
+
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string key = env->GetStringUTFChars(jKey, nullptr);
+ rep->setValue(key, value);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueBoolean2DArray
+* Signature: (Ljava/lang/String;[[Z)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean2DArray
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)
+{
+ LOGD("OcRepresentation_setValueBoolean2DArray");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+ std::vector<std::vector<bool>> value;
+ const jsize lenOuter = env->GetArrayLength(jValue);
+ for (jsize j = 0; j < lenOuter; ++j)
+ {
+ jbooleanArray jInnerArray = static_cast<jbooleanArray>(env->GetObjectArrayElement(jValue, j));
+ const jsize lenInner = env->GetArrayLength(jInnerArray);
+ jboolean* booleans = env->GetBooleanArrayElements(jInnerArray, nullptr);
+
+ std::vector<bool> innerVector;
+ for (jsize i = 0; i < lenInner; ++i)
+ {
+ innerVector.push_back(static_cast<bool>(booleans[i]));
+ }
+ env->ReleaseBooleanArrayElements(jInnerArray, booleans, JNI_ABORT);
+ env->DeleteLocalRef(jInnerArray);
+ value.push_back(innerVector);
+ }
+
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string key = env->GetStringUTFChars(jKey, nullptr);
+ rep->setValue(key, value);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueBoolean3DArray
+* Signature: (Ljava/lang/String;[[[Z)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean3DArray
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)
+{
+ LOGD("OcRepresentation_setValueBoolean3DArray");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+ std::vector<std::vector<std::vector<bool>>> value;
+ const jsize lenOuter = env->GetArrayLength(jValue);
+ for (jsize k = 0; k < lenOuter; ++k)
+ {
+ jobjectArray jMiddleArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, k));
+ const jsize lenMiddle = env->GetArrayLength(jMiddleArray);
+ std::vector<std::vector<bool>> middleArray;
+ for (jsize j = 0; j < lenMiddle; ++j)
+ {
+ jbooleanArray jInnerArray = static_cast<jbooleanArray>(env->GetObjectArrayElement(jMiddleArray, j));
+ const jsize lenInner = env->GetArrayLength(jInnerArray);
+ jboolean* booleans = env->GetBooleanArrayElements(jInnerArray, nullptr);
+
+ std::vector<bool> innerVector;
+ for (jsize i = 0; i < lenInner; ++i)
+ {
+ innerVector.push_back(static_cast<bool>(booleans[i]));
+ }
+ env->ReleaseBooleanArrayElements(jInnerArray, booleans, JNI_ABORT);
+ env->DeleteLocalRef(jInnerArray);
+ middleArray.push_back(innerVector);
+ }
+ env->DeleteLocalRef(jMiddleArray);
+ value.push_back(middleArray);
+ }
+
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string key = env->GetStringUTFChars(jKey, nullptr);
+ rep->setValue(key, value);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueStringArray
+* Signature: (Ljava/lang/String;[Ljava/lang/String;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueStringArray
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)
+{
+ LOGD("OcRepresentation_setValueStringArray");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+
+ std::vector<std::string> value;
+ JniUtils::convertJavaStrArrToStrVector(env, jValue, value);
+
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string key = env->GetStringUTFChars(jKey, nullptr);
+ rep->setValue(key, value);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueString2DArray
+* Signature: (Ljava/lang/String;[[Ljava/lang/String;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueString2DArray
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)
+{
+ LOGD("OcRepresentation_setValueString2DArray");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+ std::vector<std::vector<std::string>> value;
+ const jsize lenOuter = env->GetArrayLength(jValue);
+ for (jsize j = 0; j < lenOuter; ++j)
+ {
+ jobjectArray jInnerArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, j));
+ std::vector<std::string> innerVector;
+ JniUtils::convertJavaStrArrToStrVector(env, jInnerArray, innerVector);
+ env->DeleteLocalRef(jInnerArray);
+ value.push_back(innerVector);
+ }
+
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string key = env->GetStringUTFChars(jKey, nullptr);
+ rep->setValue(key, value);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueString3DArray
+* Signature: (Ljava/lang/String;[[[Ljava/lang/String;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueString3DArray
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)
+{
+ LOGD("OcRepresentation_setValueString3DArray");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+ std::vector<std::vector<std::vector<std::string>>> value;
+ const jsize lenOuter = env->GetArrayLength(jValue);
+ for (jsize k = 0; k < lenOuter; ++k)
+ {
+ jobjectArray jMiddleArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, k));
+ const jsize lenMiddle = env->GetArrayLength(jMiddleArray);
+ std::vector<std::vector<std::string>> middleArray;
+ for (jsize j = 0; j < lenMiddle; ++j)
+ {
+ jobjectArray jInnerArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jMiddleArray, j));
+ std::vector<std::string> innerVector;
+ JniUtils::convertJavaStrArrToStrVector(env, jInnerArray, innerVector);
+ env->DeleteLocalRef(jInnerArray);
+ middleArray.push_back(innerVector);
+ }
+ env->DeleteLocalRef(jMiddleArray);
+ value.push_back(middleArray);
+ }
+
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string key = env->GetStringUTFChars(jKey, nullptr);
+ rep->setValue(key, value);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueRepresentationArray
+* Signature: (Ljava/lang/String;[Lorg/iotivity/base/OcRepresentation;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentationArray
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)
+{
+ LOGD("OcRepresentation_setValueRepresentationArray");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+
+ std::vector<OCRepresentation> value;
+ JniUtils::convertJavaRepresentationArrToVector(env, jValue, value);
+
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string key = env->GetStringUTFChars(jKey, nullptr);
+ rep->setValue(key, value);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueRepresentation2DArray
+* Signature: (Ljava/lang/String;[[Lorg/iotivity/base/OcRepresentation;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation2DArray
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)
+{
+ LOGD("OcRepresentation_setValueRepresentation2DArray");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+ std::vector<std::vector<OCRepresentation>> value;
+ const jsize lenOuter = env->GetArrayLength(jValue);
+ for (jsize j = 0; j < lenOuter; ++j)
+ {
+ jobjectArray jInnerArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, j));
+ std::vector<OCRepresentation> innerVector;
+ JniUtils::convertJavaRepresentationArrToVector(env, jInnerArray, innerVector);
+ env->DeleteLocalRef(jInnerArray);
+ value.push_back(innerVector);
+ }
+
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string key = env->GetStringUTFChars(jKey, nullptr);
+ rep->setValue(key, value);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setValueRepresentation3DArray
+* Signature: (Ljava/lang/String;[[[Lorg/iotivity/base/OcRepresentation;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueRepresentation3DArray
+(JNIEnv *env, jobject thiz, jstring jKey, jobjectArray jValue)
+{
+ LOGD("OcRepresentation_setValueRepresentation3DArray");
+ if (!jKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "key cannot be null");
+ return;
+ }
+ std::vector<std::vector<std::vector<OCRepresentation>>> value;
+ const jsize lenOuter = env->GetArrayLength(jValue);
+ for (jsize k = 0; k < lenOuter; ++k)
+ {
+ jobjectArray jMiddleArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jValue, k));
+ const jsize lenMiddle = env->GetArrayLength(jMiddleArray);
+ std::vector<std::vector<OCRepresentation>> middleArray;
+ for (jsize j = 0; j < lenMiddle; ++j)
+ {
+ jobjectArray jInnerArray = static_cast<jobjectArray>(env->GetObjectArrayElement(jMiddleArray, j));
+ std::vector<OCRepresentation> innerVector;
+ JniUtils::convertJavaRepresentationArrToVector(env, jInnerArray, innerVector);
+ env->DeleteLocalRef(jInnerArray);
+ middleArray.push_back(innerVector);
+ }
+ env->DeleteLocalRef(jMiddleArray);
+ value.push_back(middleArray);
+ }
+
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string key = env->GetStringUTFChars(jKey, nullptr);
+ rep->setValue(key, value);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: addChild
+* Signature: (Lorg/iotivity/base/OcRepresentation;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_addChild
+(JNIEnv *env, jobject thiz, jobject jOcRepresentation)
+{
+ LOGD("OcRepresentation_addChild");
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ OCRepresentation *child = JniOcRepresentation::getOCRepresentationPtr(env, jOcRepresentation);
+ if (!child) return;
+
+ rep->addChild(*child);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: clearChildren
+* Signature: ()V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_clearChildren
+(JNIEnv *env, jobject thiz)
+{
+ LOGD("OcRepresentation_clearChildren");
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ rep->clearChildren();
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: getChildrenArray
+* Signature: ()[Lorg/iotivity/base/OcRepresentation;
+*/
+JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcRepresentation_getChildrenArray
+(JNIEnv *env, jobject thiz)
+{
+ LOGD("OcRepresentation_getChildrenArray");
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return nullptr;
+
+ return JniUtils::convertRepresentationVectorToJavaArray(env, rep->getChildren());
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: getUri
+* Signature: ()Ljava/lang/String;
+*/
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcRepresentation_getUri
+(JNIEnv *env, jobject thiz)
+{
+ LOGD("OcRepresentation_getUri");
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return nullptr;
+
+ std::string uri(rep->getUri());
+ return env->NewStringUTF(uri.c_str());
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setUri
+* Signature: (Ljava/lang/String;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setUri
+(JNIEnv *env, jobject thiz, jstring jUri)
+{
+ LOGD("OcRepresentation_setUri");
+ if (!jUri)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "uri cannot be null");
+ return;
+ }
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ rep->setUri(env->GetStringUTFChars(jUri, nullptr));
+}
+
+JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_hasAttribute
+(JNIEnv *env, jobject thiz, jstring jstr)
+{
+ LOGD("OcRepresentation_hasAttribute");
+ if (!jstr)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null");
+ return false;
+ }
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return false;
+
+ std::string str = env->GetStringUTFChars(jstr, nullptr);
+ return rep->hasAttribute(str);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: getResourceTypes
+* Signature: ()Ljava/util/List;
+*/
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getResourceTypes
+(JNIEnv *env, jobject thiz)
+{
+ LOGD("OcRepresentation_getResourceTypes");
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return nullptr;
+
+ std::vector<std::string> resourceTypes = rep->getResourceTypes();
+ return JniUtils::convertStrVectorToJavaStrList(env, resourceTypes);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setResourceTypeArray
+* Signature: ([Ljava/lang/String;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setResourceTypeArray
+(JNIEnv *env, jobject thiz, jobjectArray jResourceTypeArray)
+{
+ LOGD("OcRepresentation_setResourceTypeArray");
+ if (!jResourceTypeArray)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "resourceTypeList cannot be null");
+ return;
+ }
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::vector<std::string> resourceTypes;
+ JniUtils::convertJavaStrArrToStrVector(env, jResourceTypeArray, resourceTypes);
+ rep->setResourceTypes(resourceTypes);
+}
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: getResourceInterfaces
+* Signature: ()Ljava/util/List;
+*/
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getResourceInterfaces
+(JNIEnv *env, jobject thiz)
+{
+ LOGD("OcRepresentation_getResourceInterfaces");
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return nullptr;
+
+ std::vector<std::string> resourceInterfaces = rep->getResourceInterfaces();
+ return JniUtils::convertStrVectorToJavaStrList(env, resourceInterfaces);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setResourceInterfaceArray
+* Signature: ([Ljava/lang/String;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setResourceInterfaceArray
+(JNIEnv *env, jobject thiz, jobjectArray jResourceInterfaceArray)
+{
+ LOGD("OcRepresentation_setResourceInterfaceArray");
+ if (!jResourceInterfaceArray)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "resourceInterfaceList cannot be null");
+ return;
+ }
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::vector<std::string> resourceInterfaces;
+ JniUtils::convertJavaStrArrToStrVector(env, jResourceInterfaceArray, resourceInterfaces);
+ rep->setResourceInterfaces(resourceInterfaces);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: isEmpty
+* Signature: ()Z
+*/
+JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_isEmpty
+(JNIEnv *env, jobject thiz)
+{
+ LOGD("OcRepresentation_isEmpty");
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return false;
+
+ return static_cast<jboolean>(rep->empty());
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: size
+* Signature: ()I
+*/
+JNIEXPORT jint JNICALL Java_org_iotivity_base_OcRepresentation_size
+(JNIEnv *env, jobject thiz)
+{
+ LOGD("OcRepresentation_size");
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return -1;
+
+ return static_cast<jint>(rep->numberOfAttributes());
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: remove
+* Signature: (Ljava/lang/String;)Z
+*/
+JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_remove
+(JNIEnv *env, jobject thiz, jstring jAttributeKey)
+{
+ LOGD("OcRepresentation_remove");
+ if (!jAttributeKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null");
+ return false;
+ }
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return false;
+
+ std::string attributeKey = env->GetStringUTFChars(jAttributeKey, nullptr);
+ return static_cast<jboolean>(rep->erase(attributeKey));
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: setNull
+* Signature: (Ljava/lang/String;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setNull
+(JNIEnv *env, jobject thiz, jstring jAttributeKey)
+{
+ LOGD("OcRepresentation_setNull");
+ if (!jAttributeKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null");
+ return;
+ }
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return;
+
+ std::string attributeKey = env->GetStringUTFChars(jAttributeKey, nullptr);
+ rep->setNULL(attributeKey);
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: isNull
+* Signature: (Ljava/lang/String;)Z
+*/
+JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_isNull
+(JNIEnv *env, jobject thiz, jstring jAttributeKey)
+{
+ LOGD("OcRepresentation_isNull");
+ if (!jAttributeKey)
+ {
+ ThrowOcException(OC_STACK_INVALID_PARAM, "attributeKey cannot be null");
+ return false;
+ }
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+ if (!rep) return false;
+
+ std::string attributeKey = env->GetStringUTFChars(jAttributeKey, nullptr);
+ return static_cast<jboolean>(rep->isNULL(attributeKey));
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: create
+* Signature: ()V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_create
+(JNIEnv *env, jobject thiz)
+{
+ LOGD("OcRepresentation_create");
+ OCRepresentation *rep = new OCRepresentation();
+ SetHandle<OCRepresentation>(env, thiz, rep);
+ if (env->ExceptionCheck())
+ {
+ LOGE("Failed to set native handle for OcRepresentation");
+ delete rep;
+ }
+}
+
+/*
+* Class: org_iotivity_base_OcRepresentation
+* Method: dispose
+* Signature: ()V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_dispose
+(JNIEnv *env, jobject thiz, jboolean jNeedsDelete)
+{
+ LOGD("OcRepresentation_dispose");
+ OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, thiz);
+
+ if (jNeedsDelete)
+ {
+ delete rep;
+ }
+}