Пример #1
0
/*
* 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);
    }
}
Пример #2
0
/*
* 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);
}