It is OK now to do the following:
OcRepresentation rep = new OcRepresentation();
OcRepresentation repNull = null;
rep.setValue("key", repNull);
Change-Id: I10d554490190561e40cc97c8a1973f6ace0478cd
Signed-off-by: Tim Kourt <tim.a.kourt@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3649
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Patrick Lankswert <patrick.lankswert@intel.com>
if (!rep) return;
std::string key = env->GetStringUTFChars(jKey, nullptr);
- OCRepresentation *value = JniOcRepresentation::getOCRepresentationPtr(env, jValue);
- if (!value) return;
- rep->setValue(key, *value);
+ if (jValue)
+ {
+ OCRepresentation *value = JniOcRepresentation::getOCRepresentationPtr(env, jValue);
+ if (!value) return;
+ rep->setValue(key, *value);
+ }
+ else
+ {
+ rep->setNULL(key);
+ }
}
/*
public void testAttributeAccessByType() throws OcException {
OcRepresentation rep = new OcRepresentation();
+ //null
+ OcRepresentation repNull = null;
+ rep.setValue("nullKey", repNull);
+ OcRepresentation repNullActual = rep.getValue("nullKey");
+ assertNull(repNullActual);
+
//integer
String intK = "intK";
int intV = 4;