Clean up some SonarQube warnings (trailing whitespace, etc).
authorOssama Othman <ossama.othman@intel.com>
Wed, 29 Jul 2015 22:22:51 +0000 (15:22 -0700)
committerErich Keane <erich.keane@intel.com>
Thu, 30 Jul 2015 00:03:57 +0000 (00:03 +0000)
Clean up trailing whitespace and removed Windows line endings from
most text files to address SonarQube warnings.  As a side effect of
this clean-up, several files that should not have been executable had
their executable permission bit removed.

Change-Id: Ie388df6e383219cdebfb56ba8fa86cacf2ca3e46
Signed-off-by: Ossama Othman <ossama.othman@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1980
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Erich Keane <erich.keane@intel.com>
184 files changed:
android/BuildInstructionsForAndroidAPI.txt
android/android_api/SConscript
android/android_api/base/jni/JniEntityHandler.cpp
android/android_api/base/jni/JniEntityHandler.h
android/android_api/base/jni/JniListenerManager.cpp
android/android_api/base/jni/JniListenerManager.h
android/android_api/base/jni/JniOcPlatform.cpp
android/android_api/base/jni/JniOcPlatform.h
android/android_api/base/jni/JniOcPresenceHandle.cpp
android/android_api/base/jni/JniOcPresenceHandle.h
android/android_api/base/jni/JniOcRepresentation.cpp
android/android_api/base/jni/JniOcRepresentation.h
android/android_api/base/jni/JniOcRequestHandle.cpp
android/android_api/base/jni/JniOcRequestHandle.h
android/android_api/base/jni/JniOcResource.cpp
android/android_api/base/jni/JniOcResource.h
android/android_api/base/jni/JniOcResourceHandle.cpp
android/android_api/base/jni/JniOcResourceHandle.h
android/android_api/base/jni/JniOcResourceIdentifier.cpp
android/android_api/base/jni/JniOcResourceIdentifier.h
android/android_api/base/jni/JniOcResourceRequest.cpp
android/android_api/base/jni/JniOcResourceRequest.h
android/android_api/base/jni/JniOcResourceResponse.cpp
android/android_api/base/jni/JniOcResourceResponse.h
android/android_api/base/jni/JniOcStack.cpp
android/android_api/base/jni/JniOcStack.h
android/android_api/base/jni/JniOnDeleteListener.cpp
android/android_api/base/jni/JniOnDeleteListener.h
android/android_api/base/jni/JniOnDeviceInfoListener.cpp
android/android_api/base/jni/JniOnDeviceInfoListener.h
android/android_api/base/jni/JniOnGetListener.cpp
android/android_api/base/jni/JniOnGetListener.h
android/android_api/base/jni/JniOnObserveListener.cpp
android/android_api/base/jni/JniOnObserveListener.h
android/android_api/base/jni/JniOnPostListener.cpp
android/android_api/base/jni/JniOnPostListener.h
android/android_api/base/jni/JniOnPresenceListener.cpp
android/android_api/base/jni/JniOnPresenceListener.h
android/android_api/base/jni/JniOnPutListener.cpp
android/android_api/base/jni/JniOnPutListener.h
android/android_api/base/jni/JniOnResourceFoundListener.cpp
android/android_api/base/jni/JniOnResourceFoundListener.h
android/android_api/base/jni/JniUtils.cpp
android/android_api/base/jni/JniUtils.h
android/android_api/base/src/androidTest/AndroidManifest.xml [changed mode: 0755->0644]
android/android_api/base/src/androidTest/java/org/iotivity/base/OcRepresentationTest.java
android/android_api/base/src/main/AndroidManifest.xml [changed mode: 0755->0644]
android/android_api/base/src/main/java/org/iotivity/base/EntityHandlerResult.java
android/android_api/base/src/main/java/org/iotivity/base/ModeType.java
android/android_api/base/src/main/java/org/iotivity/base/ObservationInfo.java
android/android_api/base/src/main/java/org/iotivity/base/ObserveAction.java
android/android_api/base/src/main/java/org/iotivity/base/ObserveType.java
android/android_api/base/src/main/java/org/iotivity/base/OcDeviceInfo.java
android/android_api/base/src/main/java/org/iotivity/base/OcException.java
android/android_api/base/src/main/java/org/iotivity/base/OcHeaderOption.java
android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java
android/android_api/base/src/main/java/org/iotivity/base/OcPlatformStatus.java
android/android_api/base/src/main/java/org/iotivity/base/OcPresenceHandle.java
android/android_api/base/src/main/java/org/iotivity/base/OcPresenceStatus.java
android/android_api/base/src/main/java/org/iotivity/base/OcRepresentation.java
android/android_api/base/src/main/java/org/iotivity/base/OcRequestHandle.java
android/android_api/base/src/main/java/org/iotivity/base/OcResourceHandle.java
android/android_api/base/src/main/java/org/iotivity/base/OcResourceIdentifier.java
android/android_api/base/src/main/java/org/iotivity/base/OcResourceRequest.java
android/android_api/base/src/main/java/org/iotivity/base/OcResourceResponse.java
android/android_api/base/src/main/java/org/iotivity/base/PlatformConfig.java
android/android_api/base/src/main/java/org/iotivity/base/QualityOfService.java
android/android_api/base/src/main/java/org/iotivity/base/RequestHandlerFlag.java
android/android_api/base/src/main/java/org/iotivity/base/RequestType.java
android/android_api/base/src/main/java/org/iotivity/base/ResourceProperty.java
android/android_api/base/src/main/java/org/iotivity/base/ServiceType.java
android/android_api/base/src/main/java/org/iotivity/ca/CaInterface.java
android/android_api/base/src/main/java/org/iotivity/ca/CaIpInterface.java
android/android_api/base/src/main/java/org/iotivity/ca/CaWiFiInterface.java
android/examples/fridgeclient/src/main/AndroidManifest.xml [changed mode: 0755->0644]
android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/fridgeclient/FridgeClient.java
android/examples/fridgeclient/src/main/java/org/iotivity/base/examples/fridgeclient/StringConstants.java
android/examples/fridgeclient/src/main/res/layout/activity_fridge_client.xml [changed mode: 0755->0644]
android/examples/fridgeclient/src/main/res/menu/menu_fridge_client.xml [changed mode: 0755->0644]
android/examples/fridgeclient/src/main/res/values-w820dp/dimens.xml [changed mode: 0755->0644]
android/examples/fridgeclient/src/main/res/values/dimens.xml [changed mode: 0755->0644]
android/examples/fridgeclient/src/main/res/values/strings.xml [changed mode: 0755->0644]
android/examples/fridgeclient/src/main/res/values/styles.xml [changed mode: 0755->0644]
android/examples/fridgeserver/src/main/AndroidManifest.xml [changed mode: 0755->0644]
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DeviceResource.java
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/DoorResource.java
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/FridgeServer.java
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/LightResource.java
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Refrigerator.java
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/Resource.java
android/examples/fridgeserver/src/main/java/org/iotivity/base/examples/fridgeserver/StringConstants.java
android/examples/fridgeserver/src/main/res/layout/activity_fridge_server.xml [changed mode: 0755->0644]
android/examples/fridgeserver/src/main/res/menu/menu_fridge_server.xml [changed mode: 0755->0644]
android/examples/fridgeserver/src/main/res/values-w820dp/dimens.xml [changed mode: 0755->0644]
android/examples/fridgeserver/src/main/res/values/dimens.xml [changed mode: 0755->0644]
android/examples/fridgeserver/src/main/res/values/strings.xml [changed mode: 0755->0644]
android/examples/fridgeserver/src/main/res/values/styles.xml [changed mode: 0755->0644]
android/examples/guiclient/src/main/java/org/iotivity/guiclient/MainActivity.java
android/examples/message/src/main/AndroidManifest.xml [changed mode: 0755->0644]
android/examples/message/src/main/java/base/iotivity/org/examples/message/IMessageLogger.java
android/examples/simpleclient/src/main/AndroidManifest.xml [changed mode: 0755->0644]
android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/Light.java
android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/SimpleClient.java
android/examples/simpleclient/src/main/java/org/iotivity/base/examples/simpleclient/StringConstants.java
android/examples/simpleclient/src/main/res/layout/activity_main.xml [changed mode: 0755->0644]
android/examples/simpleclient/src/main/res/menu/menu_main.xml [changed mode: 0755->0644]
android/examples/simpleclient/src/main/res/values-w820dp/dimens.xml [changed mode: 0755->0644]
android/examples/simpleclient/src/main/res/values/dimens.xml [changed mode: 0755->0644]
android/examples/simpleclient/src/main/res/values/strings.xml [changed mode: 0755->0644]
android/examples/simpleclient/src/main/res/values/styles.xml [changed mode: 0755->0644]
android/examples/simpleserver/src/main/AndroidManifest.xml [changed mode: 0755->0644]
android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/LightRepThread.java
android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/LightResource.java
android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/SimpleServer.java
android/examples/simpleserver/src/main/java/org/iotivity/base/examples/simpleserver/StringConstants.java
android/examples/simpleserver/src/main/res/layout/activity_main.xml [changed mode: 0755->0644]
android/examples/simpleserver/src/main/res/menu/menu_main.xml [changed mode: 0755->0644]
android/examples/simpleserver/src/main/res/values-w820dp/dimens.xml [changed mode: 0755->0644]
android/examples/simpleserver/src/main/res/values/dimens.xml [changed mode: 0755->0644]
android/examples/simpleserver/src/main/res/values/strings.xml [changed mode: 0755->0644]
android/examples/simpleserver/src/main/res/values/styles.xml [changed mode: 0755->0644]
examples/OICMiddle/README
examples/OICSensorBoard/Makefile
extlibs/arduino/SConscript
extlibs/gtest/SConscript
extlibs/tinydtls/README
extlibs/tinydtls/SConscript
gbsbuild.sh [changed mode: 0644->0755]
resource/csdk/connectivity/build/android/README.txt
resource/csdk/connectivity/build/tizen/Makefile
resource/csdk/connectivity/lib/libcoap-4.1.1/README
resource/csdk/connectivity/lib/libcoap-4.1.1/async.c
resource/csdk/connectivity/lib/libcoap-4.1.1/coap.h
resource/csdk/connectivity/lib/libcoap-4.1.1/examples/etsi_iot_01.c
resource/csdk/connectivity/lib/libcoap-4.1.1/net.c
resource/csdk/connectivity/lib/libcoap-4.1.1/net.h
resource/csdk/connectivity/lib/libcoap-4.1.1/option.h
resource/csdk/connectivity/lib/libcoap-4.1.1/resource.h
resource/csdk/connectivity/lib/libcoap-4.1.1/tests/test_options.c
resource/csdk/connectivity/samples/android/SConscript
resource/csdk/connectivity/samples/android/casample/SConscript [changed mode: 0755->0644]
resource/csdk/connectivity/samples/android/casample/sampleService/src/main/jni/ResourceModel.c [changed mode: 0755->0644]
resource/csdk/connectivity/samples/android/casample/sampleService/src/main/jni/org_iotivity_ca_service_RMInterface.h [changed mode: 0755->0644]
resource/csdk/connectivity/samples/linux/SConscript [changed mode: 0755->0644]
resource/csdk/connectivity/samples/tizen/scons/SConscript
resource/csdk/connectivity/src/SConscript [changed mode: 0755->0644]
resource/csdk/connectivity/src/ip_adapter/android/caipnwmonitor.c
resource/csdk/connectivity/src/ip_adapter/android/org_iotivity_ca_CaIpInterface.h
resource/csdk/logger/README
resource/csdk/logger/test/android/README
resource/csdk/logger/test/android/androidloggertestoutput.txt
resource/csdk/logger/test/arduino/README
resource/csdk/logger/test/arduino/arduinologgertestoutput.txt
resource/csdk/logger/test/std_logbuffer.txt
resource/csdk/security/include/internal/aclresource.h [changed mode: 0755->0644]
resource/csdk/security/provisioning/sample/SConscript [changed mode: 0755->0644]
resource/csdk/security/provisioning/sample/provisioningclient.c [changed mode: 0755->0644]
resource/csdk/security/src/credresource.c [changed mode: 0755->0644]
resource/csdk/security/src/doxmresource.c [changed mode: 0755->0644]
resource/csdk/stack/samples/arduino/SimpleClientServer/README
resource/csdk/stack/samples/arduino/SimpleClientServer/ocserver/README
resource/csdk/stack/samples/tizen/SimpleClientServer/scons/SConscript
resource/csdk/stack/src/oicgroup.c [changed mode: 0755->0644]
resource/csdk/stack/test/android/README
resource/csdk/stack/test/android/stacktests.cpp
resource/csdk/stack/test/arduino/ArduinoStackTest.cpp
resource/csdk/stack/test/arduino/README
resource/include/OCApi.h [changed mode: 0755->0644]
resource/include/OCSerialization.h
resource/oc_logger/samples/linux/README
resource/releaseNotes/Aug5th2014.txt
resource/releaseNotes/Oct31st2014.txt
resource/releaseNotes/Sept2nd2014.txt
resource/releaseNotes/Sept30th2014.txt
tools/darwin/mkfwk_ios.sh
tools/darwin/mkfwk_osx.sh
tools/scons/BoostBootstrap.py
tools/scons/BoostBuild.py
tools/scons/Configure.py
tools/scons/URLDownload.py
tools/scons/UnpackAll.py
tools/style/astyle-clean-cpp-format.sh
tools/vagrant/README.md
tools/vagrant/bootstrap.sh

index 4bc0515..1b0f239 100644 (file)
@@ -1,45 +1,45 @@
-Build Instructions for Android-API:\r
-\r
-1.Verify that you have the latest JDK (you might need to set the JDK_HOME variable)\r
-2.Clone the latest iotivity codebase.\r
-3.set environment variables:\r
-    a.platform=android\r
-    b.If running in windows, change the following line in the build.gradle file (<iotivity>/android/android_api/base/build.gradle):\r
-        def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build')\r
-            to\r
-        def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build.cmd')\r
-\r
-4.Build scons for android and your targeted architecture (This will also build Android API):\r
-    a.scons TARGET_OS=android TARGET_ARCH=<target arch> TARGET_TRANSPORT=IP RELEASE=1 \r
-               where <target arch> can be armeabi, armeabi-v7a, x86.\r
-               Note: To build in debug mode, use RELEASE=0.\r
-               Note: The minimum SDK version supported is 21.\r
-               Note: Only TARGET_TRANSPORT currently supported is IP\r
-    b.If the project is setup correctly, you should see a BUILD SUCCESSFUL message on the terminal\r
-    c.You should see the .aar files generated inside of '<iotivity>/android/android_api/base/build/outputs/aar' directory. The .aar files contain jni directory and also a .jar file\r
-\r
-\r
-TO RUN UNIT TESTS IN ANDROID-API\r
-\r
-5.The '<iotivity>/android/android_api/base/src/androidTest/...' directory contains tests which can be used to get an idea about the Android API usage.\r
-\r
-\r
-TO USE THE .AAR FILE IN <iotivity>/android/examples project\r
-\r
-6. Verify that 7 different *.so files exist inside <iotivity>/android/android-api/base/libs/<TARGET_ARCH> directory. (They should already be present in the *.aar file.)\r
-7. Import Project 'Examples' into android-studio.\r
-8.To add an .aar file to the 'Examples' project,\r
-   a.Right click on Examples->New->Module->Import .JAR or .AAR Package\r
-   b.Select the .aar file from the location in step 6e above\r
-   c.Right click on Examples->Open Module Settings\r
-   d.Select each sample app module under 'Modules'->Dependencies->Add->Module Dependency\r
-   e.The .aar file selected in step 10b above should be present. Select it.\r
-   f.Repeat steps d and e for each sample app module.\r
-\r
-\r
-TO USE THE .AAR FILE IN A DIFFERENT PROJECT\r
-\r
-9. Verify that 7 different *.so files exist inside <iotivity base>/android/android-api/base/libs/<TARGET_ARCH> directory.\r
-10. Import the .aar file in your project to use it\r
-\r
-\r
+Build Instructions for Android-API:
+
+1.Verify that you have the latest JDK (you might need to set the JDK_HOME variable)
+2.Clone the latest iotivity codebase.
+3.set environment variables:
+    a.platform=android
+    b.If running in windows, change the following line in the build.gradle file (<iotivity>/android/android_api/base/build.gradle):
+        def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build')
+            to
+        def ndkBuild = new File(System.env.ANDROID_NDK_HOME, 'ndk-build.cmd')
+
+4.Build scons for android and your targeted architecture (This will also build Android API):
+    a.scons TARGET_OS=android TARGET_ARCH=<target arch> TARGET_TRANSPORT=IP RELEASE=1
+               where <target arch> can be armeabi, armeabi-v7a, x86.
+               Note: To build in debug mode, use RELEASE=0.
+               Note: The minimum SDK version supported is 21.
+               Note: Only TARGET_TRANSPORT currently supported is IP
+    b.If the project is setup correctly, you should see a BUILD SUCCESSFUL message on the terminal
+    c.You should see the .aar files generated inside of '<iotivity>/android/android_api/base/build/outputs/aar' directory. The .aar files contain jni directory and also a .jar file
+
+
+TO RUN UNIT TESTS IN ANDROID-API
+
+5.The '<iotivity>/android/android_api/base/src/androidTest/...' directory contains tests which can be used to get an idea about the Android API usage.
+
+
+TO USE THE .AAR FILE IN <iotivity>/android/examples project
+
+6. Verify that 7 different *.so files exist inside <iotivity>/android/android-api/base/libs/<TARGET_ARCH> directory. (They should already be present in the *.aar file.)
+7. Import Project 'Examples' into android-studio.
+8.To add an .aar file to the 'Examples' project,
+   a.Right click on Examples->New->Module->Import .JAR or .AAR Package
+   b.Select the .aar file from the location in step 6e above
+   c.Right click on Examples->Open Module Settings
+   d.Select each sample app module under 'Modules'->Dependencies->Add->Module Dependency
+   e.The .aar file selected in step 10b above should be present. Select it.
+   f.Repeat steps d and e for each sample app module.
+
+
+TO USE THE .AAR FILE IN A DIFFERENT PROJECT
+
+9. Verify that 7 different *.so files exist inside <iotivity base>/android/android-api/base/libs/<TARGET_ARCH> directory.
+10. Import the .aar file in your project to use it
+
+
index 2575c97..11983d7 100644 (file)
@@ -1,48 +1,48 @@
-import os\r
-import platform\r
-Import('env')\r
-\r
-android_home = env.get('ANDROID_HOME')\r
-\r
-ANDROID_TARGET_ARCH = env.get('TARGET_ARCH')\r
-if env.get('RELEASE'):\r
-       ANDROID_RELEASE="release"\r
-else:\r
-       ANDROID_RELEASE="debug"\r
-\r
-os.environ['ANDROID_HOME'] = env.get('ANDROID_HOME')\r
-os.environ['ANDROID_NDK_HOME'] = env.get('ANDROID_NDK')\r
-\r
-if not os.path.exists(android_home + '/platforms/android-21') or not os.path.exists(android_home + '/build-tools/20.0.0'):\r
-    print '''\r
-***************************************** Info ********************************\r
-*   Either 'Android API 21' is not installed or 'Android SDK Build Tools      *\r
-*   20.0.0' is not installed. The Android SDK Manager will now open. Please   *\r
-*   be sure to deselect all options, then select the following 2 packages:    *\r
-*       1. Under "Tools" select "Android SDK Build-tools" Revision 20.        *\r
-*       2. Under "Android 5.0.1 (API 21)" select "SDK Platform"               *\r
-*       3. Continue by selecting "Install 2 Packages"                         *\r
-*                                                                             *\r
-*   NOTE: If you have an http proxy, please press ctrl+c now and edit/create  *\r
-*         the following file in your $HOME directory as follows:              *\r
-*                                                                             *\r
-* Edit/Create file: "$HOME/.android/androidtool.cfg"                          *\r
-*                                                                             *\r
-*    http.proxyPort=<YOUR_PORT_NUMBER>                                        *\r
-*    sdkman.monitor.density=108                                               *\r
-*    http.proxyHost=<YOUR_HTTP_PROXY_ADDRESS>                                 *\r
-*    sdkman.show.update.only=true                                             *\r
-*    sdkman.ask.adb.restart=false                                             *\r
-*    sdkman.force.http=true                                                   *\r
-*    sdkman.show.updateonly=true                                              *\r
-*                                                                             *\r
-*******************************************************************************\r
-\r
-...Opening Android SDK Manager now. Once you are finished, the build will continue.\r
-'''\r
-    os.system(android_home + '/tools/android')\r
-\r
-jdk_env = Environment(ENV=os.environ)\r
-jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + os.getcwd()+'/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE))\r
-jdk_env.Gradle(target="base/objs", source="base/src/main/java/org/iotivity/base/OcResource.java")\r
-\r
+import os
+import platform
+Import('env')
+
+android_home = env.get('ANDROID_HOME')
+
+ANDROID_TARGET_ARCH = env.get('TARGET_ARCH')
+if env.get('RELEASE'):
+       ANDROID_RELEASE="release"
+else:
+       ANDROID_RELEASE="debug"
+
+os.environ['ANDROID_HOME'] = env.get('ANDROID_HOME')
+os.environ['ANDROID_NDK_HOME'] = env.get('ANDROID_NDK')
+
+if not os.path.exists(android_home + '/platforms/android-21') or not os.path.exists(android_home + '/build-tools/20.0.0'):
+    print '''
+***************************************** Info ********************************
+*   Either 'Android API 21' is not installed or 'Android SDK Build Tools      *
+*   20.0.0' is not installed. The Android SDK Manager will now open. Please   *
+*   be sure to deselect all options, then select the following 2 packages:    *
+*       1. Under "Tools" select "Android SDK Build-tools" Revision 20.        *
+*       2. Under "Android 5.0.1 (API 21)" select "SDK Platform"               *
+*       3. Continue by selecting "Install 2 Packages"                         *
+*                                                                             *
+*   NOTE: If you have an http proxy, please press ctrl+c now and edit/create  *
+*         the following file in your $HOME directory as follows:              *
+*                                                                             *
+* Edit/Create file: "$HOME/.android/androidtool.cfg"                          *
+*                                                                             *
+*    http.proxyPort=<YOUR_PORT_NUMBER>                                        *
+*    sdkman.monitor.density=108                                               *
+*    http.proxyHost=<YOUR_HTTP_PROXY_ADDRESS>                                 *
+*    sdkman.show.update.only=true                                             *
+*    sdkman.ask.adb.restart=false                                             *
+*    sdkman.force.http=true                                                   *
+*    sdkman.show.updateonly=true                                              *
+*                                                                             *
+*******************************************************************************
+
+...Opening Android SDK Manager now. Once you are finished, the build will continue.
+'''
+    os.system(android_home + '/tools/android')
+
+jdk_env = Environment(ENV=os.environ)
+jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + ' build -b' + os.getcwd()+'/build.gradle -PTARGET_ARCH=%s -PRELEASE=%s' %(ANDROID_TARGET_ARCH, ANDROID_RELEASE))
+jdk_env.Gradle(target="base/objs", source="base/src/main/java/org/iotivity/base/OcResource.java")
+
index 860d52b..1ca1421 100644 (file)
-/*\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 "JniEntityHandler.h"\r
-#include "JniOcResourceRequest.h"\r
-#include "JniOcResourceResponse.h"\r
-#include "JniUtils.h"\r
-\r
-JniEntityHandler::JniEntityHandler(JNIEnv *env, jobject entityHandler)\r
-{\r
-    m_jListener = env->NewGlobalRef(entityHandler);\r
-}\r
-\r
-JniEntityHandler::~JniEntityHandler()\r
-{\r
-    LOGD("~JniEntityHandler");\r
-    if (m_jListener)\r
-    {\r
-        jint ret;\r
-        JNIEnv *env = GetJNIEnv(ret);\r
-        if (NULL == env) return;\r
-        env->DeleteGlobalRef(m_jListener);\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-    }\r
-}\r
-\r
-OCEntityHandlerResult JniEntityHandler::handleEntity(const std::shared_ptr<OCResourceRequest> request)\r
-{\r
-    LOGD("JniEntityHandler_handleEntity");\r
-    jint envRet;\r
-    JNIEnv *env = GetJNIEnv(envRet);\r
-    if (NULL == env) return OC_EH_ERROR;\r
-\r
-    JniOcResourceRequest* jniResReq = new JniOcResourceRequest(request);\r
-    jlong reqHandle = reinterpret_cast<jlong>(jniResReq);\r
-    jobject jResourceRequest = env->NewObject(g_cls_OcResourceRequest, g_mid_OcResourceRequest_N_ctor,\r
-        reqHandle);\r
-    if (!jResourceRequest)\r
-    {\r
-        LOGE("Failed to create OcResourceRequest");\r
-        delete jniResReq;\r
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-        return OC_EH_ERROR;\r
-    }\r
-\r
-    jclass clsL = env->GetObjectClass(m_jListener);\r
-    if (!clsL)\r
-    {\r
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-        return OC_EH_ERROR;\r
-    }\r
-    jmethodID midL = env->GetMethodID(clsL, "handleEntity",\r
-        "(Lorg/iotivity/base/OcResourceRequest;)Lorg/iotivity/base/EntityHandlerResult;");\r
-    if (!midL)\r
-    {\r
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-        return OC_EH_ERROR;\r
-    }\r
-    jobject entityHandlerResult = env->CallObjectMethod(m_jListener, midL, jResourceRequest);\r
-    if (env->ExceptionCheck())\r
-    {\r
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-        return OC_EH_ERROR;\r
-    }\r
-    if (!entityHandlerResult)\r
-    {\r
-        ThrowOcException(JNI_INVALID_VALUE, "EntityHandlerResult cannot be null");\r
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-        return OC_EH_ERROR;\r
-    }\r
-    jclass clsResult = env->GetObjectClass(entityHandlerResult);\r
-    if (!clsResult)\r
-    {\r
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-        return OC_EH_ERROR;\r
-    }\r
-    jmethodID getValue_ID = env->GetMethodID(clsResult, "getValue", "()I");\r
-    if (!getValue_ID)\r
-    {\r
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-        return OC_EH_ERROR;\r
-    }\r
-    jint jResult = env->CallIntMethod(entityHandlerResult, getValue_ID);\r
-    if (env->ExceptionCheck())\r
-    {\r
-        LOGE("Java exception is thrown");\r
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-        return OC_EH_ERROR;\r
-    }\r
-\r
-    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-    return JniUtils::getOCEntityHandlerResult(env, static_cast<int>(jResult));\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 "JniEntityHandler.h"
+#include "JniOcResourceRequest.h"
+#include "JniOcResourceResponse.h"
+#include "JniUtils.h"
+
+JniEntityHandler::JniEntityHandler(JNIEnv *env, jobject entityHandler)
+{
+    m_jListener = env->NewGlobalRef(entityHandler);
+}
+
+JniEntityHandler::~JniEntityHandler()
+{
+    LOGD("~JniEntityHandler");
+    if (m_jListener)
+    {
+        jint ret;
+        JNIEnv *env = GetJNIEnv(ret);
+        if (NULL == env) return;
+        env->DeleteGlobalRef(m_jListener);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+    }
+}
+
+OCEntityHandlerResult JniEntityHandler::handleEntity(const std::shared_ptr<OCResourceRequest> request)
+{
+    LOGD("JniEntityHandler_handleEntity");
+    jint envRet;
+    JNIEnv *env = GetJNIEnv(envRet);
+    if (NULL == env) return OC_EH_ERROR;
+
+    JniOcResourceRequest* jniResReq = new JniOcResourceRequest(request);
+    jlong reqHandle = reinterpret_cast<jlong>(jniResReq);
+    jobject jResourceRequest = env->NewObject(g_cls_OcResourceRequest, g_mid_OcResourceRequest_N_ctor,
+        reqHandle);
+    if (!jResourceRequest)
+    {
+        LOGE("Failed to create OcResourceRequest");
+        delete jniResReq;
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return OC_EH_ERROR;
+    }
+
+    jclass clsL = env->GetObjectClass(m_jListener);
+    if (!clsL)
+    {
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return OC_EH_ERROR;
+    }
+    jmethodID midL = env->GetMethodID(clsL, "handleEntity",
+        "(Lorg/iotivity/base/OcResourceRequest;)Lorg/iotivity/base/EntityHandlerResult;");
+    if (!midL)
+    {
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return OC_EH_ERROR;
+    }
+    jobject entityHandlerResult = env->CallObjectMethod(m_jListener, midL, jResourceRequest);
+    if (env->ExceptionCheck())
+    {
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return OC_EH_ERROR;
+    }
+    if (!entityHandlerResult)
+    {
+        ThrowOcException(JNI_INVALID_VALUE, "EntityHandlerResult cannot be null");
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return OC_EH_ERROR;
+    }
+    jclass clsResult = env->GetObjectClass(entityHandlerResult);
+    if (!clsResult)
+    {
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return OC_EH_ERROR;
+    }
+    jmethodID getValue_ID = env->GetMethodID(clsResult, "getValue", "()I");
+    if (!getValue_ID)
+    {
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return OC_EH_ERROR;
+    }
+    jint jResult = env->CallIntMethod(entityHandlerResult, getValue_ID);
+    if (env->ExceptionCheck())
+    {
+        LOGE("Java exception is thrown");
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return OC_EH_ERROR;
+    }
+
+    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+    return JniUtils::getOCEntityHandlerResult(env, static_cast<int>(jResult));
 }
\ No newline at end of file
index 8cf3373..a769e56 100644 (file)
@@ -1,39 +1,39 @@
-/*\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 "JniOcStack.h"\r
-\r
-#ifndef _Included_org_iotivity_base_JniEntityHandler\r
-#define _Included_org_iotivity_base_JniEntityHandler\r
-\r
-class JniEntityHandler\r
-{\r
-public:\r
-    JniEntityHandler(JNIEnv *env, jobject listener);\r
-    ~JniEntityHandler();\r
-\r
-    OCEntityHandlerResult handleEntity(const std::shared_ptr<OC::OCResourceRequest> request);\r
-\r
-private:\r
-    jobject m_jListener;\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 "JniOcStack.h"
+
+#ifndef _Included_org_iotivity_base_JniEntityHandler
+#define _Included_org_iotivity_base_JniEntityHandler
+
+class JniEntityHandler
+{
+public:
+    JniEntityHandler(JNIEnv *env, jobject listener);
+    ~JniEntityHandler();
+
+    OCEntityHandlerResult handleEntity(const std::shared_ptr<OC::OCResourceRequest> request);
+
+private:
+    jobject m_jListener;
+};
+
 #endif
\ No newline at end of file
index c9ccaa3..b06be3b 100644 (file)
-///*\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
-//\r
-//#include "JniListenerManager.h"\r
-//\r
-//#include "JniOnGetListener.h"\r
-//\r
-//template<class T>\r
-//T* JniListenerManager<T>::addListener(JNIEnv* env, jobject jListener)\r
-//{\r
-//     T *onEventListener = NULL;\r
-//\r
-//     m_mapMutex.lock();\r
-//\r
-//     for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)\r
-//     {\r
-//             if (env->IsSameObject(jListener, it->first))\r
-//             {\r
-//                     auto refPair = it->second;\r
-//                     onEventListener = refPair.first;\r
-//                     refPair.second++;\r
-//                     it->second = refPair;\r
-//                     m_listenerMap.insert(*it);\r
-//                     LOGD("OnEventListener: ref. count is incremented");\r
-//                     break;\r
-//             }\r
-//     }\r
-//\r
-//     if (!onEventListener)\r
-//     {\r
-//             onEventListener = new T(env, jListener, this);\r
-//             jobject jgListener = env->NewGlobalRef(jListener);\r
-//\r
-//             m_listenerMap.insert(std::pair<jobject, std::pair<T*, int>>(jgListener, std::pair<T*, int>(onEventListener, 1)));\r
-//             LOGD("OnEventListener: new listener");\r
-//     }\r
-//\r
-//     m_mapMutex.unlock();\r
-//\r
-//     return onEventListener;\r
-//}\r
-//\r
-//template<class T>\r
-//void JniListenerManager<T>::removeListener(JNIEnv* env, jobject jListener)\r
-//{\r
-//     m_mapMutex.lock();\r
-//\r
-//     bool isFound = false;\r
-//\r
-//     for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)\r
-//     {\r
-//             if (env->IsSameObject(jListener, it->first))\r
-//             {\r
-//                     auto refPair = it->second;\r
-//                     if (refPair.second > 1)\r
-//                     {\r
-//                             refPair.second--;\r
-//                             it->second = refPair;\r
-//                             m_listenerMap.insert(*it);\r
-//                             LOGI("OnEventListener: ref. count is decremented");\r
-//                     }\r
-//                     else\r
-//                     {\r
-//                             env->DeleteGlobalRef(it->first);\r
-//                             T* listener = refPair.first;\r
-//                             delete listener;\r
-//                             m_listenerMap.erase(it);\r
-//\r
-//                             LOGI("OnEventListener is removed");\r
-//                     }\r
-//\r
-//                     isFound = true;\r
-//                     break;\r
-//             }\r
-//     }\r
-//\r
-//     if (!isFound)\r
-//     {\r
-//             ThrowOcException(JNI_EXCEPTION, "OnEventListener isn't found");\r
-//     }\r
-//\r
-//     m_mapMutex.unlock();\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 "JniListenerManager.h"
+//
+//#include "JniOnGetListener.h"
+//
+//template<class T>
+//T* JniListenerManager<T>::addListener(JNIEnv* env, jobject jListener)
+//{
+//     T *onEventListener = NULL;
+//
+//     m_mapMutex.lock();
+//
+//     for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)
+//     {
+//             if (env->IsSameObject(jListener, it->first))
+//             {
+//                     auto refPair = it->second;
+//                     onEventListener = refPair.first;
+//                     refPair.second++;
+//                     it->second = refPair;
+//                     m_listenerMap.insert(*it);
+//                     LOGD("OnEventListener: ref. count is incremented");
+//                     break;
+//             }
+//     }
+//
+//     if (!onEventListener)
+//     {
+//             onEventListener = new T(env, jListener, this);
+//             jobject jgListener = env->NewGlobalRef(jListener);
+//
+//             m_listenerMap.insert(std::pair<jobject, std::pair<T*, int>>(jgListener, std::pair<T*, int>(onEventListener, 1)));
+//             LOGD("OnEventListener: new listener");
+//     }
+//
+//     m_mapMutex.unlock();
+//
+//     return onEventListener;
+//}
+//
+//template<class T>
+//void JniListenerManager<T>::removeListener(JNIEnv* env, jobject jListener)
+//{
+//     m_mapMutex.lock();
+//
+//     bool isFound = false;
+//
+//     for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)
+//     {
+//             if (env->IsSameObject(jListener, it->first))
+//             {
+//                     auto refPair = it->second;
+//                     if (refPair.second > 1)
+//                     {
+//                             refPair.second--;
+//                             it->second = refPair;
+//                             m_listenerMap.insert(*it);
+//                             LOGI("OnEventListener: ref. count is decremented");
+//                     }
+//                     else
+//                     {
+//                             env->DeleteGlobalRef(it->first);
+//                             T* listener = refPair.first;
+//                             delete listener;
+//                             m_listenerMap.erase(it);
+//
+//                             LOGI("OnEventListener is removed");
+//                     }
+//
+//                     isFound = true;
+//                     break;
+//             }
+//     }
+//
+//     if (!isFound)
+//     {
+//             ThrowOcException(JNI_EXCEPTION, "OnEventListener isn't found");
+//     }
+//
+//     m_mapMutex.unlock();
+//}
+//
index a43ea82..709328a 100644 (file)
-/*\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
-\r
-#include "JniOcStack.h"\r
-#include <mutex>\r
-\r
-#ifndef _JniListenerManager\r
-#define _JniListenerManager\r
-\r
-class JniOcResource;\r
-\r
-template <class T>\r
-class JniListenerManager\r
-{\r
-public:\r
-    T* addListener(JNIEnv* env, jobject jListener, JniOcResource* owner)\r
-    {\r
-        T *onEventListener = NULL;\r
-\r
-        m_mapMutex.lock();\r
-\r
-        for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)\r
-        {\r
-            if (env->IsSameObject(jListener, it->first))\r
-            {\r
-                auto refPair = it->second;\r
-                onEventListener = refPair.first;\r
-                refPair.second++;\r
-                it->second = refPair;\r
-                m_listenerMap.insert(*it);\r
-                LOGD("OnEventListener: ref. count is incremented");\r
-                break;\r
-            }\r
-        }\r
-        if (!onEventListener)\r
-        {\r
-            onEventListener = new T(env, jListener, owner);\r
-            jobject jgListener = env->NewGlobalRef(jListener);\r
-\r
-            if (jgListener)\r
-            {\r
-                m_listenerMap.insert(std::pair<jobject, std::pair<T*, int>>(jgListener, std::pair<T*, int>(onEventListener, 1)));\r
-            }\r
-            else\r
-            {\r
-                LOGD("OnEventListener: Failed to create global listener ref.");\r
-                delete onEventListener;\r
-            }\r
-            LOGD("OnEventListener: new listener");\r
-        }\r
-        m_mapMutex.unlock();\r
-        return onEventListener;\r
-    }\r
-\r
-    void removeListener(JNIEnv* env, jobject jListener)\r
-    {\r
-        m_mapMutex.lock();\r
-        for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)\r
-        {\r
-            if (env->IsSameObject(jListener, it->first))\r
-            {\r
-                auto refPair = it->second;\r
-                if (refPair.second > 1)\r
-                {\r
-                    refPair.second--;\r
-                    it->second = refPair;\r
-                    m_listenerMap.insert(*it);\r
-                    LOGI("OnEventListener: ref. count is decremented");\r
-                }\r
-                else\r
-                {\r
-                    env->DeleteGlobalRef(it->first);\r
-                    T* listener = refPair.first;\r
-                    delete listener;\r
-                    m_listenerMap.erase(it);\r
-\r
-                    LOGI("OnEventListener is removed");\r
-                }\r
-                break;\r
-            }\r
-        }\r
-        m_mapMutex.unlock();\r
-    }\r
-\r
-    void removeAllListeners(JNIEnv* env)\r
-    {\r
-        m_mapMutex.lock();\r
-\r
-        for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)\r
-        {\r
-            env->DeleteGlobalRef(it->first);\r
-            auto refPair = it->second;\r
-            T* listener = refPair.first;\r
-            delete listener;\r
-            m_listenerMap.erase(it);\r
-        }\r
-\r
-        m_mapMutex.unlock();\r
-    }\r
-\r
-private:\r
-    std::map<jobject, std::pair<T*, int>> m_listenerMap;\r
-    std::mutex m_mapMutex;\r
-};\r
-\r
-#endif\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 "JniOcStack.h"
+#include <mutex>
+
+#ifndef _JniListenerManager
+#define _JniListenerManager
+
+class JniOcResource;
+
+template <class T>
+class JniListenerManager
+{
+public:
+    T* addListener(JNIEnv* env, jobject jListener, JniOcResource* owner)
+    {
+        T *onEventListener = NULL;
+
+        m_mapMutex.lock();
+
+        for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)
+        {
+            if (env->IsSameObject(jListener, it->first))
+            {
+                auto refPair = it->second;
+                onEventListener = refPair.first;
+                refPair.second++;
+                it->second = refPair;
+                m_listenerMap.insert(*it);
+                LOGD("OnEventListener: ref. count is incremented");
+                break;
+            }
+        }
+        if (!onEventListener)
+        {
+            onEventListener = new T(env, jListener, owner);
+            jobject jgListener = env->NewGlobalRef(jListener);
+
+            if (jgListener)
+            {
+                m_listenerMap.insert(std::pair<jobject, std::pair<T*, int>>(jgListener, std::pair<T*, int>(onEventListener, 1)));
+            }
+            else
+            {
+                LOGD("OnEventListener: Failed to create global listener ref.");
+                delete onEventListener;
+            }
+            LOGD("OnEventListener: new listener");
+        }
+        m_mapMutex.unlock();
+        return onEventListener;
+    }
+
+    void removeListener(JNIEnv* env, jobject jListener)
+    {
+        m_mapMutex.lock();
+        for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)
+        {
+            if (env->IsSameObject(jListener, it->first))
+            {
+                auto refPair = it->second;
+                if (refPair.second > 1)
+                {
+                    refPair.second--;
+                    it->second = refPair;
+                    m_listenerMap.insert(*it);
+                    LOGI("OnEventListener: ref. count is decremented");
+                }
+                else
+                {
+                    env->DeleteGlobalRef(it->first);
+                    T* listener = refPair.first;
+                    delete listener;
+                    m_listenerMap.erase(it);
+
+                    LOGI("OnEventListener is removed");
+                }
+                break;
+            }
+        }
+        m_mapMutex.unlock();
+    }
+
+    void removeAllListeners(JNIEnv* env)
+    {
+        m_mapMutex.lock();
+
+        for (auto it = m_listenerMap.begin(); it != m_listenerMap.end(); ++it)
+        {
+            env->DeleteGlobalRef(it->first);
+            auto refPair = it->second;
+            T* listener = refPair.first;
+            delete listener;
+            m_listenerMap.erase(it);
+        }
+
+        m_mapMutex.unlock();
+    }
+
+private:
+    std::map<jobject, std::pair<T*, int>> m_listenerMap;
+    std::mutex m_mapMutex;
+};
+
+#endif
index 2023fa4..4860e85 100644 (file)
-/*\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 "JniOcPlatform.h"\r
-#include "OCPlatform.h"\r
-#include "JniOcResource.h"\r
-#include "JniOcResourceHandle.h"\r
-#include "JniOcPresenceHandle.h"\r
-#include "JniOcResourceResponse.h"\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 "JniOcPlatform.h"
+#include "OCPlatform.h"
+#include "JniOcResource.h"
+#include "JniOcResourceHandle.h"
+#include "JniOcPresenceHandle.h"
+#include "JniOcResourceResponse.h"
 #include "JniOcSecurity.h"
-#include "JniUtils.h"\r
-\r
-using namespace OC;\r
-\r
-JniOnResourceFoundListener* AddOnResourceFoundListener(JNIEnv* env, jobject jListener)\r
-{\r
-    JniOnResourceFoundListener *onResourceFoundListener = NULL;\r
-\r
-    resourceFoundMapLock.lock();\r
-\r
-    for (auto it = onResourceFoundListenerMap.begin(); it != onResourceFoundListenerMap.end(); ++it)\r
-    {\r
-        if (env->IsSameObject(jListener, it->first))\r
-        {\r
-            auto refPair = it->second;\r
-            onResourceFoundListener = refPair.first;\r
-            refPair.second++;\r
-            it->second = refPair;\r
-            onResourceFoundListenerMap.insert(*it);\r
-            LOGD("OnResourceFoundListener: ref. count incremented");\r
-            break;\r
-        }\r
-    }\r
-\r
-    if (!onResourceFoundListener)\r
-    {\r
-        onResourceFoundListener = new JniOnResourceFoundListener(env, jListener, RemoveOnResourceFoundListener);\r
-        jobject jgListener = env->NewGlobalRef(jListener);\r
-\r
-        onResourceFoundListenerMap.insert(std::pair < jobject, std::pair < JniOnResourceFoundListener*,\r
-            int >> (jgListener, std::pair<JniOnResourceFoundListener*, int>(onResourceFoundListener, 1)));\r
-        LOGD("OnResourceFoundListener: new listener");\r
-    }\r
-    resourceFoundMapLock.unlock();\r
-    return onResourceFoundListener;\r
-}\r
-\r
-void RemoveOnResourceFoundListener(JNIEnv* env, jobject jListener)\r
-{\r
-    resourceFoundMapLock.lock();\r
-\r
-    for (auto it = onResourceFoundListenerMap.begin(); it != onResourceFoundListenerMap.end(); ++it)\r
-    {\r
-        if (env->IsSameObject(jListener, it->first))\r
-        {\r
-            auto refPair = it->second;\r
-            if (refPair.second > 1)\r
-            {\r
-                refPair.second--;\r
-                it->second = refPair;\r
-                onResourceFoundListenerMap.insert(*it);\r
-                LOGI("OnResourceFoundListener: ref. count decremented");\r
-            }\r
-            else\r
-            {\r
-                env->DeleteGlobalRef(it->first);\r
-                JniOnResourceFoundListener* listener = refPair.first;\r
-                delete listener;\r
-                onResourceFoundListenerMap.erase(it);\r
-                LOGI("OnResourceFoundListener removed");\r
-            }\r
-            break;\r
-        }\r
-    }\r
-    resourceFoundMapLock.unlock();\r
-}\r
-\r
-JniOnDeviceInfoListener* AddOnDeviceInfoListener(JNIEnv* env, jobject jListener)\r
-{\r
-    JniOnDeviceInfoListener *onDeviceInfoListener = NULL;\r
-\r
-    deviceInfoMapLock.lock();\r
-\r
-    for (auto it = onDeviceInfoListenerMap.begin(); it != onDeviceInfoListenerMap.end(); ++it)\r
-    {\r
-        if (env->IsSameObject(jListener, it->first))\r
-        {\r
-            auto refPair = it->second;\r
-            onDeviceInfoListener = refPair.first;\r
-            refPair.second++;\r
-            it->second = refPair;\r
-            onDeviceInfoListenerMap.insert(*it);\r
-            LOGD("OnDeviceInfoListener: ref. count incremented");\r
-            break;\r
-        }\r
-    }\r
-\r
-    if (!onDeviceInfoListener)\r
-    {\r
-        onDeviceInfoListener = new JniOnDeviceInfoListener(env, jListener, RemoveOnDeviceInfoListener);\r
-        jobject jgListener = env->NewGlobalRef(jListener);\r
-\r
-        onDeviceInfoListenerMap.insert(std::pair < jobject, std::pair < JniOnDeviceInfoListener*,\r
-            int >> (jgListener, std::pair<JniOnDeviceInfoListener*, int>(onDeviceInfoListener, 1)));\r
-        LOGI("OnDeviceInfoListener: new listener");\r
-    }\r
-\r
-    deviceInfoMapLock.unlock();\r
-    return onDeviceInfoListener;\r
-}\r
-\r
-void RemoveOnDeviceInfoListener(JNIEnv* env, jobject jListener)\r
-{\r
-    deviceInfoMapLock.lock();\r
-    bool isFound = false;\r
-    for (auto it = onDeviceInfoListenerMap.begin(); it != onDeviceInfoListenerMap.end(); ++it)\r
-    {\r
-        if (env->IsSameObject(jListener, it->first))\r
-        {\r
-            auto refPair = it->second;\r
-            if (refPair.second > 1)\r
-            {\r
-                refPair.second--;\r
-                it->second = refPair;\r
-                onDeviceInfoListenerMap.insert(*it);\r
-                LOGI("OnDeviceInfoListener: ref. count decremented");\r
-            }\r
-            else\r
-            {\r
-                env->DeleteGlobalRef(it->first);\r
-                JniOnDeviceInfoListener* listener = refPair.first;\r
-                delete listener;\r
-                onDeviceInfoListenerMap.erase(it);\r
-\r
-                LOGI("OnDeviceInfoListener removed");\r
-            }\r
-\r
-            isFound = true;\r
-            break;\r
-        }\r
-    }\r
-\r
-    if (!isFound)\r
-    {\r
-        ThrowOcException(JNI_EXCEPTION, "OnDeviceInfoListenet not found");\r
-    }\r
-    deviceInfoMapLock.unlock();\r
+#include "JniUtils.h"
+
+using namespace OC;
+
+JniOnResourceFoundListener* AddOnResourceFoundListener(JNIEnv* env, jobject jListener)
+{
+    JniOnResourceFoundListener *onResourceFoundListener = NULL;
+
+    resourceFoundMapLock.lock();
+
+    for (auto it = onResourceFoundListenerMap.begin(); it != onResourceFoundListenerMap.end(); ++it)
+    {
+        if (env->IsSameObject(jListener, it->first))
+        {
+            auto refPair = it->second;
+            onResourceFoundListener = refPair.first;
+            refPair.second++;
+            it->second = refPair;
+            onResourceFoundListenerMap.insert(*it);
+            LOGD("OnResourceFoundListener: ref. count incremented");
+            break;
+        }
+    }
+
+    if (!onResourceFoundListener)
+    {
+        onResourceFoundListener = new JniOnResourceFoundListener(env, jListener, RemoveOnResourceFoundListener);
+        jobject jgListener = env->NewGlobalRef(jListener);
+
+        onResourceFoundListenerMap.insert(std::pair < jobject, std::pair < JniOnResourceFoundListener*,
+            int >> (jgListener, std::pair<JniOnResourceFoundListener*, int>(onResourceFoundListener, 1)));
+        LOGD("OnResourceFoundListener: new listener");
+    }
+    resourceFoundMapLock.unlock();
+    return onResourceFoundListener;
+}
+
+void RemoveOnResourceFoundListener(JNIEnv* env, jobject jListener)
+{
+    resourceFoundMapLock.lock();
+
+    for (auto it = onResourceFoundListenerMap.begin(); it != onResourceFoundListenerMap.end(); ++it)
+    {
+        if (env->IsSameObject(jListener, it->first))
+        {
+            auto refPair = it->second;
+            if (refPair.second > 1)
+            {
+                refPair.second--;
+                it->second = refPair;
+                onResourceFoundListenerMap.insert(*it);
+                LOGI("OnResourceFoundListener: ref. count decremented");
+            }
+            else
+            {
+                env->DeleteGlobalRef(it->first);
+                JniOnResourceFoundListener* listener = refPair.first;
+                delete listener;
+                onResourceFoundListenerMap.erase(it);
+                LOGI("OnResourceFoundListener removed");
+            }
+            break;
+        }
+    }
+    resourceFoundMapLock.unlock();
+}
+
+JniOnDeviceInfoListener* AddOnDeviceInfoListener(JNIEnv* env, jobject jListener)
+{
+    JniOnDeviceInfoListener *onDeviceInfoListener = NULL;
+
+    deviceInfoMapLock.lock();
+
+    for (auto it = onDeviceInfoListenerMap.begin(); it != onDeviceInfoListenerMap.end(); ++it)
+    {
+        if (env->IsSameObject(jListener, it->first))
+        {
+            auto refPair = it->second;
+            onDeviceInfoListener = refPair.first;
+            refPair.second++;
+            it->second = refPair;
+            onDeviceInfoListenerMap.insert(*it);
+            LOGD("OnDeviceInfoListener: ref. count incremented");
+            break;
+        }
+    }
+
+    if (!onDeviceInfoListener)
+    {
+        onDeviceInfoListener = new JniOnDeviceInfoListener(env, jListener, RemoveOnDeviceInfoListener);
+        jobject jgListener = env->NewGlobalRef(jListener);
+
+        onDeviceInfoListenerMap.insert(std::pair < jobject, std::pair < JniOnDeviceInfoListener*,
+            int >> (jgListener, std::pair<JniOnDeviceInfoListener*, int>(onDeviceInfoListener, 1)));
+        LOGI("OnDeviceInfoListener: new listener");
+    }
+
+    deviceInfoMapLock.unlock();
+    return onDeviceInfoListener;
+}
+
+void RemoveOnDeviceInfoListener(JNIEnv* env, jobject jListener)
+{
+    deviceInfoMapLock.lock();
+    bool isFound = false;
+    for (auto it = onDeviceInfoListenerMap.begin(); it != onDeviceInfoListenerMap.end(); ++it)
+    {
+        if (env->IsSameObject(jListener, it->first))
+        {
+            auto refPair = it->second;
+            if (refPair.second > 1)
+            {
+                refPair.second--;
+                it->second = refPair;
+                onDeviceInfoListenerMap.insert(*it);
+                LOGI("OnDeviceInfoListener: ref. count decremented");
+            }
+            else
+            {
+                env->DeleteGlobalRef(it->first);
+                JniOnDeviceInfoListener* listener = refPair.first;
+                delete listener;
+                onDeviceInfoListenerMap.erase(it);
+
+                LOGI("OnDeviceInfoListener removed");
+            }
+
+            isFound = true;
+            break;
+        }
+    }
+
+    if (!isFound)
+    {
+        ThrowOcException(JNI_EXCEPTION, "OnDeviceInfoListenet not found");
+    }
+    deviceInfoMapLock.unlock();
 }
 
 JniOnPlatformInfoListener* AddOnPlatformInfoListener(JNIEnv* env, jobject jListener)
@@ -235,512 +235,140 @@ void RemoveOnPlatformInfoListener(JNIEnv* env, jobject jListener)
         ThrowOcException(JNI_EXCEPTION, "OnPlatformInfoListenet not found");
     }
     platformInfoMapLock.unlock();
-}\r
-\r
-JniOnPresenceListener* AddOnPresenceListener(JNIEnv* env, jobject jListener)\r
-{\r
-    JniOnPresenceListener *onPresenceListener = NULL;\r
-\r
-    presenceMapLock.lock();\r
-\r
-    for (auto it = onPresenceListenerMap.begin(); it != onPresenceListenerMap.end(); ++it)\r
-    {\r
-        if (env->IsSameObject(jListener, it->first))\r
-        {\r
-            auto refPair = it->second;\r
-            onPresenceListener = refPair.first;\r
-            refPair.second++;\r
-            it->second = refPair;\r
-            onPresenceListenerMap.insert(*it);\r
-            LOGD("OnPresenceListener: ref. count incremented");\r
-            break;\r
-        }\r
-    }\r
-    if (!onPresenceListener)\r
-    {\r
-        onPresenceListener = new JniOnPresenceListener(env, jListener, RemoveOnPresenceListener);\r
-        jobject jgListener = env->NewGlobalRef(jListener);\r
-        onPresenceListenerMap.insert(std::pair < jobject, std::pair < JniOnPresenceListener*,\r
-            int >> (jgListener, std::pair<JniOnPresenceListener*, int>(onPresenceListener, 1)));\r
-        LOGI("OnPresenceListener: new listener");\r
-    }\r
-    presenceMapLock.unlock();\r
-    return onPresenceListener;\r
-}\r
-\r
-void RemoveOnPresenceListener(JNIEnv* env, jobject jListener)\r
-{\r
-    presenceMapLock.lock();\r
-    bool isFound = false;\r
-    for (auto it = onPresenceListenerMap.begin(); it != onPresenceListenerMap.end(); ++it)\r
-    {\r
-        if (env->IsSameObject(jListener, it->first))\r
-        {\r
-            auto refPair = it->second;\r
-            if (refPair.second > 1)\r
-            {\r
-                refPair.second--;\r
-                it->second = refPair;\r
-                onPresenceListenerMap.insert(*it);\r
-                LOGI("OnPresenceListener: ref. count decremented");\r
-            }\r
-            else\r
-            {\r
-                env->DeleteGlobalRef(it->first);\r
-                JniOnPresenceListener* listener = refPair.first;\r
-                delete listener;\r
-                onPresenceListenerMap.erase(it);\r
-                LOGI("OnPresenceListener is removed");\r
-            }\r
-            isFound = true;\r
-            break;\r
-        }\r
-    }\r
-    if (!isFound)\r
-    {\r
-        ThrowOcException(JNI_EXCEPTION, "OnPresenceListener not found");\r
-    }\r
-    presenceMapLock.unlock();\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    configure\r
-* Signature: (IILjava/lang/String;II)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_configure\r
+}
+
+JniOnPresenceListener* AddOnPresenceListener(JNIEnv* env, jobject jListener)
+{
+    JniOnPresenceListener *onPresenceListener = NULL;
+
+    presenceMapLock.lock();
+
+    for (auto it = onPresenceListenerMap.begin(); it != onPresenceListenerMap.end(); ++it)
+    {
+        if (env->IsSameObject(jListener, it->first))
+        {
+            auto refPair = it->second;
+            onPresenceListener = refPair.first;
+            refPair.second++;
+            it->second = refPair;
+            onPresenceListenerMap.insert(*it);
+            LOGD("OnPresenceListener: ref. count incremented");
+            break;
+        }
+    }
+    if (!onPresenceListener)
+    {
+        onPresenceListener = new JniOnPresenceListener(env, jListener, RemoveOnPresenceListener);
+        jobject jgListener = env->NewGlobalRef(jListener);
+        onPresenceListenerMap.insert(std::pair < jobject, std::pair < JniOnPresenceListener*,
+            int >> (jgListener, std::pair<JniOnPresenceListener*, int>(onPresenceListener, 1)));
+        LOGI("OnPresenceListener: new listener");
+    }
+    presenceMapLock.unlock();
+    return onPresenceListener;
+}
+
+void RemoveOnPresenceListener(JNIEnv* env, jobject jListener)
+{
+    presenceMapLock.lock();
+    bool isFound = false;
+    for (auto it = onPresenceListenerMap.begin(); it != onPresenceListenerMap.end(); ++it)
+    {
+        if (env->IsSameObject(jListener, it->first))
+        {
+            auto refPair = it->second;
+            if (refPair.second > 1)
+            {
+                refPair.second--;
+                it->second = refPair;
+                onPresenceListenerMap.insert(*it);
+                LOGI("OnPresenceListener: ref. count decremented");
+            }
+            else
+            {
+                env->DeleteGlobalRef(it->first);
+                JniOnPresenceListener* listener = refPair.first;
+                delete listener;
+                onPresenceListenerMap.erase(it);
+                LOGI("OnPresenceListener is removed");
+            }
+            isFound = true;
+            break;
+        }
+    }
+    if (!isFound)
+    {
+        ThrowOcException(JNI_EXCEPTION, "OnPresenceListener not found");
+    }
+    presenceMapLock.unlock();
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    configure
+* Signature: (IILjava/lang/String;II)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_configure
 (JNIEnv *env, jclass clazz, jint jServiceType, jint jModeType, jstring jIpAddress, jint jPort,
                                                                  jint jQOS, jstring jDbPath)
-{\r
-    LOGI("OcPlatform_configure");\r
-\r
-    std::string ipAddress;\r
+{
+    LOGI("OcPlatform_configure");
+
+    std::string ipAddress;
     std::string dbfile;
-    if (jIpAddress)\r
-    {\r
-        ipAddress = env->GetStringUTFChars(jIpAddress, NULL);\r
-    }\r
+    if (jIpAddress)
+    {
+        ipAddress = env->GetStringUTFChars(jIpAddress, NULL);
+    }
     if (jDbPath)
     {
         dbfile = env->GetStringUTFChars(jDbPath, nullptr);
         JniOcSecurity::StoreDbPath(dbfile);
     }
-    uint16_t port;\r
-    if (jPort > 0)\r
-    {\r
-        port = static_cast<uint16_t>(jPort);\r
-    }\r
-    PlatformConfig cfg{\r
-        JniUtils::getServiceType(env, jServiceType),\r
-        JniUtils::getModeType(env, jModeType),\r
-        ipAddress,\r
-        port,\r
+    uint16_t port;
+    if (jPort > 0)
+    {
+        port = static_cast<uint16_t>(jPort);
+    }
+    PlatformConfig cfg{
+        JniUtils::getServiceType(env, jServiceType),
+        JniUtils::getModeType(env, jModeType),
+        ipAddress,
+        port,
         JniUtils::getQOS(env, static_cast<int>(jQOS)),
         JniOcSecurity::getOCPersistentStorage()
-    };\r
-\r
-    OCPlatform::Configure(cfg);\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    notifyAllObservers0\r
-* Signature: (Lorg/iotivity/base/OcResourceHandle;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers0\r
-(JNIEnv *env, jclass clazz, jobject jResourceHandle)\r
-{\r
-    LOGI("OcPlatform_notifyAllObservers");\r
-    if (!jResourceHandle)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
-        return;\r
-    }\r
-\r
-    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
-        env, jResourceHandle);\r
-    if (!jniOcResourceHandle) return;\r
-\r
-    try\r
-    {\r
-        OCStackResult result = OCPlatform::notifyAllObservers(jniOcResourceHandle->getOCResourceHandle());\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "Failed to notify all observers");\r
-            return;\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    notifyAllObservers1\r
-* Signature: (Lorg/iotivity/base/OcResourceHandle;I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers1\r
-(JNIEnv *env, jclass clazz, jobject jResourceHandle, jint jQoS)\r
-{\r
-    LOGI("OcPlatform_notifyAllObservers1");\r
-\r
-    if (!jResourceHandle)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
-        return;\r
-    }\r
-\r
-    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
-        env, jResourceHandle);\r
-    if (!jniOcResourceHandle) return;\r
-\r
-    try{\r
-        OCStackResult result = OCPlatform::notifyAllObservers(\r
-            jniOcResourceHandle->getOCResourceHandle(),\r
-            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "Failed to notify all observers");\r
-            return;\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    notifyListOfObservers2\r
-* Signature: (Lorg/iotivity/base/OcResourceHandle;[Ljava/lang/Byte;Lorg/iotivity/base/OcResourceResponse;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyListOfObservers2\r
-(JNIEnv *env, jclass clazz, jobject jResourceHandle, jbyteArray jObservationIdArr, jobject jResourceResponse)\r
-{\r
-    LOGD("OcPlatform_notifyListOfObservers2");\r
-    if (!jResourceHandle)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
-        return;\r
-    }\r
-    if (!jObservationIdArr)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "observationIdList cannot be null");\r
-        return;\r
-    }\r
-    if (!jResourceResponse)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceResponse cannot be null");\r
-        return;\r
-    }\r
-\r
-    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
-        env, jResourceHandle);\r
-    if (!jniOcResourceHandle) return;\r
-\r
-    JniOcResourceResponse* jniOcResourceResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(\r
-        env, jResourceResponse);\r
-    if (!jniOcResourceResponse) return;\r
-\r
-    int len = env->GetArrayLength(jObservationIdArr);\r
-    uint8_t* bArr = (uint8_t*)env->GetByteArrayElements(jObservationIdArr, 0);\r
-\r
-    ObservationIds observationIds;\r
-    for (int i = 0; i < len; ++i)\r
-    {\r
-        observationIds.push_back(bArr[i]);\r
-    }\r
-\r
-    env->ReleaseByteArrayElements(jObservationIdArr, (jbyte*)bArr, 0);\r
-\r
-    try{\r
-        OCStackResult result = OCPlatform::notifyListOfObservers(\r
-            jniOcResourceHandle->getOCResourceHandle(),\r
-            observationIds,\r
-            jniOcResourceResponse->getOCResourceResponse());\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "Failed to notify all observers");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    notifyListOfObservers3\r
-* Signature: (Lorg/iotivity/base/OcResourceHandle;[Ljava/lang/Byte;Lorg/iotivity/base/OcResourceResponse;I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyListOfObservers3\r
-(JNIEnv *env, jclass clazz, jobject jResourceHandle, jbyteArray jObservationIdArr, jobject jResourceResponse, jint jQoS)\r
-{\r
-    LOGD("OcPlatform_notifyListOfObservers3");\r
-    if (!jResourceHandle)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
-        return;\r
-    }\r
-    if (!jObservationIdArr)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "observationIdList cannot be null");\r
-        return;\r
-    }\r
-    if (!jResourceResponse)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceResponse cannot be null");\r
-        return;\r
-    }\r
-\r
-    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
-        env, jResourceHandle);\r
-    if (!jniOcResourceHandle) return;\r
-\r
-    JniOcResourceResponse* jniOcResourceResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(\r
-        env, jResourceResponse);\r
-    if (!jniOcResourceResponse) return;\r
-\r
-    int len = env->GetArrayLength(jObservationIdArr);\r
-    uint8_t* bArr = (uint8_t*)env->GetByteArrayElements(jObservationIdArr, 0);\r
-\r
-    ObservationIds observationIds;\r
-    for (int i = 0; i < len; ++i)\r
-    {\r
-        observationIds.push_back(bArr[i]);\r
-    }\r
-\r
-    env->ReleaseByteArrayElements(jObservationIdArr, (jbyte*)bArr, 0);\r
-\r
-    try{\r
-        OCStackResult result = OCPlatform::notifyListOfObservers(\r
-            jniOcResourceHandle->getOCResourceHandle(),\r
-            observationIds,\r
-            jniOcResourceResponse->getOCResourceResponse(),\r
-            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "Failed to notify all observers");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    findResource0\r
-* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnResourceFoundListener;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource0\r
-(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener)\r
-{\r
-    LOGD("OcPlatform_findResource");\r
-    std::string host;\r
-    if (jHost)\r
-    {\r
-        host = env->GetStringUTFChars(jHost, NULL);\r
-    }\r
-    std::string resourceUri;\r
-    if (jResourceUri)\r
-    {\r
-        resourceUri = env->GetStringUTFChars(jResourceUri, NULL);\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onResourceFoundListener cannot be null");\r
-        return;\r
-    }\r
-\r
-    JniOnResourceFoundListener *onResFoundListener = AddOnResourceFoundListener(env, jListener);\r
-\r
-    FindCallback findCallback = [onResFoundListener](std::shared_ptr<OCResource> resource)\r
-    {\r
-        onResFoundListener->foundResourceCallback(resource);\r
-    };\r
-\r
-    try\r
-    {\r
-        OCStackResult result = OCPlatform::findResource(\r
-            host,\r
-            resourceUri,\r
-            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),\r
-            findCallback);\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "Find resource has failed");\r
-            return;\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    findResource1\r
-* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnResourceFoundListener;I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource1\r
-(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener, jint jQoS)\r
-{\r
-    LOGD("OcPlatform_findResource");\r
-    std::string host;\r
-    if (jHost)\r
-    {\r
-        host = env->GetStringUTFChars(jHost, NULL);\r
-    }\r
-    std::string resourceUri;\r
-    if (jResourceUri)\r
-    {\r
-        resourceUri = env->GetStringUTFChars(jResourceUri, NULL);\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onResourceFoundListener cannot be null");\r
-        return;\r
-    }\r
-    JniOnResourceFoundListener *onResFoundListener = AddOnResourceFoundListener(env, jListener);\r
-\r
-    FindCallback findCallback = [onResFoundListener](std::shared_ptr<OCResource> resource)\r
-    {\r
-        onResFoundListener->foundResourceCallback(resource);\r
-    };\r
-\r
-    try\r
-    {\r
-        OCStackResult result = OCPlatform::findResource(\r
-            host,\r
-            resourceUri,\r
-            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),\r
-            findCallback,\r
-            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "Find resource has failed");\r
-            return;\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    getDeviceInfo0\r
-* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnDeviceFoundListener;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo0\r
-(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener)\r
-{\r
-    LOGD("OcPlatform_getDeviceInfo0");\r
-    std::string host;\r
-    if (jHost)\r
-    {\r
-        host = env->GetStringUTFChars(jHost, NULL);\r
-    }\r
-    std::string resourceUri;\r
-    if (jResourceUri)\r
-    {\r
-        resourceUri = env->GetStringUTFChars(jResourceUri, NULL);\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onDeviceFoundListener cannot be null");\r
-        return;\r
-    }\r
-    JniOnDeviceInfoListener *onDeviceInfoListener = AddOnDeviceInfoListener(env, jListener);\r
-\r
-    FindDeviceCallback findDeviceCallback = [onDeviceInfoListener](const OCRepresentation& ocRepresentation)\r
-    {\r
-        onDeviceInfoListener->foundDeviceCallback(ocRepresentation);\r
-    };\r
-\r
-    try\r
-    {\r
-        OCStackResult result = OCPlatform::getDeviceInfo(\r
-            host,\r
-            resourceUri,\r
-            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),\r
-            findDeviceCallback);\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "Find device has failed");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    getDeviceInfo1\r
-* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnDeviceFoundListener;I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo1\r
-(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener, jint jQoS)\r
-{\r
-    LOGD("OcPlatform_getDeviceInfo1");\r
-    std::string host;\r
-    if (jHost)\r
-    {\r
-        host = env->GetStringUTFChars(jHost, NULL);\r
-    }\r
-    std::string resourceUri;\r
-    if (jResourceUri)\r
-    {\r
-        resourceUri = env->GetStringUTFChars(jResourceUri, NULL);\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onDeviceFoundListener cannot be null");\r
-        return;\r
-    }\r
-    JniOnDeviceInfoListener *onDeviceInfoListener = AddOnDeviceInfoListener(env, jListener);\r
-\r
-    FindDeviceCallback findDeviceCallback = [onDeviceInfoListener](const OCRepresentation& ocRepresentation)\r
-    {\r
-        onDeviceInfoListener->foundDeviceCallback(ocRepresentation);\r
-    };\r
-\r
-    try\r
-    {\r
-        OCStackResult result = OCPlatform::getDeviceInfo(\r
-            host,\r
-            resourceUri,\r
-            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),\r
-            findDeviceCallback,\r
-            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "Find device has failed");\r
+    };
+
+    OCPlatform::Configure(cfg);
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    notifyAllObservers0
+* Signature: (Lorg/iotivity/base/OcResourceHandle;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers0
+(JNIEnv *env, jclass clazz, jobject jResourceHandle)
+{
+    LOGI("OcPlatform_notifyAllObservers");
+    if (!jResourceHandle)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");
+        return;
+    }
+
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(
+        env, jResourceHandle);
+    if (!jniOcResourceHandle) return;
+
+    try
+    {
+        OCStackResult result = OCPlatform::notifyAllObservers(jniOcResourceHandle->getOCResourceHandle());
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "Failed to notify all observers");
+            return;
         }
     }
     catch (OCException& e)
@@ -752,46 +380,95 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo1
 
 /*
 * Class:     org_iotivity_base_OcPlatform
-* Method:    getPlatformInfo0
-* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPlatformFoundListener;)V
+* Method:    notifyAllObservers1
+* Signature: (Lorg/iotivity/base/OcResourceHandle;I)V
 */
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getPlatformInfo0
-(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener)
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers1
+(JNIEnv *env, jclass clazz, jobject jResourceHandle, jint jQoS)
 {
-    LOGD("OcPlatform_getPlatformInfo0");
-    std::string host;
-    if (jHost)
+    LOGI("OcPlatform_notifyAllObservers1");
+
+    if (!jResourceHandle)
     {
-        host = env->GetStringUTFChars(jHost, NULL);
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");
+        return;
     }
-    std::string resourceUri;
-    if (jResourceUri)
+
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(
+        env, jResourceHandle);
+    if (!jniOcResourceHandle) return;
+
+    try{
+        OCStackResult result = OCPlatform::notifyAllObservers(
+            jniOcResourceHandle->getOCResourceHandle(),
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "Failed to notify all observers");
+            return;
+        }
+    }
+    catch (OCException& e)
     {
-        resourceUri = env->GetStringUTFChars(jResourceUri, NULL);
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
     }
-    if (!jListener)
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    notifyListOfObservers2
+* Signature: (Lorg/iotivity/base/OcResourceHandle;[Ljava/lang/Byte;Lorg/iotivity/base/OcResourceResponse;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyListOfObservers2
+(JNIEnv *env, jclass clazz, jobject jResourceHandle, jbyteArray jObservationIdArr, jobject jResourceResponse)
+{
+    LOGD("OcPlatform_notifyListOfObservers2");
+    if (!jResourceHandle)
     {
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onPlatformFoundListener cannot be null");
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");
         return;
     }
-    JniOnPlatformInfoListener *onPlatformInfoListener = AddOnPlatformInfoListener(env, jListener);
-
-    FindPlatformCallback findPlatformCallback = [onPlatformInfoListener](const OCRepresentation& ocRepresentation)
+    if (!jObservationIdArr)
     {
-        onPlatformInfoListener->foundPlatformCallback(ocRepresentation);
-    };
+        ThrowOcException(OC_STACK_INVALID_PARAM, "observationIdList cannot be null");
+        return;
+    }
+    if (!jResourceResponse)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceResponse cannot be null");
+        return;
+    }
 
-    try
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(
+        env, jResourceHandle);
+    if (!jniOcResourceHandle) return;
+
+    JniOcResourceResponse* jniOcResourceResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(
+        env, jResourceResponse);
+    if (!jniOcResourceResponse) return;
+
+    int len = env->GetArrayLength(jObservationIdArr);
+    uint8_t* bArr = (uint8_t*)env->GetByteArrayElements(jObservationIdArr, 0);
+
+    ObservationIds observationIds;
+    for (int i = 0; i < len; ++i)
     {
-        OCStackResult result = OCPlatform::getPlatformInfo(
-            host,
-            resourceUri,
-            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
-            findPlatformCallback);
+        observationIds.push_back(bArr[i]);
+    }
+
+    env->ReleaseByteArrayElements(jObservationIdArr, (jbyte*)bArr, 0);
+
+    try{
+        OCStackResult result = OCPlatform::notifyListOfObservers(
+            jniOcResourceHandle->getOCResourceHandle(),
+            observationIds,
+            jniOcResourceResponse->getOCResourceResponse());
 
         if (OC_STACK_OK != result)
         {
-            ThrowOcException(result, "Find platform has failed");
+            ThrowOcException(result, "Failed to notify all observers");
         }
     }
     catch (OCException& e)
@@ -803,231 +480,554 @@ JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getPlatformInfo0
 
 /*
 * Class:     org_iotivity_base_OcPlatform
-* Method:    getPlatformInfo1
-* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPlatformFoundListener;I)V
+* Method:    notifyListOfObservers3
+* Signature: (Lorg/iotivity/base/OcResourceHandle;[Ljava/lang/Byte;Lorg/iotivity/base/OcResourceResponse;I)V
 */
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getPlatformInfo1
-(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener, jint jQoS)
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyListOfObservers3
+(JNIEnv *env, jclass clazz, jobject jResourceHandle, jbyteArray jObservationIdArr, jobject jResourceResponse, jint jQoS)
 {
-    LOGD("OcPlatform_getPlatformInfo1");
-    std::string host;
-    if (jHost)
+    LOGD("OcPlatform_notifyListOfObservers3");
+    if (!jResourceHandle)
     {
-        host = env->GetStringUTFChars(jHost, NULL);
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");
+        return;
     }
-    std::string resourceUri;
-    if (jResourceUri)
+    if (!jObservationIdArr)
     {
-        resourceUri = env->GetStringUTFChars(jResourceUri, NULL);
+        ThrowOcException(OC_STACK_INVALID_PARAM, "observationIdList cannot be null");
+        return;
     }
-    if (!jListener)
+    if (!jResourceResponse)
     {
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onPlatformFoundListener cannot be null");
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceResponse cannot be null");
         return;
     }
-    JniOnDeviceInfoListener *onDeviceInfoListener = AddOnDeviceInfoListener(env, jListener);
 
-    FindDeviceCallback findDeviceCallback = [onDeviceInfoListener](const OCRepresentation& ocRepresentation)
-    {
-        onDeviceInfoListener->foundDeviceCallback(ocRepresentation);
-    };
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(
+        env, jResourceHandle);
+    if (!jniOcResourceHandle) return;
 
-    try
+    JniOcResourceResponse* jniOcResourceResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(
+        env, jResourceResponse);
+    if (!jniOcResourceResponse) return;
+
+    int len = env->GetArrayLength(jObservationIdArr);
+    uint8_t* bArr = (uint8_t*)env->GetByteArrayElements(jObservationIdArr, 0);
+
+    ObservationIds observationIds;
+    for (int i = 0; i < len; ++i)
     {
-        OCStackResult result = OCPlatform::getPlatformInfo(
-            host,
-            resourceUri,
-            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
-            findDeviceCallback,
+        observationIds.push_back(bArr[i]);
+    }
+
+    env->ReleaseByteArrayElements(jObservationIdArr, (jbyte*)bArr, 0);
+
+    try{
+        OCStackResult result = OCPlatform::notifyListOfObservers(
+            jniOcResourceHandle->getOCResourceHandle(),
+            observationIds,
+            jniOcResourceResponse->getOCResourceResponse(),
             JniUtils::getQOS(env, static_cast<int>(jQoS)));
 
         if (OC_STACK_OK != result)
         {
-            ThrowOcException(result, "Find platform has failed");
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    registerResource0\r
-* Signature: (Lorg/iotivity/base/OcResource;)Lorg/iotivity/base/OcResourceHandle;\r
-*/\r
-JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource0\r
-(JNIEnv *env, jclass clazz, jobject jResource)\r
-{\r
-    LOGD("OcPlatform_registerResource");\r
-    if (!jResource)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "Resource cannot be null");\r
-        return nullptr;\r
-    }\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, jResource);\r
-    if (!resource) return nullptr;\r
-    LOGD("OcPlatform_registerResource1");
-    OCResourceHandle resourceHandle;\r
-    try\r
-    {\r
-        LOGD("OcPlatform_registerResource2");
-        OCStackResult result = OCPlatform::registerResource(\r
-            resourceHandle,\r
-            resource->getOCResource());\r
-        LOGD("OcPlatform_registerResource3");
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "register resource");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-        return nullptr;\r
-    }\r
-    LOGD("OcPlatform_registerResource4");
-    JniOcResourceHandle* jniHandle = new JniOcResourceHandle(resourceHandle);\r
-    jlong handle = reinterpret_cast<jlong>(jniHandle);\r
-    jobject jResourceHandle = env->NewObject(g_cls_OcResourceHandle, g_mid_OcResourceHandle_N_ctor, handle);\r
-    LOGD("OcPlatform_registerResource5");
-    if (!jResourceHandle)\r
-    {\r
-        LOGE("Failed to create OcResourceHandle");\r
-        delete jniHandle;\r
-    }\r
-    return jResourceHandle;\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    registerResource1\r
-* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcPlatform/EntityHandler;I)Lorg/iotivity/base/OcResourceHandle;\r
-*/\r
-JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource1\r
-(JNIEnv *env, jclass clazz, jstring jResourceUri, jstring jResourceTypeName, jstring jResourceInterface,\r
-jobject jListener, jint jResourceProperty)\r
-{\r
-    LOGI("OcPlatform_registerResource1");\r
-    std::string resourceUri;\r
-    if (jResourceUri)\r
-    {\r
-        resourceUri = env->GetStringUTFChars(jResourceUri, NULL);\r
-    }\r
-    std::string resourceTypeName;\r
-    if (jResourceTypeName)\r
-    {\r
-        resourceTypeName = env->GetStringUTFChars(jResourceTypeName, NULL);\r
-    }\r
-    std::string resourceInterface;\r
-    if (jResourceInterface)\r
-    {\r
-        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "entityHandler cannot be null");\r
-        return nullptr;\r
-    }\r
-    JniEntityHandler* entityHandler = new JniEntityHandler(env, jListener);\r
-    EntityHandler handleEntityCallback = [entityHandler](const std::shared_ptr<OCResourceRequest> request) ->\r
-        OCEntityHandlerResult{\r
-        return entityHandler->handleEntity(request);\r
-    };\r
-\r
-    OCResourceHandle resourceHandle;\r
-    try\r
-    {\r
-        OCStackResult result = OCPlatform::registerResource(\r
-            resourceHandle,\r
-            resourceUri,\r
-            resourceTypeName,\r
-            resourceInterface,\r
-            handleEntityCallback,\r
-            static_cast<int>(jResourceProperty));\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            delete entityHandler;\r
-            ThrowOcException(result, "register resource");\r
-            return nullptr;\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        delete entityHandler;\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-        return nullptr;\r
-    }\r
-\r
-    JniOcResourceHandle* jniHandle = new JniOcResourceHandle(resourceHandle);\r
-    jlong handle = reinterpret_cast<jlong>(jniHandle);\r
-    jobject jResourceHandle = env->NewObject(g_cls_OcResourceHandle, g_mid_OcResourceHandle_N_ctor, handle);\r
-    if (!jResourceHandle)\r
-    {\r
-        LOGE("Failed to create OcResourceHandle");\r
-        delete jniHandle;\r
-    }\r
-\r
-    return jResourceHandle;\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    registerDeviceInfo0\r
-* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0\r
-(JNIEnv *env,\r
-jclass clazz,\r
-jstring jDeviceName)\r
-{\r
-    LOGI("OcPlatform_registerDeviceInfo");\r
-\r
-    std::string deviceName;\r
-    if (jDeviceName)\r
-    {\r
-        deviceName = env->GetStringUTFChars(jDeviceName, NULL);\r
-    }\r
-\r
-    OCDeviceInfo deviceInfo;\r
-    try\r
-    {\r
-        DuplicateString(&deviceInfo.deviceName, deviceName);\r
-    }\r
-    catch (std::exception &e)\r
-    {\r
-        ThrowOcException(JNI_EXCEPTION, "Failed to construct device info");\r
-        return;\r
-    }\r
-\r
-    try\r
-    {\r
-        OCStackResult result = OCPlatform::registerDeviceInfo(deviceInfo);\r
-\r
-        delete deviceInfo.deviceName;\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "Failed to register device info");\r
-            return;\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    registerPlatformInfo0
+            ThrowOcException(result, "Failed to notify all observers");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    findResource0
+* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnResourceFoundListener;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource0
+(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener)
+{
+    LOGD("OcPlatform_findResource");
+    std::string host;
+    if (jHost)
+    {
+        host = env->GetStringUTFChars(jHost, NULL);
+    }
+    std::string resourceUri;
+    if (jResourceUri)
+    {
+        resourceUri = env->GetStringUTFChars(jResourceUri, NULL);
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onResourceFoundListener cannot be null");
+        return;
+    }
+
+    JniOnResourceFoundListener *onResFoundListener = AddOnResourceFoundListener(env, jListener);
+
+    FindCallback findCallback = [onResFoundListener](std::shared_ptr<OCResource> resource)
+    {
+        onResFoundListener->foundResourceCallback(resource);
+    };
+
+    try
+    {
+        OCStackResult result = OCPlatform::findResource(
+            host,
+            resourceUri,
+            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
+            findCallback);
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "Find resource has failed");
+            return;
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    findResource1
+* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnResourceFoundListener;I)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource1
+(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener, jint jQoS)
+{
+    LOGD("OcPlatform_findResource");
+    std::string host;
+    if (jHost)
+    {
+        host = env->GetStringUTFChars(jHost, NULL);
+    }
+    std::string resourceUri;
+    if (jResourceUri)
+    {
+        resourceUri = env->GetStringUTFChars(jResourceUri, NULL);
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onResourceFoundListener cannot be null");
+        return;
+    }
+    JniOnResourceFoundListener *onResFoundListener = AddOnResourceFoundListener(env, jListener);
+
+    FindCallback findCallback = [onResFoundListener](std::shared_ptr<OCResource> resource)
+    {
+        onResFoundListener->foundResourceCallback(resource);
+    };
+
+    try
+    {
+        OCStackResult result = OCPlatform::findResource(
+            host,
+            resourceUri,
+            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
+            findCallback,
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "Find resource has failed");
+            return;
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    getDeviceInfo0
+* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnDeviceFoundListener;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo0
+(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener)
+{
+    LOGD("OcPlatform_getDeviceInfo0");
+    std::string host;
+    if (jHost)
+    {
+        host = env->GetStringUTFChars(jHost, NULL);
+    }
+    std::string resourceUri;
+    if (jResourceUri)
+    {
+        resourceUri = env->GetStringUTFChars(jResourceUri, NULL);
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onDeviceFoundListener cannot be null");
+        return;
+    }
+    JniOnDeviceInfoListener *onDeviceInfoListener = AddOnDeviceInfoListener(env, jListener);
+
+    FindDeviceCallback findDeviceCallback = [onDeviceInfoListener](const OCRepresentation& ocRepresentation)
+    {
+        onDeviceInfoListener->foundDeviceCallback(ocRepresentation);
+    };
+
+    try
+    {
+        OCStackResult result = OCPlatform::getDeviceInfo(
+            host,
+            resourceUri,
+            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
+            findDeviceCallback);
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "Find device has failed");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    getDeviceInfo1
+* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnDeviceFoundListener;I)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo1
+(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener, jint jQoS)
+{
+    LOGD("OcPlatform_getDeviceInfo1");
+    std::string host;
+    if (jHost)
+    {
+        host = env->GetStringUTFChars(jHost, NULL);
+    }
+    std::string resourceUri;
+    if (jResourceUri)
+    {
+        resourceUri = env->GetStringUTFChars(jResourceUri, NULL);
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onDeviceFoundListener cannot be null");
+        return;
+    }
+    JniOnDeviceInfoListener *onDeviceInfoListener = AddOnDeviceInfoListener(env, jListener);
+
+    FindDeviceCallback findDeviceCallback = [onDeviceInfoListener](const OCRepresentation& ocRepresentation)
+    {
+        onDeviceInfoListener->foundDeviceCallback(ocRepresentation);
+    };
+
+    try
+    {
+        OCStackResult result = OCPlatform::getDeviceInfo(
+            host,
+            resourceUri,
+            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
+            findDeviceCallback,
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "Find device has failed");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    getPlatformInfo0
+* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPlatformFoundListener;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getPlatformInfo0
+(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener)
+{
+    LOGD("OcPlatform_getPlatformInfo0");
+    std::string host;
+    if (jHost)
+    {
+        host = env->GetStringUTFChars(jHost, NULL);
+    }
+    std::string resourceUri;
+    if (jResourceUri)
+    {
+        resourceUri = env->GetStringUTFChars(jResourceUri, NULL);
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPlatformFoundListener cannot be null");
+        return;
+    }
+    JniOnPlatformInfoListener *onPlatformInfoListener = AddOnPlatformInfoListener(env, jListener);
+
+    FindPlatformCallback findPlatformCallback = [onPlatformInfoListener](const OCRepresentation& ocRepresentation)
+    {
+        onPlatformInfoListener->foundPlatformCallback(ocRepresentation);
+    };
+
+    try
+    {
+        OCStackResult result = OCPlatform::getPlatformInfo(
+            host,
+            resourceUri,
+            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
+            findPlatformCallback);
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "Find platform has failed");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    getPlatformInfo1
+* Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPlatformFoundListener;I)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getPlatformInfo1
+(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceUri, jint jConnectivityType, jobject jListener, jint jQoS)
+{
+    LOGD("OcPlatform_getPlatformInfo1");
+    std::string host;
+    if (jHost)
+    {
+        host = env->GetStringUTFChars(jHost, NULL);
+    }
+    std::string resourceUri;
+    if (jResourceUri)
+    {
+        resourceUri = env->GetStringUTFChars(jResourceUri, NULL);
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPlatformFoundListener cannot be null");
+        return;
+    }
+    JniOnDeviceInfoListener *onDeviceInfoListener = AddOnDeviceInfoListener(env, jListener);
+
+    FindDeviceCallback findDeviceCallback = [onDeviceInfoListener](const OCRepresentation& ocRepresentation)
+    {
+        onDeviceInfoListener->foundDeviceCallback(ocRepresentation);
+    };
+
+    try
+    {
+        OCStackResult result = OCPlatform::getPlatformInfo(
+            host,
+            resourceUri,
+            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
+            findDeviceCallback,
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "Find platform has failed");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    registerResource0
+* Signature: (Lorg/iotivity/base/OcResource;)Lorg/iotivity/base/OcResourceHandle;
+*/
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource0
+(JNIEnv *env, jclass clazz, jobject jResource)
+{
+    LOGD("OcPlatform_registerResource");
+    if (!jResource)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "Resource cannot be null");
+        return nullptr;
+    }
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, jResource);
+    if (!resource) return nullptr;
+    LOGD("OcPlatform_registerResource1");
+    OCResourceHandle resourceHandle;
+    try
+    {
+        LOGD("OcPlatform_registerResource2");
+        OCStackResult result = OCPlatform::registerResource(
+            resourceHandle,
+            resource->getOCResource());
+        LOGD("OcPlatform_registerResource3");
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "register resource");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+        return nullptr;
+    }
+    LOGD("OcPlatform_registerResource4");
+    JniOcResourceHandle* jniHandle = new JniOcResourceHandle(resourceHandle);
+    jlong handle = reinterpret_cast<jlong>(jniHandle);
+    jobject jResourceHandle = env->NewObject(g_cls_OcResourceHandle, g_mid_OcResourceHandle_N_ctor, handle);
+    LOGD("OcPlatform_registerResource5");
+    if (!jResourceHandle)
+    {
+        LOGE("Failed to create OcResourceHandle");
+        delete jniHandle;
+    }
+    return jResourceHandle;
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    registerResource1
+* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcPlatform/EntityHandler;I)Lorg/iotivity/base/OcResourceHandle;
+*/
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource1
+(JNIEnv *env, jclass clazz, jstring jResourceUri, jstring jResourceTypeName, jstring jResourceInterface,
+jobject jListener, jint jResourceProperty)
+{
+    LOGI("OcPlatform_registerResource1");
+    std::string resourceUri;
+    if (jResourceUri)
+    {
+        resourceUri = env->GetStringUTFChars(jResourceUri, NULL);
+    }
+    std::string resourceTypeName;
+    if (jResourceTypeName)
+    {
+        resourceTypeName = env->GetStringUTFChars(jResourceTypeName, NULL);
+    }
+    std::string resourceInterface;
+    if (jResourceInterface)
+    {
+        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "entityHandler cannot be null");
+        return nullptr;
+    }
+    JniEntityHandler* entityHandler = new JniEntityHandler(env, jListener);
+    EntityHandler handleEntityCallback = [entityHandler](const std::shared_ptr<OCResourceRequest> request) ->
+        OCEntityHandlerResult{
+        return entityHandler->handleEntity(request);
+    };
+
+    OCResourceHandle resourceHandle;
+    try
+    {
+        OCStackResult result = OCPlatform::registerResource(
+            resourceHandle,
+            resourceUri,
+            resourceTypeName,
+            resourceInterface,
+            handleEntityCallback,
+            static_cast<int>(jResourceProperty));
+
+        if (OC_STACK_OK != result)
+        {
+            delete entityHandler;
+            ThrowOcException(result, "register resource");
+            return nullptr;
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        delete entityHandler;
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+        return nullptr;
+    }
+
+    JniOcResourceHandle* jniHandle = new JniOcResourceHandle(resourceHandle);
+    jlong handle = reinterpret_cast<jlong>(jniHandle);
+    jobject jResourceHandle = env->NewObject(g_cls_OcResourceHandle, g_mid_OcResourceHandle_N_ctor, handle);
+    if (!jResourceHandle)
+    {
+        LOGE("Failed to create OcResourceHandle");
+        delete jniHandle;
+    }
+
+    return jResourceHandle;
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    registerDeviceInfo0
+* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0
+(JNIEnv *env,
+jclass clazz,
+jstring jDeviceName)
+{
+    LOGI("OcPlatform_registerDeviceInfo");
+
+    std::string deviceName;
+    if (jDeviceName)
+    {
+        deviceName = env->GetStringUTFChars(jDeviceName, NULL);
+    }
+
+    OCDeviceInfo deviceInfo;
+    try
+    {
+        DuplicateString(&deviceInfo.deviceName, deviceName);
+    }
+    catch (std::exception &e)
+    {
+        ThrowOcException(JNI_EXCEPTION, "Failed to construct device info");
+        return;
+    }
+
+    try
+    {
+        OCStackResult result = OCPlatform::registerDeviceInfo(deviceInfo);
+
+        delete deviceInfo.deviceName;
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "Failed to register device info");
+            return;
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    registerPlatformInfo0
 * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
 */
 JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerPlatformInfo0
@@ -1082,742 +1082,742 @@ jstring jSystemTime)
         }
         if (jPlatformVersion)
         {
-            platformVersion = env->GetStringUTFChars(jPlatformVersion, NULL);
+            platformVersion = env->GetStringUTFChars(jPlatformVersion, NULL);
+        }
+        if (jOperatingSystemVersion)
+        {
+            operatingSystemVersion = env->GetStringUTFChars(jOperatingSystemVersion, NULL);
+        }
+        if (jHardwareVersion)
+        {
+            hardwareVersion = env->GetStringUTFChars(jHardwareVersion, NULL);
+        }
+        if (jFirmwareVersion)
+        {
+            firmwareVersion = env->GetStringUTFChars(jFirmwareVersion, NULL);
+        }
+        if (jSupportUrl)
+        {
+            supportUrl = env->GetStringUTFChars(jSupportUrl, NULL);
+        }
+        if (jSystemTime)
+        {
+            systemTime = env->GetStringUTFChars(jSystemTime, NULL);
+        }
+
+        OCPlatformInfo platformInfo;
+        try
+        {
+            DuplicateString(&platformInfo.platformID, platformID);
+            DuplicateString(&platformInfo.manufacturerName, manufacturerName);
+            DuplicateString(&platformInfo.manufacturerUrl, manufacturerUrl);
+            DuplicateString(&platformInfo.modelNumber, modelNumber);
+            DuplicateString(&platformInfo.dateOfManufacture, dateOfManufacture);
+            DuplicateString(&platformInfo.platformVersion, platformVersion);
+            DuplicateString(&platformInfo.operatingSystemVersion, operatingSystemVersion);
+            DuplicateString(&platformInfo.hardwareVersion, hardwareVersion);
+            DuplicateString(&platformInfo.firmwareVersion, firmwareVersion);
+            DuplicateString(&platformInfo.supportUrl, supportUrl);
+            DuplicateString(&platformInfo.systemTime, systemTime);
+        }
+        catch (std::exception &e)
+        {
+            ThrowOcException(JNI_EXCEPTION, "Failed to construct platform info");
+            return;
+        }
+
+       // __android_log_print(ANDROID_LOG_INFO, "Rahul", "platformID  = %s", platformID);
+        try
+        {
+            OCStackResult result = OCPlatform::registerPlatformInfo(platformInfo);
+
+            delete platformInfo.platformID;
+            delete platformInfo.manufacturerName;
+            delete platformInfo.manufacturerUrl;
+            delete platformInfo.modelNumber;
+            delete platformInfo.dateOfManufacture;
+            delete platformInfo.platformVersion;
+            delete platformInfo.operatingSystemVersion;
+            delete platformInfo.hardwareVersion;
+            delete platformInfo.firmwareVersion;
+            delete platformInfo.supportUrl;
+            delete platformInfo.systemTime;
+
+            if (OC_STACK_OK != result)
+            {
+                ThrowOcException(result, "Failed to register platform info");
+                return;
+            }
+        }
+        catch (OCException& e)
+        {
+            LOGE("Error is due to %s", e.reason().c_str());
+            ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+        }
+
+
+
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    unregisterResource0
+* Signature: (Lorg/iotivity/base/OcResourceHandle;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unregisterResource0
+(JNIEnv *env, jclass clazz, jobject jResourceHandle)
+{
+    LOGI("OcPlatform_unregisterResource");
+    if (!jResourceHandle)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");
+        return;
+    }
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(
+        env, jResourceHandle);
+    if (!jniOcResourceHandle) return;
+
+    try
+    {
+        OCResourceHandle resHandle = jniOcResourceHandle->getOCResourceHandle();
+        OCStackResult result = OCPlatform::unregisterResource(resHandle);
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "Failed to unregister resource");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    bindResource0
+* Signature: (Lorg/iotivity/base/OcResourceHandle;Lorg/iotivity/base/OcResourceHandle;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResource0
+(JNIEnv *env, jclass clazz, jobject jResourceCollectionHandle, jobject jResourceHandle)
+{
+    LOGI("OcPlatform_bindResource");
+    if (!jResourceCollectionHandle)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceCollectionHandle cannot be null");
+        return;
+    }
+    if (!jResourceHandle)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");
+        return;
+    }
+    JniOcResourceHandle* jniOcResourceCollectionHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(
+        env, jResourceCollectionHandle);
+    if (!jniOcResourceCollectionHandle) return;
+
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(
+        env, jResourceHandle);
+    if (!jniOcResourceHandle) return;
+
+    try
+    {
+        OCStackResult result = OCPlatform::bindResource(
+            jniOcResourceCollectionHandle->getOCResourceHandle(),
+            jniOcResourceHandle->getOCResourceHandle()
+            );
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "Failed to bind resource");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    bindResources0
+* Signature: (Lorg/iotivity/base/OcResourceHandle;[Lorg/iotivity/base/OcResourceHandle;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResources0
+(JNIEnv *env, jclass clazz, jobject jResourceCollectionHandle, jobjectArray jResourceHandleArray)
+{
+    LOGI("OcPlatform_bindResources");
+
+    if (!jResourceCollectionHandle)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceCollectionHandle cannot be null");
+        return;
+    }
+    if (!jResourceHandleArray)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandleList cannot be null");
+        return;
+    }
+
+    JniOcResourceHandle* jniOcResourceCollectionHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(
+        env, jResourceCollectionHandle);
+    if (!jniOcResourceCollectionHandle) return;
+
+    std::vector<OCResourceHandle> resourceHandleList;
+    int len = env->GetArrayLength(jResourceHandleArray);
+    for (int i = 0; i < len; ++i)
+    {
+        jobject jResourceHandle = env->GetObjectArrayElement(jResourceHandleArray, i);
+        if (!jResourceHandle)
+        {
+            ThrowOcException(JNI_EXCEPTION, "resource handle cannot be null");
+            return;
+        }
+
+        JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(
+            env, jResourceHandle);
+        if (!jniOcResourceHandle) return;
+
+        resourceHandleList.push_back(
+            jniOcResourceHandle->getOCResourceHandle());
+    }
+
+    try
+    {
+        OCStackResult result = OCPlatform::bindResources(
+            jniOcResourceCollectionHandle->getOCResourceHandle(),
+            resourceHandleList
+            );
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "Failed to bind resources");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    unbindResource0
+* Signature: (Lorg/iotivity/base/OcResourceHandle;Lorg/iotivity/base/OcResourceHandle;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unbindResource0
+(JNIEnv *env, jclass clazz, jobject jResourceCollectionHandle, jobject jResourceHandle)
+{
+    LOGI("OcPlatform_unbindResource");
+    if (!jResourceCollectionHandle)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceCollectionHandle cannot be null");
+        return;
+    }
+    if (!jResourceHandle)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");
+        return;
+    }
+
+    JniOcResourceHandle* jniOcResourceCollectionHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(
+        env, jResourceCollectionHandle);
+    if (!jniOcResourceCollectionHandle) return;
+
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(
+        env, jResourceHandle);
+    if (!jniOcResourceHandle) return;
+
+    try
+    {
+        OCStackResult result = OCPlatform::unbindResource(
+            jniOcResourceCollectionHandle->getOCResourceHandle(),
+            jniOcResourceHandle->getOCResourceHandle()
+            );
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "Failed to unbind resource");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    unbindResources0
+* Signature: (Lorg/iotivity/base/OcResourceHandle;[Lorg/iotivity/base/OcResourceHandle;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unbindResources0
+(JNIEnv *env, jclass clazz, jobject jResourceCollectionHandle, jobjectArray jResourceHandleArray)
+{
+    LOGI("OcPlatform_unbindResources");
+    if (!jResourceCollectionHandle)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceCollectionHandle cannot be null");
+        return;
+    }
+    if (!jResourceHandleArray)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandleList cannot be null");
+        return;
+    }
+
+    JniOcResourceHandle* jniOcResourceCollectionHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(
+        env, jResourceCollectionHandle);
+    if (!jniOcResourceCollectionHandle) return;
+
+    std::vector<OCResourceHandle> resourceHandleList;
+    int len = env->GetArrayLength(jResourceHandleArray);
+    for (int i = 0; i < len; ++i)
+    {
+        jobject jResourceHandle = env->GetObjectArrayElement(jResourceHandleArray, i);
+        if (!jResourceHandle)
+        {
+            ThrowOcException(JNI_EXCEPTION, "resource handle cannot be null");
+            return;
+        }
+
+        JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(
+            env, jResourceHandle);
+        if (!jniOcResourceHandle) return;
+
+        resourceHandleList.push_back(
+            jniOcResourceHandle->getOCResourceHandle());
+    }
+
+    try
+    {
+        OCStackResult result = OCPlatform::unbindResources(
+            jniOcResourceCollectionHandle->getOCResourceHandle(),
+            resourceHandleList
+            );
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "Failed to unbind resources");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    bindTypeToResource0
+* Signature: (Lorg/iotivity/base/OcResourceHandle;Ljava/lang/String;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindTypeToResource0
+(JNIEnv *env, jclass clazz, jobject jResourceHandle, jstring jResourceTypeName)
+{
+    LOGI("OcPlatform_bindTypeToResource");
+    if (!jResourceHandle)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");
+        return;
+    }
+    std::string typeName;
+    if (jResourceTypeName)
+    {
+        typeName = env->GetStringUTFChars(jResourceTypeName, NULL);
+    }
+
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(
+        env, jResourceHandle);
+    if (!jniOcResourceHandle) return;
+
+    try
+    {
+        OCStackResult result = OCPlatform::bindTypeToResource(
+            jniOcResourceHandle->getOCResourceHandle(),
+            typeName
+            );
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "Failed to bind type to resource");
         }
-        if (jOperatingSystemVersion)
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    bindInterfaceToResource0
+* Signature: (Lorg/iotivity/base/OcResourceHandle;Ljava/lang/String;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindInterfaceToResource0
+(JNIEnv *env, jclass clazz, jobject jResourceHandle, jstring jResourceInterfaceName)
+{
+    LOGI("OcPlatform_bindInterfaceToResource");
+    if (!jResourceHandle)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");
+        return;
+    }
+    std::string interfaceName;
+    if (jResourceInterfaceName)
+    {
+        interfaceName = env->GetStringUTFChars(jResourceInterfaceName, NULL);
+    }
+
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(
+        env, jResourceHandle);
+    if (!jniOcResourceHandle) return;
+
+    try
+    {
+        OCStackResult result = OCPlatform::bindInterfaceToResource(
+            jniOcResourceHandle->getOCResourceHandle(),
+            interfaceName
+            );
+
+        if (OC_STACK_OK != result)
         {
-            operatingSystemVersion = env->GetStringUTFChars(jOperatingSystemVersion, NULL);
+            ThrowOcException(result, "Failed to bind interface to resource");
         }
-        if (jHardwareVersion)
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    startPresence0
+* Signature: (I)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_startPresence0
+(JNIEnv *env, jclass clazz, jint ttl)
+{
+    LOGI("OcPlatform_startPresence");
+
+    try
+    {
+        OCStackResult result = OCPlatform::startPresence((unsigned int)ttl);
+
+        if (OC_STACK_OK != result)
         {
-            hardwareVersion = env->GetStringUTFChars(jHardwareVersion, NULL);
+            ThrowOcException(result, "Failed to start presence");
         }
-        if (jFirmwareVersion)
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    stopPresence0
+* Signature: ()V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_stopPresence0
+(JNIEnv *env, jclass clazz)
+{
+    LOGI("OcPlatform_stopPresence");
+
+    try
+    {
+        OCStackResult result = OCPlatform::stopPresence();
+
+        if (OC_STACK_OK != result)
         {
-            firmwareVersion = env->GetStringUTFChars(jFirmwareVersion, NULL);
+            ThrowOcException(result, "Failed to stop presence");
         }
-        if (jSupportUrl)
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    subscribePresence0
+* Signature: (Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPresenceListener;)Lorg/iotivity/base/OcPresenceHandle;
+*/
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence0
+(JNIEnv *env, jclass clazz, jstring jHost, jint jConnectivityType, jobject jListener)
+{
+    LOGD("OcPlatform_subscribePresence");
+    std::string host;
+    if (jHost)
+    {
+        host = env->GetStringUTFChars(jHost, NULL);
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPresenceListener cannot be null");
+        return nullptr;
+    }
+
+    JniOnPresenceListener *onPresenceListener = AddOnPresenceListener(env, jListener);
+
+    SubscribeCallback subscribeCallback = [onPresenceListener](OCStackResult result, const unsigned int nonce,
+        const std::string& hostAddress)
+    {
+        onPresenceListener->onPresenceCallback(result, nonce, hostAddress);
+    };
+
+    OCPlatform::OCPresenceHandle presenceHandle;
+    try
+    {
+        OCStackResult result = OCPlatform::subscribePresence(
+            presenceHandle,
+            host,
+            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
+            subscribeCallback);
+
+        if (OC_STACK_OK != result)
         {
-            supportUrl = env->GetStringUTFChars(jSupportUrl, NULL);
+            ThrowOcException(result, "subscribe presence has failed");
         }
-        if (jSystemTime)
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+        return nullptr;
+    }
+
+    JniOcPresenceHandle* jniPresenceHandle = new JniOcPresenceHandle(onPresenceListener, presenceHandle);
+    jlong jhandle = reinterpret_cast<jlong>(jniPresenceHandle);
+    jobject jPresenceHandle = env->NewObject(g_cls_OcPresenceHandle, g_mid_OcPresenceHandle_N_ctor, jhandle);
+    if (!jPresenceHandle)
+    {
+        LOGE("Failed to create OcPresenceHandle");
+        delete jniPresenceHandle;
+    }
+    return jPresenceHandle;
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    subscribePresence1
+* Signature: (Ljava/lang/String;Ljava/lang/String;I
+Lorg/iotivity/base/OcPlatform/OnPresenceListener;)Lorg/iotivity/base/OcPresenceHandle;
+*/
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence1
+(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceType, jint jConnectivityType, jobject jListener)
+{
+    LOGD("OcPlatform_subscribePresence1");
+    std::string host;
+    if (jHost)
+    {
+        host = env->GetStringUTFChars(jHost, NULL);
+    }
+    std::string resourceType;
+    if (jResourceType)
+    {
+        resourceType = env->GetStringUTFChars(jResourceType, NULL);
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPresenceListener cannot be null");
+        return nullptr;
+    }
+
+    JniOnPresenceListener *onPresenceListener = AddOnPresenceListener(env, jListener);
+
+    SubscribeCallback subscribeCallback = [onPresenceListener](OCStackResult result,
+        const unsigned int nonce, const std::string& hostAddress)
+    {
+        onPresenceListener->onPresenceCallback(result, nonce, hostAddress);
+    };
+
+    OCPlatform::OCPresenceHandle presenceHandle;
+    try
+    {
+        OCStackResult result = OCPlatform::subscribePresence(
+            presenceHandle,
+            host,
+            resourceType,
+            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
+            subscribeCallback);
+
+        if (OC_STACK_OK != result)
         {
-            systemTime = env->GetStringUTFChars(jSystemTime, NULL);
+            ThrowOcException(result, "subscribe presence has failed");
         }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+        return nullptr;
+    }
 
-        OCPlatformInfo platformInfo;
-        try
+    JniOcPresenceHandle* jniPresenceHandle = new JniOcPresenceHandle(onPresenceListener, presenceHandle);
+    jlong jhandle = reinterpret_cast<jlong>(jniPresenceHandle);
+    jobject jPresenceHandle = env->NewObject(g_cls_OcPresenceHandle, g_mid_OcPresenceHandle_N_ctor, jhandle);
+    if (!jPresenceHandle)
+    {
+        LOGE("Failed to create OcPresenceHandle");
+        delete jniPresenceHandle;
+    }
+    return jPresenceHandle;
+}
+
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    unsubscribePresence0
+* Signature: (Lorg/iotivity/base/OcPresenceHandle;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unsubscribePresence0
+(JNIEnv *env, jclass clazz, jobject jPresenceHandle)
+{
+    LOGD("OcPlatform_unsubscribePresence");
+    if (!jPresenceHandle)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "presenceHandle cannot be null");
+        return;
+    }
+    JniOcPresenceHandle* jniPresenceHandle = JniOcPresenceHandle::getJniOcPresenceHandlePtr(env, jPresenceHandle);
+    if (!jniPresenceHandle) return;
+
+    OCPresenceHandle presenceHandle = jniPresenceHandle->getOCPresenceHandle();
+
+    try
+    {
+        OCStackResult result = OCPlatform::unsubscribePresence(presenceHandle);
+
+        if (OC_STACK_OK != result)
         {
-            DuplicateString(&platformInfo.platformID, platformID);
-            DuplicateString(&platformInfo.manufacturerName, manufacturerName);
-            DuplicateString(&platformInfo.manufacturerUrl, manufacturerUrl);
-            DuplicateString(&platformInfo.modelNumber, modelNumber);
-            DuplicateString(&platformInfo.dateOfManufacture, dateOfManufacture);
-            DuplicateString(&platformInfo.platformVersion, platformVersion);
-            DuplicateString(&platformInfo.operatingSystemVersion, operatingSystemVersion);
-            DuplicateString(&platformInfo.hardwareVersion, hardwareVersion);
-            DuplicateString(&platformInfo.firmwareVersion, firmwareVersion);
-            DuplicateString(&platformInfo.supportUrl, supportUrl);
-            DuplicateString(&platformInfo.systemTime, systemTime);
+            ThrowOcException(result, "unsubscribe presence has failed");
+            return;
         }
-        catch (std::exception &e)
+        jweak jwOnPresenceListener = jniPresenceHandle->getJniOnPresenceListener()->getJWListener();
+        if (jwOnPresenceListener)
         {
-            ThrowOcException(JNI_EXCEPTION, "Failed to construct platform info");
-            return;
+            RemoveOnPresenceListener(env, jwOnPresenceListener);
         }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+    }
+}
 
-       // __android_log_print(ANDROID_LOG_INFO, "Rahul", "platformID  = %s", platformID);
-        try
-        {
-            OCStackResult result = OCPlatform::registerPlatformInfo(platformInfo);
+/*
+* Class:     org_iotivity_base_OcPlatform
+* Method:    constructResourceObject0
+* Signature: (Ljava/lang/String;Ljava/lang/String;IZ[Ljava/lang/String;[Ljava/lang/String;)
+Lorg/iotivity/base/OcResource;
+*/
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_constructResourceObject0
+(JNIEnv *env, jclass clazz, jstring jHost, jstring jUri, jint jConnectivityType,
+jboolean jIsObservable, jobjectArray jResourceTypeArray, jobjectArray jInterfaceArray)
+{
+    LOGD("OcPlatform_constructResourceObject");
+    std::string host;
+    if (jHost)
+    {
+        host = env->GetStringUTFChars(jHost, NULL);
+    }
+    std::string uri;
+    if (jUri)
+    {
+        uri = env->GetStringUTFChars(jUri, NULL);
+    }
+    if (!jResourceTypeArray)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceTypeList cannot be null");
+        return nullptr;
+    }
+    if (!jInterfaceArray)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "interfaceList cannot be null");
+        return nullptr;
+    }
 
-            delete platformInfo.platformID;
-            delete platformInfo.manufacturerName;
-            delete platformInfo.manufacturerUrl;
-            delete platformInfo.modelNumber;
-            delete platformInfo.dateOfManufacture;
-            delete platformInfo.platformVersion;
-            delete platformInfo.operatingSystemVersion;
-            delete platformInfo.hardwareVersion;
-            delete platformInfo.firmwareVersion;
-            delete platformInfo.supportUrl;
-            delete platformInfo.systemTime;
+    std::vector<std::string> resourceTypes;
+    JniUtils::convertJavaStrArrToStrVector(env, jResourceTypeArray, resourceTypes);
 
-            if (OC_STACK_OK != result)
-            {
-                ThrowOcException(result, "Failed to register platform info");
-                return;
-            }
-        }
-        catch (OCException& e)
-        {
-            LOGE("Error is due to %s", e.reason().c_str());
-            ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
-        }
+    std::vector<std::string> interfaces;
+    JniUtils::convertJavaStrArrToStrVector(env, jInterfaceArray, interfaces);
 
+    std::shared_ptr<OCResource> resource = OCPlatform::constructResourceObject(
+        host,
+        uri,
+        JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),
+        static_cast<bool>(jIsObservable),
+        resourceTypes,
+        interfaces);
+
+    if (!resource)
+    {
+        ThrowOcException(OC_STACK_ERROR, "Failed to create OCResource");
+        return nullptr;
+    }
 
+    JniOcResource *jniOcResource = new JniOcResource(resource);
+    jlong handle = reinterpret_cast<jlong>(jniOcResource);
 
+    jobject jResource = env->NewObject(g_cls_OcResource, g_mid_OcResource_ctor);
+    if (!jResource)
+    {
+        delete jniOcResource;
+        return nullptr;
+    }
+    SetHandle<JniOcResource>(env, jResource, jniOcResource);
+    if (env->ExceptionCheck())
+    {
+        delete jniOcResource;
+        return nullptr;
+    }
+    return jResource;
 }
 
 /*
 * Class:     org_iotivity_base_OcPlatform
-* Method:    unregisterResource0\r
-* Signature: (Lorg/iotivity/base/OcResourceHandle;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unregisterResource0\r
-(JNIEnv *env, jclass clazz, jobject jResourceHandle)\r
-{\r
-    LOGI("OcPlatform_unregisterResource");\r
-    if (!jResourceHandle)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
-        return;\r
-    }\r
-    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
-        env, jResourceHandle);\r
-    if (!jniOcResourceHandle) return;\r
-\r
-    try\r
-    {\r
-        OCResourceHandle resHandle = jniOcResourceHandle->getOCResourceHandle();\r
-        OCStackResult result = OCPlatform::unregisterResource(resHandle);\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "Failed to unregister resource");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    bindResource0\r
-* Signature: (Lorg/iotivity/base/OcResourceHandle;Lorg/iotivity/base/OcResourceHandle;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResource0\r
-(JNIEnv *env, jclass clazz, jobject jResourceCollectionHandle, jobject jResourceHandle)\r
-{\r
-    LOGI("OcPlatform_bindResource");\r
-    if (!jResourceCollectionHandle)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceCollectionHandle cannot be null");\r
-        return;\r
-    }\r
-    if (!jResourceHandle)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
-        return;\r
-    }\r
-    JniOcResourceHandle* jniOcResourceCollectionHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
-        env, jResourceCollectionHandle);\r
-    if (!jniOcResourceCollectionHandle) return;\r
-\r
-    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
-        env, jResourceHandle);\r
-    if (!jniOcResourceHandle) return;\r
-\r
-    try\r
-    {\r
-        OCStackResult result = OCPlatform::bindResource(\r
-            jniOcResourceCollectionHandle->getOCResourceHandle(),\r
-            jniOcResourceHandle->getOCResourceHandle()\r
-            );\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "Failed to bind resource");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    bindResources0\r
-* Signature: (Lorg/iotivity/base/OcResourceHandle;[Lorg/iotivity/base/OcResourceHandle;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResources0\r
-(JNIEnv *env, jclass clazz, jobject jResourceCollectionHandle, jobjectArray jResourceHandleArray)\r
-{\r
-    LOGI("OcPlatform_bindResources");\r
-\r
-    if (!jResourceCollectionHandle)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceCollectionHandle cannot be null");\r
-        return;\r
-    }\r
-    if (!jResourceHandleArray)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandleList cannot be null");\r
-        return;\r
-    }\r
-\r
-    JniOcResourceHandle* jniOcResourceCollectionHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
-        env, jResourceCollectionHandle);\r
-    if (!jniOcResourceCollectionHandle) return;\r
-\r
-    std::vector<OCResourceHandle> resourceHandleList;\r
-    int len = env->GetArrayLength(jResourceHandleArray);\r
-    for (int i = 0; i < len; ++i)\r
-    {\r
-        jobject jResourceHandle = env->GetObjectArrayElement(jResourceHandleArray, i);\r
-        if (!jResourceHandle)\r
-        {\r
-            ThrowOcException(JNI_EXCEPTION, "resource handle cannot be null");\r
-            return;\r
-        }\r
-\r
-        JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
-            env, jResourceHandle);\r
-        if (!jniOcResourceHandle) return;\r
-\r
-        resourceHandleList.push_back(\r
-            jniOcResourceHandle->getOCResourceHandle());\r
-    }\r
-\r
-    try\r
-    {\r
-        OCStackResult result = OCPlatform::bindResources(\r
-            jniOcResourceCollectionHandle->getOCResourceHandle(),\r
-            resourceHandleList\r
-            );\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "Failed to bind resources");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    unbindResource0\r
-* Signature: (Lorg/iotivity/base/OcResourceHandle;Lorg/iotivity/base/OcResourceHandle;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unbindResource0\r
-(JNIEnv *env, jclass clazz, jobject jResourceCollectionHandle, jobject jResourceHandle)\r
-{\r
-    LOGI("OcPlatform_unbindResource");\r
-    if (!jResourceCollectionHandle)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceCollectionHandle cannot be null");\r
-        return;\r
-    }\r
-    if (!jResourceHandle)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
-        return;\r
-    }\r
-\r
-    JniOcResourceHandle* jniOcResourceCollectionHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
-        env, jResourceCollectionHandle);\r
-    if (!jniOcResourceCollectionHandle) return;\r
-\r
-    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
-        env, jResourceHandle);\r
-    if (!jniOcResourceHandle) return;\r
-\r
-    try\r
-    {\r
-        OCStackResult result = OCPlatform::unbindResource(\r
-            jniOcResourceCollectionHandle->getOCResourceHandle(),\r
-            jniOcResourceHandle->getOCResourceHandle()\r
-            );\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "Failed to unbind resource");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    unbindResources0\r
-* Signature: (Lorg/iotivity/base/OcResourceHandle;[Lorg/iotivity/base/OcResourceHandle;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unbindResources0\r
-(JNIEnv *env, jclass clazz, jobject jResourceCollectionHandle, jobjectArray jResourceHandleArray)\r
-{\r
-    LOGI("OcPlatform_unbindResources");\r
-    if (!jResourceCollectionHandle)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceCollectionHandle cannot be null");\r
-        return;\r
-    }\r
-    if (!jResourceHandleArray)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandleList cannot be null");\r
-        return;\r
-    }\r
-\r
-    JniOcResourceHandle* jniOcResourceCollectionHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
-        env, jResourceCollectionHandle);\r
-    if (!jniOcResourceCollectionHandle) return;\r
-\r
-    std::vector<OCResourceHandle> resourceHandleList;\r
-    int len = env->GetArrayLength(jResourceHandleArray);\r
-    for (int i = 0; i < len; ++i)\r
-    {\r
-        jobject jResourceHandle = env->GetObjectArrayElement(jResourceHandleArray, i);\r
-        if (!jResourceHandle)\r
-        {\r
-            ThrowOcException(JNI_EXCEPTION, "resource handle cannot be null");\r
-            return;\r
-        }\r
-\r
-        JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
-            env, jResourceHandle);\r
-        if (!jniOcResourceHandle) return;\r
-\r
-        resourceHandleList.push_back(\r
-            jniOcResourceHandle->getOCResourceHandle());\r
-    }\r
-\r
-    try\r
-    {\r
-        OCStackResult result = OCPlatform::unbindResources(\r
-            jniOcResourceCollectionHandle->getOCResourceHandle(),\r
-            resourceHandleList\r
-            );\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "Failed to unbind resources");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    bindTypeToResource0\r
-* Signature: (Lorg/iotivity/base/OcResourceHandle;Ljava/lang/String;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindTypeToResource0\r
-(JNIEnv *env, jclass clazz, jobject jResourceHandle, jstring jResourceTypeName)\r
-{\r
-    LOGI("OcPlatform_bindTypeToResource");\r
-    if (!jResourceHandle)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
-        return;\r
-    }\r
-    std::string typeName;\r
-    if (jResourceTypeName)\r
-    {\r
-        typeName = env->GetStringUTFChars(jResourceTypeName, NULL);\r
-    }\r
-\r
-    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
-        env, jResourceHandle);\r
-    if (!jniOcResourceHandle) return;\r
-\r
-    try\r
-    {\r
-        OCStackResult result = OCPlatform::bindTypeToResource(\r
-            jniOcResourceHandle->getOCResourceHandle(),\r
-            typeName\r
-            );\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "Failed to bind type to resource");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    bindInterfaceToResource0\r
-* Signature: (Lorg/iotivity/base/OcResourceHandle;Ljava/lang/String;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindInterfaceToResource0\r
-(JNIEnv *env, jclass clazz, jobject jResourceHandle, jstring jResourceInterfaceName)\r
-{\r
-    LOGI("OcPlatform_bindInterfaceToResource");\r
-    if (!jResourceHandle)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
-        return;\r
-    }\r
-    std::string interfaceName;\r
-    if (jResourceInterfaceName)\r
-    {\r
-        interfaceName = env->GetStringUTFChars(jResourceInterfaceName, NULL);\r
-    }\r
-\r
-    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(\r
-        env, jResourceHandle);\r
-    if (!jniOcResourceHandle) return;\r
-\r
-    try\r
-    {\r
-        OCStackResult result = OCPlatform::bindInterfaceToResource(\r
-            jniOcResourceHandle->getOCResourceHandle(),\r
-            interfaceName\r
-            );\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "Failed to bind interface to resource");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    startPresence0\r
-* Signature: (I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_startPresence0\r
-(JNIEnv *env, jclass clazz, jint ttl)\r
-{\r
-    LOGI("OcPlatform_startPresence");\r
-\r
-    try\r
-    {\r
-        OCStackResult result = OCPlatform::startPresence((unsigned int)ttl);\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "Failed to start presence");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    stopPresence0\r
-* Signature: ()V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_stopPresence0\r
-(JNIEnv *env, jclass clazz)\r
-{\r
-    LOGI("OcPlatform_stopPresence");\r
-\r
-    try\r
-    {\r
-        OCStackResult result = OCPlatform::stopPresence();\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "Failed to stop presence");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    subscribePresence0\r
-* Signature: (Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPresenceListener;)Lorg/iotivity/base/OcPresenceHandle;\r
-*/\r
-JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence0\r
-(JNIEnv *env, jclass clazz, jstring jHost, jint jConnectivityType, jobject jListener)\r
-{\r
-    LOGD("OcPlatform_subscribePresence");\r
-    std::string host;\r
-    if (jHost)\r
-    {\r
-        host = env->GetStringUTFChars(jHost, NULL);\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onPresenceListener cannot be null");\r
-        return nullptr;\r
-    }\r
-\r
-    JniOnPresenceListener *onPresenceListener = AddOnPresenceListener(env, jListener);\r
-\r
-    SubscribeCallback subscribeCallback = [onPresenceListener](OCStackResult result, const unsigned int nonce,\r
-        const std::string& hostAddress)\r
-    {\r
-        onPresenceListener->onPresenceCallback(result, nonce, hostAddress);\r
-    };\r
-\r
-    OCPlatform::OCPresenceHandle presenceHandle;\r
-    try\r
-    {\r
-        OCStackResult result = OCPlatform::subscribePresence(\r
-            presenceHandle,\r
-            host,\r
-            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),\r
-            subscribeCallback);\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "subscribe presence has failed");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-        return nullptr;\r
-    }\r
-\r
-    JniOcPresenceHandle* jniPresenceHandle = new JniOcPresenceHandle(onPresenceListener, presenceHandle);\r
-    jlong jhandle = reinterpret_cast<jlong>(jniPresenceHandle);\r
-    jobject jPresenceHandle = env->NewObject(g_cls_OcPresenceHandle, g_mid_OcPresenceHandle_N_ctor, jhandle);\r
-    if (!jPresenceHandle)\r
-    {\r
-        LOGE("Failed to create OcPresenceHandle");\r
-        delete jniPresenceHandle;\r
-    }\r
-    return jPresenceHandle;\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    subscribePresence1\r
-* Signature: (Ljava/lang/String;Ljava/lang/String;I\r
-Lorg/iotivity/base/OcPlatform/OnPresenceListener;)Lorg/iotivity/base/OcPresenceHandle;\r
-*/\r
-JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence1\r
-(JNIEnv *env, jclass clazz, jstring jHost, jstring jResourceType, jint jConnectivityType, jobject jListener)\r
-{\r
-    LOGD("OcPlatform_subscribePresence1");\r
-    std::string host;\r
-    if (jHost)\r
-    {\r
-        host = env->GetStringUTFChars(jHost, NULL);\r
-    }\r
-    std::string resourceType;\r
-    if (jResourceType)\r
-    {\r
-        resourceType = env->GetStringUTFChars(jResourceType, NULL);\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onPresenceListener cannot be null");\r
-        return nullptr;\r
-    }\r
-\r
-    JniOnPresenceListener *onPresenceListener = AddOnPresenceListener(env, jListener);\r
-\r
-    SubscribeCallback subscribeCallback = [onPresenceListener](OCStackResult result,\r
-        const unsigned int nonce, const std::string& hostAddress)\r
-    {\r
-        onPresenceListener->onPresenceCallback(result, nonce, hostAddress);\r
-    };\r
-\r
-    OCPlatform::OCPresenceHandle presenceHandle;\r
-    try\r
-    {\r
-        OCStackResult result = OCPlatform::subscribePresence(\r
-            presenceHandle,\r
-            host,\r
-            resourceType,\r
-            JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),\r
-            subscribeCallback);\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "subscribe presence has failed");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-        return nullptr;\r
-    }\r
-\r
-    JniOcPresenceHandle* jniPresenceHandle = new JniOcPresenceHandle(onPresenceListener, presenceHandle);\r
-    jlong jhandle = reinterpret_cast<jlong>(jniPresenceHandle);\r
-    jobject jPresenceHandle = env->NewObject(g_cls_OcPresenceHandle, g_mid_OcPresenceHandle_N_ctor, jhandle);\r
-    if (!jPresenceHandle)\r
-    {\r
-        LOGE("Failed to create OcPresenceHandle");\r
-        delete jniPresenceHandle;\r
-    }\r
-    return jPresenceHandle;\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    unsubscribePresence0\r
-* Signature: (Lorg/iotivity/base/OcPresenceHandle;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unsubscribePresence0\r
-(JNIEnv *env, jclass clazz, jobject jPresenceHandle)\r
-{\r
-    LOGD("OcPlatform_unsubscribePresence");\r
-    if (!jPresenceHandle)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "presenceHandle cannot be null");\r
-        return;\r
-    }\r
-    JniOcPresenceHandle* jniPresenceHandle = JniOcPresenceHandle::getJniOcPresenceHandlePtr(env, jPresenceHandle);\r
-    if (!jniPresenceHandle) return;\r
-\r
-    OCPresenceHandle presenceHandle = jniPresenceHandle->getOCPresenceHandle();\r
-\r
-    try\r
-    {\r
-        OCStackResult result = OCPlatform::unsubscribePresence(presenceHandle);\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "unsubscribe presence has failed");\r
-            return;\r
-        }\r
-        jweak jwOnPresenceListener = jniPresenceHandle->getJniOnPresenceListener()->getJWListener();\r
-        if (jwOnPresenceListener)\r
-        {\r
-            RemoveOnPresenceListener(env, jwOnPresenceListener);\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    constructResourceObject0\r
-* Signature: (Ljava/lang/String;Ljava/lang/String;IZ[Ljava/lang/String;[Ljava/lang/String;)\r
-Lorg/iotivity/base/OcResource;\r
-*/\r
-JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_constructResourceObject0\r
-(JNIEnv *env, jclass clazz, jstring jHost, jstring jUri, jint jConnectivityType,\r
-jboolean jIsObservable, jobjectArray jResourceTypeArray, jobjectArray jInterfaceArray)\r
-{\r
-    LOGD("OcPlatform_constructResourceObject");\r
-    std::string host;\r
-    if (jHost)\r
-    {\r
-        host = env->GetStringUTFChars(jHost, NULL);\r
-    }\r
-    std::string uri;\r
-    if (jUri)\r
-    {\r
-        uri = env->GetStringUTFChars(jUri, NULL);\r
-    }\r
-    if (!jResourceTypeArray)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceTypeList cannot be null");\r
-        return nullptr;\r
-    }\r
-    if (!jInterfaceArray)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "interfaceList cannot be null");\r
-        return nullptr;\r
-    }\r
-\r
-    std::vector<std::string> resourceTypes;\r
-    JniUtils::convertJavaStrArrToStrVector(env, jResourceTypeArray, resourceTypes);\r
-\r
-    std::vector<std::string> interfaces;\r
-    JniUtils::convertJavaStrArrToStrVector(env, jInterfaceArray, interfaces);\r
-\r
-    std::shared_ptr<OCResource> resource = OCPlatform::constructResourceObject(\r
-        host,\r
-        uri,\r
-        JniUtils::getConnectivityType(env, static_cast<int>(jConnectivityType)),\r
-        static_cast<bool>(jIsObservable),\r
-        resourceTypes,\r
-        interfaces);\r
-\r
-    if (!resource)\r
-    {\r
-        ThrowOcException(OC_STACK_ERROR, "Failed to create OCResource");\r
-        return nullptr;\r
-    }\r
-\r
-    JniOcResource *jniOcResource = new JniOcResource(resource);\r
-    jlong handle = reinterpret_cast<jlong>(jniOcResource);\r
-\r
-    jobject jResource = env->NewObject(g_cls_OcResource, g_mid_OcResource_ctor);\r
-    if (!jResource)\r
-    {\r
-        delete jniOcResource;\r
-        return nullptr;\r
-    }\r
-    SetHandle<JniOcResource>(env, jResource, jniOcResource);\r
-    if (env->ExceptionCheck())\r
-    {\r
-        delete jniOcResource;\r
-        return nullptr;\r
-    }\r
-    return jResource;\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPlatform\r
-* Method:    sendResponse0\r
-* Signature: (Lorg/iotivity/base/OcResourceResponse;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_sendResponse0\r
-(JNIEnv *env, jclass clazz, jobject jResourceResponse)\r
-{\r
-    LOGD("OcPlatform_sendResponse");\r
-    if (!jResourceResponse)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceResponse cannot be null");\r
-        return;\r
-    }\r
-\r
-    JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(\r
-        env, jResourceResponse);\r
-    if (!jniResponse) return;\r
-\r
-    try\r
-    {\r
-        OCStackResult result = OCPlatform::sendResponse(jniResponse->getOCResourceResponse());\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "failed to send response");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());\r
-    }\r
+* Method:    sendResponse0
+* Signature: (Lorg/iotivity/base/OcResourceResponse;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_sendResponse0
+(JNIEnv *env, jclass clazz, jobject jResourceResponse)
+{
+    LOGD("OcPlatform_sendResponse");
+    if (!jResourceResponse)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceResponse cannot be null");
+        return;
+    }
+
+    JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(
+        env, jResourceResponse);
+    if (!jniResponse) return;
+
+    try
+    {
+        OCStackResult result = OCPlatform::sendResponse(jniResponse->getOCResourceResponse());
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "failed to send response");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(OC_STACK_ERROR, e.reason().c_str());
+    }
 }
index ca7051e..cfd6853 100644 (file)
-/*\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 "JniOcStack.h"\r
-#include "JniOnResourceFoundListener.h"\r
-#include "JniOnDeviceInfoListener.h"\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 "JniOcStack.h"
+#include "JniOnResourceFoundListener.h"
+#include "JniOnDeviceInfoListener.h"
 #include "JniOnPlatformInfoListener.h"
-#include "JniOnPresenceListener.h"\r
-#include <mutex>\r
-\r
-#ifndef _Included_org_iotivity_base_OcPlatform\r
-#define _Included_org_iotivity_base_OcPlatform\r
-\r
-using namespace OC;\r
-\r
-JniOnResourceFoundListener* AddOnResourceFoundListener(JNIEnv* env, jobject jListener);\r
-void RemoveOnResourceFoundListener(JNIEnv* env, jobject jListener);\r
-\r
-JniOnDeviceInfoListener* AddOnDeviceInfoListener(JNIEnv* env, jobject jListener);\r
-void RemoveOnDeviceInfoListener(JNIEnv* env, jobject jListener);\r
-\r
+#include "JniOnPresenceListener.h"
+#include <mutex>
+
+#ifndef _Included_org_iotivity_base_OcPlatform
+#define _Included_org_iotivity_base_OcPlatform
+
+using namespace OC;
+
+JniOnResourceFoundListener* AddOnResourceFoundListener(JNIEnv* env, jobject jListener);
+void RemoveOnResourceFoundListener(JNIEnv* env, jobject jListener);
+
+JniOnDeviceInfoListener* AddOnDeviceInfoListener(JNIEnv* env, jobject jListener);
+void RemoveOnDeviceInfoListener(JNIEnv* env, jobject jListener);
+
 JniOnPlatformInfoListener* AddOnPlatformInfoListener(JNIEnv* env, jobject jListener);
 void RemoveOnPlatformInfoListener(JNIEnv* env, jobject jListener);
 
-JniOnPresenceListener* AddOnPresenceListener(JNIEnv* env, jobject jListener);\r
-void RemoveOnPresenceListener(JNIEnv* env, jobject jListener);\r
-\r
-std::map<jobject, std::pair<JniOnResourceFoundListener*, int>> onResourceFoundListenerMap;\r
-std::map<jobject, std::pair<JniOnDeviceInfoListener*, int>> onDeviceInfoListenerMap;\r
+JniOnPresenceListener* AddOnPresenceListener(JNIEnv* env, jobject jListener);
+void RemoveOnPresenceListener(JNIEnv* env, jobject jListener);
+
+std::map<jobject, std::pair<JniOnResourceFoundListener*, int>> onResourceFoundListenerMap;
+std::map<jobject, std::pair<JniOnDeviceInfoListener*, int>> onDeviceInfoListenerMap;
 std::map<jobject, std::pair<JniOnPlatformInfoListener*, int>> onPlatformInfoListenerMap;
-std::map<jobject, std::pair<JniOnPresenceListener*, int>> onPresenceListenerMap;\r
-\r
-std::mutex resourceFoundMapLock;\r
-std::mutex deviceInfoMapLock;\r
+std::map<jobject, std::pair<JniOnPresenceListener*, int>> onPresenceListenerMap;
+
+std::mutex resourceFoundMapLock;
+std::mutex deviceInfoMapLock;
 std::mutex platformInfoMapLock;
-std::mutex presenceMapLock;\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    configure\r
-    * Signature: (IILjava/lang/String;II)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_configure\r
+std::mutex presenceMapLock;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    configure
+    * Signature: (IILjava/lang/String;II)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_configure
         (JNIEnv *, jclass, jint, jint, jstring, jint, jint, jstring);
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    notifyAllObservers0\r
-    * Signature: (Lorg/iotivity/base/OcResourceHandle;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers0\r
-        (JNIEnv *, jclass, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    notifyAllObservers1\r
-    * Signature: (Lorg/iotivity/base/OcResourceHandle;I)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers1\r
-        (JNIEnv *, jclass, jobject, jint);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    notifyListOfObservers2\r
-    * Signature: (Lorg/iotivity/base/OcResourceHandle;[BLorg/iotivity/base/OcResourceResponse;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyListOfObservers2\r
-        (JNIEnv *, jclass, jobject, jbyteArray, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    notifyListOfObservers3\r
-    * Signature: (Lorg/iotivity/base/OcResourceHandle;[BLorg/iotivity/base/OcResourceResponse;I)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyListOfObservers3\r
-        (JNIEnv *, jclass, jobject, jbyteArray, jobject, jint);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    findResource0\r
-    * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnResourceFoundListener;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource0\r
-        (JNIEnv *, jclass, jstring, jstring, jint, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    findResource1\r
-    * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnResourceFoundListener;I)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource1\r
-        (JNIEnv *, jclass, jstring, jstring, jint, jobject, jint);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    getDeviceInfo0\r
-    * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnDeviceFoundListener;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo0\r
-        (JNIEnv *, jclass, jstring, jstring, jint, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    getDeviceInfo1\r
-    * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnDeviceFoundListener;I)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo1\r
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    notifyAllObservers0
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers0
+        (JNIEnv *, jclass, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    notifyAllObservers1
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyAllObservers1
+        (JNIEnv *, jclass, jobject, jint);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    notifyListOfObservers2
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;[BLorg/iotivity/base/OcResourceResponse;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyListOfObservers2
+        (JNIEnv *, jclass, jobject, jbyteArray, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    notifyListOfObservers3
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;[BLorg/iotivity/base/OcResourceResponse;I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_notifyListOfObservers3
+        (JNIEnv *, jclass, jobject, jbyteArray, jobject, jint);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    findResource0
+    * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnResourceFoundListener;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource0
+        (JNIEnv *, jclass, jstring, jstring, jint, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    findResource1
+    * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnResourceFoundListener;I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_findResource1
+        (JNIEnv *, jclass, jstring, jstring, jint, jobject, jint);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    getDeviceInfo0
+    * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnDeviceFoundListener;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo0
+        (JNIEnv *, jclass, jstring, jstring, jint, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    getDeviceInfo1
+    * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnDeviceFoundListener;I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getDeviceInfo1
         (JNIEnv *, jclass, jstring, jstring, jint, jobject, jint);
 
     /*
@@ -142,30 +142,30 @@ extern "C" {
      * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPlatformFoundListener;I)V
      */
      JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_getPlatformInfo1
-        (JNIEnv *, jclass, jstring, jstring, jint, jobject, jint);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    registerResource0\r
-    * Signature: (Lorg/iotivity/base/OcResource;)Lorg/iotivity/base/OcResourceHandle;\r
-    */\r
-    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource0\r
-        (JNIEnv *, jclass, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    registerResource1\r
-    * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcPlatform/EntityHandler;I)Lorg/iotivity/base/OcResourceHandle;\r
-    */\r
-    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource1\r
-        (JNIEnv *, jclass, jstring, jstring, jstring, jobject, jint);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    registerDeviceInfo0\r
+        (JNIEnv *, jclass, jstring, jstring, jint, jobject, jint);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    registerResource0
+    * Signature: (Lorg/iotivity/base/OcResource;)Lorg/iotivity/base/OcResourceHandle;
+    */
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource0
+        (JNIEnv *, jclass, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    registerResource1
+    * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcPlatform/EntityHandler;I)Lorg/iotivity/base/OcResourceHandle;
+    */
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_registerResource1
+        (JNIEnv *, jclass, jstring, jstring, jstring, jobject, jint);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    registerDeviceInfo0
     * Signature: (Ljava/lang/String;)V
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0\r
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerDeviceInfo0
         (JNIEnv *, jclass, jstring);
 
     /*
@@ -175,121 +175,121 @@ extern "C" {
     */
     JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_registerPlatformInfo0
         (JNIEnv *, jclass, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jstring, jstring);
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    unregisterResource0\r
-    * Signature: (Lorg/iotivity/base/OcResourceHandle;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unregisterResource0\r
-        (JNIEnv *, jclass, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    bindResource0\r
-    * Signature: (Lorg/iotivity/base/OcResourceHandle;Lorg/iotivity/base/OcResourceHandle;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResource0\r
-        (JNIEnv *, jclass, jobject, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    bindResources0\r
-    * Signature: (Lorg/iotivity/base/OcResourceHandle;[Lorg/iotivity/base/OcResourceHandle;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResources0\r
-        (JNIEnv *, jclass, jobject, jobjectArray);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    unbindResource0\r
-    * Signature: (Lorg/iotivity/base/OcResourceHandle;Lorg/iotivity/base/OcResourceHandle;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unbindResource0\r
-        (JNIEnv *, jclass, jobject, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    unbindResources0\r
-    * Signature: (Lorg/iotivity/base/OcResourceHandle;[Lorg/iotivity/base/OcResourceHandle;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unbindResources0\r
-        (JNIEnv *, jclass, jobject, jobjectArray);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    bindTypeToResource0\r
-    * Signature: (Lorg/iotivity/base/OcResourceHandle;Ljava/lang/String;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindTypeToResource0\r
-        (JNIEnv *, jclass, jobject, jstring);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    bindInterfaceToResource0\r
-    * Signature: (Lorg/iotivity/base/OcResourceHandle;Ljava/lang/String;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindInterfaceToResource0\r
-        (JNIEnv *, jclass, jobject, jstring);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    startPresence0\r
-    * Signature: (I)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_startPresence0\r
-        (JNIEnv *, jclass, jint);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    stopPresence0\r
-    * Signature: ()V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_stopPresence0\r
-        (JNIEnv *, jclass);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    subscribePresence0\r
-    * Signature: (Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPresenceListener;)Lorg/iotivity/base/OcPresenceHandle;\r
-    */\r
-    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence0\r
-        (JNIEnv *, jclass, jstring, jint, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    subscribePresence1\r
-    * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPresenceListener;)Lorg/iotivity/base/OcPresenceHandle;\r
-    */\r
-    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence1\r
-        (JNIEnv *, jclass, jstring, jstring, jint, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    unsubscribePresence0\r
-    * Signature: (Lorg/iotivity/base/OcPresenceHandle;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unsubscribePresence0\r
-        (JNIEnv *, jclass, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform\r
-    * Method:    constructResourceObject0\r
-    * Signature: (Ljava/lang/String;Ljava/lang/String;IZ[Ljava/lang/String;[Ljava/lang/String;)Lorg/iotivity/base/OcResource;\r
-    */\r
-    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_constructResourceObject0\r
-        (JNIEnv *, jclass, jstring, jstring, jint, jboolean, jobjectArray, jobjectArray);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPlatform0\r
-    * Method:    sendResponse0\r
-    * Signature: (Lorg/iotivity/base/OcResourceResponse;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_sendResponse0\r
-        (JNIEnv *, jclass, jobject);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-#endif\r
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    unregisterResource0
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unregisterResource0
+        (JNIEnv *, jclass, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    bindResource0
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;Lorg/iotivity/base/OcResourceHandle;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResource0
+        (JNIEnv *, jclass, jobject, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    bindResources0
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;[Lorg/iotivity/base/OcResourceHandle;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindResources0
+        (JNIEnv *, jclass, jobject, jobjectArray);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    unbindResource0
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;Lorg/iotivity/base/OcResourceHandle;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unbindResource0
+        (JNIEnv *, jclass, jobject, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    unbindResources0
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;[Lorg/iotivity/base/OcResourceHandle;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unbindResources0
+        (JNIEnv *, jclass, jobject, jobjectArray);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    bindTypeToResource0
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;Ljava/lang/String;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindTypeToResource0
+        (JNIEnv *, jclass, jobject, jstring);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    bindInterfaceToResource0
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;Ljava/lang/String;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_bindInterfaceToResource0
+        (JNIEnv *, jclass, jobject, jstring);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    startPresence0
+    * Signature: (I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_startPresence0
+        (JNIEnv *, jclass, jint);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    stopPresence0
+    * Signature: ()V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_stopPresence0
+        (JNIEnv *, jclass);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    subscribePresence0
+    * Signature: (Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPresenceListener;)Lorg/iotivity/base/OcPresenceHandle;
+    */
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence0
+        (JNIEnv *, jclass, jstring, jint, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    subscribePresence1
+    * Signature: (Ljava/lang/String;Ljava/lang/String;ILorg/iotivity/base/OcPlatform/OnPresenceListener;)Lorg/iotivity/base/OcPresenceHandle;
+    */
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_subscribePresence1
+        (JNIEnv *, jclass, jstring, jstring, jint, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    unsubscribePresence0
+    * Signature: (Lorg/iotivity/base/OcPresenceHandle;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_unsubscribePresence0
+        (JNIEnv *, jclass, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform
+    * Method:    constructResourceObject0
+    * Signature: (Ljava/lang/String;Ljava/lang/String;IZ[Ljava/lang/String;[Ljava/lang/String;)Lorg/iotivity/base/OcResource;
+    */
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcPlatform_constructResourceObject0
+        (JNIEnv *, jclass, jstring, jstring, jint, jboolean, jobjectArray, jobjectArray);
+
+    /*
+    * Class:     org_iotivity_base_OcPlatform0
+    * Method:    sendResponse0
+    * Signature: (Lorg/iotivity/base/OcResourceResponse;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPlatform_sendResponse0
+        (JNIEnv *, jclass, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
 
index 83950bc..00f81a1 100644 (file)
@@ -1,73 +1,73 @@
-/*\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 "JniOcPresenceHandle.h"\r
-#include "OCPlatform.h"\r
-\r
-JniOcPresenceHandle::JniOcPresenceHandle(JniOnPresenceListener* jniListener, OCPresenceHandle presenceHandle)\r
-    : m_jniListener(jniListener), m_presenceHandle(presenceHandle)\r
-{}\r
-\r
-JniOcPresenceHandle::~JniOcPresenceHandle()\r
-{\r
-    LOGD("~JniOcPresenceHandle()");\r
-\r
-    //delete m_jniListener;\r
-    m_presenceHandle = nullptr;\r
-}\r
-\r
-JniOcPresenceHandle* JniOcPresenceHandle::getJniOcPresenceHandlePtr\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    JniOcPresenceHandle *handle = GetHandle<JniOcPresenceHandle>(env, thiz);\r
-    if (env->ExceptionCheck())\r
-    {\r
-        LOGE("Failed to get native handle from OcPresenceHandle");\r
-    }\r
-    if (!handle)\r
-    {\r
-        ThrowOcException(JNI_NO_NATIVE_POINTER, "");\r
-    }\r
-    return handle;\r
-}\r
-\r
-OCPresenceHandle JniOcPresenceHandle::getOCPresenceHandle()\r
-{\r
-    return this->m_presenceHandle;\r
-}\r
-\r
-JniOnPresenceListener* JniOcPresenceHandle::getJniOnPresenceListener()\r
-{\r
-    return this->m_jniListener;\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcPresenceHandle\r
-* Method:    dispose\r
-* Signature: ()V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcPresenceHandle_dispose\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcPresenceHandle_dispose");\r
-    JniOcPresenceHandle *presenceHandle = JniOcPresenceHandle::getJniOcPresenceHandlePtr(env, thiz);\r
-    delete presenceHandle;\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 "JniOcPresenceHandle.h"
+#include "OCPlatform.h"
+
+JniOcPresenceHandle::JniOcPresenceHandle(JniOnPresenceListener* jniListener, OCPresenceHandle presenceHandle)
+    : m_jniListener(jniListener), m_presenceHandle(presenceHandle)
+{}
+
+JniOcPresenceHandle::~JniOcPresenceHandle()
+{
+    LOGD("~JniOcPresenceHandle()");
+
+    //delete m_jniListener;
+    m_presenceHandle = nullptr;
+}
+
+JniOcPresenceHandle* JniOcPresenceHandle::getJniOcPresenceHandlePtr
+(JNIEnv *env, jobject thiz)
+{
+    JniOcPresenceHandle *handle = GetHandle<JniOcPresenceHandle>(env, thiz);
+    if (env->ExceptionCheck())
+    {
+        LOGE("Failed to get native handle from OcPresenceHandle");
+    }
+    if (!handle)
+    {
+        ThrowOcException(JNI_NO_NATIVE_POINTER, "");
+    }
+    return handle;
+}
+
+OCPresenceHandle JniOcPresenceHandle::getOCPresenceHandle()
+{
+    return this->m_presenceHandle;
+}
+
+JniOnPresenceListener* JniOcPresenceHandle::getJniOnPresenceListener()
+{
+    return this->m_jniListener;
+}
+
+/*
+* Class:     org_iotivity_base_OcPresenceHandle
+* Method:    dispose
+* Signature: ()V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcPresenceHandle_dispose
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcPresenceHandle_dispose");
+    JniOcPresenceHandle *presenceHandle = JniOcPresenceHandle::getJniOcPresenceHandlePtr(env, thiz);
+    delete presenceHandle;
 }
\ No newline at end of file
index 26f6a8d..4052cec 100644 (file)
@@ -1,65 +1,65 @@
-/*\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 "JniOcStack.h"\r
-#include "JniOnPresenceListener.h"\r
-#include "OCPlatform.h"\r
-\r
-#ifndef _Included_org_iotivity_base_OcPresenceHandle\r
-#define _Included_org_iotivity_base_OcPresenceHandle\r
-\r
-using namespace OC::OCPlatform;\r
-\r
-class JniOcPresenceHandle\r
-{\r
-public:\r
-\r
-    JniOcPresenceHandle(JniOnPresenceListener* jniListener, OCPresenceHandle presenceHandle);\r
-    ~JniOcPresenceHandle();\r
-    JniOcPresenceHandle(const JniOcPresenceHandle &) = delete;\r
-    void operator=(const JniOcPresenceHandle &) = delete;\r
-\r
-    static JniOcPresenceHandle* getJniOcPresenceHandlePtr(JNIEnv *env, jobject thiz);\r
-\r
-    OCPresenceHandle getOCPresenceHandle();\r
-    JniOnPresenceListener* getJniOnPresenceListener();\r
-\r
-private:\r
-    JniOnPresenceListener* m_jniListener;\r
-    OCPresenceHandle m_presenceHandle;\r
-};\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcPresenceHandle\r
-    * Method:    dispose\r
-    * Signature: ()V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPresenceHandle_dispose\r
-        (JNIEnv *, jobject);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-#endif\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 "JniOcStack.h"
+#include "JniOnPresenceListener.h"
+#include "OCPlatform.h"
+
+#ifndef _Included_org_iotivity_base_OcPresenceHandle
+#define _Included_org_iotivity_base_OcPresenceHandle
+
+using namespace OC::OCPlatform;
+
+class JniOcPresenceHandle
+{
+public:
+
+    JniOcPresenceHandle(JniOnPresenceListener* jniListener, OCPresenceHandle presenceHandle);
+    ~JniOcPresenceHandle();
+    JniOcPresenceHandle(const JniOcPresenceHandle &) = delete;
+    void operator=(const JniOcPresenceHandle &) = delete;
+
+    static JniOcPresenceHandle* getJniOcPresenceHandlePtr(JNIEnv *env, jobject thiz);
+
+    OCPresenceHandle getOCPresenceHandle();
+    JniOnPresenceListener* getJniOnPresenceListener();
+
+private:
+    JniOnPresenceListener* m_jniListener;
+    OCPresenceHandle m_presenceHandle;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+    /*
+    * Class:     org_iotivity_base_OcPresenceHandle
+    * Method:    dispose
+    * Signature: ()V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcPresenceHandle_dispose
+        (JNIEnv *, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
index c143069..da4a3cd 100644 (file)
-/*\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, NULL);
+
+    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, NULL);
+    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, NULL);
+    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, NULL);
+    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, NULL);
+    std::string value = env->GetStringUTFChars(jValue, NULL);
+
+    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, NULL);
+    OCRepresentation *value = JniOcRepresentation::getOCRepresentationPtr(env, jValue);
+    if (!value) return;
+
+    rep->setValue(key, *value);
+}
+
+/*
+* 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, NULL);
+
+    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, NULL);
+    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, NULL);
+        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, NULL);
+    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, NULL);
+            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, NULL);
+    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, NULL);
+
+    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, NULL);
+    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, NULL);
+        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, NULL);
+    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, NULL);
+            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, NULL);
+    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, NULL);
+
+    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, NULL);
+    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, NULL);
+
+        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, NULL);
+    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, NULL);
+
+            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, NULL);
+    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, NULL);
+    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, NULL);
+    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, NULL);
+    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, NULL);
+    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, NULL);
+    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, NULL);
+    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, NULL));
+}
+
+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, NULL);
+    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, NULL);
+    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, NULL);
+    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, NULL);
+    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;
+    }
+}
index fbf3131..6f1e695 100644 (file)
@@ -1,42 +1,42 @@
-/*\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 "JniOcStack.h"\r
-#include <AttributeValue.h>\r
-\r
-#ifndef _Included_org_iotivity_base_OcRepresentation\r
-#define _Included_org_iotivity_base_OcRepresentation\r
-\r
-using namespace OC;\r
-\r
-class JniOcRepresentation\r
-{\r
-public:\r
-    static OCRepresentation* getOCRepresentationPtr(JNIEnv *env, jobject thiz);\r
-};\r
-\r
-struct JObjectConverter : boost::static_visitor < jobject >\r
-{\r
-    JObjectConverter(JNIEnv *env) : env(env){}\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 "JniOcStack.h"
+#include <AttributeValue.h>
+
+#ifndef _Included_org_iotivity_base_OcRepresentation
+#define _Included_org_iotivity_base_OcRepresentation
+
+using namespace OC;
+
+class JniOcRepresentation
+{
+public:
+    static OCRepresentation* getOCRepresentationPtr(JNIEnv *env, jobject thiz);
+};
+
+struct JObjectConverter : boost::static_visitor < jobject >
+{
+    JObjectConverter(JNIEnv *env) : env(env){}
+
     jobject operator()(const NullType&) const { return nullptr; }
     jobject operator()(const int& val) const
     {
@@ -69,8 +69,8 @@ struct JObjectConverter : boost::static_visitor < jobject >
     }
     jobject operator()(const OC::OCRepresentation& val) const
     {
-        OCRepresentation * rep = new OCRepresentation(val);\r
-        jlong handle = reinterpret_cast<jlong>(rep);\r
+        OCRepresentation * rep = new OCRepresentation(val);
+        jlong handle = reinterpret_cast<jlong>(rep);
         jobject jRepresentation = env->NewObject(
             g_cls_OcRepresentation,
             g_mid_OcRepresentation_N_ctor_bool,
@@ -86,30 +86,30 @@ struct JObjectConverter : boost::static_visitor < jobject >
     jobject operator()(const std::vector<int>& val) const
     {
         size_t len = val.size();
-        jintArray jIntArray = env->NewIntArray(len);\r
-        if (!jIntArray) return nullptr;\r
-        const int* ints = &val[0];\r
+        jintArray jIntArray = env->NewIntArray(len);
+        if (!jIntArray) return nullptr;
+        const int* ints = &val[0];
         env->SetIntArrayRegion(jIntArray, 0, len, reinterpret_cast<const jint*>(ints));
         return jIntArray;
     }
     jobject operator()(const std::vector<double>& val) const
     {
         size_t len = val.size();
-        jdoubleArray jDoubleArray = env->NewDoubleArray(len);\r
-        if (!jDoubleArray) return nullptr;\r
-        const double* doubles = &val[0];\r
+        jdoubleArray jDoubleArray = env->NewDoubleArray(len);
+        if (!jDoubleArray) return nullptr;
+        const double* doubles = &val[0];
         env->SetDoubleArrayRegion(jDoubleArray, 0, len, reinterpret_cast<const jdouble*>(doubles));
         return jDoubleArray;
     }
     jobject operator()(const std::vector<bool>& val) const
     {
         size_t len = val.size();
-        jbooleanArray jBooleanArray = env->NewBooleanArray(len);\r
-        if (!jBooleanArray) return nullptr;\r
-        jboolean* booleans = new jboolean[len];\r
-        for (size_t i = 0; i < len; ++i) {\r
-            booleans[i] = static_cast<jboolean>(val[i]);\r
-        }\r
+        jbooleanArray jBooleanArray = env->NewBooleanArray(len);
+        if (!jBooleanArray) return nullptr;
+        jboolean* booleans = new jboolean[len];
+        for (size_t i = 0; i < len; ++i) {
+            booleans[i] = static_cast<jboolean>(val[i]);
+        }
         env->SetBooleanArrayRegion(jBooleanArray, 0, len, booleans);
         if (env->ExceptionCheck()) return nullptr;
         env->ReleaseBooleanArrayElements(jBooleanArray, booleans, 0);
@@ -117,60 +117,60 @@ struct JObjectConverter : boost::static_visitor < jobject >
     }
     jobject operator()(const std::vector<std::string>& val) const
     {
-        size_t len = val.size();\r
-        jobjectArray strArr = env->NewObjectArray(len, g_cls_String, NULL);\r
-        if (!strArr) return nullptr;\r
-        for (size_t i = 0; i < len; ++i)\r
-        {\r
-            jstring jString = env->NewStringUTF(val[i].c_str());\r
-            env->SetObjectArrayElement(strArr, static_cast<jsize>(i), jString);\r
-            if (env->ExceptionCheck()) return nullptr;\r
-            env->DeleteLocalRef(jString);\r
-        }\r
+        size_t len = val.size();
+        jobjectArray strArr = env->NewObjectArray(len, g_cls_String, NULL);
+        if (!strArr) return nullptr;
+        for (size_t i = 0; i < len; ++i)
+        {
+            jstring jString = env->NewStringUTF(val[i].c_str());
+            env->SetObjectArrayElement(strArr, static_cast<jsize>(i), jString);
+            if (env->ExceptionCheck()) return nullptr;
+            env->DeleteLocalRef(jString);
+        }
         return strArr;
     }
     jobject operator()(const std::vector<OC::OCRepresentation>& val) const
     {
-        jsize len = static_cast<jsize>(val.size());\r
-        jobjectArray repArr = env->NewObjectArray(len, g_cls_OcRepresentation, NULL);\r
-        if (!repArr) return nullptr;\r
-        for (jsize i = 0; i < len; ++i)\r
-        {\r
-            OCRepresentation* rep = new OCRepresentation(val[i]);\r
-            jlong handle = reinterpret_cast<jlong>(rep);\r
-            jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,\r
-                handle, true);\r
-            if (!jRepresentation)\r
-            {\r
-                delete rep;\r
-                return nullptr;\r
-            }\r
-            env->SetObjectArrayElement(repArr, i, jRepresentation);\r
-            if (env->ExceptionCheck())\r
-            {\r
-                delete rep;\r
-                return nullptr;\r
-            }\r
-            env->DeleteLocalRef(jRepresentation);\r
-        }\r
+        jsize len = static_cast<jsize>(val.size());
+        jobjectArray repArr = env->NewObjectArray(len, g_cls_OcRepresentation, NULL);
+        if (!repArr) return nullptr;
+        for (jsize i = 0; i < len; ++i)
+        {
+            OCRepresentation* rep = new OCRepresentation(val[i]);
+            jlong handle = reinterpret_cast<jlong>(rep);
+            jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,
+                handle, true);
+            if (!jRepresentation)
+            {
+                delete rep;
+                return nullptr;
+            }
+            env->SetObjectArrayElement(repArr, i, jRepresentation);
+            if (env->ExceptionCheck())
+            {
+                delete rep;
+                return nullptr;
+            }
+            env->DeleteLocalRef(jRepresentation);
+        }
         return repArr;
     }
 
     // Nested sequences:
     jobject operator()(const std::vector<std::vector<int>>& val) const
     {
-        jsize lenOuter = static_cast<jsize>(val.size());\r
-        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_int1DArray, NULL);\r
+        jsize lenOuter = static_cast<jsize>(val.size());
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_int1DArray, NULL);
         if (!jOuterArr)
         {
             return nullptr;
-        }\r
-        for (jsize i = 0; i < lenOuter; ++i)\r
+        }
+        for (jsize i = 0; i < lenOuter; ++i)
         {
             size_t lenInner = val[i].size();
-            jintArray jIntArray = env->NewIntArray(lenInner);\r
-            if (!jIntArray) return nullptr;\r
-            const int* ints = &val[i][0];\r
+            jintArray jIntArray = env->NewIntArray(lenInner);
+            if (!jIntArray) return nullptr;
+            const int* ints = &val[i][0];
             env->SetIntArrayRegion(jIntArray, 0, lenInner, reinterpret_cast<const jint*>(ints));
             if (env->ExceptionCheck()) return nullptr;
             env->SetObjectArrayElement(jOuterArr, i, static_cast<jobject>(jIntArray));
@@ -181,20 +181,20 @@ struct JObjectConverter : boost::static_visitor < jobject >
     }
     jobject operator()(const std::vector<std::vector<std::vector<int>>>& val) const
     {
-        jsize lenOuter = static_cast<jsize>(val.size());\r
-        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_int2DArray, NULL);\r
-        if (!jOuterArr) return nullptr;\r
-        for (jsize k = 0; k < lenOuter; ++k)\r
-        {\r
-            jsize lenMiddle = static_cast<jsize>(val[k].size());\r
-            jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_int1DArray, NULL);\r
-            if (!jMiddleArr) return nullptr;\r
-            for (jsize i = 0; i < lenMiddle; ++i)\r
+        jsize lenOuter = static_cast<jsize>(val.size());
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_int2DArray, NULL);
+        if (!jOuterArr) return nullptr;
+        for (jsize k = 0; k < lenOuter; ++k)
+        {
+            jsize lenMiddle = static_cast<jsize>(val[k].size());
+            jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_int1DArray, NULL);
+            if (!jMiddleArr) return nullptr;
+            for (jsize i = 0; i < lenMiddle; ++i)
             {
                 jsize lenInner = static_cast<jsize>(val[k][i].size());
-                jintArray jIntArray = env->NewIntArray(lenInner);\r
-                if (!jIntArray) return nullptr;\r
-                const int* ints = &val[k][i][0];\r
+                jintArray jIntArray = env->NewIntArray(lenInner);
+                if (!jIntArray) return nullptr;
+                const int* ints = &val[k][i][0];
                 env->SetIntArrayRegion(jIntArray, 0, lenInner, reinterpret_cast<const jint*>(ints));
                 if (env->ExceptionCheck()) return nullptr;
                 env->SetObjectArrayElement(jMiddleArr, i, jIntArray);
@@ -210,15 +210,15 @@ struct JObjectConverter : boost::static_visitor < jobject >
 
     jobject operator()(const std::vector<std::vector<double>>& val) const
     {
-        jsize lenOuter = static_cast<jsize>(val.size());\r
-        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_double1DArray, NULL);\r
-        if (!jOuterArr) return nullptr;\r
-        for (jsize i = 0; i < lenOuter; ++i)\r
+        jsize lenOuter = static_cast<jsize>(val.size());
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_double1DArray, NULL);
+        if (!jOuterArr) return nullptr;
+        for (jsize i = 0; i < lenOuter; ++i)
         {
             size_t lenInner = val[i].size();
-            jdoubleArray jDoubleArray = env->NewDoubleArray(lenInner);\r
-            if (!jDoubleArray) return nullptr;\r
-            const double* doubles = &val[i][0];\r
+            jdoubleArray jDoubleArray = env->NewDoubleArray(lenInner);
+            if (!jDoubleArray) return nullptr;
+            const double* doubles = &val[i][0];
             env->SetDoubleArrayRegion(jDoubleArray, 0, lenInner, reinterpret_cast<const jdouble*>(doubles));
             if (env->ExceptionCheck()) return nullptr;
             env->SetObjectArrayElement(jOuterArr, i, jDoubleArray);
@@ -230,20 +230,20 @@ struct JObjectConverter : boost::static_visitor < jobject >
     }
     jobject operator()(const std::vector<std::vector<std::vector<double>>>& val) const
     {
-        jsize lenOuter = static_cast<jsize>(val.size());\r
-        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_double2DArray, NULL);\r
-        if (!jOuterArr) return nullptr;\r
-        for (jsize k = 0; k < lenOuter; ++k)\r
-        {\r
-            jsize lenMiddle = static_cast<jsize>(val[k].size());\r
-            jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_double1DArray, NULL);\r
-            if (!jMiddleArr) return nullptr;\r
-            for (jsize i = 0; i < lenMiddle; ++i)\r
+        jsize lenOuter = static_cast<jsize>(val.size());
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_double2DArray, NULL);
+        if (!jOuterArr) return nullptr;
+        for (jsize k = 0; k < lenOuter; ++k)
+        {
+            jsize lenMiddle = static_cast<jsize>(val[k].size());
+            jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_double1DArray, NULL);
+            if (!jMiddleArr) return nullptr;
+            for (jsize i = 0; i < lenMiddle; ++i)
             {
                 jsize lenInner = static_cast<jsize>(val[k][i].size());
-                jdoubleArray jDoubleArray = env->NewDoubleArray(lenInner);\r
-                if (!jDoubleArray) return nullptr;\r
-                const double* doubles = &val[k][i][0];\r
+                jdoubleArray jDoubleArray = env->NewDoubleArray(lenInner);
+                if (!jDoubleArray) return nullptr;
+                const double* doubles = &val[k][i][0];
                 env->SetDoubleArrayRegion(jDoubleArray, 0, lenInner, reinterpret_cast<const jdouble*>(doubles));
                 if (env->ExceptionCheck()) return nullptr;
                 env->SetObjectArrayElement(jMiddleArr, i, jDoubleArray);
@@ -259,18 +259,18 @@ struct JObjectConverter : boost::static_visitor < jobject >
 
     jobject operator()(const std::vector<std::vector<bool>>& val) const
     {
-        jsize lenOuter = static_cast<jsize>(val.size());\r
-        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_boolean1DArray, 0);\r
-        if (!jOuterArr) return nullptr;\r
-        for (jsize i = 0; i < lenOuter; ++i)\r
+        jsize lenOuter = static_cast<jsize>(val.size());
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_boolean1DArray, 0);
+        if (!jOuterArr) return nullptr;
+        for (jsize i = 0; i < lenOuter; ++i)
         {
             size_t lenInner = val[i].size();
-            jbooleanArray jBooleanArray = env->NewBooleanArray(lenInner);\r
-            if (!jBooleanArray) return nullptr;\r
-            jboolean* booleans = new jboolean[lenInner];\r
-            for (size_t j = 0; j < lenInner; ++j) {\r
-                booleans[j] = static_cast<jboolean>(val[i][j]);\r
-            }\r
+            jbooleanArray jBooleanArray = env->NewBooleanArray(lenInner);
+            if (!jBooleanArray) return nullptr;
+            jboolean* booleans = new jboolean[lenInner];
+            for (size_t j = 0; j < lenInner; ++j) {
+                booleans[j] = static_cast<jboolean>(val[i][j]);
+            }
             env->SetBooleanArrayRegion(jBooleanArray, 0, lenInner, booleans);
             if (env->ExceptionCheck()) return nullptr;
             env->SetObjectArrayElement(jOuterArr, i, jBooleanArray);
@@ -283,26 +283,26 @@ struct JObjectConverter : boost::static_visitor < jobject >
     }
     jobject operator()(const std::vector<std::vector<std::vector<bool>>>& val) const
     {
-        jsize lenOuter = static_cast<jsize>(val.size());\r
-        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_boolean2DArray, NULL);\r
-        if (!jOuterArr) return nullptr;\r
-        for (jsize k = 0; k < lenOuter; ++k)\r
-        {\r
-            jsize lenMiddle = static_cast<jsize>(val[k].size());\r
-            jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_boolean1DArray, NULL);\r
-            if (!jMiddleArr) return nullptr;\r
-            for (jsize i = 0; i < lenMiddle; ++i)\r
+        jsize lenOuter = static_cast<jsize>(val.size());
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_boolean2DArray, NULL);
+        if (!jOuterArr) return nullptr;
+        for (jsize k = 0; k < lenOuter; ++k)
+        {
+            jsize lenMiddle = static_cast<jsize>(val[k].size());
+            jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_boolean1DArray, NULL);
+            if (!jMiddleArr) return nullptr;
+            for (jsize i = 0; i < lenMiddle; ++i)
             {
                 size_t lenInner = val[k][i].size();
-                jbooleanArray jBooleanArray = env->NewBooleanArray(lenInner);\r
-                jboolean* booleans = new jboolean[lenInner];\r
-                for (size_t j = 0; j < lenInner; ++j) {\r
-                    booleans[j] = val[k][i][j];\r
-                }\r
+                jbooleanArray jBooleanArray = env->NewBooleanArray(lenInner);
+                jboolean* booleans = new jboolean[lenInner];
+                for (size_t j = 0; j < lenInner; ++j) {
+                    booleans[j] = val[k][i][j];
+                }
                 env->SetBooleanArrayRegion(jBooleanArray, 0, lenInner, booleans);
                 if (env->ExceptionCheck()) return nullptr;
-                env->SetObjectArrayElement(jMiddleArr, i, jBooleanArray);\r
-                if (env->ExceptionCheck()) return nullptr;\r
+                env->SetObjectArrayElement(jMiddleArr, i, jBooleanArray);
+                if (env->ExceptionCheck()) return nullptr;
                 env->ReleaseBooleanArrayElements(jBooleanArray, booleans, 0);
                 if (env->ExceptionCheck()) return nullptr;
                 env->DeleteLocalRef(jBooleanArray);
@@ -316,20 +316,20 @@ struct JObjectConverter : boost::static_visitor < jobject >
 
     jobject operator()(const std::vector<std::vector<std::string>>& val) const
     {
-        jsize lenOuter = static_cast<jsize>(val.size());\r
-        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_String1DArray, NULL);\r
-        if (!jOuterArr) return nullptr;\r
-        for (jsize i = 0; i < lenOuter; ++i)\r
+        jsize lenOuter = static_cast<jsize>(val.size());
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_String1DArray, NULL);
+        if (!jOuterArr) return nullptr;
+        for (jsize i = 0; i < lenOuter; ++i)
         {
-            jsize lenInner = static_cast<jsize>(val[i].size());\r
-            jobjectArray strArr = env->NewObjectArray(lenInner, g_cls_String, NULL);\r
-            if (!strArr) return nullptr;\r
-            for (jsize j = 0; j < lenInner; ++j)\r
-            {\r
-                jstring jString = env->NewStringUTF(val[i][j].c_str());\r
-                env->SetObjectArrayElement(strArr, j, jString);\r
-                if (env->ExceptionCheck()) return nullptr;\r
-                env->DeleteLocalRef(jString);\r
+            jsize lenInner = static_cast<jsize>(val[i].size());
+            jobjectArray strArr = env->NewObjectArray(lenInner, g_cls_String, NULL);
+            if (!strArr) return nullptr;
+            for (jsize j = 0; j < lenInner; ++j)
+            {
+                jstring jString = env->NewStringUTF(val[i][j].c_str());
+                env->SetObjectArrayElement(strArr, j, jString);
+                if (env->ExceptionCheck()) return nullptr;
+                env->DeleteLocalRef(jString);
             }
             env->SetObjectArrayElement(jOuterArr, i, strArr);
             if (env->ExceptionCheck()) return nullptr;
@@ -340,25 +340,25 @@ struct JObjectConverter : boost::static_visitor < jobject >
     }
     jobject operator()(const std::vector<std::vector<std::vector<std::string>>>& val) const
     {
-        jsize lenOuter = static_cast<jsize>(val.size());\r
-        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_String2DArray, NULL);\r
-        if (!jOuterArr) return nullptr;\r
-        for (jsize k = 0; k < lenOuter; ++k)\r
-        {\r
-            jsize lenMiddle = static_cast<jsize>(val[k].size());\r
-            jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_String1DArray, NULL);\r
-            if (!jMiddleArr) return nullptr;\r
-            for (jsize i = 0; i < lenMiddle; ++i)\r
+        jsize lenOuter = static_cast<jsize>(val.size());
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_String2DArray, NULL);
+        if (!jOuterArr) return nullptr;
+        for (jsize k = 0; k < lenOuter; ++k)
+        {
+            jsize lenMiddle = static_cast<jsize>(val[k].size());
+            jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_String1DArray, NULL);
+            if (!jMiddleArr) return nullptr;
+            for (jsize i = 0; i < lenMiddle; ++i)
             {
-                jsize lenInner = static_cast<jsize>(val[k][i].size());\r
-                jobjectArray strArr = env->NewObjectArray(lenInner, g_cls_String, NULL);\r
-                if (!strArr) return nullptr;\r
-                for (jsize j = 0; j < lenInner; ++j)\r
-                {\r
-                    jstring jString = env->NewStringUTF(val[k][i][j].c_str());\r
-                    env->SetObjectArrayElement(strArr, j, jString);\r
-                    if (env->ExceptionCheck()) return nullptr;\r
-                    env->DeleteLocalRef(jString);\r
+                jsize lenInner = static_cast<jsize>(val[k][i].size());
+                jobjectArray strArr = env->NewObjectArray(lenInner, g_cls_String, NULL);
+                if (!strArr) return nullptr;
+                for (jsize j = 0; j < lenInner; ++j)
+                {
+                    jstring jString = env->NewStringUTF(val[k][i][j].c_str());
+                    env->SetObjectArrayElement(strArr, j, jString);
+                    if (env->ExceptionCheck()) return nullptr;
+                    env->DeleteLocalRef(jString);
                 }
                 env->SetObjectArrayElement(jMiddleArr, i, strArr);
                 if (env->ExceptionCheck()) return nullptr;
@@ -373,28 +373,28 @@ struct JObjectConverter : boost::static_visitor < jobject >
 
     jobject operator()(const std::vector<std::vector<OC::OCRepresentation>>& val) const
     {
-        jsize lenOuter = static_cast<jsize>(val.size());\r
-        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_OcRepresentation1DArray, NULL);\r
-        if (!jOuterArr) return nullptr;\r
-        for (jsize i = 0; i < lenOuter; ++i)\r
+        jsize lenOuter = static_cast<jsize>(val.size());
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_OcRepresentation1DArray, NULL);
+        if (!jOuterArr) return nullptr;
+        for (jsize i = 0; i < lenOuter; ++i)
         {
-            jsize lenInner = static_cast<jsize>(val[i].size());\r
-            jobjectArray repArr = env->NewObjectArray(lenInner, g_cls_OcRepresentation, NULL);\r
-            if (!repArr) return nullptr;\r
-            for (jsize j = 0; j < lenInner; ++j)\r
-            {\r
-                OCRepresentation* rep = new OCRepresentation(val[i][j]);\r
-                jlong handle = reinterpret_cast<jlong>(rep);\r
-                jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,\r
-                    handle, true);\r
-                if (!jRepresentation)\r
-                {\r
-                    delete rep;\r
-                    return nullptr;\r
-                }\r
-                env->SetObjectArrayElement(repArr, j, jRepresentation);\r
-                if (env->ExceptionCheck()) return nullptr;\r
-                env->DeleteLocalRef(jRepresentation);\r
+            jsize lenInner = static_cast<jsize>(val[i].size());
+            jobjectArray repArr = env->NewObjectArray(lenInner, g_cls_OcRepresentation, NULL);
+            if (!repArr) return nullptr;
+            for (jsize j = 0; j < lenInner; ++j)
+            {
+                OCRepresentation* rep = new OCRepresentation(val[i][j]);
+                jlong handle = reinterpret_cast<jlong>(rep);
+                jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,
+                    handle, true);
+                if (!jRepresentation)
+                {
+                    delete rep;
+                    return nullptr;
+                }
+                env->SetObjectArrayElement(repArr, j, jRepresentation);
+                if (env->ExceptionCheck()) return nullptr;
+                env->DeleteLocalRef(jRepresentation);
             }
             env->SetObjectArrayElement(jOuterArr, i, repArr);
             if (env->ExceptionCheck()) return nullptr;
@@ -402,35 +402,35 @@ struct JObjectConverter : boost::static_visitor < jobject >
         }
         return jOuterArr;
     }
-    jobject operator()(const std::vector<std::vector<std::vector<OC::OCRepresentation>>>& val) const\r
-    {\r
-        jsize lenOuter = static_cast<jsize>(val.size());\r
-        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_OcRepresentation2DArray, NULL);\r
-        if (!jOuterArr) return nullptr;\r
-        for (jsize k = 0; k < lenOuter; ++k)\r
-        {\r
-            jsize lenMiddle = static_cast<jsize>(val[k].size());\r
-            jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_OcRepresentation1DArray, NULL);\r
-            if (!jMiddleArr) return nullptr;\r
-            for (jsize i = 0; i < lenMiddle; ++i)\r
+    jobject operator()(const std::vector<std::vector<std::vector<OC::OCRepresentation>>>& val) const
+    {
+        jsize lenOuter = static_cast<jsize>(val.size());
+        jobjectArray jOuterArr = env->NewObjectArray(lenOuter, g_cls_OcRepresentation2DArray, NULL);
+        if (!jOuterArr) return nullptr;
+        for (jsize k = 0; k < lenOuter; ++k)
+        {
+            jsize lenMiddle = static_cast<jsize>(val[k].size());
+            jobjectArray jMiddleArr = env->NewObjectArray(lenMiddle, g_cls_OcRepresentation1DArray, NULL);
+            if (!jMiddleArr) return nullptr;
+            for (jsize i = 0; i < lenMiddle; ++i)
             {
-                jsize lenInner = static_cast<jsize>(val[k][i].size());\r
-                jobjectArray repArr = env->NewObjectArray(lenInner, g_cls_OcRepresentation, NULL);\r
-                if (!repArr) return nullptr;\r
-                for (jsize j = 0; j < lenInner; ++j)\r
-                {\r
-                    OCRepresentation* rep = new OCRepresentation(val[k][i][j]);\r
-                    jlong handle = reinterpret_cast<jlong>(rep);\r
-                    jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,\r
-                        handle, true);\r
-                    if (!jRepresentation)\r
-                    {\r
-                        delete rep;\r
-                        return nullptr;\r
-                    }\r
-                    env->SetObjectArrayElement(repArr, j, jRepresentation);\r
-                    if (env->ExceptionCheck()) return nullptr;\r
-                    env->DeleteLocalRef(jRepresentation);\r
+                jsize lenInner = static_cast<jsize>(val[k][i].size());
+                jobjectArray repArr = env->NewObjectArray(lenInner, g_cls_OcRepresentation, NULL);
+                if (!repArr) return nullptr;
+                for (jsize j = 0; j < lenInner; ++j)
+                {
+                    OCRepresentation* rep = new OCRepresentation(val[k][i][j]);
+                    jlong handle = reinterpret_cast<jlong>(rep);
+                    jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,
+                        handle, true);
+                    if (!jRepresentation)
+                    {
+                        delete rep;
+                        return nullptr;
+                    }
+                    env->SetObjectArrayElement(repArr, j, jRepresentation);
+                    if (env->ExceptionCheck()) return nullptr;
+                    env->DeleteLocalRef(jRepresentation);
                 }
                 env->SetObjectArrayElement(jMiddleArr, i, repArr);
                 if (env->ExceptionCheck()) return nullptr;
@@ -440,322 +440,322 @@ struct JObjectConverter : boost::static_visitor < jobject >
             if (env->ExceptionCheck()) return nullptr;
             env->DeleteLocalRef(jMiddleArr);
         }
-        return jOuterArr;\r
-    }\r
-\r
-private:\r
-    JNIEnv *env;\r
-};\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\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 *, jobject, jstring);\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 *, jobject, jstring, jint);\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 *, jobject, jstring, jdouble);\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 *, jobject, jstring, jboolean);\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 *, jobject, jstring, jstring);\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 *, jobject, jstring, jobject);\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 *, jobject, jstring, jintArray);\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 *, jobject, jstring, jobjectArray);\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 *, jobject, jstring, jobjectArray);\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 *, jobject, jstring, jdoubleArray);\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 *, jobject, jstring, jobjectArray);\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 *, jobject, jstring, jobjectArray);\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 *, jobject, jstring, jbooleanArray);\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 *, jobject, jstring, jobjectArray);\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 *, jobject, jstring, jobjectArray);\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 *, jobject, jstring, jobjectArray);\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 *, jobject, jstring, jobjectArray);\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 *, jobject, jstring, jobjectArray);\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 *, jobject, jstring, jobjectArray);\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 *, jobject, jstring, jobjectArray);\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 *, jobject, jstring, jobjectArray);\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 *, jobject, jobject);\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 *, jobject);\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 *, jobject);\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 *, jobject);\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 *, jobject, jstring);\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 *, jobject);\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 *, jobject, jobjectArray);\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 *, jobject);\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 *, jobject, jobjectArray);\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 *, jobject);\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 *, jobject);\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 *, jobject, jstring);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcRepresentation\r
-    * Method:    hasAttribute\r
-    * Signature: (Ljava/lang/String;)Z\r
-    */\r
-    JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_hasAttribute\r
-        (JNIEnv *, jobject, jstring);\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 *, jobject, jstring);\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 *, jobject, jstring);\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 *, jobject);\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 *, jobject, jboolean);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
+        return jOuterArr;
+    }
+
+private:
+    JNIEnv *env;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    getValueN
+    * Signature: (Ljava/lang/String;)Ljava/lang/Object;
+    */
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getValueN
+        (JNIEnv *, jobject, jstring);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    setValueInteger
+    * Signature: (Ljava/lang/String;I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger
+        (JNIEnv *, jobject, jstring, jint);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    setValueDouble
+    * Signature: (Ljava/lang/String;D)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble
+        (JNIEnv *, jobject, jstring, jdouble);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    setValueBoolean
+    * Signature: (Ljava/lang/String;Z)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean
+        (JNIEnv *, jobject, jstring, jboolean);
+
+    /*
+    * 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 *, jobject, jstring, jstring);
+
+    /*
+    * 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 *, jobject, jstring, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    setValueIntegerArray
+    * Signature: (Ljava/lang/String;[I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueIntegerArray
+        (JNIEnv *, jobject, jstring, jintArray);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    setValueInteger2DArray
+    * Signature: (Ljava/lang/String;[[I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger2DArray
+        (JNIEnv *, jobject, jstring, jobjectArray);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    setValueInteger3DArray
+    * Signature: (Ljava/lang/String;[[[I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueInteger3DArray
+        (JNIEnv *, jobject, jstring, jobjectArray);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    setValueDoubleArray
+    * Signature: (Ljava/lang/String;[D)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDoubleArray
+        (JNIEnv *, jobject, jstring, jdoubleArray);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    setValueDouble2DArray
+    * Signature: (Ljava/lang/String;[[D)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble2DArray
+        (JNIEnv *, jobject, jstring, jobjectArray);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    setValueDouble3DArray
+    * Signature: (Ljava/lang/String;[[[D)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueDouble3DArray
+        (JNIEnv *, jobject, jstring, jobjectArray);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    setValueBooleanArray
+    * Signature: (Ljava/lang/String;[Z)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBooleanArray
+        (JNIEnv *, jobject, jstring, jbooleanArray);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    setValueBoolean2DArray
+    * Signature: (Ljava/lang/String;[[Z)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean2DArray
+        (JNIEnv *, jobject, jstring, jobjectArray);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    setValueBoolean3DArray
+    * Signature: (Ljava/lang/String;[[[Z)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setValueBoolean3DArray
+        (JNIEnv *, jobject, jstring, jobjectArray);
+
+    /*
+    * 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 *, jobject, jstring, jobjectArray);
+
+    /*
+    * 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 *, jobject, jstring, jobjectArray);
+
+    /*
+    * 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 *, jobject, jstring, jobjectArray);
+
+    /*
+    * 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 *, jobject, jstring, jobjectArray);
+
+    /*
+    * 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 *, jobject, jstring, jobjectArray);
+
+    /*
+    * 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 *, jobject, jstring, jobjectArray);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    addChild
+    * Signature: (Lorg/iotivity/base/OcRepresentation;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_addChild
+        (JNIEnv *, jobject, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    clearChildren
+    * Signature: ()V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_clearChildren
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    getChildrenArray
+    * Signature: ()[Lorg/iotivity/base/OcRepresentation;
+    */
+    JNIEXPORT jobjectArray JNICALL Java_org_iotivity_base_OcRepresentation_getChildrenArray
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    getUri
+    * Signature: ()Ljava/lang/String;
+    */
+    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcRepresentation_getUri
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    setUri
+    * Signature: (Ljava/lang/String;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setUri
+        (JNIEnv *, jobject, jstring);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    getResourceTypes
+    * Signature: ()Ljava/util/List;
+    */
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getResourceTypes
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    setResourceTypeArray
+    * Signature: ([Ljava/lang/String;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setResourceTypeArray
+        (JNIEnv *, jobject, jobjectArray);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    getResourceInterfaces
+    * Signature: ()Ljava/util/List;
+    */
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcRepresentation_getResourceInterfaces
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    setResourceInterfaceArray
+    * Signature: ([Ljava/lang/String;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setResourceInterfaceArray
+        (JNIEnv *, jobject, jobjectArray);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    isEmpty
+    * Signature: ()Z
+    */
+    JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_isEmpty
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    size
+    * Signature: ()I
+    */
+    JNIEXPORT jint JNICALL Java_org_iotivity_base_OcRepresentation_size
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    remove
+    * Signature: (Ljava/lang/String;)Z
+    */
+    JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_remove
+        (JNIEnv *, jobject, jstring);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    hasAttribute
+    * Signature: (Ljava/lang/String;)Z
+    */
+    JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_hasAttribute
+        (JNIEnv *, jobject, jstring);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    setNull
+    * Signature: (Ljava/lang/String;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_setNull
+        (JNIEnv *, jobject, jstring);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    isNull
+    * Signature: (Ljava/lang/String;)Z
+    */
+    JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcRepresentation_isNull
+        (JNIEnv *, jobject, jstring);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    create
+    * Signature: ()V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_create
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcRepresentation
+    * Method:    dispose
+    * Signature: ()V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRepresentation_dispose
+        (JNIEnv *, jobject, jboolean);
+
+#ifdef __cplusplus
+}
+#endif
 #endif
index 444689d..b916490 100644 (file)
@@ -1,63 +1,63 @@
-/*\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 "JniOcRequestHandle.h"\r
-\r
-JniOcRequestHandle::JniOcRequestHandle(OCRequestHandle requestHandle) : m_requestHandle(requestHandle)\r
-{}\r
-\r
-JniOcRequestHandle::~JniOcRequestHandle()\r
-{\r
-    LOGD("~JniOcRequestHandle()");\r
-}\r
-\r
-JniOcRequestHandle* JniOcRequestHandle::getJniOcRequestHandlePtr\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    JniOcRequestHandle *handle = GetHandle<JniOcRequestHandle>(env, thiz);\r
-    if (env->ExceptionCheck())\r
-    {\r
-        LOGE("Failed to get native handle from OcRequestHandle");\r
-    }\r
-    if (!handle)\r
-    {\r
-        ThrowOcException(JNI_NO_NATIVE_POINTER, "");\r
-    }\r
-    return handle;\r
-}\r
-\r
-OCRequestHandle JniOcRequestHandle::getOCRequestHandle()\r
-{\r
-    return this->m_requestHandle;\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcRequestHandle\r
-* Method:    dispose\r
-* Signature: ()V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcRequestHandle_dispose\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcRequestHandle_dispose");\r
-    JniOcRequestHandle *handle = JniOcRequestHandle::getJniOcRequestHandlePtr(env, thiz);\r
-    delete handle;\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 "JniOcRequestHandle.h"
+
+JniOcRequestHandle::JniOcRequestHandle(OCRequestHandle requestHandle) : m_requestHandle(requestHandle)
+{}
+
+JniOcRequestHandle::~JniOcRequestHandle()
+{
+    LOGD("~JniOcRequestHandle()");
+}
+
+JniOcRequestHandle* JniOcRequestHandle::getJniOcRequestHandlePtr
+(JNIEnv *env, jobject thiz)
+{
+    JniOcRequestHandle *handle = GetHandle<JniOcRequestHandle>(env, thiz);
+    if (env->ExceptionCheck())
+    {
+        LOGE("Failed to get native handle from OcRequestHandle");
+    }
+    if (!handle)
+    {
+        ThrowOcException(JNI_NO_NATIVE_POINTER, "");
+    }
+    return handle;
+}
+
+OCRequestHandle JniOcRequestHandle::getOCRequestHandle()
+{
+    return this->m_requestHandle;
+}
+
+/*
+* Class:     org_iotivity_base_OcRequestHandle
+* Method:    dispose
+* Signature: ()V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcRequestHandle_dispose
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcRequestHandle_dispose");
+    JniOcRequestHandle *handle = JniOcRequestHandle::getJniOcRequestHandlePtr(env, thiz);
+    delete handle;
 }
\ No newline at end of file
index 2160728..a9b2f2e 100644 (file)
@@ -1,58 +1,58 @@
-/*\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 "JniOcStack.h"\r
-#include "ocstack.h"\r
-\r
-#ifndef _Included_org_iotivity_base_OcRequestHandle\r
-#define _Included_org_iotivity_base_OcRequestHandle\r
-\r
-class JniOcRequestHandle\r
-{\r
-public:\r
-\r
-    JniOcRequestHandle(OCRequestHandle request);\r
-    ~JniOcRequestHandle();\r
-\r
-    static JniOcRequestHandle* getJniOcRequestHandlePtr(JNIEnv *env, jobject thiz);\r
-\r
-    OCRequestHandle getOCRequestHandle();\r
-\r
-private:\r
-    OCRequestHandle m_requestHandle;\r
-};\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcRequestHandle\r
-    * Method:    dispose\r
-    * Signature: ()V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRequestHandle_dispose\r
-        (JNIEnv *, jobject);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-#endif\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 "JniOcStack.h"
+#include "ocstack.h"
+
+#ifndef _Included_org_iotivity_base_OcRequestHandle
+#define _Included_org_iotivity_base_OcRequestHandle
+
+class JniOcRequestHandle
+{
+public:
+
+    JniOcRequestHandle(OCRequestHandle request);
+    ~JniOcRequestHandle();
+
+    static JniOcRequestHandle* getJniOcRequestHandlePtr(JNIEnv *env, jobject thiz);
+
+    OCRequestHandle getOCRequestHandle();
+
+private:
+    OCRequestHandle m_requestHandle;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+    /*
+    * Class:     org_iotivity_base_OcRequestHandle
+    * Method:    dispose
+    * Signature: ()V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcRequestHandle_dispose
+        (JNIEnv *, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
index 2850d65..13a8451 100644 (file)
-/*\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
-\r
-#include "JniOcResource.h"\r
-#include "JniOcRepresentation.h"\r
-#include "JniUtils.h"\r
-\r
-JniOcResource::JniOcResource(std::shared_ptr<OCResource> resource)\r
-    : m_sharedResource(resource)\r
-{}\r
-\r
-JniOcResource::~JniOcResource()\r
-{\r
-    LOGD("~JniOcResource()");\r
-    m_sharedResource = NULL;\r
-\r
-    jint envRet;\r
-    JNIEnv *env = GetJNIEnv(envRet);\r
-    if (NULL == env) return;\r
-\r
-    m_onGetManager.removeAllListeners(env);\r
-    m_onPutManager.removeAllListeners(env);\r
-    m_onPostManager.removeAllListeners(env);\r
-    m_onDeleteManager.removeAllListeners(env);\r
-    m_onObserveManager.removeAllListeners(env);\r
-\r
-    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-}\r
-\r
-OCStackResult JniOcResource::get(JNIEnv* env, const QueryParamsMap &queryParametersMap, jobject jListener)\r
-{\r
-    JniOnGetListener *onGetListener = addOnGetListener(env, jListener);\r
-\r
-    GetCallback getCallback = [onGetListener](\r
-        const HeaderOptions& opts,\r
-        const OCRepresentation& rep,\r
-        const int eCode)\r
-    {\r
-        onGetListener->onGetCallback(opts, rep, eCode);\r
-    };\r
-\r
-    return m_sharedResource->get(queryParametersMap, getCallback);\r
-}\r
-\r
-OCStackResult JniOcResource::get(JNIEnv* env, const QueryParamsMap &queryParametersMap, jobject jListener,\r
-    QualityOfService QoS)\r
-{\r
-    JniOnGetListener *onGetListener = addOnGetListener(env, jListener);\r
-\r
-    GetCallback getCallback = [onGetListener](const HeaderOptions& opts, const OCRepresentation& rep,\r
-        const int eCode)\r
-    {\r
-        onGetListener->onGetCallback(opts, rep, eCode);\r
-    };\r
-\r
-    return m_sharedResource->get(queryParametersMap, getCallback, QoS);\r
-}\r
-\r
-OCStackResult JniOcResource::get(\r
-    JNIEnv* env,\r
-    const std::string &resourceType,\r
-    const std::string &resourceInterface,\r
-    const QueryParamsMap &queryParametersMap,\r
-    jobject jListener)\r
-{\r
-    JniOnGetListener *onGetListener = addOnGetListener(env, jListener);\r
-\r
-    GetCallback getCallback = [onGetListener](const HeaderOptions& opts,\r
-        const OCRepresentation& rep, const int eCode)\r
-    {\r
-        onGetListener->onGetCallback(opts, rep, eCode);\r
-    };\r
-\r
-    return m_sharedResource->get(resourceType, resourceInterface, queryParametersMap,\r
-        getCallback);\r
-}\r
-\r
-OCStackResult JniOcResource::get(JNIEnv* env, const std::string &resourceType,\r
-    const std::string &resourceInterface, const QueryParamsMap &queryParametersMap,\r
-    jobject jListener, QualityOfService QoS)\r
-{\r
-    JniOnGetListener *onGetListener = addOnGetListener(env, jListener);\r
-\r
-    GetCallback getCallback = [onGetListener](const HeaderOptions& opts,\r
-        const OCRepresentation& rep, const int eCode)\r
-    {\r
-        onGetListener->onGetCallback(opts, rep, eCode);\r
-    };\r
-\r
-    return m_sharedResource->get(resourceType, resourceInterface, queryParametersMap,\r
-        getCallback, QoS);\r
-}\r
-\r
-OCStackResult JniOcResource::put(JNIEnv* env, const OCRepresentation &representation,\r
-    const QueryParamsMap &queryParametersMap, jobject jListener)\r
-{\r
-    JniOnPutListener *onPutListener = addOnPutListener(env, jListener);\r
-\r
-    PutCallback putCallback = [onPutListener](const HeaderOptions& opts,\r
-        const OCRepresentation& rep, const int eCode)\r
-    {\r
-        onPutListener->onPutCallback(opts, rep, eCode);\r
-    };\r
-\r
-    return m_sharedResource->put(representation, queryParametersMap, putCallback);\r
-}\r
-\r
-OCStackResult JniOcResource::put(JNIEnv* env, const OCRepresentation &representation,\r
-    const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS)\r
-{\r
-    JniOnPutListener *onPutListener = addOnPutListener(env, jListener);\r
-\r
-    PutCallback putCallback = [onPutListener](const HeaderOptions& opts,\r
-        const OCRepresentation& rep, const int eCode)\r
-    {\r
-        onPutListener->onPutCallback(opts, rep, eCode);\r
-    };\r
-\r
-    return m_sharedResource->put(representation, queryParametersMap, putCallback, QoS);\r
-}\r
-\r
-OCStackResult JniOcResource::put(JNIEnv* env, const std::string &resourceType,\r
-    const std::string &resourceInterface, const OCRepresentation &representation,\r
-    const QueryParamsMap &queryParametersMap, jobject jListener)\r
-{\r
-    JniOnPutListener *onPutListener = addOnPutListener(env, jListener);\r
-\r
-    PutCallback putCallback = [onPutListener](const HeaderOptions& opts,\r
-        const OCRepresentation& rep, const int eCode)\r
-    {\r
-        onPutListener->onPutCallback(opts, rep, eCode);\r
-    };\r
-\r
-    return m_sharedResource->put(resourceType, resourceInterface, representation,\r
-        queryParametersMap, putCallback);\r
-}\r
-\r
-OCStackResult JniOcResource::put(JNIEnv* env, const std::string &resourceType,\r
-    const std::string &resourceInterface, const OCRepresentation &representation,\r
-    const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS)\r
-{\r
-    JniOnPutListener *onPutListener = addOnPutListener(env, jListener);\r
-\r
-    PutCallback putCallback = [onPutListener](const HeaderOptions& opts,\r
-        const OCRepresentation& rep, const int eCode)\r
-    {\r
-        onPutListener->onPutCallback(opts, rep, eCode);\r
-    };\r
-\r
-    return m_sharedResource->put(resourceType, resourceInterface, representation,\r
-        queryParametersMap, putCallback, QoS);\r
-}\r
-\r
-OCStackResult JniOcResource::post(JNIEnv* env, const OCRepresentation &representation,\r
-    const QueryParamsMap &queryParametersMap, jobject jListener)\r
-{\r
-    JniOnPostListener *onPostListener = addOnPostListener(env, jListener);\r
-\r
-    PostCallback postCallback = [onPostListener](const HeaderOptions& opts,\r
-        const OCRepresentation& rep, const int eCode)\r
-    {\r
-        onPostListener->onPostCallback(opts, rep, eCode);\r
-    };\r
-\r
-    return m_sharedResource->post(representation, queryParametersMap, postCallback);\r
-}\r
-\r
-OCStackResult JniOcResource::post(JNIEnv* env, const OCRepresentation &representation,\r
-    const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS)\r
-{\r
-    JniOnPostListener *onPostListener = addOnPostListener(env, jListener);\r
-\r
-    PostCallback postCallback = [onPostListener](const HeaderOptions& opts,\r
-        const OCRepresentation& rep, const int eCode)\r
-    {\r
-        onPostListener->onPostCallback(opts, rep, eCode);\r
-    };\r
-\r
-    return m_sharedResource->post(representation, queryParametersMap, postCallback, QoS);\r
-}\r
-\r
-OCStackResult JniOcResource::post(JNIEnv* env, const std::string &resourceType,\r
-    const std::string &resourceInterface, const OCRepresentation &representation,\r
-    const QueryParamsMap &queryParametersMap, jobject jListener)\r
-{\r
-    JniOnPostListener *onPostListener = addOnPostListener(env, jListener);\r
-\r
-    PostCallback postCallback = [onPostListener](const HeaderOptions& opts,\r
-        const OCRepresentation& rep, const int eCode)\r
-    {\r
-        onPostListener->onPostCallback(opts, rep, eCode);\r
-    };\r
-\r
-    return m_sharedResource->post(resourceType, resourceInterface, representation,\r
-        queryParametersMap, postCallback);\r
-}\r
-\r
-OCStackResult JniOcResource::post(JNIEnv* env, const std::string &resourceType,\r
-    const std::string &resourceInterface, const OCRepresentation &representation,\r
-    const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS)\r
-{\r
-    JniOnPostListener *onPostListener = addOnPostListener(env, jListener);\r
-\r
-    PostCallback postCallback = [onPostListener](const HeaderOptions& opts,\r
-        const OCRepresentation& rep, const int eCode)\r
-    {\r
-        onPostListener->onPostCallback(opts, rep, eCode);\r
-    };\r
-\r
-    return m_sharedResource->post(resourceType, resourceInterface, representation,\r
-        queryParametersMap, postCallback, QoS);\r
-}\r
-\r
-OCStackResult JniOcResource::deleteResource(JNIEnv* env, jobject jListener)\r
-{\r
-    JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);\r
-\r
-    DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts,\r
-        const int eCode)\r
-    {\r
-        onDeleteListener->onDeleteCallback(opts, eCode);\r
-    };\r
-\r
-    return m_sharedResource->deleteResource(deleteCallback);\r
-}\r
-\r
-OCStackResult JniOcResource::deleteResource(JNIEnv* env, jobject jListener, QualityOfService QoS)\r
-{\r
-    JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);\r
-\r
-    DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts, const int eCode)\r
-    {\r
-        onDeleteListener->onDeleteCallback(opts, eCode);\r
-    };\r
-\r
-    return m_sharedResource->deleteResource(deleteCallback, QoS);\r
-}\r
-\r
-OCStackResult JniOcResource::observe(JNIEnv* env, ObserveType observeType,\r
-    const QueryParamsMap &queryParametersMap, jobject jListener)\r
-{\r
-    JniOnObserveListener *onObserveListener = addOnObserveListener(env, jListener);\r
-\r
-    ObserveCallback observeCallback = [onObserveListener](const HeaderOptions& opts,\r
-        const OCRepresentation& rep, const int& eCode, const int& sequenceNumber)\r
-    {\r
-        onObserveListener->onObserveCallback(opts, rep, eCode, sequenceNumber);\r
-    };\r
-\r
-    return m_sharedResource->observe(observeType, queryParametersMap, observeCallback);\r
-}\r
-\r
-OCStackResult JniOcResource::observe(JNIEnv* env, ObserveType observeType,\r
-    const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS)\r
-{\r
-    JniOnObserveListener *onObserveListener = addOnObserveListener(env, jListener);\r
-\r
-    ObserveCallback observeCallback = [onObserveListener](const HeaderOptions& opts,\r
-        const OCRepresentation& rep, const int& eCode, const int& sequenceNumber)\r
-    {\r
-        onObserveListener->onObserveCallback(opts, rep, eCode, sequenceNumber);\r
-    };\r
-\r
-    return m_sharedResource->observe(observeType, queryParametersMap, observeCallback, QoS);\r
-}\r
-\r
-OCStackResult JniOcResource::cancelObserve(JNIEnv* env)\r
-{\r
-    this->m_onObserveManager.removeAllListeners(env);\r
-    return m_sharedResource->cancelObserve();\r
-}\r
-\r
-OCStackResult JniOcResource::cancelObserve(JNIEnv* env, QualityOfService qos)\r
-{\r
-    //TODO confirm behavior\r
-    //add removal of java listeners by qos\r
-    this->m_onObserveManager.removeAllListeners(env);\r
-    return m_sharedResource->cancelObserve(qos);\r
-}\r
-\r
-void JniOcResource::setHeaderOptions(const HeaderOptions &headerOptions)\r
-{\r
-    m_sharedResource->setHeaderOptions(headerOptions);\r
-}\r
-\r
-void JniOcResource::unsetHeaderOptions()\r
-{\r
-    m_sharedResource->unsetHeaderOptions();\r
-}\r
-\r
-std::string JniOcResource::host()\r
-{\r
-    return m_sharedResource->host();\r
-}\r
-\r
-std::string JniOcResource::uri()\r
-{\r
-    return m_sharedResource->uri();\r
-}\r
-\r
-OCConnectivityType JniOcResource::connectivityType() const\r
-{\r
-    return m_sharedResource->connectivityType();\r
-}\r
-\r
-bool JniOcResource::isObservable()\r
-{\r
-    return m_sharedResource->isObservable();\r
-}\r
-\r
-std::vector< std::string > JniOcResource::getResourceTypes() const\r
-{\r
-    return m_sharedResource->getResourceTypes();\r
-}\r
-\r
-std::vector< std::string > JniOcResource::getResourceInterfaces(void) const\r
-{\r
-    return m_sharedResource->getResourceInterfaces();\r
-}\r
-\r
-OCResourceIdentifier JniOcResource::uniqueIdentifier() const\r
-{\r
-    return m_sharedResource->uniqueIdentifier();\r
-}\r
-\r
-std::string JniOcResource::sid() const\r
-{\r
-    return m_sharedResource->sid();\r
-}\r
-\r
-JniOnGetListener* JniOcResource::addOnGetListener(JNIEnv* env, jobject jListener)\r
-{\r
-    return this->m_onGetManager.addListener(env, jListener, this);\r
-}\r
-\r
-JniOnPutListener* JniOcResource::addOnPutListener(JNIEnv* env, jobject jListener)\r
-{\r
-    return this->m_onPutManager.addListener(env, jListener, this);\r
-}\r
-\r
-JniOnPostListener* JniOcResource::addOnPostListener(JNIEnv* env, jobject jListener)\r
-{\r
-    return this->m_onPostManager.addListener(env, jListener, this);\r
-}\r
-\r
-JniOnDeleteListener* JniOcResource::addOnDeleteListener(JNIEnv* env, jobject jListener)\r
-{\r
-    return this->m_onDeleteManager.addListener(env, jListener, this);\r
-}\r
-\r
-JniOnObserveListener* JniOcResource::addOnObserveListener(JNIEnv* env, jobject jListener)\r
-{\r
-    return this->m_onObserveManager.addListener(env, jListener, this);\r
-}\r
-\r
-void JniOcResource::removeOnGetListener(JNIEnv* env, jobject jListener)\r
-{\r
-    this->m_onGetManager.removeListener(env, jListener);\r
-}\r
-\r
-void JniOcResource::removeOnPutListener(JNIEnv* env, jobject jListener)\r
-{\r
-    this->m_onPutManager.removeListener(env, jListener);\r
-}\r
-\r
-void JniOcResource::removeOnPostListener(JNIEnv* env, jobject jListener)\r
-{\r
-    this->m_onPostManager.removeListener(env, jListener);\r
-}\r
-\r
-void JniOcResource::removeOnDeleteListener(JNIEnv* env, jobject jListener)\r
-{\r
-    this->m_onDeleteManager.removeListener(env, jListener);\r
-}\r
-\r
-void JniOcResource::removeOnObserveListener(JNIEnv* env, jobject jListener)\r
-{\r
-    this->m_onObserveManager.removeListener(env, jListener);\r
-}\r
-\r
-std::shared_ptr<OCResource> JniOcResource::getOCResource()\r
-{\r
-    return this->m_sharedResource;\r
-}\r
-\r
-JniOcResource* JniOcResource::getJniOcResourcePtr(JNIEnv *env, jobject thiz)\r
-{\r
-    JniOcResource *resource = GetHandle<JniOcResource>(env, thiz);\r
-    if (env->ExceptionCheck())\r
-    {\r
-        LOGE("Failed to get native handle from OcResource");\r
-    }\r
-    if (!resource)\r
-    {\r
-        ThrowOcException(JNI_NO_NATIVE_POINTER, "");\r
-    }\r
-    return resource;\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    get\r
-* Signature: (Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get\r
-(JNIEnv *env, jobject thiz, jobject jQueryParamsMap, jobject jListener)\r
-{\r
-    LOGD("OcResource_get");\r
-    if (!jQueryParamsMap)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
-        return;\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null");\r
-        return;\r
-    }\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    QueryParamsMap qpm;\r
-    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
-\r
-    try\r
-    {\r
-        OCStackResult result = resource->get(\r
-            env,\r
-            qpm,\r
-            jListener);\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "OcResource_get");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(e.code(), e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    get1\r
-* Signature: (Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get1\r
-(JNIEnv *env, jobject thiz, jobject jQueryParamsMap, jobject jListener, jint jQoS)\r
-{\r
-    LOGD("OcResource_get");\r
-    if (!jQueryParamsMap)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
-        return;\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null");\r
-        return;\r
-    }\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    QueryParamsMap qpm;\r
-    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
-\r
-    try\r
-    {\r
-        OCStackResult result = resource->get(\r
-            env,\r
-            qpm,\r
-            jListener,\r
-            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "OcResource_get");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(e.code(), e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    get2\r
-* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;\r
-Lorg/iotivity/base/OcResource/OnGetListener;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get2\r
-(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface,\r
-jobject jQueryParamsMap, jobject jListener)\r
-{\r
-    LOGD("OcResource_get");\r
-    std::string resourceType;\r
-    if (jResourceType)\r
-    {\r
-        resourceType = env->GetStringUTFChars(jResourceType, NULL);\r
-    }\r
-    std::string resourceInterface;\r
-    if (jResourceInterface)\r
-    {\r
-        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);\r
-    }\r
-    if (!jQueryParamsMap)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
-        return;\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null");\r
-        return;\r
-    }\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    QueryParamsMap qpm;\r
-    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
-    try\r
-    {\r
-        OCStackResult result = resource->get(\r
-            env,\r
-            resourceType,\r
-            resourceInterface,\r
-            qpm,\r
-            jListener);\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "OcResource_get");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(e.code(), e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    get3\r
-* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;\r
-Lorg/iotivity/base/OcResource/OnGetListener;I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get3\r
-(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface,\r
-jobject jQueryParamsMap, jobject jListener, jint jQoS)\r
-{\r
-    LOGD("OcResource_get");\r
-    if (!jQueryParamsMap)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
-        return;\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null");\r
-        return;\r
-    }\r
-    std::string resourceType;\r
-    if (jResourceType)\r
-    {\r
-        resourceType = env->GetStringUTFChars(jResourceType, NULL);\r
-    }\r
-    std::string resourceInterface;\r
-    if (jResourceInterface)\r
-    {\r
-        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);\r
-    }\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    QueryParamsMap qpm;\r
-    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
-\r
-    try\r
-    {\r
-        OCStackResult result = resource->get(\r
-            env,\r
-            resourceType,\r
-            resourceInterface,\r
-            qpm,\r
-            jListener,\r
-            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "OcResource_get");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(e.code(), e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    put\r
-* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;\r
-Lorg/iotivity/base/OcResource/OnPutListener;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put\r
-(JNIEnv *env, jobject thiz, jobject jRepresentation, jobject jQueryParamsMap, jobject jListener)\r
-{\r
-    LOGD("OcResource_put");\r
-    if (!jRepresentation)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
-        return;\r
-    }\r
-    if (!jQueryParamsMap)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
-        return;\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onPutListener cannot be null");\r
-        return;\r
-    }\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);\r
-    if (!representation) return;\r
-\r
-    QueryParamsMap qpm;\r
-    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
-\r
-    try\r
-    {\r
-        OCStackResult result = resource->put(\r
-            env,\r
-            *representation,\r
-            qpm,\r
-            jListener);\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "OcResource_put");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(e.code(), e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    put1\r
-* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;\r
-Lorg/iotivity/base/OcResource/OnPutListener;I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put1\r
-(JNIEnv *env, jobject thiz, jobject jRepresentation, jobject jQueryParamsMap,\r
-jobject jListener, jint jQoS)\r
-{\r
-    LOGD("OcResource_put");\r
-    if (!jRepresentation)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
-        return;\r
-    }\r
-    if (!jQueryParamsMap)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
-        return;\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onPutListener cannot be null");\r
-        return;\r
-    }\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);\r
-    if (!representation) return;\r
-\r
-    QueryParamsMap qpm;\r
-    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
-\r
-    try\r
-    {\r
-        OCStackResult result = resource->put(\r
-            env,\r
-            *representation,\r
-            qpm,\r
-            jListener,\r
-            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "OcResource_put");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(e.code(), e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    put2\r
-* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;\r
-Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put2\r
-(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface,\r
-jobject jRepresentation, jobject jQueryParamsMap, jobject jListener)\r
-{\r
-    LOGD("OcResource_put");\r
-    std::string resourceType;\r
-    if (jResourceType)\r
-    {\r
-        resourceType = env->GetStringUTFChars(jResourceType, NULL);\r
-    }\r
-    std::string resourceInterface;\r
-    if (jResourceInterface)\r
-    {\r
-        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);\r
-    }\r
-    if (!jRepresentation)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
-        return;\r
-    }\r
-    if (!jQueryParamsMap)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
-        return;\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onPutListener cannot be null");\r
-        return;\r
-    }\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);\r
-    if (!representation) return;\r
-\r
-    QueryParamsMap qpm;\r
-    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
-\r
-    try\r
-    {\r
-        OCStackResult result = resource->put(\r
-            env,\r
-            resourceType,\r
-            resourceInterface,\r
-            *representation,\r
-            qpm,\r
-            jListener);\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "OcResource_put");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(e.code(), e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    put3\r
-* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;\r
-Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put3\r
-(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface, jobject jRepresentation,\r
-jobject jQueryParamsMap, jobject jListener, jint jQoS)\r
-{\r
-    LOGD("OcResource_put");\r
-    if (!jRepresentation)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null");\r
-        return;\r
-    }\r
-    if (!jQueryParamsMap)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
-        return;\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onPutListener cannot be null");\r
-        return;\r
-    }\r
-    std::string resourceType;\r
-    if (jResourceType)\r
-    {\r
-        resourceType = env->GetStringUTFChars(jResourceType, NULL);\r
-    }\r
-    std::string resourceInterface;\r
-    if (jResourceInterface)\r
-    {\r
-        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);\r
-    }\r
-\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);\r
-    if (!representation) return;\r
-\r
-    QueryParamsMap qpm;\r
-    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
-\r
-    try\r
-    {\r
-        OCStackResult result = resource->put(\r
-            env,\r
-            resourceType,\r
-            resourceInterface,\r
-            *representation,\r
-            qpm,\r
-            jListener,\r
-            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "OcResource_put");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(e.code(), e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    post\r
-* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post\r
-(JNIEnv *env, jobject thiz, jobject jRepresentation, jobject jQueryParamsMap, jobject jListener)\r
-{\r
-    LOGD("OcResource_post");\r
-    if (!jRepresentation)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null");\r
-        return;\r
-    }\r
-    if (!jQueryParamsMap)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
-        return;\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");\r
-        return;\r
-    }\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);\r
-    if (!representation) return;\r
-\r
-    QueryParamsMap qpm;\r
-    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
-\r
-    try\r
-    {\r
-        OCStackResult result = resource->post(\r
-            env,\r
-            *representation,\r
-            qpm,\r
-            jListener);\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "OcResource_post");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(e.code(), e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    post1\r
-* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post1\r
-(JNIEnv *env, jobject thiz, jobject jRepresentation, jobject jQueryParamsMap, jobject jListener, jint jQoS)\r
-{\r
-    LOGD("OcResource_post");\r
-    if (!jRepresentation)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null");\r
-        return;\r
-    }\r
-    if (!jQueryParamsMap)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
-        return;\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");\r
-        return;\r
-    }\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);\r
-    if (!representation) return;\r
-\r
-    QueryParamsMap qpm;\r
-    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
-\r
-    try\r
-    {\r
-        OCStackResult result = resource->post(\r
-            env,\r
-            *representation,\r
-            qpm,\r
-            jListener,\r
-            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "OcResource_post");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(e.code(), e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    post2\r
-* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;\r
-Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post2\r
-(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface,\r
-jobject jRepresentation, jobject jQueryParamsMap, jobject jListener)\r
-{\r
-    LOGD("OcResource_post");\r
-    if (!jRepresentation)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null");\r
-        return;\r
-    }\r
-    if (!jQueryParamsMap)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
-        return;\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");\r
-        return;\r
-    }\r
-    std::string resourceType;\r
-    if (jResourceType)\r
-    {\r
-        resourceType = env->GetStringUTFChars(jResourceType, NULL);\r
-    }\r
-    std::string resourceInterface;\r
-    if (jResourceInterface)\r
-    {\r
-        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);\r
-    }\r
-\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);\r
-    if (!representation) return;\r
-\r
-    QueryParamsMap qpm;\r
-    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
-\r
-    try\r
-    {\r
-        OCStackResult result = resource->post(\r
-            env,\r
-            resourceType,\r
-            resourceInterface,\r
-            *representation,\r
-            qpm,\r
-            jListener);\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "OcResource_post");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(e.code(), e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    post3\r
-* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;\r
-Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post3\r
-(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface,\r
-jobject jRepresentation, jobject jQueryParamsMap, jobject jListener, jint jQoS)\r
-{\r
-    LOGD("OcResource_post");\r
-    if (!jRepresentation)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null");\r
-        return;\r
-    }\r
-    if (!jQueryParamsMap)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
-        return;\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");\r
-        return;\r
-    }\r
-    std::string resourceType;\r
-    if (jResourceType)\r
-    {\r
-        resourceType = env->GetStringUTFChars(jResourceType, NULL);\r
-    }\r
-    std::string resourceInterface;\r
-    if (jResourceInterface)\r
-    {\r
-        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);\r
-    }\r
-\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);\r
-    if (!representation) return;\r
-\r
-    QueryParamsMap qpm;\r
-    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
-\r
-    try\r
-    {\r
-        OCStackResult result = resource->post(\r
-            env,\r
-            resourceType,\r
-            resourceInterface,\r
-            *representation,\r
-            qpm,\r
-            jListener,\r
-            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "OcResource_post");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(e.code(), e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    deleteResource\r
-* Signature: (Lorg/iotivity/base/OcResource/OnDeleteListener;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_deleteResource\r
-(JNIEnv *env, jobject thiz, jobject jListener)\r
-{\r
-    LOGD("OcResource_deleteResource");\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onDeleteListener cannot be null");\r
-        return;\r
-    }\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    try\r
-    {\r
-        OCStackResult result = resource->deleteResource(\r
-            env,\r
-            jListener);\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "OcResource_deleteResource");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(e.code(), e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    deleteResource1\r
-* Signature: (Lorg/iotivity/base/OcResource/OnDeleteListener;I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_deleteResource1\r
-(JNIEnv *env, jobject thiz, jobject jListener, jint jQoS)\r
-{\r
-    LOGD("OcResource_deleteResource");\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onDeleteListener cannot be null");\r
-        return;\r
-    }\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    try\r
-    {\r
-        OCStackResult result = resource->deleteResource(\r
-            env,\r
-            jListener,\r
-            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "OcResource_deleteResource");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(e.code(), e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    observe\r
-* Signature: (Lorg/iotivity/base/ObserveType;Ljava/util/Map;\r
-Lorg/iotivity/base/OcResource/OnObserveListener;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_observe\r
-(JNIEnv *env, jobject thiz, jint observeType, jobject jQueryParamsMap, jobject jListener)\r
-{\r
-    LOGD("OcResource_observe");\r
-    if (!jQueryParamsMap)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
-        return;\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onObserveListener cannot be null");\r
-        return;\r
-    }\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    QueryParamsMap qpm;\r
-    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
-\r
-    try\r
-    {\r
-        OCStackResult result = resource->observe(\r
-            env,\r
-            JniUtils::getObserveType(env, static_cast<int>(observeType)),\r
-            qpm,\r
-            jListener);\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "OcResource_observe");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(e.code(), e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    observe1\r
-* Signature: (Lorg/iotivity/base/ObserveType;Ljava/util/Map;\r
-Lorg/iotivity/base/OcResource/OnObserveListener;I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_observe1\r
-(JNIEnv *env, jobject thiz, jint observeType, jobject jQueryParamsMap,\r
-jobject jListener, jint jQoS)\r
-{\r
-    LOGD("OcResource_observe");\r
-    if (!jQueryParamsMap)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");\r
-        return;\r
-    }\r
-    if (!jListener)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "onObserveListener cannot be null");\r
-        return;\r
-    }\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    QueryParamsMap qpm;\r
-    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);\r
-\r
-    try\r
-    {\r
-        OCStackResult result = resource->observe(\r
-            env,\r
-            JniUtils::getObserveType(env, static_cast<int>(observeType)),\r
-            qpm,\r
-            jListener,\r
-            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "OcResource_observe");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(e.code(), e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    cancelObserve\r
-* Signature: ()V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_cancelObserve\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResource_cancelObserve");\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    try\r
-    {\r
-        OCStackResult result = resource->cancelObserve(env);\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "OcResource_cancelObserve");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(e.code(), e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    cancelObserve1\r
-* Signature: I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_cancelObserve1\r
-(JNIEnv *env, jobject thiz, jint jQoS)\r
-{\r
-    LOGD("OcResource_cancelObserve1");\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    try\r
-    {\r
-        OCStackResult result = resource->cancelObserve(\r
-            env,\r
-            JniUtils::getQOS(env, static_cast<int>(jQoS)));\r
-\r
-        if (OC_STACK_OK != result)\r
-        {\r
-            ThrowOcException(result, "OcResource_cancelObserve");\r
-        }\r
-    }\r
-    catch (OCException& e)\r
-    {\r
-        LOGE("%s", e.reason().c_str());\r
-        ThrowOcException(e.code(), e.reason().c_str());\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    setHeaderOptions\r
-* Signature: ([Lorg/iotivity/OcHeaderOption;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_setHeaderOptions\r
-(JNIEnv *env, jobject thiz, jobjectArray jheaderOptionArr)\r
-{\r
-    LOGD("OcResource_setHeaderOptions");\r
-    if (!jheaderOptionArr)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "headerOptionList cannot be null");\r
-        return;\r
-    }\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    HeaderOptions headerOptions;\r
-    JniUtils::convertJavaHeaderOptionsArrToVector(env, jheaderOptionArr, headerOptions);\r
-\r
-    resource->setHeaderOptions(headerOptions);\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    unsetHeaderOptions\r
-* Signature: ()V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_unsetHeaderOptions\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResource_unsetHeaderOptions");\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return;\r
-\r
-    resource->unsetHeaderOptions();\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    getHost\r
-* Signature: ()Ljava/lang/String;\r
-*/\r
-JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getHost\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResource_getHost");\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return nullptr;\r
-\r
-    return env->NewStringUTF(resource->host().c_str());\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    getUri\r
-* Signature: ()Ljava/lang/String;\r
-*/\r
-JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getUri\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResource_getUri");\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return nullptr;\r
-\r
-    return env->NewStringUTF(resource->uri().c_str());\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    getConnectivityTypeN\r
-* Signature: ()I\r
-*/\r
-JNIEXPORT jint JNICALL Java_org_iotivity_base_OcResource_getConnectivityTypeN\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResource_getConnectivityType");\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return -1;\r
-\r
-    OCConnectivityType connectivityType = resource->connectivityType();\r
-    return static_cast<jint>(connectivityType);\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    isObservable\r
-* Signature: ()Z\r
-*/\r
-JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcResource_isObservable\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResource_isObservable");\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    return (jboolean)resource->isObservable();\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    getResourceTypes\r
-* Signature: ()Ljava/util/List;\r
-*/\r
-JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getResourceTypes\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResource_getResourceTypes");\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return nullptr;\r
-\r
-    std::vector<std::string> resourceTypes = resource->getResourceTypes();\r
-\r
-    return JniUtils::convertStrVectorToJavaStrList(env, resourceTypes);\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    getResourceInterfaces\r
-* Signature: ()Ljava/util/List;\r
-*/\r
-JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getResourceInterfaces\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResource_getResourceInterfaces");\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return nullptr;\r
-\r
-    std::vector<std::string> resourceInterfaces = resource->getResourceInterfaces();\r
-\r
-    return JniUtils::convertStrVectorToJavaStrList(env, resourceInterfaces);\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    getUniqueIdentifier\r
-* Signature: ()Lorg/iotivity/base/OcResourceIdentifier;\r
-*/\r
-JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getUniqueIdentifier\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResource_getUniqueIdentifier");\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return nullptr;\r
-\r
-    JniOcResourceIdentifier *jniResourceIdentifier =\r
-        new JniOcResourceIdentifier(resource->uniqueIdentifier());\r
-    if (!jniResourceIdentifier) return nullptr;\r
-\r
-    jlong handle = reinterpret_cast<jlong>(jniResourceIdentifier);\r
-    jobject jResourceIdentifier = env->NewObject(g_cls_OcResourceIdentifier,\r
-        g_mid_OcResourceIdentifier_N_ctor, handle);\r
-    if (!jResourceIdentifier)\r
-    {\r
-        delete jniResourceIdentifier;\r
-    }\r
-    return jResourceIdentifier;\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    getServerId\r
-* Signature: ()Ljava/lang/String;\r
-*/\r
-JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getServerId\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResource_getServerId");\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    if (!resource) return nullptr;\r
-\r
-    return env->NewStringUTF(resource->sid().c_str());\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResource\r
-* Method:    dispose\r
-* Signature: ()V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_dispose\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResource_dispose");\r
-    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);\r
-    delete resource;\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 "JniOcResource.h"
+#include "JniOcRepresentation.h"
+#include "JniUtils.h"
+
+JniOcResource::JniOcResource(std::shared_ptr<OCResource> resource)
+    : m_sharedResource(resource)
+{}
+
+JniOcResource::~JniOcResource()
+{
+    LOGD("~JniOcResource()");
+    m_sharedResource = NULL;
+
+    jint envRet;
+    JNIEnv *env = GetJNIEnv(envRet);
+    if (NULL == env) return;
+
+    m_onGetManager.removeAllListeners(env);
+    m_onPutManager.removeAllListeners(env);
+    m_onPostManager.removeAllListeners(env);
+    m_onDeleteManager.removeAllListeners(env);
+    m_onObserveManager.removeAllListeners(env);
+
+    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+}
+
+OCStackResult JniOcResource::get(JNIEnv* env, const QueryParamsMap &queryParametersMap, jobject jListener)
+{
+    JniOnGetListener *onGetListener = addOnGetListener(env, jListener);
+
+    GetCallback getCallback = [onGetListener](
+        const HeaderOptions& opts,
+        const OCRepresentation& rep,
+        const int eCode)
+    {
+        onGetListener->onGetCallback(opts, rep, eCode);
+    };
+
+    return m_sharedResource->get(queryParametersMap, getCallback);
+}
+
+OCStackResult JniOcResource::get(JNIEnv* env, const QueryParamsMap &queryParametersMap, jobject jListener,
+    QualityOfService QoS)
+{
+    JniOnGetListener *onGetListener = addOnGetListener(env, jListener);
+
+    GetCallback getCallback = [onGetListener](const HeaderOptions& opts, const OCRepresentation& rep,
+        const int eCode)
+    {
+        onGetListener->onGetCallback(opts, rep, eCode);
+    };
+
+    return m_sharedResource->get(queryParametersMap, getCallback, QoS);
+}
+
+OCStackResult JniOcResource::get(
+    JNIEnv* env,
+    const std::string &resourceType,
+    const std::string &resourceInterface,
+    const QueryParamsMap &queryParametersMap,
+    jobject jListener)
+{
+    JniOnGetListener *onGetListener = addOnGetListener(env, jListener);
+
+    GetCallback getCallback = [onGetListener](const HeaderOptions& opts,
+        const OCRepresentation& rep, const int eCode)
+    {
+        onGetListener->onGetCallback(opts, rep, eCode);
+    };
+
+    return m_sharedResource->get(resourceType, resourceInterface, queryParametersMap,
+        getCallback);
+}
+
+OCStackResult JniOcResource::get(JNIEnv* env, const std::string &resourceType,
+    const std::string &resourceInterface, const QueryParamsMap &queryParametersMap,
+    jobject jListener, QualityOfService QoS)
+{
+    JniOnGetListener *onGetListener = addOnGetListener(env, jListener);
+
+    GetCallback getCallback = [onGetListener](const HeaderOptions& opts,
+        const OCRepresentation& rep, const int eCode)
+    {
+        onGetListener->onGetCallback(opts, rep, eCode);
+    };
+
+    return m_sharedResource->get(resourceType, resourceInterface, queryParametersMap,
+        getCallback, QoS);
+}
+
+OCStackResult JniOcResource::put(JNIEnv* env, const OCRepresentation &representation,
+    const QueryParamsMap &queryParametersMap, jobject jListener)
+{
+    JniOnPutListener *onPutListener = addOnPutListener(env, jListener);
+
+    PutCallback putCallback = [onPutListener](const HeaderOptions& opts,
+        const OCRepresentation& rep, const int eCode)
+    {
+        onPutListener->onPutCallback(opts, rep, eCode);
+    };
+
+    return m_sharedResource->put(representation, queryParametersMap, putCallback);
+}
+
+OCStackResult JniOcResource::put(JNIEnv* env, const OCRepresentation &representation,
+    const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS)
+{
+    JniOnPutListener *onPutListener = addOnPutListener(env, jListener);
+
+    PutCallback putCallback = [onPutListener](const HeaderOptions& opts,
+        const OCRepresentation& rep, const int eCode)
+    {
+        onPutListener->onPutCallback(opts, rep, eCode);
+    };
+
+    return m_sharedResource->put(representation, queryParametersMap, putCallback, QoS);
+}
+
+OCStackResult JniOcResource::put(JNIEnv* env, const std::string &resourceType,
+    const std::string &resourceInterface, const OCRepresentation &representation,
+    const QueryParamsMap &queryParametersMap, jobject jListener)
+{
+    JniOnPutListener *onPutListener = addOnPutListener(env, jListener);
+
+    PutCallback putCallback = [onPutListener](const HeaderOptions& opts,
+        const OCRepresentation& rep, const int eCode)
+    {
+        onPutListener->onPutCallback(opts, rep, eCode);
+    };
+
+    return m_sharedResource->put(resourceType, resourceInterface, representation,
+        queryParametersMap, putCallback);
+}
+
+OCStackResult JniOcResource::put(JNIEnv* env, const std::string &resourceType,
+    const std::string &resourceInterface, const OCRepresentation &representation,
+    const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS)
+{
+    JniOnPutListener *onPutListener = addOnPutListener(env, jListener);
+
+    PutCallback putCallback = [onPutListener](const HeaderOptions& opts,
+        const OCRepresentation& rep, const int eCode)
+    {
+        onPutListener->onPutCallback(opts, rep, eCode);
+    };
+
+    return m_sharedResource->put(resourceType, resourceInterface, representation,
+        queryParametersMap, putCallback, QoS);
+}
+
+OCStackResult JniOcResource::post(JNIEnv* env, const OCRepresentation &representation,
+    const QueryParamsMap &queryParametersMap, jobject jListener)
+{
+    JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
+
+    PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
+        const OCRepresentation& rep, const int eCode)
+    {
+        onPostListener->onPostCallback(opts, rep, eCode);
+    };
+
+    return m_sharedResource->post(representation, queryParametersMap, postCallback);
+}
+
+OCStackResult JniOcResource::post(JNIEnv* env, const OCRepresentation &representation,
+    const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS)
+{
+    JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
+
+    PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
+        const OCRepresentation& rep, const int eCode)
+    {
+        onPostListener->onPostCallback(opts, rep, eCode);
+    };
+
+    return m_sharedResource->post(representation, queryParametersMap, postCallback, QoS);
+}
+
+OCStackResult JniOcResource::post(JNIEnv* env, const std::string &resourceType,
+    const std::string &resourceInterface, const OCRepresentation &representation,
+    const QueryParamsMap &queryParametersMap, jobject jListener)
+{
+    JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
+
+    PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
+        const OCRepresentation& rep, const int eCode)
+    {
+        onPostListener->onPostCallback(opts, rep, eCode);
+    };
+
+    return m_sharedResource->post(resourceType, resourceInterface, representation,
+        queryParametersMap, postCallback);
+}
+
+OCStackResult JniOcResource::post(JNIEnv* env, const std::string &resourceType,
+    const std::string &resourceInterface, const OCRepresentation &representation,
+    const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS)
+{
+    JniOnPostListener *onPostListener = addOnPostListener(env, jListener);
+
+    PostCallback postCallback = [onPostListener](const HeaderOptions& opts,
+        const OCRepresentation& rep, const int eCode)
+    {
+        onPostListener->onPostCallback(opts, rep, eCode);
+    };
+
+    return m_sharedResource->post(resourceType, resourceInterface, representation,
+        queryParametersMap, postCallback, QoS);
+}
+
+OCStackResult JniOcResource::deleteResource(JNIEnv* env, jobject jListener)
+{
+    JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);
+
+    DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts,
+        const int eCode)
+    {
+        onDeleteListener->onDeleteCallback(opts, eCode);
+    };
+
+    return m_sharedResource->deleteResource(deleteCallback);
+}
+
+OCStackResult JniOcResource::deleteResource(JNIEnv* env, jobject jListener, QualityOfService QoS)
+{
+    JniOnDeleteListener *onDeleteListener = addOnDeleteListener(env, jListener);
+
+    DeleteCallback deleteCallback = [onDeleteListener](const HeaderOptions& opts, const int eCode)
+    {
+        onDeleteListener->onDeleteCallback(opts, eCode);
+    };
+
+    return m_sharedResource->deleteResource(deleteCallback, QoS);
+}
+
+OCStackResult JniOcResource::observe(JNIEnv* env, ObserveType observeType,
+    const QueryParamsMap &queryParametersMap, jobject jListener)
+{
+    JniOnObserveListener *onObserveListener = addOnObserveListener(env, jListener);
+
+    ObserveCallback observeCallback = [onObserveListener](const HeaderOptions& opts,
+        const OCRepresentation& rep, const int& eCode, const int& sequenceNumber)
+    {
+        onObserveListener->onObserveCallback(opts, rep, eCode, sequenceNumber);
+    };
+
+    return m_sharedResource->observe(observeType, queryParametersMap, observeCallback);
+}
+
+OCStackResult JniOcResource::observe(JNIEnv* env, ObserveType observeType,
+    const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS)
+{
+    JniOnObserveListener *onObserveListener = addOnObserveListener(env, jListener);
+
+    ObserveCallback observeCallback = [onObserveListener](const HeaderOptions& opts,
+        const OCRepresentation& rep, const int& eCode, const int& sequenceNumber)
+    {
+        onObserveListener->onObserveCallback(opts, rep, eCode, sequenceNumber);
+    };
+
+    return m_sharedResource->observe(observeType, queryParametersMap, observeCallback, QoS);
+}
+
+OCStackResult JniOcResource::cancelObserve(JNIEnv* env)
+{
+    this->m_onObserveManager.removeAllListeners(env);
+    return m_sharedResource->cancelObserve();
+}
+
+OCStackResult JniOcResource::cancelObserve(JNIEnv* env, QualityOfService qos)
+{
+    //TODO confirm behavior
+    //add removal of java listeners by qos
+    this->m_onObserveManager.removeAllListeners(env);
+    return m_sharedResource->cancelObserve(qos);
+}
+
+void JniOcResource::setHeaderOptions(const HeaderOptions &headerOptions)
+{
+    m_sharedResource->setHeaderOptions(headerOptions);
+}
+
+void JniOcResource::unsetHeaderOptions()
+{
+    m_sharedResource->unsetHeaderOptions();
+}
+
+std::string JniOcResource::host()
+{
+    return m_sharedResource->host();
+}
+
+std::string JniOcResource::uri()
+{
+    return m_sharedResource->uri();
+}
+
+OCConnectivityType JniOcResource::connectivityType() const
+{
+    return m_sharedResource->connectivityType();
+}
+
+bool JniOcResource::isObservable()
+{
+    return m_sharedResource->isObservable();
+}
+
+std::vector< std::string > JniOcResource::getResourceTypes() const
+{
+    return m_sharedResource->getResourceTypes();
+}
+
+std::vector< std::string > JniOcResource::getResourceInterfaces(void) const
+{
+    return m_sharedResource->getResourceInterfaces();
+}
+
+OCResourceIdentifier JniOcResource::uniqueIdentifier() const
+{
+    return m_sharedResource->uniqueIdentifier();
+}
+
+std::string JniOcResource::sid() const
+{
+    return m_sharedResource->sid();
+}
+
+JniOnGetListener* JniOcResource::addOnGetListener(JNIEnv* env, jobject jListener)
+{
+    return this->m_onGetManager.addListener(env, jListener, this);
+}
+
+JniOnPutListener* JniOcResource::addOnPutListener(JNIEnv* env, jobject jListener)
+{
+    return this->m_onPutManager.addListener(env, jListener, this);
+}
+
+JniOnPostListener* JniOcResource::addOnPostListener(JNIEnv* env, jobject jListener)
+{
+    return this->m_onPostManager.addListener(env, jListener, this);
+}
+
+JniOnDeleteListener* JniOcResource::addOnDeleteListener(JNIEnv* env, jobject jListener)
+{
+    return this->m_onDeleteManager.addListener(env, jListener, this);
+}
+
+JniOnObserveListener* JniOcResource::addOnObserveListener(JNIEnv* env, jobject jListener)
+{
+    return this->m_onObserveManager.addListener(env, jListener, this);
+}
+
+void JniOcResource::removeOnGetListener(JNIEnv* env, jobject jListener)
+{
+    this->m_onGetManager.removeListener(env, jListener);
+}
+
+void JniOcResource::removeOnPutListener(JNIEnv* env, jobject jListener)
+{
+    this->m_onPutManager.removeListener(env, jListener);
+}
+
+void JniOcResource::removeOnPostListener(JNIEnv* env, jobject jListener)
+{
+    this->m_onPostManager.removeListener(env, jListener);
+}
+
+void JniOcResource::removeOnDeleteListener(JNIEnv* env, jobject jListener)
+{
+    this->m_onDeleteManager.removeListener(env, jListener);
+}
+
+void JniOcResource::removeOnObserveListener(JNIEnv* env, jobject jListener)
+{
+    this->m_onObserveManager.removeListener(env, jListener);
+}
+
+std::shared_ptr<OCResource> JniOcResource::getOCResource()
+{
+    return this->m_sharedResource;
+}
+
+JniOcResource* JniOcResource::getJniOcResourcePtr(JNIEnv *env, jobject thiz)
+{
+    JniOcResource *resource = GetHandle<JniOcResource>(env, thiz);
+    if (env->ExceptionCheck())
+    {
+        LOGE("Failed to get native handle from OcResource");
+    }
+    if (!resource)
+    {
+        ThrowOcException(JNI_NO_NATIVE_POINTER, "");
+    }
+    return resource;
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    get
+* Signature: (Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get
+(JNIEnv *env, jobject thiz, jobject jQueryParamsMap, jobject jListener)
+{
+    LOGD("OcResource_get");
+    if (!jQueryParamsMap)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");
+        return;
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null");
+        return;
+    }
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    QueryParamsMap qpm;
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
+
+    try
+    {
+        OCStackResult result = resource->get(
+            env,
+            qpm,
+            jListener);
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcResource_get");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    get1
+* Signature: (Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;I)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get1
+(JNIEnv *env, jobject thiz, jobject jQueryParamsMap, jobject jListener, jint jQoS)
+{
+    LOGD("OcResource_get");
+    if (!jQueryParamsMap)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");
+        return;
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null");
+        return;
+    }
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    QueryParamsMap qpm;
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
+
+    try
+    {
+        OCStackResult result = resource->get(
+            env,
+            qpm,
+            jListener,
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcResource_get");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    get2
+* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;
+Lorg/iotivity/base/OcResource/OnGetListener;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get2
+(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface,
+jobject jQueryParamsMap, jobject jListener)
+{
+    LOGD("OcResource_get");
+    std::string resourceType;
+    if (jResourceType)
+    {
+        resourceType = env->GetStringUTFChars(jResourceType, NULL);
+    }
+    std::string resourceInterface;
+    if (jResourceInterface)
+    {
+        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);
+    }
+    if (!jQueryParamsMap)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");
+        return;
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null");
+        return;
+    }
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    QueryParamsMap qpm;
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
+    try
+    {
+        OCStackResult result = resource->get(
+            env,
+            resourceType,
+            resourceInterface,
+            qpm,
+            jListener);
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcResource_get");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    get3
+* Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;
+Lorg/iotivity/base/OcResource/OnGetListener;I)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get3
+(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface,
+jobject jQueryParamsMap, jobject jListener, jint jQoS)
+{
+    LOGD("OcResource_get");
+    if (!jQueryParamsMap)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");
+        return;
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onGetListener cannot be null");
+        return;
+    }
+    std::string resourceType;
+    if (jResourceType)
+    {
+        resourceType = env->GetStringUTFChars(jResourceType, NULL);
+    }
+    std::string resourceInterface;
+    if (jResourceInterface)
+    {
+        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);
+    }
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    QueryParamsMap qpm;
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
+
+    try
+    {
+        OCStackResult result = resource->get(
+            env,
+            resourceType,
+            resourceInterface,
+            qpm,
+            jListener,
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcResource_get");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    put
+* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;
+Lorg/iotivity/base/OcResource/OnPutListener;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put
+(JNIEnv *env, jobject thiz, jobject jRepresentation, jobject jQueryParamsMap, jobject jListener)
+{
+    LOGD("OcResource_put");
+    if (!jRepresentation)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");
+        return;
+    }
+    if (!jQueryParamsMap)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");
+        return;
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPutListener cannot be null");
+        return;
+    }
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
+    if (!representation) return;
+
+    QueryParamsMap qpm;
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
+
+    try
+    {
+        OCStackResult result = resource->put(
+            env,
+            *representation,
+            qpm,
+            jListener);
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcResource_put");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    put1
+* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;
+Lorg/iotivity/base/OcResource/OnPutListener;I)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put1
+(JNIEnv *env, jobject thiz, jobject jRepresentation, jobject jQueryParamsMap,
+jobject jListener, jint jQoS)
+{
+    LOGD("OcResource_put");
+    if (!jRepresentation)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");
+        return;
+    }
+    if (!jQueryParamsMap)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");
+        return;
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPutListener cannot be null");
+        return;
+    }
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
+    if (!representation) return;
+
+    QueryParamsMap qpm;
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
+
+    try
+    {
+        OCStackResult result = resource->put(
+            env,
+            *representation,
+            qpm,
+            jListener,
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcResource_put");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    put2
+* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;
+Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put2
+(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface,
+jobject jRepresentation, jobject jQueryParamsMap, jobject jListener)
+{
+    LOGD("OcResource_put");
+    std::string resourceType;
+    if (jResourceType)
+    {
+        resourceType = env->GetStringUTFChars(jResourceType, NULL);
+    }
+    std::string resourceInterface;
+    if (jResourceInterface)
+    {
+        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);
+    }
+    if (!jRepresentation)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");
+        return;
+    }
+    if (!jQueryParamsMap)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");
+        return;
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPutListener cannot be null");
+        return;
+    }
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
+    if (!representation) return;
+
+    QueryParamsMap qpm;
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
+
+    try
+    {
+        OCStackResult result = resource->put(
+            env,
+            resourceType,
+            resourceInterface,
+            *representation,
+            qpm,
+            jListener);
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcResource_put");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    put3
+* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;
+Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;I)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put3
+(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface, jobject jRepresentation,
+jobject jQueryParamsMap, jobject jListener, jint jQoS)
+{
+    LOGD("OcResource_put");
+    if (!jRepresentation)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null");
+        return;
+    }
+    if (!jQueryParamsMap)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");
+        return;
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPutListener cannot be null");
+        return;
+    }
+    std::string resourceType;
+    if (jResourceType)
+    {
+        resourceType = env->GetStringUTFChars(jResourceType, NULL);
+    }
+    std::string resourceInterface;
+    if (jResourceInterface)
+    {
+        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);
+    }
+
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
+    if (!representation) return;
+
+    QueryParamsMap qpm;
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
+
+    try
+    {
+        OCStackResult result = resource->put(
+            env,
+            resourceType,
+            resourceInterface,
+            *representation,
+            qpm,
+            jListener,
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcResource_put");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    post
+* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post
+(JNIEnv *env, jobject thiz, jobject jRepresentation, jobject jQueryParamsMap, jobject jListener)
+{
+    LOGD("OcResource_post");
+    if (!jRepresentation)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null");
+        return;
+    }
+    if (!jQueryParamsMap)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");
+        return;
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");
+        return;
+    }
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
+    if (!representation) return;
+
+    QueryParamsMap qpm;
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
+
+    try
+    {
+        OCStackResult result = resource->post(
+            env,
+            *representation,
+            qpm,
+            jListener);
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcResource_post");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    post1
+* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;I)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post1
+(JNIEnv *env, jobject thiz, jobject jRepresentation, jobject jQueryParamsMap, jobject jListener, jint jQoS)
+{
+    LOGD("OcResource_post");
+    if (!jRepresentation)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null");
+        return;
+    }
+    if (!jQueryParamsMap)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");
+        return;
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");
+        return;
+    }
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
+    if (!representation) return;
+
+    QueryParamsMap qpm;
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
+
+    try
+    {
+        OCStackResult result = resource->post(
+            env,
+            *representation,
+            qpm,
+            jListener,
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcResource_post");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    post2
+* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;
+Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post2
+(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface,
+jobject jRepresentation, jobject jQueryParamsMap, jobject jListener)
+{
+    LOGD("OcResource_post");
+    if (!jRepresentation)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null");
+        return;
+    }
+    if (!jQueryParamsMap)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");
+        return;
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");
+        return;
+    }
+    std::string resourceType;
+    if (jResourceType)
+    {
+        resourceType = env->GetStringUTFChars(jResourceType, NULL);
+    }
+    std::string resourceInterface;
+    if (jResourceInterface)
+    {
+        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);
+    }
+
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
+    if (!representation) return;
+
+    QueryParamsMap qpm;
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
+
+    try
+    {
+        OCStackResult result = resource->post(
+            env,
+            resourceType,
+            resourceInterface,
+            *representation,
+            qpm,
+            jListener);
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcResource_post");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    post3
+* Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;
+Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;I)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post3
+(JNIEnv *env, jobject thiz, jstring jResourceType, jstring jResourceInterface,
+jobject jRepresentation, jobject jQueryParamsMap, jobject jListener, jint jQoS)
+{
+    LOGD("OcResource_post");
+    if (!jRepresentation)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "representation cannot be null");
+        return;
+    }
+    if (!jQueryParamsMap)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");
+        return;
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onPostListener cannot be null");
+        return;
+    }
+    std::string resourceType;
+    if (jResourceType)
+    {
+        resourceType = env->GetStringUTFChars(jResourceType, NULL);
+    }
+    std::string resourceInterface;
+    if (jResourceInterface)
+    {
+        resourceInterface = env->GetStringUTFChars(jResourceInterface, NULL);
+    }
+
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env, jRepresentation);
+    if (!representation) return;
+
+    QueryParamsMap qpm;
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
+
+    try
+    {
+        OCStackResult result = resource->post(
+            env,
+            resourceType,
+            resourceInterface,
+            *representation,
+            qpm,
+            jListener,
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcResource_post");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    deleteResource
+* Signature: (Lorg/iotivity/base/OcResource/OnDeleteListener;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_deleteResource
+(JNIEnv *env, jobject thiz, jobject jListener)
+{
+    LOGD("OcResource_deleteResource");
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onDeleteListener cannot be null");
+        return;
+    }
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    try
+    {
+        OCStackResult result = resource->deleteResource(
+            env,
+            jListener);
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcResource_deleteResource");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    deleteResource1
+* Signature: (Lorg/iotivity/base/OcResource/OnDeleteListener;I)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_deleteResource1
+(JNIEnv *env, jobject thiz, jobject jListener, jint jQoS)
+{
+    LOGD("OcResource_deleteResource");
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onDeleteListener cannot be null");
+        return;
+    }
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    try
+    {
+        OCStackResult result = resource->deleteResource(
+            env,
+            jListener,
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcResource_deleteResource");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    observe
+* Signature: (Lorg/iotivity/base/ObserveType;Ljava/util/Map;
+Lorg/iotivity/base/OcResource/OnObserveListener;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_observe
+(JNIEnv *env, jobject thiz, jint observeType, jobject jQueryParamsMap, jobject jListener)
+{
+    LOGD("OcResource_observe");
+    if (!jQueryParamsMap)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");
+        return;
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onObserveListener cannot be null");
+        return;
+    }
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    QueryParamsMap qpm;
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
+
+    try
+    {
+        OCStackResult result = resource->observe(
+            env,
+            JniUtils::getObserveType(env, static_cast<int>(observeType)),
+            qpm,
+            jListener);
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcResource_observe");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    observe1
+* Signature: (Lorg/iotivity/base/ObserveType;Ljava/util/Map;
+Lorg/iotivity/base/OcResource/OnObserveListener;I)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_observe1
+(JNIEnv *env, jobject thiz, jint observeType, jobject jQueryParamsMap,
+jobject jListener, jint jQoS)
+{
+    LOGD("OcResource_observe");
+    if (!jQueryParamsMap)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "queryParamsMap cannot be null");
+        return;
+    }
+    if (!jListener)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "onObserveListener cannot be null");
+        return;
+    }
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    QueryParamsMap qpm;
+    JniUtils::convertJavaMapToQueryParamsMap(env, jQueryParamsMap, qpm);
+
+    try
+    {
+        OCStackResult result = resource->observe(
+            env,
+            JniUtils::getObserveType(env, static_cast<int>(observeType)),
+            qpm,
+            jListener,
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcResource_observe");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    cancelObserve
+* Signature: ()V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_cancelObserve
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResource_cancelObserve");
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    try
+    {
+        OCStackResult result = resource->cancelObserve(env);
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcResource_cancelObserve");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    cancelObserve1
+* Signature: I)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_cancelObserve1
+(JNIEnv *env, jobject thiz, jint jQoS)
+{
+    LOGD("OcResource_cancelObserve1");
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    try
+    {
+        OCStackResult result = resource->cancelObserve(
+            env,
+            JniUtils::getQOS(env, static_cast<int>(jQoS)));
+
+        if (OC_STACK_OK != result)
+        {
+            ThrowOcException(result, "OcResource_cancelObserve");
+        }
+    }
+    catch (OCException& e)
+    {
+        LOGE("%s", e.reason().c_str());
+        ThrowOcException(e.code(), e.reason().c_str());
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    setHeaderOptions
+* Signature: ([Lorg/iotivity/OcHeaderOption;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_setHeaderOptions
+(JNIEnv *env, jobject thiz, jobjectArray jheaderOptionArr)
+{
+    LOGD("OcResource_setHeaderOptions");
+    if (!jheaderOptionArr)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "headerOptionList cannot be null");
+        return;
+    }
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    HeaderOptions headerOptions;
+    JniUtils::convertJavaHeaderOptionsArrToVector(env, jheaderOptionArr, headerOptions);
+
+    resource->setHeaderOptions(headerOptions);
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    unsetHeaderOptions
+* Signature: ()V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_unsetHeaderOptions
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResource_unsetHeaderOptions");
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return;
+
+    resource->unsetHeaderOptions();
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    getHost
+* Signature: ()Ljava/lang/String;
+*/
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getHost
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResource_getHost");
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return nullptr;
+
+    return env->NewStringUTF(resource->host().c_str());
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    getUri
+* Signature: ()Ljava/lang/String;
+*/
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getUri
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResource_getUri");
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return nullptr;
+
+    return env->NewStringUTF(resource->uri().c_str());
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    getConnectivityTypeN
+* Signature: ()I
+*/
+JNIEXPORT jint JNICALL Java_org_iotivity_base_OcResource_getConnectivityTypeN
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResource_getConnectivityType");
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return -1;
+
+    OCConnectivityType connectivityType = resource->connectivityType();
+    return static_cast<jint>(connectivityType);
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    isObservable
+* Signature: ()Z
+*/
+JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcResource_isObservable
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResource_isObservable");
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    return (jboolean)resource->isObservable();
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    getResourceTypes
+* Signature: ()Ljava/util/List;
+*/
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getResourceTypes
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResource_getResourceTypes");
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return nullptr;
+
+    std::vector<std::string> resourceTypes = resource->getResourceTypes();
+
+    return JniUtils::convertStrVectorToJavaStrList(env, resourceTypes);
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    getResourceInterfaces
+* Signature: ()Ljava/util/List;
+*/
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getResourceInterfaces
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResource_getResourceInterfaces");
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return nullptr;
+
+    std::vector<std::string> resourceInterfaces = resource->getResourceInterfaces();
+
+    return JniUtils::convertStrVectorToJavaStrList(env, resourceInterfaces);
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    getUniqueIdentifier
+* Signature: ()Lorg/iotivity/base/OcResourceIdentifier;
+*/
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getUniqueIdentifier
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResource_getUniqueIdentifier");
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return nullptr;
+
+    JniOcResourceIdentifier *jniResourceIdentifier =
+        new JniOcResourceIdentifier(resource->uniqueIdentifier());
+    if (!jniResourceIdentifier) return nullptr;
+
+    jlong handle = reinterpret_cast<jlong>(jniResourceIdentifier);
+    jobject jResourceIdentifier = env->NewObject(g_cls_OcResourceIdentifier,
+        g_mid_OcResourceIdentifier_N_ctor, handle);
+    if (!jResourceIdentifier)
+    {
+        delete jniResourceIdentifier;
+    }
+    return jResourceIdentifier;
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    getServerId
+* Signature: ()Ljava/lang/String;
+*/
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getServerId
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResource_getServerId");
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    if (!resource) return nullptr;
+
+    return env->NewStringUTF(resource->sid().c_str());
+}
+
+/*
+* Class:     org_iotivity_base_OcResource
+* Method:    dispose
+* Signature: ()V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_dispose
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResource_dispose");
+    JniOcResource *resource = JniOcResource::getJniOcResourcePtr(env, thiz);
+    delete resource;
 }
\ No newline at end of file
index 737dd5f..cb36691 100644 (file)
-/*\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
-\r
-#include "JniOcStack.h"\r
-#include "OCResource.h"\r
-#include "JniListenerManager.h"\r
-#include "JniOnGetListener.h"\r
-#include "JniOnPutListener.h"\r
-#include "JniOnPostListener.h"\r
-#include "JniOnDeleteListener.h"\r
-#include "JniOnObserveListener.h"\r
-#include "JniOcResourceIdentifier.h"\r
-\r
-#ifndef _Included_org_iotivity_base_OcResource\r
-#define _Included_org_iotivity_base_OcResource\r
-\r
-using namespace OC;\r
-\r
-class JniOcResource\r
-{\r
-public:\r
-    JniOcResource(std::shared_ptr<OCResource> resource);\r
-    ~JniOcResource();\r
-\r
-    OCStackResult get(JNIEnv* env, const QueryParamsMap &queryParametersMap, jobject jListener);\r
-    OCStackResult get(JNIEnv* env, const QueryParamsMap &queryParametersMap, jobject jListener,\r
-        QualityOfService QoS);\r
-    OCStackResult get(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface,\r
-        const QueryParamsMap &queryParametersMap, jobject jListener);\r
-    OCStackResult get(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface,\r
-        const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS);\r
-\r
-    OCStackResult put(JNIEnv* env, const OCRepresentation &representation, const QueryParamsMap &queryParametersMap,\r
-        jobject jListener);\r
-    OCStackResult put(JNIEnv* env, const OCRepresentation &representation, const QueryParamsMap &queryParametersMap,\r
-        jobject jListener, QualityOfService QoS);\r
-    OCStackResult put(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface,\r
-        const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, jobject jListener);\r
-    OCStackResult put(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface,\r
-        const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS);\r
-\r
-    OCStackResult post(JNIEnv* env, const OCRepresentation &representation, const QueryParamsMap &queryParametersMap,\r
-        jobject jListener);\r
-    OCStackResult post(JNIEnv* env, const OCRepresentation &representation, const QueryParamsMap &queryParametersMap,\r
-        jobject jListener, QualityOfService QoS);\r
-    OCStackResult post(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface,\r
-        const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, jobject jListener);\r
-    OCStackResult post(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface,\r
-        const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS);\r
-\r
-    OCStackResult deleteResource(JNIEnv* env, jobject jListener);\r
-    OCStackResult deleteResource(JNIEnv* env, jobject jListener, QualityOfService QoS);\r
-\r
-    OCStackResult observe(JNIEnv* env, ObserveType observeType, const QueryParamsMap &queryParametersMap,\r
-        jobject jListener);\r
-    OCStackResult observe(JNIEnv* env, ObserveType observeType, const QueryParamsMap &queryParametersMap,\r
-        jobject jListener, QualityOfService qos);\r
-\r
-    OCStackResult cancelObserve(JNIEnv* env);\r
-    OCStackResult cancelObserve(JNIEnv* env, QualityOfService qos);\r
-\r
-    void setHeaderOptions(const HeaderOptions &headerOptions);\r
-    void unsetHeaderOptions();\r
-    std::string host();\r
-    std::string uri();\r
-    OCConnectivityType connectivityType() const;\r
-    bool isObservable();\r
-    std::vector< std::string >         getResourceTypes() const;\r
-    std::vector< std::string >         getResourceInterfaces(void) const;\r
-    OCResourceIdentifier uniqueIdentifier() const;\r
-    std::string sid() const;\r
-\r
-    JniOnGetListener* addOnGetListener(JNIEnv* env, jobject jListener);\r
-    JniOnPutListener* addOnPutListener(JNIEnv* env, jobject jListener);\r
-    JniOnPostListener* addOnPostListener(JNIEnv* env, jobject jListener);\r
-    JniOnDeleteListener* addOnDeleteListener(JNIEnv* env, jobject jListener);\r
-    JniOnObserveListener* addOnObserveListener(JNIEnv* env, jobject jListener);\r
-\r
-    void removeOnGetListener(JNIEnv* env, jobject jListener);\r
-    void removeOnPutListener(JNIEnv* env, jobject jListener);\r
-    void removeOnPostListener(JNIEnv* env, jobject jListener);\r
-    void removeOnDeleteListener(JNIEnv* env, jobject jListener);\r
-    void removeOnObserveListener(JNIEnv* env, jobject jListener);\r
-\r
-    std::shared_ptr<OCResource> getOCResource();\r
-\r
-    static JniOcResource* getJniOcResourcePtr(JNIEnv *env, jobject thiz);\r
-\r
-private:\r
-    JniListenerManager<JniOnGetListener> m_onGetManager;\r
-    JniListenerManager<JniOnPutListener> m_onPutManager;\r
-    JniListenerManager<JniOnPostListener> m_onPostManager;\r
-    JniListenerManager<JniOnDeleteListener> m_onDeleteManager;\r
-    JniListenerManager<JniOnObserveListener> m_onObserveManager;\r
-\r
-    std::shared_ptr<OCResource> m_sharedResource;\r
-};\r
-\r
-/* DO NOT EDIT THIS FILE BEYOND THIS LINE - it is machine generated */\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    get\r
-    * Signature: (Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get\r
-        (JNIEnv *, jobject, jobject, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    get1\r
-    * Signature: (Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;I)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get1\r
-        (JNIEnv *, jobject, jobject, jobject, jint);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    get2\r
-    * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get2\r
-        (JNIEnv *, jobject, jstring, jstring, jobject, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    get3\r
-    * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;I)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get3\r
-        (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jint);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    put\r
-    * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put\r
-        (JNIEnv *, jobject, jobject, jobject, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    put1\r
-    * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;I)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put1\r
-        (JNIEnv *, jobject, jobject, jobject, jobject, jint);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    put2\r
-    * Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put2\r
-        (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    put3\r
-    * Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;I)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put3\r
-        (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jobject, jint);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    post\r
-    * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post\r
-        (JNIEnv *, jobject, jobject, jobject, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    post1\r
-    * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;I)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post1\r
-        (JNIEnv *, jobject, jobject, jobject, jobject, jint);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    post2\r
-    * Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post2\r
-        (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    post3\r
-    * Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;I)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post3\r
-        (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jobject, jint);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    deleteResource\r
-    * Signature: (Lorg/iotivity/base/OcResource/OnDeleteListener;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_deleteResource\r
-        (JNIEnv *, jobject, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    deleteResource1\r
-    * Signature: (Lorg/iotivity/base/OcResource/OnDeleteListener;I)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_deleteResource1\r
-        (JNIEnv *, jobject, jobject, jint);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    observe\r
-    * Signature: (Lorg/iotivity/base/ObserveType;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnObserveListener;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_observe\r
-        (JNIEnv *, jobject, jint, jobject, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    observe1\r
-    * Signature: (Lorg/iotivity/base/ObserveType;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnObserveListener;I)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_observe1\r
-        (JNIEnv *, jobject, jint, jobject, jobject, jint);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    cancelObserve\r
-    * Signature: ()V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_cancelObserve\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    cancelObserve1\r
-    * Signature: (I)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_cancelObserve1\r
-        (JNIEnv *, jobject, jint);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    setHeaderOptions\r
-    * Signature: ([Lorg/iotivity/OcHeaderOption;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_setHeaderOptions\r
-        (JNIEnv *, jobject, jobjectArray);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    unsetHeaderOptions\r
-    * Signature: ()V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_unsetHeaderOptions\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    getHost\r
-    * Signature: ()Ljava/lang/String;\r
-    */\r
-    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getHost\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    getUri\r
-    * Signature: ()Ljava/lang/String;\r
-    */\r
-    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getUri\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    getConnectivityTypeN\r
-    * Signature: ()I\r
-    */\r
-    JNIEXPORT jint JNICALL Java_org_iotivity_base_OcResource_getConnectivityTypeN\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    isObservable\r
-    * Signature: ()Z\r
-    */\r
-    JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcResource_isObservable\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    getResourceTypes\r
-    * Signature: ()Ljava/util/List;\r
-    */\r
-    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getResourceTypes\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    getResourceInterfaces\r
-    * Signature: ()Ljava/util/List;\r
-    */\r
-    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getResourceInterfaces\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    getUniqueIdentifier\r
-    * Signature: ()Lorg/iotivity/base/OcResourceIdentifier;\r
-    */\r
-    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getUniqueIdentifier\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    getServerId\r
-    * Signature: ()Ljava/lang/String;\r
-    */\r
-    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getServerId\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResource\r
-    * Method:    dispose\r
-    * Signature: ()V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_dispose\r
-        (JNIEnv *, jobject);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\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 "JniOcStack.h"
+#include "OCResource.h"
+#include "JniListenerManager.h"
+#include "JniOnGetListener.h"
+#include "JniOnPutListener.h"
+#include "JniOnPostListener.h"
+#include "JniOnDeleteListener.h"
+#include "JniOnObserveListener.h"
+#include "JniOcResourceIdentifier.h"
+
+#ifndef _Included_org_iotivity_base_OcResource
+#define _Included_org_iotivity_base_OcResource
+
+using namespace OC;
+
+class JniOcResource
+{
+public:
+    JniOcResource(std::shared_ptr<OCResource> resource);
+    ~JniOcResource();
+
+    OCStackResult get(JNIEnv* env, const QueryParamsMap &queryParametersMap, jobject jListener);
+    OCStackResult get(JNIEnv* env, const QueryParamsMap &queryParametersMap, jobject jListener,
+        QualityOfService QoS);
+    OCStackResult get(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface,
+        const QueryParamsMap &queryParametersMap, jobject jListener);
+    OCStackResult get(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface,
+        const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS);
+
+    OCStackResult put(JNIEnv* env, const OCRepresentation &representation, const QueryParamsMap &queryParametersMap,
+        jobject jListener);
+    OCStackResult put(JNIEnv* env, const OCRepresentation &representation, const QueryParamsMap &queryParametersMap,
+        jobject jListener, QualityOfService QoS);
+    OCStackResult put(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface,
+        const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, jobject jListener);
+    OCStackResult put(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface,
+        const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS);
+
+    OCStackResult post(JNIEnv* env, const OCRepresentation &representation, const QueryParamsMap &queryParametersMap,
+        jobject jListener);
+    OCStackResult post(JNIEnv* env, const OCRepresentation &representation, const QueryParamsMap &queryParametersMap,
+        jobject jListener, QualityOfService QoS);
+    OCStackResult post(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface,
+        const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, jobject jListener);
+    OCStackResult post(JNIEnv* env, const std::string &resourceType, const std::string &resourceInterface,
+        const OCRepresentation &representation, const QueryParamsMap &queryParametersMap, jobject jListener, QualityOfService QoS);
+
+    OCStackResult deleteResource(JNIEnv* env, jobject jListener);
+    OCStackResult deleteResource(JNIEnv* env, jobject jListener, QualityOfService QoS);
+
+    OCStackResult observe(JNIEnv* env, ObserveType observeType, const QueryParamsMap &queryParametersMap,
+        jobject jListener);
+    OCStackResult observe(JNIEnv* env, ObserveType observeType, const QueryParamsMap &queryParametersMap,
+        jobject jListener, QualityOfService qos);
+
+    OCStackResult cancelObserve(JNIEnv* env);
+    OCStackResult cancelObserve(JNIEnv* env, QualityOfService qos);
+
+    void setHeaderOptions(const HeaderOptions &headerOptions);
+    void unsetHeaderOptions();
+    std::string host();
+    std::string uri();
+    OCConnectivityType connectivityType() const;
+    bool isObservable();
+    std::vector< std::string >         getResourceTypes() const;
+    std::vector< std::string >         getResourceInterfaces(void) const;
+    OCResourceIdentifier uniqueIdentifier() const;
+    std::string sid() const;
+
+    JniOnGetListener* addOnGetListener(JNIEnv* env, jobject jListener);
+    JniOnPutListener* addOnPutListener(JNIEnv* env, jobject jListener);
+    JniOnPostListener* addOnPostListener(JNIEnv* env, jobject jListener);
+    JniOnDeleteListener* addOnDeleteListener(JNIEnv* env, jobject jListener);
+    JniOnObserveListener* addOnObserveListener(JNIEnv* env, jobject jListener);
+
+    void removeOnGetListener(JNIEnv* env, jobject jListener);
+    void removeOnPutListener(JNIEnv* env, jobject jListener);
+    void removeOnPostListener(JNIEnv* env, jobject jListener);
+    void removeOnDeleteListener(JNIEnv* env, jobject jListener);
+    void removeOnObserveListener(JNIEnv* env, jobject jListener);
+
+    std::shared_ptr<OCResource> getOCResource();
+
+    static JniOcResource* getJniOcResourcePtr(JNIEnv *env, jobject thiz);
+
+private:
+    JniListenerManager<JniOnGetListener> m_onGetManager;
+    JniListenerManager<JniOnPutListener> m_onPutManager;
+    JniListenerManager<JniOnPostListener> m_onPostManager;
+    JniListenerManager<JniOnDeleteListener> m_onDeleteManager;
+    JniListenerManager<JniOnObserveListener> m_onObserveManager;
+
+    std::shared_ptr<OCResource> m_sharedResource;
+};
+
+/* DO NOT EDIT THIS FILE BEYOND THIS LINE - it is machine generated */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    get
+    * Signature: (Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get
+        (JNIEnv *, jobject, jobject, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    get1
+    * Signature: (Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get1
+        (JNIEnv *, jobject, jobject, jobject, jint);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    get2
+    * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get2
+        (JNIEnv *, jobject, jstring, jstring, jobject, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    get3
+    * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnGetListener;I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_get3
+        (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jint);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    put
+    * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put
+        (JNIEnv *, jobject, jobject, jobject, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    put1
+    * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put1
+        (JNIEnv *, jobject, jobject, jobject, jobject, jint);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    put2
+    * Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put2
+        (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    put3
+    * Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPutListener;I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_put3
+        (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jobject, jint);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    post
+    * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post
+        (JNIEnv *, jobject, jobject, jobject, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    post1
+    * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post1
+        (JNIEnv *, jobject, jobject, jobject, jobject, jint);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    post2
+    * Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post2
+        (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    post3
+    * Signature: (Ljava/lang/String;Ljava/lang/String;Lorg/iotivity/base/OcRepresentation;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnPostListener;I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_post3
+        (JNIEnv *, jobject, jstring, jstring, jobject, jobject, jobject, jint);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    deleteResource
+    * Signature: (Lorg/iotivity/base/OcResource/OnDeleteListener;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_deleteResource
+        (JNIEnv *, jobject, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    deleteResource1
+    * Signature: (Lorg/iotivity/base/OcResource/OnDeleteListener;I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_deleteResource1
+        (JNIEnv *, jobject, jobject, jint);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    observe
+    * Signature: (Lorg/iotivity/base/ObserveType;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnObserveListener;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_observe
+        (JNIEnv *, jobject, jint, jobject, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    observe1
+    * Signature: (Lorg/iotivity/base/ObserveType;Ljava/util/Map;Lorg/iotivity/base/OcResource/OnObserveListener;I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_observe1
+        (JNIEnv *, jobject, jint, jobject, jobject, jint);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    cancelObserve
+    * Signature: ()V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_cancelObserve
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    cancelObserve1
+    * Signature: (I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_cancelObserve1
+        (JNIEnv *, jobject, jint);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    setHeaderOptions
+    * Signature: ([Lorg/iotivity/OcHeaderOption;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_setHeaderOptions
+        (JNIEnv *, jobject, jobjectArray);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    unsetHeaderOptions
+    * Signature: ()V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_unsetHeaderOptions
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    getHost
+    * Signature: ()Ljava/lang/String;
+    */
+    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getHost
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    getUri
+    * Signature: ()Ljava/lang/String;
+    */
+    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getUri
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    getConnectivityTypeN
+    * Signature: ()I
+    */
+    JNIEXPORT jint JNICALL Java_org_iotivity_base_OcResource_getConnectivityTypeN
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    isObservable
+    * Signature: ()Z
+    */
+    JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcResource_isObservable
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    getResourceTypes
+    * Signature: ()Ljava/util/List;
+    */
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getResourceTypes
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    getResourceInterfaces
+    * Signature: ()Ljava/util/List;
+    */
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getResourceInterfaces
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    getUniqueIdentifier
+    * Signature: ()Lorg/iotivity/base/OcResourceIdentifier;
+    */
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResource_getUniqueIdentifier
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    getServerId
+    * Signature: ()Ljava/lang/String;
+    */
+    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResource_getServerId
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResource
+    * Method:    dispose
+    * Signature: ()V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResource_dispose
+        (JNIEnv *, jobject);
+
+#ifdef __cplusplus
+}
+#endif
 #endif
\ No newline at end of file
index 84f748e..2d438f2 100644 (file)
@@ -1,66 +1,66 @@
-/*\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 "JniOcResourceHandle.h"\r
-\r
-using namespace OC;\r
-\r
-JniOcResourceHandle::JniOcResourceHandle(OCResourceHandle resourceHandle)\r
-    : m_resourceHandle(resourceHandle)\r
-{}\r
-\r
-JniOcResourceHandle::~JniOcResourceHandle()\r
-{\r
-    LOGD("~JniOcResourceHandle()");\r
-}\r
-\r
-JniOcResourceHandle* JniOcResourceHandle::getJniOcResourceHandlePtr\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    JniOcResourceHandle *handle = GetHandle<JniOcResourceHandle>(env, thiz);\r
-    if (env->ExceptionCheck())\r
-    {\r
-        LOGE("Failed to get native handle from OcResourceHandle");\r
-    }\r
-    if (!handle)\r
-    {\r
-        ThrowOcException(JNI_NO_NATIVE_POINTER, "");\r
-    }\r
-    return handle;\r
-}\r
-\r
-OCResourceHandle JniOcResourceHandle::getOCResourceHandle()\r
-{\r
-    return this->m_resourceHandle;\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceHandle\r
-* Method:    dispose\r
-* Signature: ()V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceHandle_dispose\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResourceHandle_dispose");\r
-    JniOcResourceHandle *resourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(env, thiz);\r
-    delete resourceHandle;\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 "JniOcResourceHandle.h"
+
+using namespace OC;
+
+JniOcResourceHandle::JniOcResourceHandle(OCResourceHandle resourceHandle)
+    : m_resourceHandle(resourceHandle)
+{}
+
+JniOcResourceHandle::~JniOcResourceHandle()
+{
+    LOGD("~JniOcResourceHandle()");
+}
+
+JniOcResourceHandle* JniOcResourceHandle::getJniOcResourceHandlePtr
+(JNIEnv *env, jobject thiz)
+{
+    JniOcResourceHandle *handle = GetHandle<JniOcResourceHandle>(env, thiz);
+    if (env->ExceptionCheck())
+    {
+        LOGE("Failed to get native handle from OcResourceHandle");
+    }
+    if (!handle)
+    {
+        ThrowOcException(JNI_NO_NATIVE_POINTER, "");
+    }
+    return handle;
+}
+
+OCResourceHandle JniOcResourceHandle::getOCResourceHandle()
+{
+    return this->m_resourceHandle;
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceHandle
+* Method:    dispose
+* Signature: ()V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceHandle_dispose
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResourceHandle_dispose");
+    JniOcResourceHandle *resourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(env, thiz);
+    delete resourceHandle;
 }
\ No newline at end of file
index b8b4e1c..22b3f9b 100644 (file)
@@ -1,56 +1,56 @@
-/*\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 "JniOcStack.h"\r
-#include "JniEntityHandler.h"\r
-\r
-#ifndef _Included_org_iotivity_base_OcResourceHandle\r
-#define _Included_org_iotivity_base_OcResourceHandle\r
-\r
-class JniOcResourceHandle\r
-{\r
-public:\r
-    JniOcResourceHandle(OCResourceHandle resourceHandle);\r
-    ~JniOcResourceHandle();\r
-\r
-    static JniOcResourceHandle* getJniOcResourceHandlePtr(JNIEnv *env, jobject thiz);\r
-\r
-    OCResourceHandle getOCResourceHandle();\r
-private:\r
-    OCResourceHandle m_resourceHandle;\r
-};\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceHandle\r
-    * Method:    dispose\r
-    * Signature: ()V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceHandle_dispose\r
-        (JNIEnv *, jobject);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-#endif\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 "JniOcStack.h"
+#include "JniEntityHandler.h"
+
+#ifndef _Included_org_iotivity_base_OcResourceHandle
+#define _Included_org_iotivity_base_OcResourceHandle
+
+class JniOcResourceHandle
+{
+public:
+    JniOcResourceHandle(OCResourceHandle resourceHandle);
+    ~JniOcResourceHandle();
+
+    static JniOcResourceHandle* getJniOcResourceHandlePtr(JNIEnv *env, jobject thiz);
+
+    OCResourceHandle getOCResourceHandle();
+private:
+    OCResourceHandle m_resourceHandle;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+    /*
+    * Class:     org_iotivity_base_OcResourceHandle
+    * Method:    dispose
+    * Signature: ()V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceHandle_dispose
+        (JNIEnv *, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
index 59b918c..b0b7d65 100644 (file)
@@ -1,89 +1,89 @@
-/*\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
-\r
-#include "JniOcResourceIdentifier.h"\r
-\r
-JniOcResourceIdentifier::JniOcResourceIdentifier(OC::OCResourceIdentifier resourceIdentifier)\r
-    : m_resourceIdentifier(resourceIdentifier)\r
-{}\r
-\r
-JniOcResourceIdentifier::~JniOcResourceIdentifier()\r
-{\r
-    LOGD("~JniOcResourceIdentifier()");\r
-}\r
-\r
-OC::OCResourceIdentifier JniOcResourceIdentifier::getOCResourceIdentifier()\r
-{\r
-    return this->m_resourceIdentifier;\r
-}\r
-\r
-JniOcResourceIdentifier* JniOcResourceIdentifier::getJniOcResourceIdentifierPtr\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    JniOcResourceIdentifier *identifier = GetHandle<JniOcResourceIdentifier>(env, thiz);\r
-    if (env->ExceptionCheck())\r
-    {\r
-        LOGE("Failed to get native handle from OcResourceIdentifier");\r
-    }\r
-    if (!identifier)\r
-    {\r
-        ThrowOcException(JNI_NO_NATIVE_POINTER, "");\r
-    }\r
-    return identifier;\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceIdentifier\r
-* Method:    equalsN\r
-* Signature: (Lorg/iotivity/base/OcResourceIdentifier;)Z\r
-*/\r
-JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcResourceIdentifier_equalsN\r
-(JNIEnv *env, jobject jThiz, jobject jOther)\r
-{\r
-    JniOcResourceIdentifier *thiz = JniOcResourceIdentifier::getJniOcResourceIdentifierPtr(env, jThiz);\r
-    if (!thiz) return false;\r
-\r
-    JniOcResourceIdentifier *other = JniOcResourceIdentifier::getJniOcResourceIdentifierPtr(env, jOther);\r
-    if (!other) return false;\r
-\r
-    if (thiz->getOCResourceIdentifier() == other->getOCResourceIdentifier())\r
-    {\r
-        return true;\r
-    }\r
-    else\r
-    {\r
-        return false;\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceIdentifier\r
-* Method:    dispose\r
-* Signature: ()V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceIdentifier_dispose\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("JniOcResourceIdentifier_dispose");\r
-    JniOcResourceIdentifier *identifier = JniOcResourceIdentifier::getJniOcResourceIdentifierPtr(env, thiz);\r
-    delete identifier;\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 "JniOcResourceIdentifier.h"
+
+JniOcResourceIdentifier::JniOcResourceIdentifier(OC::OCResourceIdentifier resourceIdentifier)
+    : m_resourceIdentifier(resourceIdentifier)
+{}
+
+JniOcResourceIdentifier::~JniOcResourceIdentifier()
+{
+    LOGD("~JniOcResourceIdentifier()");
+}
+
+OC::OCResourceIdentifier JniOcResourceIdentifier::getOCResourceIdentifier()
+{
+    return this->m_resourceIdentifier;
+}
+
+JniOcResourceIdentifier* JniOcResourceIdentifier::getJniOcResourceIdentifierPtr
+(JNIEnv *env, jobject thiz)
+{
+    JniOcResourceIdentifier *identifier = GetHandle<JniOcResourceIdentifier>(env, thiz);
+    if (env->ExceptionCheck())
+    {
+        LOGE("Failed to get native handle from OcResourceIdentifier");
+    }
+    if (!identifier)
+    {
+        ThrowOcException(JNI_NO_NATIVE_POINTER, "");
+    }
+    return identifier;
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceIdentifier
+* Method:    equalsN
+* Signature: (Lorg/iotivity/base/OcResourceIdentifier;)Z
+*/
+JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcResourceIdentifier_equalsN
+(JNIEnv *env, jobject jThiz, jobject jOther)
+{
+    JniOcResourceIdentifier *thiz = JniOcResourceIdentifier::getJniOcResourceIdentifierPtr(env, jThiz);
+    if (!thiz) return false;
+
+    JniOcResourceIdentifier *other = JniOcResourceIdentifier::getJniOcResourceIdentifierPtr(env, jOther);
+    if (!other) return false;
+
+    if (thiz->getOCResourceIdentifier() == other->getOCResourceIdentifier())
+    {
+        return true;
+    }
+    else
+    {
+        return false;
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceIdentifier
+* Method:    dispose
+* Signature: ()V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceIdentifier_dispose
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("JniOcResourceIdentifier_dispose");
+    JniOcResourceIdentifier *identifier = JniOcResourceIdentifier::getJniOcResourceIdentifierPtr(env, thiz);
+    delete identifier;
 }
\ No newline at end of file
index 9c7651a..6dd304e 100644 (file)
@@ -1,65 +1,65 @@
-/*\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 "JniOcStack.h"\r
-#include "OCResource.h"\r
-\r
-#ifndef _Included_org_iotivity_base_OcResourceIdentifier\r
-#define _Included_org_iotivity_base_OcResourceIdentifier\r
-\r
-class JniOcResourceIdentifier\r
-{\r
-public:\r
-\r
-    JniOcResourceIdentifier(OC::OCResourceIdentifier identifier);\r
-    ~JniOcResourceIdentifier();\r
-\r
-    static JniOcResourceIdentifier* getJniOcResourceIdentifierPtr(JNIEnv *env, jobject thiz);\r
-\r
-    OC::OCResourceIdentifier getOCResourceIdentifier();\r
-\r
-private:\r
-    OC::OCResourceIdentifier m_resourceIdentifier;\r
-};\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceIdentifier\r
-    * Method:    equalsN\r
-    * Signature: (Lorg/iotivity/base/OcResourceIdentifier;)Z\r
-    */\r
-    JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcResourceIdentifier_equalsN\r
-        (JNIEnv *, jobject, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceIdentifier\r
-    * Method:    dispose\r
-    * Signature: ()V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceIdentifier_dispose\r
-        (JNIEnv *, jobject);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\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 "JniOcStack.h"
+#include "OCResource.h"
+
+#ifndef _Included_org_iotivity_base_OcResourceIdentifier
+#define _Included_org_iotivity_base_OcResourceIdentifier
+
+class JniOcResourceIdentifier
+{
+public:
+
+    JniOcResourceIdentifier(OC::OCResourceIdentifier identifier);
+    ~JniOcResourceIdentifier();
+
+    static JniOcResourceIdentifier* getJniOcResourceIdentifierPtr(JNIEnv *env, jobject thiz);
+
+    OC::OCResourceIdentifier getOCResourceIdentifier();
+
+private:
+    OC::OCResourceIdentifier m_resourceIdentifier;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+    /*
+    * Class:     org_iotivity_base_OcResourceIdentifier
+    * Method:    equalsN
+    * Signature: (Lorg/iotivity/base/OcResourceIdentifier;)Z
+    */
+    JNIEXPORT jboolean JNICALL Java_org_iotivity_base_OcResourceIdentifier_equalsN
+        (JNIEnv *, jobject, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceIdentifier
+    * Method:    dispose
+    * Signature: ()V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceIdentifier_dispose
+        (JNIEnv *, jobject);
+
+#ifdef __cplusplus
+}
+#endif
 #endif
\ No newline at end of file
index b1d981c..c943f70 100644 (file)
-/*\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 "JniOcResourceRequest.h"\r
-#include "OCResourceRequest.h"\r
-#include "JniOcResourceHandle.h"\r
-#include "JniOcRequestHandle.h"\r
-#include "JniUtils.h"\r
-\r
-using namespace OC;\r
-\r
-JniOcResourceRequest::JniOcResourceRequest(const std::shared_ptr<OCResourceRequest> request)\r
-    : m_request(request)\r
-{}\r
-\r
-JniOcResourceRequest::~JniOcResourceRequest()\r
-{}\r
-\r
-std::string\r
-JniOcResourceRequest::getRequestType()\r
-{\r
-    return m_request->getRequestType();\r
-}\r
-\r
-const QueryParamsMap&\r
-JniOcResourceRequest::getQueryParameters() const\r
-{\r
-    return m_request->getQueryParameters();\r
-}\r
-\r
-int\r
-JniOcResourceRequest::getRequestHandlerFlag() const\r
-{\r
-    return m_request->getRequestHandlerFlag();\r
-}\r
-\r
-const OCRepresentation&\r
-JniOcResourceRequest::getResourceRepresentation() const\r
-{\r
-    return m_request->getResourceRepresentation();\r
-}\r
-\r
-const ObservationInfo&\r
-JniOcResourceRequest::getObservationInfo() const\r
-{\r
-    return m_request->getObservationInfo();\r
-}\r
-\r
-void\r
-JniOcResourceRequest::setResourceUri(const std::string resourceUri)\r
-{\r
-    m_request->setResourceUri(resourceUri);\r
-}\r
-\r
-std::string\r
-JniOcResourceRequest::getResourceUri(void)\r
-{\r
-    return m_request->getResourceUri();\r
-}\r
-\r
-const HeaderOptions&\r
-JniOcResourceRequest::getHeaderOptions() const\r
-{\r
-    return m_request->getHeaderOptions();\r
-}\r
-\r
-const OCRequestHandle&\r
-JniOcResourceRequest::getRequestHandle() const\r
-{\r
-    return m_request->getRequestHandle();\r
-}\r
-\r
-const OCResourceHandle&\r
-JniOcResourceRequest::getResourceHandle() const\r
-{\r
-    return m_request->getResourceHandle();\r
-}\r
-\r
-JniOcResourceRequest* JniOcResourceRequest::getJniOcResourceRequestPtr\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    JniOcResourceRequest *request = GetHandle<JniOcResourceRequest>(env, thiz);\r
-    if (env->ExceptionCheck())\r
-    {\r
-        LOGE("Failed to get native handle from OcResourceRequest");\r
-    }\r
-    if (!request)\r
-    {\r
-        ThrowOcException(JNI_NO_NATIVE_POINTER, "");\r
-    }\r
-    return request;\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceRequest\r
-* Method:    getRequestTypeNative\r
-* Signature: ()Ljava/lang/String;\r
-*/\r
-JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestTypeNative\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResourceRequest_getRequestTypeNative");\r
-    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
-    if (!request) return nullptr;\r
-\r
-    std::string requestType = request->getRequestType();\r
-    return env->NewStringUTF(requestType.c_str());\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceRequest\r
-* Method:    getQueryParameters\r
-* Signature: ()Ljava/util/Map;\r
-*/\r
-JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getQueryParameters\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResourceRequest_getQueryParameters");\r
-    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
-    if (!request) return nullptr;\r
-\r
-    return JniUtils::convertQueryParamsMapToJavaMap(env, request->getQueryParameters());\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceRequest\r
-* Method:    getRequestHandlerFlagNative\r
-* Signature: ()I\r
-*/\r
-JNIEXPORT jint JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestHandlerFlagNative\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResourceRequest_getRequestHandlerFlagNative");\r
-    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
-    if (!request) return -1;\r
-\r
-    return static_cast<jint>(request->getRequestHandlerFlag());\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceRequest\r
-* Method:    getResourceRepresentation\r
-* Signature: ()Lorg/iotivity/base/OcRepresentation;\r
-*/\r
-JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceRepresentation\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResourceRequest_getResourceRepresentation");\r
-    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
-    if (!request) return nullptr;\r
-\r
-    OCRepresentation *ocRepresentation = new OCRepresentation(request->getResourceRepresentation());\r
-    if (!ocRepresentation) return nullptr;\r
-\r
-    jlong handle = reinterpret_cast<jlong>(ocRepresentation);\r
-    jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,\r
-        handle, true);\r
-    if (!jRepresentation)\r
-    {\r
-        LOGE("Failed to create OcRepresentation");\r
-        delete ocRepresentation;\r
-    }\r
-\r
-    return jRepresentation;\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceRequest\r
-* Method:    getObservationInfo\r
-* Signature: ()Lorg/iotivity/base/ObservationInfo;\r
-*/\r
-JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getObservationInfo\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResourceRequest_getObservationInfo");\r
-    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
-    if (!request) return nullptr;\r
-\r
-    ObservationInfo oInfo = request->getObservationInfo();\r
-\r
-    jobject jObservationInfo = env->NewObject(g_cls_ObservationInfo, g_mid_ObservationInfo_N_ctor,\r
-        (jint)oInfo.action, (jbyte)oInfo.obsId);\r
-\r
-    if (!jObservationInfo)\r
-    {\r
-        LOGE("Failed to create ObservationInfo");\r
-    }\r
-\r
-    return jObservationInfo;\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceRequest\r
-* Method:    setResourceUri\r
-* Signature: (Ljava/lang/String);\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceRequest_setResourceUri\r
-(JNIEnv *env, jobject thiz, jstring jUri)\r
-{\r
-    LOGD("OcResourceRequest_setResourceUri");\r
-    if (!jUri)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "URI cannot be null");\r
-        return;\r
-    }\r
-    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
-    if (!request) return;\r
-\r
-    request->setResourceUri(env->GetStringUTFChars(jUri, 0));\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceRequest\r
-* Method:    getResourceUri\r
-* Signature: ()Ljava/lang/String;\r
-*/\r
-JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceUri\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResourceRequest_getResourceUri");\r
-    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
-    if (!request) return nullptr;\r
-\r
-    std::string requestUri = request->getResourceUri();\r
-    return env->NewStringUTF(requestUri.c_str());\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceRequest\r
-* Method:    getHeaderOptions\r
-* Signature: ()Ljava/util/List;\r
-*/\r
-JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getHeaderOptions\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResourceRequest_getHeaderOptions");\r
-    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
-    if (!request) return nullptr;\r
-\r
-    return JniUtils::convertHeaderOptionsVectorToJavaList(env, request->getHeaderOptions());\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceRequest\r
-* Method:    getRequestHandle\r
-* Signature: ()Lorg/iotivity/base/OcRequestHandle;\r
-*/\r
-JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestHandle\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResourceRequest_getRequestHandle");\r
-    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
-    if (!request) return nullptr;\r
-\r
-    JniOcRequestHandle* jniHandle = new JniOcRequestHandle(request->getRequestHandle());\r
-    jlong handle = reinterpret_cast<jlong>(jniHandle);\r
-    jobject jRequestHandle = env->NewObject(g_cls_OcRequestHandle, g_mid_OcRequestHandle_N_ctor, handle);\r
-    if (!jRequestHandle)\r
-    {\r
-        LOGE("Failed to create OcRequestHandle");\r
-        delete jniHandle;\r
-    }\r
-\r
-    return jRequestHandle;\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceRequest\r
-* Method:    getResourceHandle\r
-* Signature: ()Lorg/iotivity/base/OcResourceHandle;\r
-*/\r
-JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceHandle\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResourceRequest_getResourceHandle");\r
-    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
-    if (!request) return nullptr;\r
-\r
-    JniOcResourceHandle* jniHandle = new JniOcResourceHandle(\r
-        request->getResourceHandle());\r
-    jlong handle = reinterpret_cast<jlong>(jniHandle);\r
-    jobject jResourceHandle = env->NewObject(g_cls_OcResourceHandle, g_mid_OcResourceHandle_N_ctor, handle);\r
-    if (!jResourceHandle)\r
-    {\r
-        LOGE("Failed to create OcResourceHandle");\r
-        delete jniHandle;\r
-    }\r
-\r
-    return jResourceHandle;\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceRequest\r
-* Method:    dispose\r
-* Signature: ()V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceRequest_dispose\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResourceRequest_dispose");\r
-    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);\r
-    delete request;\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 "JniOcResourceRequest.h"
+#include "OCResourceRequest.h"
+#include "JniOcResourceHandle.h"
+#include "JniOcRequestHandle.h"
+#include "JniUtils.h"
+
+using namespace OC;
+
+JniOcResourceRequest::JniOcResourceRequest(const std::shared_ptr<OCResourceRequest> request)
+    : m_request(request)
+{}
+
+JniOcResourceRequest::~JniOcResourceRequest()
+{}
+
+std::string
+JniOcResourceRequest::getRequestType()
+{
+    return m_request->getRequestType();
+}
+
+const QueryParamsMap&
+JniOcResourceRequest::getQueryParameters() const
+{
+    return m_request->getQueryParameters();
+}
+
+int
+JniOcResourceRequest::getRequestHandlerFlag() const
+{
+    return m_request->getRequestHandlerFlag();
+}
+
+const OCRepresentation&
+JniOcResourceRequest::getResourceRepresentation() const
+{
+    return m_request->getResourceRepresentation();
+}
+
+const ObservationInfo&
+JniOcResourceRequest::getObservationInfo() const
+{
+    return m_request->getObservationInfo();
+}
+
+void
+JniOcResourceRequest::setResourceUri(const std::string resourceUri)
+{
+    m_request->setResourceUri(resourceUri);
+}
+
+std::string
+JniOcResourceRequest::getResourceUri(void)
+{
+    return m_request->getResourceUri();
+}
+
+const HeaderOptions&
+JniOcResourceRequest::getHeaderOptions() const
+{
+    return m_request->getHeaderOptions();
+}
+
+const OCRequestHandle&
+JniOcResourceRequest::getRequestHandle() const
+{
+    return m_request->getRequestHandle();
+}
+
+const OCResourceHandle&
+JniOcResourceRequest::getResourceHandle() const
+{
+    return m_request->getResourceHandle();
+}
+
+JniOcResourceRequest* JniOcResourceRequest::getJniOcResourceRequestPtr
+(JNIEnv *env, jobject thiz)
+{
+    JniOcResourceRequest *request = GetHandle<JniOcResourceRequest>(env, thiz);
+    if (env->ExceptionCheck())
+    {
+        LOGE("Failed to get native handle from OcResourceRequest");
+    }
+    if (!request)
+    {
+        ThrowOcException(JNI_NO_NATIVE_POINTER, "");
+    }
+    return request;
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceRequest
+* Method:    getRequestTypeNative
+* Signature: ()Ljava/lang/String;
+*/
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestTypeNative
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResourceRequest_getRequestTypeNative");
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
+    if (!request) return nullptr;
+
+    std::string requestType = request->getRequestType();
+    return env->NewStringUTF(requestType.c_str());
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceRequest
+* Method:    getQueryParameters
+* Signature: ()Ljava/util/Map;
+*/
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getQueryParameters
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResourceRequest_getQueryParameters");
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
+    if (!request) return nullptr;
+
+    return JniUtils::convertQueryParamsMapToJavaMap(env, request->getQueryParameters());
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceRequest
+* Method:    getRequestHandlerFlagNative
+* Signature: ()I
+*/
+JNIEXPORT jint JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestHandlerFlagNative
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResourceRequest_getRequestHandlerFlagNative");
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
+    if (!request) return -1;
+
+    return static_cast<jint>(request->getRequestHandlerFlag());
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceRequest
+* Method:    getResourceRepresentation
+* Signature: ()Lorg/iotivity/base/OcRepresentation;
+*/
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceRepresentation
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResourceRequest_getResourceRepresentation");
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
+    if (!request) return nullptr;
+
+    OCRepresentation *ocRepresentation = new OCRepresentation(request->getResourceRepresentation());
+    if (!ocRepresentation) return nullptr;
+
+    jlong handle = reinterpret_cast<jlong>(ocRepresentation);
+    jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,
+        handle, true);
+    if (!jRepresentation)
+    {
+        LOGE("Failed to create OcRepresentation");
+        delete ocRepresentation;
+    }
+
+    return jRepresentation;
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceRequest
+* Method:    getObservationInfo
+* Signature: ()Lorg/iotivity/base/ObservationInfo;
+*/
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getObservationInfo
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResourceRequest_getObservationInfo");
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
+    if (!request) return nullptr;
+
+    ObservationInfo oInfo = request->getObservationInfo();
+
+    jobject jObservationInfo = env->NewObject(g_cls_ObservationInfo, g_mid_ObservationInfo_N_ctor,
+        (jint)oInfo.action, (jbyte)oInfo.obsId);
+
+    if (!jObservationInfo)
+    {
+        LOGE("Failed to create ObservationInfo");
+    }
+
+    return jObservationInfo;
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceRequest
+* Method:    setResourceUri
+* Signature: (Ljava/lang/String);
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceRequest_setResourceUri
+(JNIEnv *env, jobject thiz, jstring jUri)
+{
+    LOGD("OcResourceRequest_setResourceUri");
+    if (!jUri)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "URI cannot be null");
+        return;
+    }
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
+    if (!request) return;
+
+    request->setResourceUri(env->GetStringUTFChars(jUri, 0));
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceRequest
+* Method:    getResourceUri
+* Signature: ()Ljava/lang/String;
+*/
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceUri
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResourceRequest_getResourceUri");
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
+    if (!request) return nullptr;
+
+    std::string requestUri = request->getResourceUri();
+    return env->NewStringUTF(requestUri.c_str());
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceRequest
+* Method:    getHeaderOptions
+* Signature: ()Ljava/util/List;
+*/
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getHeaderOptions
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResourceRequest_getHeaderOptions");
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
+    if (!request) return nullptr;
+
+    return JniUtils::convertHeaderOptionsVectorToJavaList(env, request->getHeaderOptions());
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceRequest
+* Method:    getRequestHandle
+* Signature: ()Lorg/iotivity/base/OcRequestHandle;
+*/
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestHandle
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResourceRequest_getRequestHandle");
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
+    if (!request) return nullptr;
+
+    JniOcRequestHandle* jniHandle = new JniOcRequestHandle(request->getRequestHandle());
+    jlong handle = reinterpret_cast<jlong>(jniHandle);
+    jobject jRequestHandle = env->NewObject(g_cls_OcRequestHandle, g_mid_OcRequestHandle_N_ctor, handle);
+    if (!jRequestHandle)
+    {
+        LOGE("Failed to create OcRequestHandle");
+        delete jniHandle;
+    }
+
+    return jRequestHandle;
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceRequest
+* Method:    getResourceHandle
+* Signature: ()Lorg/iotivity/base/OcResourceHandle;
+*/
+JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceHandle
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResourceRequest_getResourceHandle");
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
+    if (!request) return nullptr;
+
+    JniOcResourceHandle* jniHandle = new JniOcResourceHandle(
+        request->getResourceHandle());
+    jlong handle = reinterpret_cast<jlong>(jniHandle);
+    jobject jResourceHandle = env->NewObject(g_cls_OcResourceHandle, g_mid_OcResourceHandle_N_ctor, handle);
+    if (!jResourceHandle)
+    {
+        LOGE("Failed to create OcResourceHandle");
+        delete jniHandle;
+    }
+
+    return jResourceHandle;
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceRequest
+* Method:    dispose
+* Signature: ()V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceRequest_dispose
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResourceRequest_dispose");
+    JniOcResourceRequest *request = JniOcResourceRequest::getJniOcResourceRequestPtr(env, thiz);
+    delete request;
 }
\ No newline at end of file
index 5b58f0c..f2de51d 100644 (file)
-/*\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 "JniOcStack.h"\r
-\r
-#ifndef _Included_org_iotivity_base_OcResourceRequest\r
-#define _Included_org_iotivity_base_OcResourceRequest\r
-\r
-using namespace OC;\r
-\r
-class JniOcResourceRequest\r
-{\r
-public:\r
-    JniOcResourceRequest(const std::shared_ptr<OCResourceRequest> resourceRequest);\r
-\r
-    ~JniOcResourceRequest();\r
-\r
-    std::string getRequestType();\r
-\r
-    const QueryParamsMap& getQueryParameters() const;\r
-\r
-    int getRequestHandlerFlag() const;\r
-\r
-    const OCRepresentation& getResourceRepresentation() const;\r
-\r
-    const ObservationInfo& getObservationInfo() const;\r
-\r
-    void setResourceUri(const std::string resourceUri);\r
-\r
-    std::string getResourceUri(void);\r
-\r
-    const HeaderOptions& getHeaderOptions() const;\r
-\r
-    const OCRequestHandle& getRequestHandle() const;\r
-\r
-    const OCResourceHandle& getResourceHandle() const;\r
-\r
-    static JniOcResourceRequest* getJniOcResourceRequestPtr\r
-        (JNIEnv *env, jobject thiz);\r
-\r
-private:\r
-    std::shared_ptr<OCResourceRequest> m_request;\r
-};\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceRequest\r
-    * Method:    getRequestTypeNative\r
-    * Signature: ()Ljava/lang/String;\r
-    */\r
-    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestTypeNative\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceRequest\r
-    * Method:    getQueryParameters\r
-    * Signature: ()Ljava/util/Map;\r
-    */\r
-    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getQueryParameters\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceRequest\r
-    * Method:    getRequestHandlerFlagNative\r
-    * Signature: ()I\r
-    */\r
-    JNIEXPORT jint JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestHandlerFlagNative\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceRequest\r
-    * Method:    getResourceRepresentation\r
-    * Signature: ()Lorg/iotivity/base/OcRepresentation;\r
-    */\r
-    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceRepresentation\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceRequest\r
-    * Method:    getObservationInfo\r
-    * Signature: ()Lorg/iotivity/base/ObservationInfo;\r
-    */\r
-    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getObservationInfo\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceRequest\r
-    * Method:    setResourceUri\r
-    * Signature: (Ljava/lang/String;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceRequest_setResourceUri\r
-        (JNIEnv *, jobject, jstring);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceRequest\r
-    * Method:    getResourceUri\r
-    * Signature: ()Ljava/lang/String;\r
-    */\r
-    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceUri\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceRequest\r
-    * Method:    getHeaderOptions\r
-    * Signature: ()Ljava/util/List;\r
-    */\r
-    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getHeaderOptions\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceRequest\r
-    * Method:    getRequestHandle\r
-    * Signature: ()Lorg/iotivity/base/OcRequestHandle;\r
-    */\r
-    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestHandle\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceRequest\r
-    * Method:    getResourceHandle\r
-    * Signature: ()Lorg/iotivity/base/OcResourceHandle;\r
-    */\r
-    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceHandle\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceRequest\r
-    * Method:    dispose\r
-    * Signature: ()V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceRequest_dispose\r
-        (JNIEnv *, jobject);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\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 "JniOcStack.h"
+
+#ifndef _Included_org_iotivity_base_OcResourceRequest
+#define _Included_org_iotivity_base_OcResourceRequest
+
+using namespace OC;
+
+class JniOcResourceRequest
+{
+public:
+    JniOcResourceRequest(const std::shared_ptr<OCResourceRequest> resourceRequest);
+
+    ~JniOcResourceRequest();
+
+    std::string getRequestType();
+
+    const QueryParamsMap& getQueryParameters() const;
+
+    int getRequestHandlerFlag() const;
+
+    const OCRepresentation& getResourceRepresentation() const;
+
+    const ObservationInfo& getObservationInfo() const;
+
+    void setResourceUri(const std::string resourceUri);
+
+    std::string getResourceUri(void);
+
+    const HeaderOptions& getHeaderOptions() const;
+
+    const OCRequestHandle& getRequestHandle() const;
+
+    const OCResourceHandle& getResourceHandle() const;
+
+    static JniOcResourceRequest* getJniOcResourceRequestPtr
+        (JNIEnv *env, jobject thiz);
+
+private:
+    std::shared_ptr<OCResourceRequest> m_request;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+    /*
+    * Class:     org_iotivity_base_OcResourceRequest
+    * Method:    getRequestTypeNative
+    * Signature: ()Ljava/lang/String;
+    */
+    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestTypeNative
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceRequest
+    * Method:    getQueryParameters
+    * Signature: ()Ljava/util/Map;
+    */
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getQueryParameters
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceRequest
+    * Method:    getRequestHandlerFlagNative
+    * Signature: ()I
+    */
+    JNIEXPORT jint JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestHandlerFlagNative
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceRequest
+    * Method:    getResourceRepresentation
+    * Signature: ()Lorg/iotivity/base/OcRepresentation;
+    */
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceRepresentation
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceRequest
+    * Method:    getObservationInfo
+    * Signature: ()Lorg/iotivity/base/ObservationInfo;
+    */
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getObservationInfo
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceRequest
+    * Method:    setResourceUri
+    * Signature: (Ljava/lang/String;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceRequest_setResourceUri
+        (JNIEnv *, jobject, jstring);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceRequest
+    * Method:    getResourceUri
+    * Signature: ()Ljava/lang/String;
+    */
+    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceUri
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceRequest
+    * Method:    getHeaderOptions
+    * Signature: ()Ljava/util/List;
+    */
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getHeaderOptions
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceRequest
+    * Method:    getRequestHandle
+    * Signature: ()Lorg/iotivity/base/OcRequestHandle;
+    */
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getRequestHandle
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceRequest
+    * Method:    getResourceHandle
+    * Signature: ()Lorg/iotivity/base/OcResourceHandle;
+    */
+    JNIEXPORT jobject JNICALL Java_org_iotivity_base_OcResourceRequest_getResourceHandle
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceRequest
+    * Method:    dispose
+    * Signature: ()V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceRequest_dispose
+        (JNIEnv *, jobject);
+
+#ifdef __cplusplus
+}
+#endif
 #endif
\ No newline at end of file
index f8771c3..b871176 100644 (file)
-/*\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 "JniOcResourceResponse.h"\r
-#include "OCResourceResponse.h"\r
-#include "JniOcRepresentation.h"\r
-#include "JniOcRequestHandle.h"\r
-#include "JniOcResourceHandle.h"\r
-#include "JniUtils.h"\r
-\r
-using namespace OC;\r
-\r
-JniOcResourceResponse::JniOcResourceResponse\r
-(std::shared_ptr<OCResourceResponse> resourceResponse)\r
-: m_response(resourceResponse){}\r
-\r
-JniOcResourceResponse::~JniOcResourceResponse()\r
-{}\r
-\r
-void JniOcResourceResponse::setErrorCode(const int eCode)\r
-{\r
-    this->m_response->setErrorCode(eCode);\r
-}\r
-\r
-std::string JniOcResourceResponse::getNewResourceUri(void)\r
-{\r
-    this->m_response->getNewResourceUri();\r
-}\r
-\r
-void\r
-JniOcResourceResponse::setNewResourceUri(const std::string newResourceUri)\r
-{\r
-    this->m_response->setNewResourceUri(newResourceUri);\r
-}\r
-\r
-void JniOcResourceResponse::setHeaderOptions(const HeaderOptions& headerOptions)\r
-{\r
-    this->m_response->setHeaderOptions(headerOptions);\r
-}\r
-\r
-void JniOcResourceResponse::setRequestHandle(const OCRequestHandle& requestHandle)\r
-{\r
-    this->m_response->setRequestHandle(requestHandle);\r
-}\r
-\r
-void JniOcResourceResponse::setResourceHandle(const OCResourceHandle& resourceHandle)\r
-{\r
-    this->m_response->setResourceHandle(resourceHandle);\r
-}\r
-\r
-void JniOcResourceResponse::setResponseResult(const OCEntityHandlerResult& responseResult)\r
-{\r
-    this->m_response->setResponseResult(responseResult);\r
-}\r
-\r
-void JniOcResourceResponse::setResourceRepresentation(OCRepresentation& rep,\r
-    std::string interfaceStr)\r
-{\r
-    this->m_response->setResourceRepresentation(rep, interfaceStr);\r
-}\r
-\r
-void JniOcResourceResponse::setResourceRepresentation(OCRepresentation& rep)\r
-{\r
-    this->m_response->setResourceRepresentation(rep);\r
-}\r
-\r
-std::shared_ptr<OCResourceResponse> JniOcResourceResponse::getOCResourceResponse()\r
-{\r
-    return this->m_response;\r
-}\r
-\r
-JniOcResourceResponse* JniOcResourceResponse::getJniOcResourceResponsePtr\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    JniOcResourceResponse *request = GetHandle<JniOcResourceResponse>(env, thiz);\r
-    if (env->ExceptionCheck())\r
-    {\r
-        LOGE("Failed to get native handle from JniOcResourceResponse");\r
-    }\r
-    if (!request)\r
-    {\r
-        ThrowOcException(JNI_NO_NATIVE_POINTER, "");\r
-    }\r
-    return request;\r
-}\r
-/*\r
-* Class:     org_iotivity_base_OcResourceResponse\r
-* Method:    setErrorCode\r
-* Signature: (I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setErrorCode\r
-(JNIEnv *env, jobject thiz, jint eCode)\r
-{\r
-    LOGD("OcResourceResponse_setErrorCode");\r
-    JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);\r
-    if (!response) return;\r
-\r
-    response->setErrorCode(static_cast<int>(eCode));\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceResponse\r
-* Method:    getNewResourceUri\r
-* Signature: ()Ljava/lang/String;\r
-*/\r
-JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceResponse_getNewResourceUri\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResourceResponse_getNewResourceUri");\r
-    JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);\r
-    if (!response) return nullptr;\r
-\r
-    return env->NewStringUTF(response->getNewResourceUri().c_str());\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceResponse\r
-* Method:    setNewResourceUri\r
-* Signature: (Ljava/lang/String;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setNewResourceUri\r
-(JNIEnv *env, jobject thiz, jstring jstr)\r
-{\r
-    LOGD("OcResourceResponse_setNewResourceUri");\r
-    JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);\r
-    if (!response) return;\r
-\r
-    response->setNewResourceUri(env->GetStringUTFChars(jstr, 0));\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceResponse\r
-* Method:    setHeaderOptions\r
-* Signature: (Ljava/util/List;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setHeaderOptions\r
-(JNIEnv *env, jobject thiz, jobjectArray jHeaderOptions)\r
-{\r
-    LOGD("OcResourceResponse_setHeaderOptions");\r
-    if (!jHeaderOptions)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "headerOptionList cannot be null");\r
-        return;\r
-    }\r
-    JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);\r
-    if (!jniResponse) return;\r
-\r
-    HeaderOptions headerOptions;\r
-    JniUtils::convertJavaHeaderOptionsArrToVector(env, jHeaderOptions, headerOptions);\r
-\r
-    jniResponse->setHeaderOptions(headerOptions);\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceResponse\r
-* Method:    setRequestHandle\r
-* Signature: (Lorg/iotivity/base/OcRequestHandle;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setRequestHandle\r
-(JNIEnv *env, jobject thiz, jobject jRequestHandle)\r
-{\r
-    LOGI("OcResourceResponse_setRequestHandle");\r
-    if (!jRequestHandle)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "requestHandle cannot be null");\r
-        return;\r
-    }\r
-    JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);\r
-    if (!jniResponse) return;\r
-\r
-    JniOcRequestHandle* jniOcRequestHandle = JniOcRequestHandle::getJniOcRequestHandlePtr(env, jRequestHandle);\r
-    if (!jniOcRequestHandle) return;\r
-\r
-    jniResponse->setRequestHandle(jniOcRequestHandle->getOCRequestHandle());\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceResponse\r
-* Method:    setResourceHandle\r
-* Signature: (Lorg/iotivity/base/OcResourceHandle;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceHandle\r
-(JNIEnv *env, jobject thiz, jobject jResourceHandle)\r
-{\r
-    LOGI("OcResourceResponse_setResourceHandle");\r
-    if (!jResourceHandle)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");\r
-        return;\r
-    }\r
-    JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);\r
-    if (!jniResponse) return;\r
-\r
-    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(env, jResourceHandle);\r
-    if (!jniOcResourceHandle) return;\r
-\r
-    jniResponse->setResourceHandle(jniOcResourceHandle->getOCResourceHandle());\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceResponse\r
-* Method:    setResponseResult\r
-* Signature: (I)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResponseResult\r
-(JNIEnv *env, jobject thiz, jint responseResult)\r
-{\r
-    LOGD("OcResourceResponse_setResponseResult");\r
-    JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);\r
-    if (!response) return;\r
-\r
-    response->setResponseResult(JniUtils::getOCEntityHandlerResult(env, static_cast<int>(responseResult)));\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceResponse\r
-* Method:    setResourceRepresentation\r
-* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/lang/String;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceRepresentation\r
-(JNIEnv *env, jobject thiz, jobject jRepresentation, jstring jstr)\r
-{\r
-    LOGD("OcResourceResponse_setResourceRepresentation");\r
-    if (!jRepresentation)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "Representation cannot be null");\r
-        return;\r
-    }\r
-    if (!jstr)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "interface cannot be null");\r
-        return;\r
-    }\r
-\r
-    JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env,\r
-        thiz);\r
-    if (!response) return;\r
-\r
-    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env,\r
-        jRepresentation);\r
-    if (!representation) return;\r
-\r
-    response->setResourceRepresentation(*representation, env->GetStringUTFChars(jstr, 0));\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceResponse\r
-* Method:    setResourceRepresentation1\r
-* Signature: (Lorg/iotivity/base/OcRepresentation;)V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceRepresentation1\r
-(JNIEnv *env, jobject thiz, jobject jRepresentation)\r
-{\r
-    LOGD("OcResourceResponse_setResourceRepresentation");\r
-    if (!jRepresentation)\r
-    {\r
-        ThrowOcException(OC_STACK_INVALID_PARAM, "Representation cannot be null");\r
-        return;\r
-    }\r
-    JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);\r
-    if (!response) return;\r
-\r
-    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env,\r
-        jRepresentation);\r
-\r
-    if (representation)\r
-    {\r
-        response->setResourceRepresentation(*representation);\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceResponse\r
-* Method:    create\r
-* Signature: ()V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_create\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGI("OcResourceResponse_create");\r
-    auto pResponse = std::make_shared<OC::OCResourceResponse>();\r
-    JniOcResourceResponse* jniResourceResponse = new JniOcResourceResponse(pResponse);\r
-    SetHandle<JniOcResourceResponse>(env, thiz, jniResourceResponse);\r
-    if (env->ExceptionCheck())\r
-    {\r
-        LOGE("Failed to create OcResourceResponse");\r
-        delete jniResourceResponse;\r
-    }\r
-}\r
-\r
-/*\r
-* Class:     org_iotivity_base_OcResourceResponse\r
-* Method:    dispose\r
-* Signature: ()V\r
-*/\r
-JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_dispose\r
-(JNIEnv *env, jobject thiz)\r
-{\r
-    LOGD("OcResourceResponse_dispose");\r
-    JniOcResourceResponse *resp = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);\r
-    delete resp;\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 "JniOcResourceResponse.h"
+#include "OCResourceResponse.h"
+#include "JniOcRepresentation.h"
+#include "JniOcRequestHandle.h"
+#include "JniOcResourceHandle.h"
+#include "JniUtils.h"
+
+using namespace OC;
+
+JniOcResourceResponse::JniOcResourceResponse
+(std::shared_ptr<OCResourceResponse> resourceResponse)
+: m_response(resourceResponse){}
+
+JniOcResourceResponse::~JniOcResourceResponse()
+{}
+
+void JniOcResourceResponse::setErrorCode(const int eCode)
+{
+    this->m_response->setErrorCode(eCode);
+}
+
+std::string JniOcResourceResponse::getNewResourceUri(void)
+{
+    this->m_response->getNewResourceUri();
+}
+
+void
+JniOcResourceResponse::setNewResourceUri(const std::string newResourceUri)
+{
+    this->m_response->setNewResourceUri(newResourceUri);
+}
+
+void JniOcResourceResponse::setHeaderOptions(const HeaderOptions& headerOptions)
+{
+    this->m_response->setHeaderOptions(headerOptions);
+}
+
+void JniOcResourceResponse::setRequestHandle(const OCRequestHandle& requestHandle)
+{
+    this->m_response->setRequestHandle(requestHandle);
+}
+
+void JniOcResourceResponse::setResourceHandle(const OCResourceHandle& resourceHandle)
+{
+    this->m_response->setResourceHandle(resourceHandle);
+}
+
+void JniOcResourceResponse::setResponseResult(const OCEntityHandlerResult& responseResult)
+{
+    this->m_response->setResponseResult(responseResult);
+}
+
+void JniOcResourceResponse::setResourceRepresentation(OCRepresentation& rep,
+    std::string interfaceStr)
+{
+    this->m_response->setResourceRepresentation(rep, interfaceStr);
+}
+
+void JniOcResourceResponse::setResourceRepresentation(OCRepresentation& rep)
+{
+    this->m_response->setResourceRepresentation(rep);
+}
+
+std::shared_ptr<OCResourceResponse> JniOcResourceResponse::getOCResourceResponse()
+{
+    return this->m_response;
+}
+
+JniOcResourceResponse* JniOcResourceResponse::getJniOcResourceResponsePtr
+(JNIEnv *env, jobject thiz)
+{
+    JniOcResourceResponse *request = GetHandle<JniOcResourceResponse>(env, thiz);
+    if (env->ExceptionCheck())
+    {
+        LOGE("Failed to get native handle from JniOcResourceResponse");
+    }
+    if (!request)
+    {
+        ThrowOcException(JNI_NO_NATIVE_POINTER, "");
+    }
+    return request;
+}
+/*
+* Class:     org_iotivity_base_OcResourceResponse
+* Method:    setErrorCode
+* Signature: (I)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setErrorCode
+(JNIEnv *env, jobject thiz, jint eCode)
+{
+    LOGD("OcResourceResponse_setErrorCode");
+    JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
+    if (!response) return;
+
+    response->setErrorCode(static_cast<int>(eCode));
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceResponse
+* Method:    getNewResourceUri
+* Signature: ()Ljava/lang/String;
+*/
+JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceResponse_getNewResourceUri
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResourceResponse_getNewResourceUri");
+    JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
+    if (!response) return nullptr;
+
+    return env->NewStringUTF(response->getNewResourceUri().c_str());
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceResponse
+* Method:    setNewResourceUri
+* Signature: (Ljava/lang/String;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setNewResourceUri
+(JNIEnv *env, jobject thiz, jstring jstr)
+{
+    LOGD("OcResourceResponse_setNewResourceUri");
+    JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
+    if (!response) return;
+
+    response->setNewResourceUri(env->GetStringUTFChars(jstr, 0));
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceResponse
+* Method:    setHeaderOptions
+* Signature: (Ljava/util/List;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setHeaderOptions
+(JNIEnv *env, jobject thiz, jobjectArray jHeaderOptions)
+{
+    LOGD("OcResourceResponse_setHeaderOptions");
+    if (!jHeaderOptions)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "headerOptionList cannot be null");
+        return;
+    }
+    JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
+    if (!jniResponse) return;
+
+    HeaderOptions headerOptions;
+    JniUtils::convertJavaHeaderOptionsArrToVector(env, jHeaderOptions, headerOptions);
+
+    jniResponse->setHeaderOptions(headerOptions);
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceResponse
+* Method:    setRequestHandle
+* Signature: (Lorg/iotivity/base/OcRequestHandle;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setRequestHandle
+(JNIEnv *env, jobject thiz, jobject jRequestHandle)
+{
+    LOGI("OcResourceResponse_setRequestHandle");
+    if (!jRequestHandle)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "requestHandle cannot be null");
+        return;
+    }
+    JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
+    if (!jniResponse) return;
+
+    JniOcRequestHandle* jniOcRequestHandle = JniOcRequestHandle::getJniOcRequestHandlePtr(env, jRequestHandle);
+    if (!jniOcRequestHandle) return;
+
+    jniResponse->setRequestHandle(jniOcRequestHandle->getOCRequestHandle());
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceResponse
+* Method:    setResourceHandle
+* Signature: (Lorg/iotivity/base/OcResourceHandle;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceHandle
+(JNIEnv *env, jobject thiz, jobject jResourceHandle)
+{
+    LOGI("OcResourceResponse_setResourceHandle");
+    if (!jResourceHandle)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "resourceHandle cannot be null");
+        return;
+    }
+    JniOcResourceResponse *jniResponse = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
+    if (!jniResponse) return;
+
+    JniOcResourceHandle* jniOcResourceHandle = JniOcResourceHandle::getJniOcResourceHandlePtr(env, jResourceHandle);
+    if (!jniOcResourceHandle) return;
+
+    jniResponse->setResourceHandle(jniOcResourceHandle->getOCResourceHandle());
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceResponse
+* Method:    setResponseResult
+* Signature: (I)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResponseResult
+(JNIEnv *env, jobject thiz, jint responseResult)
+{
+    LOGD("OcResourceResponse_setResponseResult");
+    JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
+    if (!response) return;
+
+    response->setResponseResult(JniUtils::getOCEntityHandlerResult(env, static_cast<int>(responseResult)));
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceResponse
+* Method:    setResourceRepresentation
+* Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/lang/String;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceRepresentation
+(JNIEnv *env, jobject thiz, jobject jRepresentation, jstring jstr)
+{
+    LOGD("OcResourceResponse_setResourceRepresentation");
+    if (!jRepresentation)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "Representation cannot be null");
+        return;
+    }
+    if (!jstr)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "interface cannot be null");
+        return;
+    }
+
+    JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env,
+        thiz);
+    if (!response) return;
+
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env,
+        jRepresentation);
+    if (!representation) return;
+
+    response->setResourceRepresentation(*representation, env->GetStringUTFChars(jstr, 0));
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceResponse
+* Method:    setResourceRepresentation1
+* Signature: (Lorg/iotivity/base/OcRepresentation;)V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceRepresentation1
+(JNIEnv *env, jobject thiz, jobject jRepresentation)
+{
+    LOGD("OcResourceResponse_setResourceRepresentation");
+    if (!jRepresentation)
+    {
+        ThrowOcException(OC_STACK_INVALID_PARAM, "Representation cannot be null");
+        return;
+    }
+    JniOcResourceResponse *response = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
+    if (!response) return;
+
+    OCRepresentation *representation = JniOcRepresentation::getOCRepresentationPtr(env,
+        jRepresentation);
+
+    if (representation)
+    {
+        response->setResourceRepresentation(*representation);
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceResponse
+* Method:    create
+* Signature: ()V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_create
+(JNIEnv *env, jobject thiz)
+{
+    LOGI("OcResourceResponse_create");
+    auto pResponse = std::make_shared<OC::OCResourceResponse>();
+    JniOcResourceResponse* jniResourceResponse = new JniOcResourceResponse(pResponse);
+    SetHandle<JniOcResourceResponse>(env, thiz, jniResourceResponse);
+    if (env->ExceptionCheck())
+    {
+        LOGE("Failed to create OcResourceResponse");
+        delete jniResourceResponse;
+    }
+}
+
+/*
+* Class:     org_iotivity_base_OcResourceResponse
+* Method:    dispose
+* Signature: ()V
+*/
+JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_dispose
+(JNIEnv *env, jobject thiz)
+{
+    LOGD("OcResourceResponse_dispose");
+    JniOcResourceResponse *resp = JniOcResourceResponse::getJniOcResourceResponsePtr(env, thiz);
+    delete resp;
 }
\ No newline at end of file
index acabdf6..2fc5768 100644 (file)
-/*\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 "JniOcStack.h"\r
-#include "OCResourceResponse.h"\r
-\r
-#ifndef _Included_org_iotivity_base_OcResourceResponse\r
-#define _Included_org_iotivity_base_OcResourceResponse\r
-\r
-using namespace OC;\r
-\r
-class JniOcResourceResponse\r
-{\r
-public:\r
-    JniOcResourceResponse(std::shared_ptr<OCResourceResponse> resourceResponse);\r
-    ~JniOcResourceResponse();\r
-    void setErrorCode(const int eCode);\r
-    std::string getNewResourceUri(void);\r
-    void setNewResourceUri(const std::string newResourceUri);\r
-    void setHeaderOptions(const HeaderOptions& headerOptions);\r
-    void setRequestHandle(const OCRequestHandle& requestHandle);\r
-    void setResourceHandle(const OCResourceHandle& resourceHandle);\r
-    void setResponseResult(const OCEntityHandlerResult& responseResult);\r
-    void setResourceRepresentation(OCRepresentation& rep, std::string interfaceStr);\r
-    void setResourceRepresentation(OCRepresentation& rep);\r
-    std::shared_ptr<OCResourceResponse> getOCResourceResponse();\r
-    static JniOcResourceResponse* getJniOcResourceResponsePtr(JNIEnv *env, jobject thiz);\r
-private:\r
-    std::shared_ptr<OCResourceResponse> m_response;\r
-};\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceResponse\r
-    * Method:    setErrorCode\r
-    * Signature: (I)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setErrorCode\r
-        (JNIEnv *, jobject, jint);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceResponse\r
-    * Method:    getNewResourceUri\r
-    * Signature: ()Ljava/lang/String;\r
-    */\r
-    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceResponse_getNewResourceUri\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceResponse\r
-    * Method:    setNewResourceUri\r
-    * Signature: (Ljava/lang/String;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setNewResourceUri\r
-        (JNIEnv *, jobject, jstring);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceResponse\r
-    * Method:    setHeaderOptions\r
-    * Signature: (Ljava/util/List;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setHeaderOptions\r
-        (JNIEnv *, jobject, jobjectArray);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceResponse\r
-    * Method:    setRequestHandle\r
-    * Signature: (Lorg/iotivity/base/OcRequestHandle;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setRequestHandle\r
-        (JNIEnv *, jobject, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceResponse\r
-    * Method:    setResourceHandle\r
-    * Signature: (Lorg/iotivity/base/OcResourceHandle;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceHandle\r
-        (JNIEnv *, jobject, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceResponse\r
-    * Method:    setResponseResult\r
-    * Signature: (I)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResponseResult\r
-        (JNIEnv *, jobject, jint);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceResponse\r
-    * Method:    setResourceRepresentation\r
-    * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/lang/String;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceRepresentation\r
-        (JNIEnv *, jobject, jobject, jstring);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceResponse\r
-    * Method:    setResourceRepresentation1\r
-    * Signature: (Lorg/iotivity/base/OcRepresentation;)V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceRepresentation1\r
-        (JNIEnv *, jobject, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceResponse\r
-    * Method:    create\r
-    * Signature: ()V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_create\r
-        (JNIEnv *, jobject);\r
-\r
-    /*\r
-    * Class:     org_iotivity_base_OcResourceResponse\r
-    * Method:    dispose\r
-    * Signature: ()V\r
-    */\r
-    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_dispose\r
-        (JNIEnv *, jobject);\r
-#ifdef __cplusplus\r
-}\r
-#endif\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 "JniOcStack.h"
+#include "OCResourceResponse.h"
+
+#ifndef _Included_org_iotivity_base_OcResourceResponse
+#define _Included_org_iotivity_base_OcResourceResponse
+
+using namespace OC;
+
+class JniOcResourceResponse
+{
+public:
+    JniOcResourceResponse(std::shared_ptr<OCResourceResponse> resourceResponse);
+    ~JniOcResourceResponse();
+    void setErrorCode(const int eCode);
+    std::string getNewResourceUri(void);
+    void setNewResourceUri(const std::string newResourceUri);
+    void setHeaderOptions(const HeaderOptions& headerOptions);
+    void setRequestHandle(const OCRequestHandle& requestHandle);
+    void setResourceHandle(const OCResourceHandle& resourceHandle);
+    void setResponseResult(const OCEntityHandlerResult& responseResult);
+    void setResourceRepresentation(OCRepresentation& rep, std::string interfaceStr);
+    void setResourceRepresentation(OCRepresentation& rep);
+    std::shared_ptr<OCResourceResponse> getOCResourceResponse();
+    static JniOcResourceResponse* getJniOcResourceResponsePtr(JNIEnv *env, jobject thiz);
+private:
+    std::shared_ptr<OCResourceResponse> m_response;
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+    /*
+    * Class:     org_iotivity_base_OcResourceResponse
+    * Method:    setErrorCode
+    * Signature: (I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setErrorCode
+        (JNIEnv *, jobject, jint);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceResponse
+    * Method:    getNewResourceUri
+    * Signature: ()Ljava/lang/String;
+    */
+    JNIEXPORT jstring JNICALL Java_org_iotivity_base_OcResourceResponse_getNewResourceUri
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceResponse
+    * Method:    setNewResourceUri
+    * Signature: (Ljava/lang/String;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setNewResourceUri
+        (JNIEnv *, jobject, jstring);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceResponse
+    * Method:    setHeaderOptions
+    * Signature: (Ljava/util/List;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setHeaderOptions
+        (JNIEnv *, jobject, jobjectArray);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceResponse
+    * Method:    setRequestHandle
+    * Signature: (Lorg/iotivity/base/OcRequestHandle;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setRequestHandle
+        (JNIEnv *, jobject, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceResponse
+    * Method:    setResourceHandle
+    * Signature: (Lorg/iotivity/base/OcResourceHandle;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceHandle
+        (JNIEnv *, jobject, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceResponse
+    * Method:    setResponseResult
+    * Signature: (I)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResponseResult
+        (JNIEnv *, jobject, jint);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceResponse
+    * Method:    setResourceRepresentation
+    * Signature: (Lorg/iotivity/base/OcRepresentation;Ljava/lang/String;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceRepresentation
+        (JNIEnv *, jobject, jobject, jstring);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceResponse
+    * Method:    setResourceRepresentation1
+    * Signature: (Lorg/iotivity/base/OcRepresentation;)V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_setResourceRepresentation1
+        (JNIEnv *, jobject, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceResponse
+    * Method:    create
+    * Signature: ()V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_create
+        (JNIEnv *, jobject);
+
+    /*
+    * Class:     org_iotivity_base_OcResourceResponse
+    * Method:    dispose
+    * Signature: ()V
+    */
+    JNIEXPORT void JNICALL Java_org_iotivity_base_OcResourceResponse_dispose
+        (JNIEnv *, jobject);
+#ifdef __cplusplus
+}
+#endif
 #endif
\ No newline at end of file
index 5f6c1d4..bb9868c 100644 (file)
-/*\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 "JniOcStack.h"\r
-#include "OCApi.h"\r
-#include "OCPlatform.h"\r
-#include "OCRepresentation.h"\r
-#include "JniUtils.h"\r
-\r
-JavaVM* g_jvm = NULL;\r
-\r
-jclass g_cls_Integer = NULL;\r
-jclass g_cls_int1DArray = NULL;\r
-jclass g_cls_int2DArray = NULL;\r
-jclass g_cls_Double = NULL;\r
-jclass g_cls_double1DArray = NULL;\r
-jclass g_cls_double2DArray = NULL;\r
-jclass g_cls_Boolean = NULL;\r
-jclass g_cls_boolean1DArray = NULL;\r
-jclass g_cls_boolean2DArray = NULL;\r
-jclass g_cls_String = NULL;\r
-jclass g_cls_String1DArray = NULL;\r
-jclass g_cls_String2DArray = NULL;\r
-jclass g_cls_LinkedList = NULL;\r
-jclass g_cls_Map = NULL;\r
-jclass g_cls_MapEntry = NULL;\r
-jclass g_cls_Set = NULL;\r
-jclass g_cls_Iterator = NULL;\r
-jclass g_cls_HashMap = NULL;\r
-jclass g_cls_OcException = NULL;\r
-jclass g_cls_OcResource = NULL;\r
-jclass g_cls_OcRepresentation = NULL;\r
-jclass g_cls_OcRepresentation1DArray = NULL;\r
-jclass g_cls_OcRepresentation2DArray = NULL;\r
-jclass g_cls_OcResourceRequest = NULL;\r
-jclass g_cls_OcResourceResponse = NULL;\r
-jclass g_cls_OcResourceHandle = NULL;\r
-jclass g_cls_OcPresenceHandle = NULL;\r
-jclass g_cls_OcRequestHandle = NULL;\r
-jclass g_cls_OcPresenceStatus = NULL;\r
-jclass g_cls_OcHeaderOption = NULL;\r
-jclass g_cls_ObservationInfo = NULL;\r
-jclass g_cls_OcResourceIdentifier = NULL;\r
-\r
-jmethodID g_mid_Integer_ctor = NULL;\r
-jmethodID g_mid_Double_ctor = NULL;\r
-jmethodID g_mid_Boolean_ctor = NULL;\r
-jmethodID g_mid_LinkedList_ctor = NULL;\r
-jmethodID g_mid_LinkedList_add_object = NULL;\r
-jmethodID g_mid_Map_entrySet = NULL;\r
-jmethodID g_mid_MapEntry_getKey = NULL;\r
-jmethodID g_mid_MapEntry_getValue = NULL;\r
-jmethodID g_mid_Set_iterator = NULL;\r
-jmethodID g_mid_Iterator_hasNext = NULL;\r
-jmethodID g_mid_Iterator_next = NULL;\r
-jmethodID g_mid_HashMap_ctor = NULL;\r
-jmethodID g_mid_HashMap_put = NULL;\r
-jmethodID g_mid_OcException_ctor = NULL;\r
-jmethodID g_mid_OcException_setNativeExceptionLocation = NULL;\r
-jmethodID g_mid_OcResource_ctor = NULL;\r
-jmethodID g_mid_OcRepresentation_N_ctor = NULL;\r
-jmethodID g_mid_OcRepresentation_N_ctor_bool = NULL;\r
-jmethodID g_mid_OcResourceRequest_N_ctor = NULL;\r
-jmethodID g_mid_OcResourceResponse_N_ctor = NULL;\r
-jmethodID g_mid_OcResourceHandle_N_ctor = NULL;\r
-jmethodID g_mid_OcPresenceHandle_N_ctor = NULL;\r
-jmethodID g_mid_OcRequestHandle_N_ctor = NULL;\r
-jmethodID g_mid_OcHeaderOption_ctor = NULL;\r
-jmethodID g_mid_OcHeaderOption_get_id = NULL;\r
-jmethodID g_mid_OcHeaderOption_get_data = NULL;\r
-jmethodID g_mid_ObservationInfo_N_ctor = NULL;\r
-jmethodID g_mid_OcPresenceStatus_get = NULL;\r
-jmethodID g_mid_OcResourceIdentifier_N_ctor = NULL;\r
-\r
-jobject getOcException(JNIEnv* env, const char* file, const char* functionName,\r
-    const int line, const int code, const char* message)\r
-{\r
-    std::string codeStr = JniUtils::stackResultToStr(code);\r
-    if (codeStr.empty())\r
-    {\r
-        codeStr = JniUtils::stackResultToStr(JNI_INVALID_VALUE);\r
-    }\r
-    jobject ex = env->NewObject(g_cls_OcException,\r
-        g_mid_OcException_ctor,\r
-        env->NewStringUTF(codeStr.c_str()),\r
-        env->NewStringUTF(message));\r
-    if (!ex)\r
-    {\r
-        return nullptr;\r
-    }\r
-    env->CallVoidMethod(ex,\r
-        g_mid_OcException_setNativeExceptionLocation,\r
-        env->NewStringUTF(file),\r
-        env->NewStringUTF(functionName),\r
-        line);\r
-    if (env->ExceptionCheck())\r
-    {\r
-        return nullptr;\r
-    }\r
-    return ex;\r
-}\r
-\r
-void throwOcException(JNIEnv* env, jobject ex)\r
-{\r
-    env->Throw((jthrowable)ex);\r
-}\r
-\r
-// JNI OnLoad\r
-JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)\r
-{\r
-    LOGI("JNI_OnLoad");\r
-    JNIEnv* env;\r
-    g_jvm = vm;\r
-\r
-    if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)\r
-    {\r
-        LOGE("Failed to get the environment using GetEnv()");\r
-        return JNI_ERR;\r
-    }\r
-\r
-    jclass clazz = nullptr;\r
-\r
-    //Integer\r
-    clazz = env->FindClass("java/lang/Integer");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_Integer = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    g_mid_Integer_ctor = env->GetMethodID(g_cls_Integer, "<init>", "(I)V");\r
-    if (!g_mid_Integer_ctor) return JNI_ERR;\r
-\r
-    clazz = env->FindClass("[I");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_int1DArray = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    clazz = env->FindClass("[[I");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_int2DArray = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    //Double\r
-    clazz = env->FindClass("java/lang/Double");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_Double = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    g_mid_Double_ctor = env->GetMethodID(g_cls_Double, "<init>", "(D)V");\r
-    if (!g_mid_Double_ctor) return JNI_ERR;\r
-\r
-    clazz = env->FindClass("[D");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_double1DArray = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    clazz = env->FindClass("[[D");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_double2DArray = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    //Boolean\r
-    clazz = env->FindClass("java/lang/Boolean");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_Boolean = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    g_mid_Boolean_ctor = env->GetMethodID(g_cls_Boolean, "<init>", "(Z)V");\r
-    if (!g_mid_Boolean_ctor) return JNI_ERR;\r
-\r
-    clazz = env->FindClass("[Z");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_boolean1DArray = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    clazz = env->FindClass("[[Z");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_boolean2DArray = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    //String\r
-    clazz = env->FindClass("java/lang/String");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_String = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    clazz = env->FindClass("[Ljava/lang/String;");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_String1DArray = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    clazz = env->FindClass("[[Ljava/lang/String;");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_String2DArray = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    //LinkedList\r
-    clazz = env->FindClass("java/util/LinkedList");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_LinkedList = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    g_mid_LinkedList_ctor = env->GetMethodID(g_cls_LinkedList, "<init>", "()V");\r
-    if (!g_mid_LinkedList_ctor) return JNI_ERR;\r
-\r
-    g_mid_LinkedList_add_object = env->GetMethodID(g_cls_LinkedList, "add", "(Ljava/lang/Object;)Z");\r
-    if (!g_mid_LinkedList_add_object) return JNI_ERR;\r
-\r
-    //Map\r
-    clazz = env->FindClass("java/util/Map");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_Map = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    g_mid_Map_entrySet = env->GetMethodID(g_cls_Map, "entrySet", "()Ljava/util/Set;");\r
-    if (!g_mid_Map_entrySet) return JNI_ERR;\r
-\r
-    //MapEntry\r
-    clazz = env->FindClass("java/util/Map$Entry");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_MapEntry = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    g_mid_MapEntry_getKey = env->GetMethodID(g_cls_MapEntry, "getKey", "()Ljava/lang/Object;");\r
-    if (!g_mid_MapEntry_getKey) return JNI_ERR;\r
-    g_mid_MapEntry_getValue = env->GetMethodID(g_cls_MapEntry, "getValue", "()Ljava/lang/Object;");\r
-    if (!g_mid_MapEntry_getValue) return JNI_ERR;\r
-\r
-    //Set\r
-    clazz = env->FindClass("java/util/Set");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_Set = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    g_mid_Set_iterator = env->GetMethodID(g_cls_Set, "iterator", "()Ljava/util/Iterator;");\r
-    if (!g_mid_Set_iterator) return JNI_ERR;\r
-\r
-    //Iterator\r
-    clazz = env->FindClass("java/util/Iterator");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_Iterator = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    g_mid_Iterator_hasNext = env->GetMethodID(g_cls_Iterator, "hasNext", "()Z");\r
-    if (!g_mid_Iterator_hasNext) return JNI_ERR;\r
-\r
-    g_mid_Iterator_next = env->GetMethodID(g_cls_Iterator, "next", "()Ljava/lang/Object;");\r
-    if (!g_mid_Iterator_next) return JNI_ERR;\r
-\r
-    //HashMap\r
-    clazz = env->FindClass("java/util/HashMap");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_HashMap = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    g_mid_HashMap_ctor = env->GetMethodID(g_cls_HashMap, "<init>", "()V");\r
-    if (!g_mid_HashMap_ctor) return JNI_ERR;\r
-\r
-    g_mid_HashMap_put = env->GetMethodID(g_cls_HashMap, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");\r
-    if (!g_mid_HashMap_put) return JNI_ERR;\r
-\r
-    //OcException\r
-    clazz = env->FindClass("org/iotivity/base/OcException");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_OcException = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    g_mid_OcException_ctor = env->GetMethodID(g_cls_OcException, "<init>", "(Ljava/lang/String;Ljava/lang/String;)V");\r
-    if (!g_mid_OcException_ctor) return JNI_ERR;\r
-\r
-    g_mid_OcException_setNativeExceptionLocation = env->GetMethodID(g_cls_OcException, "setNativeExceptionLocation",\r
-        "(Ljava/lang/String;""Ljava/lang/String;""I)V");\r
-    if (!g_mid_OcException_setNativeExceptionLocation) return JNI_ERR;\r
-\r
-    //OcResource\r
-    clazz = env->FindClass("org/iotivity/base/OcResource");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_OcResource = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    g_mid_OcResource_ctor = env->GetMethodID(g_cls_OcResource, "<init>", "(J)V");\r
-    if (!g_mid_OcResource_ctor) return JNI_ERR;\r
-\r
-    //OcRepresentation\r
-    clazz = env->FindClass("org/iotivity/base/OcRepresentation");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_OcRepresentation = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    g_mid_OcRepresentation_N_ctor = env->GetMethodID(g_cls_OcRepresentation, "<init>", "(J)V");\r
-    if (!g_mid_OcRepresentation_N_ctor) return JNI_ERR;\r
-\r
-    g_mid_OcRepresentation_N_ctor_bool = env->GetMethodID(g_cls_OcRepresentation, "<init>", "(JZ)V");\r
-    if (!g_mid_OcRepresentation_N_ctor_bool) return JNI_ERR;\r
-\r
-    clazz = env->FindClass("[Lorg/iotivity/base/OcRepresentation;");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_OcRepresentation1DArray = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    clazz = env->FindClass("[[Lorg/iotivity/base/OcRepresentation;");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_OcRepresentation2DArray = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    //HeaderOptions\r
-    clazz = env->FindClass("org/iotivity/base/OcHeaderOption");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_OcHeaderOption = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-    g_mid_OcHeaderOption_ctor = env->GetMethodID(g_cls_OcHeaderOption, "<init>", "(ILjava/lang/String;)V");\r
-    if (!g_mid_OcHeaderOption_ctor) return JNI_ERR;\r
-\r
-    g_mid_OcHeaderOption_get_id = env->GetMethodID(g_cls_OcHeaderOption, "getOptionId", "()I");\r
-    if (!g_mid_OcHeaderOption_get_id) return JNI_ERR;\r
-\r
-    g_mid_OcHeaderOption_get_data = env->GetMethodID(g_cls_OcHeaderOption, "getOptionData", "()Ljava/lang/String;");\r
-    if (!g_mid_OcHeaderOption_get_data) return JNI_ERR;\r
-\r
-    //OcResourceRequest\r
-    clazz = env->FindClass("org/iotivity/base/OcResourceRequest");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_OcResourceRequest = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    g_mid_OcResourceRequest_N_ctor = env->GetMethodID(g_cls_OcResourceRequest, "<init>", "(J)V");\r
-    if (!g_mid_OcResourceRequest_N_ctor) return JNI_ERR;\r
-\r
-    //OcResourceResponse\r
-    clazz = env->FindClass("org/iotivity/base/OcResourceResponse");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_OcResourceResponse = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-\r
-    g_mid_OcResourceResponse_N_ctor = env->GetMethodID(g_cls_OcResourceResponse, "<init>", "(J)V");\r
-    if (!g_mid_OcResourceResponse_N_ctor) return JNI_ERR;\r
-\r
-    //OcResourceHandle\r
-    clazz = env->FindClass("org/iotivity/base/OcResourceHandle");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_OcResourceHandle = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-    g_mid_OcResourceHandle_N_ctor = env->GetMethodID(g_cls_OcResourceHandle, "<init>", "(J)V");\r
-    if (!g_mid_OcResourceHandle_N_ctor) return JNI_ERR;\r
-\r
-    //OcPresenceHandle\r
-    clazz = env->FindClass("org/iotivity/base/OcPresenceHandle");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_OcPresenceHandle = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-    g_mid_OcPresenceHandle_N_ctor = env->GetMethodID(g_cls_OcPresenceHandle, "<init>", "(J)V");\r
-    if (!g_mid_OcPresenceHandle_N_ctor) return JNI_ERR;\r
-\r
-    //OcRequestHandle\r
-    clazz = env->FindClass("org/iotivity/base/OcRequestHandle");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_OcRequestHandle = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-    g_mid_OcRequestHandle_N_ctor = env->GetMethodID(g_cls_OcRequestHandle, "<init>", "(J)V");\r
-    if (!g_mid_OcRequestHandle_N_ctor) return JNI_ERR;\r
-\r
-    //OcPresenceStatus\r
-    clazz = env->FindClass("org/iotivity/base/OcPresenceStatus");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_OcPresenceStatus = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-    g_mid_OcPresenceStatus_get = env->GetStaticMethodID(g_cls_OcPresenceStatus, "get",\r
-        "(Ljava/lang/String;)Lorg/iotivity/base/OcPresenceStatus;");\r
-    if (!g_mid_OcPresenceStatus_get) return JNI_ERR;\r
-\r
-    //ObservationInfo\r
-    clazz = env->FindClass("org/iotivity/base/ObservationInfo");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_ObservationInfo = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-    g_mid_ObservationInfo_N_ctor = env->GetMethodID(g_cls_ObservationInfo, "<init>", "(IB)V");\r
-    if (!g_mid_ObservationInfo_N_ctor) return JNI_ERR;\r
-\r
-    clazz = env->FindClass("org/iotivity/base/OcResourceIdentifier");\r
-    if (!clazz) return JNI_ERR;\r
-    g_cls_OcResourceIdentifier = (jclass)env->NewGlobalRef(clazz);\r
-    env->DeleteLocalRef(clazz);\r
-    g_mid_OcResourceIdentifier_N_ctor = env->GetMethodID(g_cls_OcResourceIdentifier, "<init>", "(J)V");\r
-    if (!g_mid_OcResourceIdentifier_N_ctor) return JNI_ERR;\r
-\r
-    return JNI_CURRENT_VERSION;\r
-}\r
-\r
-JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)\r
-{\r
-    LOGI("JNI_OnUnload");\r
-    JNIEnv* env;\r
-\r
-    if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)\r
-    {\r
-        LOGE("Failed to get the environment using GetEnv()");\r
-        return;\r
-    }\r
-\r
-    env->DeleteGlobalRef(g_cls_Integer);\r
-    env->DeleteGlobalRef(g_cls_int1DArray);\r
-    env->DeleteGlobalRef(g_cls_int2DArray);\r
-    env->DeleteGlobalRef(g_cls_Double);\r
-    env->DeleteGlobalRef(g_cls_double1DArray);\r
-    env->DeleteGlobalRef(g_cls_double2DArray);\r
-    env->DeleteGlobalRef(g_cls_Boolean);\r
-    env->DeleteGlobalRef(g_cls_boolean1DArray);\r
-    env->DeleteGlobalRef(g_cls_boolean2DArray);\r
-    env->DeleteGlobalRef(g_cls_String);\r
-    env->DeleteGlobalRef(g_cls_String1DArray);\r
-    env->DeleteGlobalRef(g_cls_String2DArray);\r
-    env->DeleteGlobalRef(g_cls_LinkedList);\r
-    env->DeleteGlobalRef(g_cls_Map);\r
-    env->DeleteGlobalRef(g_cls_MapEntry);\r
-    env->DeleteGlobalRef(g_cls_Set);\r
-    env->DeleteGlobalRef(g_cls_Iterator);\r
-    env->DeleteGlobalRef(g_cls_HashMap);\r
-    env->DeleteGlobalRef(g_cls_OcResource);\r
-    env->DeleteGlobalRef(g_cls_OcException);\r
-    env->DeleteGlobalRef(g_cls_OcRepresentation);\r
-    env->DeleteGlobalRef(g_cls_OcRepresentation1DArray);\r
-    env->DeleteGlobalRef(g_cls_OcRepresentation2DArray);\r
-    env->DeleteGlobalRef(g_cls_OcResourceRequest);\r
-    env->DeleteGlobalRef(g_cls_OcResourceResponse);\r
-    env->DeleteGlobalRef(g_cls_OcResourceHandle);\r
-    env->DeleteGlobalRef(g_cls_OcPresenceHandle);\r
-    env->DeleteGlobalRef(g_cls_OcRequestHandle);\r
-    env->DeleteGlobalRef(g_cls_OcPresenceStatus);\r
-    env->DeleteGlobalRef(g_cls_OcHeaderOption);\r
-    env->DeleteGlobalRef(g_cls_ObservationInfo);\r
-    env->DeleteGlobalRef(g_cls_OcResourceIdentifier);\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 "JniOcStack.h"
+#include "OCApi.h"
+#include "OCPlatform.h"
+#include "OCRepresentation.h"
+#include "JniUtils.h"
+
+JavaVM* g_jvm = NULL;
+
+jclass g_cls_Integer = NULL;
+jclass g_cls_int1DArray = NULL;
+jclass g_cls_int2DArray = NULL;
+jclass g_cls_Double = NULL;
+jclass g_cls_double1DArray = NULL;
+jclass g_cls_double2DArray = NULL;
+jclass g_cls_Boolean = NULL;
+jclass g_cls_boolean1DArray = NULL;
+jclass g_cls_boolean2DArray = NULL;
+jclass g_cls_String = NULL;
+jclass g_cls_String1DArray = NULL;
+jclass g_cls_String2DArray = NULL;
+jclass g_cls_LinkedList = NULL;
+jclass g_cls_Map = NULL;
+jclass g_cls_MapEntry = NULL;
+jclass g_cls_Set = NULL;
+jclass g_cls_Iterator = NULL;
+jclass g_cls_HashMap = NULL;
+jclass g_cls_OcException = NULL;
+jclass g_cls_OcResource = NULL;
+jclass g_cls_OcRepresentation = NULL;
+jclass g_cls_OcRepresentation1DArray = NULL;
+jclass g_cls_OcRepresentation2DArray = NULL;
+jclass g_cls_OcResourceRequest = NULL;
+jclass g_cls_OcResourceResponse = NULL;
+jclass g_cls_OcResourceHandle = NULL;
+jclass g_cls_OcPresenceHandle = NULL;
+jclass g_cls_OcRequestHandle = NULL;
+jclass g_cls_OcPresenceStatus = NULL;
+jclass g_cls_OcHeaderOption = NULL;
+jclass g_cls_ObservationInfo = NULL;
+jclass g_cls_OcResourceIdentifier = NULL;
+
+jmethodID g_mid_Integer_ctor = NULL;
+jmethodID g_mid_Double_ctor = NULL;
+jmethodID g_mid_Boolean_ctor = NULL;
+jmethodID g_mid_LinkedList_ctor = NULL;
+jmethodID g_mid_LinkedList_add_object = NULL;
+jmethodID g_mid_Map_entrySet = NULL;
+jmethodID g_mid_MapEntry_getKey = NULL;
+jmethodID g_mid_MapEntry_getValue = NULL;
+jmethodID g_mid_Set_iterator = NULL;
+jmethodID g_mid_Iterator_hasNext = NULL;
+jmethodID g_mid_Iterator_next = NULL;
+jmethodID g_mid_HashMap_ctor = NULL;
+jmethodID g_mid_HashMap_put = NULL;
+jmethodID g_mid_OcException_ctor = NULL;
+jmethodID g_mid_OcException_setNativeExceptionLocation = NULL;
+jmethodID g_mid_OcResource_ctor = NULL;
+jmethodID g_mid_OcRepresentation_N_ctor = NULL;
+jmethodID g_mid_OcRepresentation_N_ctor_bool = NULL;
+jmethodID g_mid_OcResourceRequest_N_ctor = NULL;
+jmethodID g_mid_OcResourceResponse_N_ctor = NULL;
+jmethodID g_mid_OcResourceHandle_N_ctor = NULL;
+jmethodID g_mid_OcPresenceHandle_N_ctor = NULL;
+jmethodID g_mid_OcRequestHandle_N_ctor = NULL;
+jmethodID g_mid_OcHeaderOption_ctor = NULL;
+jmethodID g_mid_OcHeaderOption_get_id = NULL;
+jmethodID g_mid_OcHeaderOption_get_data = NULL;
+jmethodID g_mid_ObservationInfo_N_ctor = NULL;
+jmethodID g_mid_OcPresenceStatus_get = NULL;
+jmethodID g_mid_OcResourceIdentifier_N_ctor = NULL;
+
+jobject getOcException(JNIEnv* env, const char* file, const char* functionName,
+    const int line, const int code, const char* message)
+{
+    std::string codeStr = JniUtils::stackResultToStr(code);
+    if (codeStr.empty())
+    {
+        codeStr = JniUtils::stackResultToStr(JNI_INVALID_VALUE);
+    }
+    jobject ex = env->NewObject(g_cls_OcException,
+        g_mid_OcException_ctor,
+        env->NewStringUTF(codeStr.c_str()),
+        env->NewStringUTF(message));
+    if (!ex)
+    {
+        return nullptr;
+    }
+    env->CallVoidMethod(ex,
+        g_mid_OcException_setNativeExceptionLocation,
+        env->NewStringUTF(file),
+        env->NewStringUTF(functionName),
+        line);
+    if (env->ExceptionCheck())
+    {
+        return nullptr;
+    }
+    return ex;
+}
+
+void throwOcException(JNIEnv* env, jobject ex)
+{
+    env->Throw((jthrowable)ex);
+}
+
+// JNI OnLoad
+JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
+{
+    LOGI("JNI_OnLoad");
+    JNIEnv* env;
+    g_jvm = vm;
+
+    if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)
+    {
+        LOGE("Failed to get the environment using GetEnv()");
+        return JNI_ERR;
+    }
+
+    jclass clazz = nullptr;
+
+    //Integer
+    clazz = env->FindClass("java/lang/Integer");
+    if (!clazz) return JNI_ERR;
+    g_cls_Integer = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    g_mid_Integer_ctor = env->GetMethodID(g_cls_Integer, "<init>", "(I)V");
+    if (!g_mid_Integer_ctor) return JNI_ERR;
+
+    clazz = env->FindClass("[I");
+    if (!clazz) return JNI_ERR;
+    g_cls_int1DArray = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    clazz = env->FindClass("[[I");
+    if (!clazz) return JNI_ERR;
+    g_cls_int2DArray = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    //Double
+    clazz = env->FindClass("java/lang/Double");
+    if (!clazz) return JNI_ERR;
+    g_cls_Double = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    g_mid_Double_ctor = env->GetMethodID(g_cls_Double, "<init>", "(D)V");
+    if (!g_mid_Double_ctor) return JNI_ERR;
+
+    clazz = env->FindClass("[D");
+    if (!clazz) return JNI_ERR;
+    g_cls_double1DArray = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    clazz = env->FindClass("[[D");
+    if (!clazz) return JNI_ERR;
+    g_cls_double2DArray = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    //Boolean
+    clazz = env->FindClass("java/lang/Boolean");
+    if (!clazz) return JNI_ERR;
+    g_cls_Boolean = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    g_mid_Boolean_ctor = env->GetMethodID(g_cls_Boolean, "<init>", "(Z)V");
+    if (!g_mid_Boolean_ctor) return JNI_ERR;
+
+    clazz = env->FindClass("[Z");
+    if (!clazz) return JNI_ERR;
+    g_cls_boolean1DArray = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    clazz = env->FindClass("[[Z");
+    if (!clazz) return JNI_ERR;
+    g_cls_boolean2DArray = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    //String
+    clazz = env->FindClass("java/lang/String");
+    if (!clazz) return JNI_ERR;
+    g_cls_String = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    clazz = env->FindClass("[Ljava/lang/String;");
+    if (!clazz) return JNI_ERR;
+    g_cls_String1DArray = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    clazz = env->FindClass("[[Ljava/lang/String;");
+    if (!clazz) return JNI_ERR;
+    g_cls_String2DArray = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    //LinkedList
+    clazz = env->FindClass("java/util/LinkedList");
+    if (!clazz) return JNI_ERR;
+    g_cls_LinkedList = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    g_mid_LinkedList_ctor = env->GetMethodID(g_cls_LinkedList, "<init>", "()V");
+    if (!g_mid_LinkedList_ctor) return JNI_ERR;
+
+    g_mid_LinkedList_add_object = env->GetMethodID(g_cls_LinkedList, "add", "(Ljava/lang/Object;)Z");
+    if (!g_mid_LinkedList_add_object) return JNI_ERR;
+
+    //Map
+    clazz = env->FindClass("java/util/Map");
+    if (!clazz) return JNI_ERR;
+    g_cls_Map = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    g_mid_Map_entrySet = env->GetMethodID(g_cls_Map, "entrySet", "()Ljava/util/Set;");
+    if (!g_mid_Map_entrySet) return JNI_ERR;
+
+    //MapEntry
+    clazz = env->FindClass("java/util/Map$Entry");
+    if (!clazz) return JNI_ERR;
+    g_cls_MapEntry = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    g_mid_MapEntry_getKey = env->GetMethodID(g_cls_MapEntry, "getKey", "()Ljava/lang/Object;");
+    if (!g_mid_MapEntry_getKey) return JNI_ERR;
+    g_mid_MapEntry_getValue = env->GetMethodID(g_cls_MapEntry, "getValue", "()Ljava/lang/Object;");
+    if (!g_mid_MapEntry_getValue) return JNI_ERR;
+
+    //Set
+    clazz = env->FindClass("java/util/Set");
+    if (!clazz) return JNI_ERR;
+    g_cls_Set = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    g_mid_Set_iterator = env->GetMethodID(g_cls_Set, "iterator", "()Ljava/util/Iterator;");
+    if (!g_mid_Set_iterator) return JNI_ERR;
+
+    //Iterator
+    clazz = env->FindClass("java/util/Iterator");
+    if (!clazz) return JNI_ERR;
+    g_cls_Iterator = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    g_mid_Iterator_hasNext = env->GetMethodID(g_cls_Iterator, "hasNext", "()Z");
+    if (!g_mid_Iterator_hasNext) return JNI_ERR;
+
+    g_mid_Iterator_next = env->GetMethodID(g_cls_Iterator, "next", "()Ljava/lang/Object;");
+    if (!g_mid_Iterator_next) return JNI_ERR;
+
+    //HashMap
+    clazz = env->FindClass("java/util/HashMap");
+    if (!clazz) return JNI_ERR;
+    g_cls_HashMap = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    g_mid_HashMap_ctor = env->GetMethodID(g_cls_HashMap, "<init>", "()V");
+    if (!g_mid_HashMap_ctor) return JNI_ERR;
+
+    g_mid_HashMap_put = env->GetMethodID(g_cls_HashMap, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
+    if (!g_mid_HashMap_put) return JNI_ERR;
+
+    //OcException
+    clazz = env->FindClass("org/iotivity/base/OcException");
+    if (!clazz) return JNI_ERR;
+    g_cls_OcException = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    g_mid_OcException_ctor = env->GetMethodID(g_cls_OcException, "<init>", "(Ljava/lang/String;Ljava/lang/String;)V");
+    if (!g_mid_OcException_ctor) return JNI_ERR;
+
+    g_mid_OcException_setNativeExceptionLocation = env->GetMethodID(g_cls_OcException, "setNativeExceptionLocation",
+        "(Ljava/lang/String;""Ljava/lang/String;""I)V");
+    if (!g_mid_OcException_setNativeExceptionLocation) return JNI_ERR;
+
+    //OcResource
+    clazz = env->FindClass("org/iotivity/base/OcResource");
+    if (!clazz) return JNI_ERR;
+    g_cls_OcResource = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    g_mid_OcResource_ctor = env->GetMethodID(g_cls_OcResource, "<init>", "(J)V");
+    if (!g_mid_OcResource_ctor) return JNI_ERR;
+
+    //OcRepresentation
+    clazz = env->FindClass("org/iotivity/base/OcRepresentation");
+    if (!clazz) return JNI_ERR;
+    g_cls_OcRepresentation = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    g_mid_OcRepresentation_N_ctor = env->GetMethodID(g_cls_OcRepresentation, "<init>", "(J)V");
+    if (!g_mid_OcRepresentation_N_ctor) return JNI_ERR;
+
+    g_mid_OcRepresentation_N_ctor_bool = env->GetMethodID(g_cls_OcRepresentation, "<init>", "(JZ)V");
+    if (!g_mid_OcRepresentation_N_ctor_bool) return JNI_ERR;
+
+    clazz = env->FindClass("[Lorg/iotivity/base/OcRepresentation;");
+    if (!clazz) return JNI_ERR;
+    g_cls_OcRepresentation1DArray = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    clazz = env->FindClass("[[Lorg/iotivity/base/OcRepresentation;");
+    if (!clazz) return JNI_ERR;
+    g_cls_OcRepresentation2DArray = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    //HeaderOptions
+    clazz = env->FindClass("org/iotivity/base/OcHeaderOption");
+    if (!clazz) return JNI_ERR;
+    g_cls_OcHeaderOption = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+    g_mid_OcHeaderOption_ctor = env->GetMethodID(g_cls_OcHeaderOption, "<init>", "(ILjava/lang/String;)V");
+    if (!g_mid_OcHeaderOption_ctor) return JNI_ERR;
+
+    g_mid_OcHeaderOption_get_id = env->GetMethodID(g_cls_OcHeaderOption, "getOptionId", "()I");
+    if (!g_mid_OcHeaderOption_get_id) return JNI_ERR;
+
+    g_mid_OcHeaderOption_get_data = env->GetMethodID(g_cls_OcHeaderOption, "getOptionData", "()Ljava/lang/String;");
+    if (!g_mid_OcHeaderOption_get_data) return JNI_ERR;
+
+    //OcResourceRequest
+    clazz = env->FindClass("org/iotivity/base/OcResourceRequest");
+    if (!clazz) return JNI_ERR;
+    g_cls_OcResourceRequest = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    g_mid_OcResourceRequest_N_ctor = env->GetMethodID(g_cls_OcResourceRequest, "<init>", "(J)V");
+    if (!g_mid_OcResourceRequest_N_ctor) return JNI_ERR;
+
+    //OcResourceResponse
+    clazz = env->FindClass("org/iotivity/base/OcResourceResponse");
+    if (!clazz) return JNI_ERR;
+    g_cls_OcResourceResponse = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+
+    g_mid_OcResourceResponse_N_ctor = env->GetMethodID(g_cls_OcResourceResponse, "<init>", "(J)V");
+    if (!g_mid_OcResourceResponse_N_ctor) return JNI_ERR;
+
+    //OcResourceHandle
+    clazz = env->FindClass("org/iotivity/base/OcResourceHandle");
+    if (!clazz) return JNI_ERR;
+    g_cls_OcResourceHandle = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+    g_mid_OcResourceHandle_N_ctor = env->GetMethodID(g_cls_OcResourceHandle, "<init>", "(J)V");
+    if (!g_mid_OcResourceHandle_N_ctor) return JNI_ERR;
+
+    //OcPresenceHandle
+    clazz = env->FindClass("org/iotivity/base/OcPresenceHandle");
+    if (!clazz) return JNI_ERR;
+    g_cls_OcPresenceHandle = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+    g_mid_OcPresenceHandle_N_ctor = env->GetMethodID(g_cls_OcPresenceHandle, "<init>", "(J)V");
+    if (!g_mid_OcPresenceHandle_N_ctor) return JNI_ERR;
+
+    //OcRequestHandle
+    clazz = env->FindClass("org/iotivity/base/OcRequestHandle");
+    if (!clazz) return JNI_ERR;
+    g_cls_OcRequestHandle = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+    g_mid_OcRequestHandle_N_ctor = env->GetMethodID(g_cls_OcRequestHandle, "<init>", "(J)V");
+    if (!g_mid_OcRequestHandle_N_ctor) return JNI_ERR;
+
+    //OcPresenceStatus
+    clazz = env->FindClass("org/iotivity/base/OcPresenceStatus");
+    if (!clazz) return JNI_ERR;
+    g_cls_OcPresenceStatus = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+    g_mid_OcPresenceStatus_get = env->GetStaticMethodID(g_cls_OcPresenceStatus, "get",
+        "(Ljava/lang/String;)Lorg/iotivity/base/OcPresenceStatus;");
+    if (!g_mid_OcPresenceStatus_get) return JNI_ERR;
+
+    //ObservationInfo
+    clazz = env->FindClass("org/iotivity/base/ObservationInfo");
+    if (!clazz) return JNI_ERR;
+    g_cls_ObservationInfo = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+    g_mid_ObservationInfo_N_ctor = env->GetMethodID(g_cls_ObservationInfo, "<init>", "(IB)V");
+    if (!g_mid_ObservationInfo_N_ctor) return JNI_ERR;
+
+    clazz = env->FindClass("org/iotivity/base/OcResourceIdentifier");
+    if (!clazz) return JNI_ERR;
+    g_cls_OcResourceIdentifier = (jclass)env->NewGlobalRef(clazz);
+    env->DeleteLocalRef(clazz);
+    g_mid_OcResourceIdentifier_N_ctor = env->GetMethodID(g_cls_OcResourceIdentifier, "<init>", "(J)V");
+    if (!g_mid_OcResourceIdentifier_N_ctor) return JNI_ERR;
+
+    return JNI_CURRENT_VERSION;
+}
+
+JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
+{
+    LOGI("JNI_OnUnload");
+    JNIEnv* env;
+
+    if (g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION) != JNI_OK)
+    {
+        LOGE("Failed to get the environment using GetEnv()");
+        return;
+    }
+
+    env->DeleteGlobalRef(g_cls_Integer);
+    env->DeleteGlobalRef(g_cls_int1DArray);
+    env->DeleteGlobalRef(g_cls_int2DArray);
+    env->DeleteGlobalRef(g_cls_Double);
+    env->DeleteGlobalRef(g_cls_double1DArray);
+    env->DeleteGlobalRef(g_cls_double2DArray);
+    env->DeleteGlobalRef(g_cls_Boolean);
+    env->DeleteGlobalRef(g_cls_boolean1DArray);
+    env->DeleteGlobalRef(g_cls_boolean2DArray);
+    env->DeleteGlobalRef(g_cls_String);
+    env->DeleteGlobalRef(g_cls_String1DArray);
+    env->DeleteGlobalRef(g_cls_String2DArray);
+    env->DeleteGlobalRef(g_cls_LinkedList);
+    env->DeleteGlobalRef(g_cls_Map);
+    env->DeleteGlobalRef(g_cls_MapEntry);
+    env->DeleteGlobalRef(g_cls_Set);
+    env->DeleteGlobalRef(g_cls_Iterator);
+    env->DeleteGlobalRef(g_cls_HashMap);
+    env->DeleteGlobalRef(g_cls_OcResource);
+    env->DeleteGlobalRef(g_cls_OcException);
+    env->DeleteGlobalRef(g_cls_OcRepresentation);
+    env->DeleteGlobalRef(g_cls_OcRepresentation1DArray);
+    env->DeleteGlobalRef(g_cls_OcRepresentation2DArray);
+    env->DeleteGlobalRef(g_cls_OcResourceRequest);
+    env->DeleteGlobalRef(g_cls_OcResourceResponse);
+    env->DeleteGlobalRef(g_cls_OcResourceHandle);
+    env->DeleteGlobalRef(g_cls_OcPresenceHandle);
+    env->DeleteGlobalRef(g_cls_OcRequestHandle);
+    env->DeleteGlobalRef(g_cls_OcPresenceStatus);
+    env->DeleteGlobalRef(g_cls_OcHeaderOption);
+    env->DeleteGlobalRef(g_cls_ObservationInfo);
+    env->DeleteGlobalRef(g_cls_OcResourceIdentifier);
 }
\ No newline at end of file
index bd0ddd5..f6b1ee0 100644 (file)
-/*\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 <jni.h>\r
-#include <android/log.h>\r
-#include "OCApi.h"\r
-\r
-#ifndef _Included_org_iotivity_base_ocstack\r
-#define _Included_org_iotivity_base_ocstack\r
-\r
-#define TAG "OIC-JNI"\r
-\r
-#define JNI_CURRENT_VERSION JNI_VERSION_1_6\r
-\r
-#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)\r
-#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)\r
-#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)\r
-\r
-#define JNI_EXCEPTION 1000\r
-#define JNI_NO_NATIVE_POINTER 1001\r
-#define JNI_INVALID_VALUE 1002\r
-#define JNI_NO_SUCH_KEY 1003\r
-\r
-jobject getOcException(JNIEnv* env, const char* file, const char* functionName, const int line,\r
-    const int code, const char* message);\r
-void throwOcException(JNIEnv* env, jobject ex);\r
-#define GetOcException(code, message) getOcException (env,__FILE__,__func__,__LINE__,code,message)\r
-#define ThrowOcException(code, message) throwOcException (env, GetOcException(code, message))\r
-\r
-extern JavaVM* g_jvm;\r
-\r
-extern jclass g_cls_Integer;\r
-extern jclass g_cls_int1DArray;\r
-extern jclass g_cls_int2DArray;\r
-extern jclass g_cls_Double;\r
-extern jclass g_cls_double1DArray;\r
-extern jclass g_cls_double2DArray;\r
-extern jclass g_cls_Boolean;\r
-extern jclass g_cls_boolean1DArray;\r
-extern jclass g_cls_boolean2DArray;\r
-extern jclass g_cls_String;\r
-extern jclass g_cls_String1DArray;\r
-extern jclass g_cls_String2DArray;\r
-extern jclass g_cls_LinkedList;\r
-extern jclass g_cls_Map;\r
-extern jclass g_cls_MapEntry;\r
-extern jclass g_cls_Set;\r
-extern jclass g_cls_Iterator;\r
-extern jclass g_cls_HashMap;\r
-extern jclass g_cls_OcException;\r
-extern jclass g_cls_OcResource;\r
-extern jclass g_cls_OcRepresentation;\r
-extern jclass g_cls_OcRepresentation1DArray;\r
-extern jclass g_cls_OcRepresentation2DArray;\r
-extern jclass g_cls_OcResourceRequest;\r
-extern jclass g_cls_OcResourceResponse;\r
-extern jclass g_cls_OcResourceHandle;\r
-extern jclass g_cls_OcPresenceHandle;\r
-extern jclass g_cls_OcRequestHandle;\r
-extern jclass g_cls_OcPresenceStatus;\r
-extern jclass g_cls_OcHeaderOption;\r
-extern jclass g_cls_ObservationInfo;\r
-extern jclass g_cls_OcResourceIdentifier;\r
-\r
-extern jmethodID g_mid_Integer_ctor;\r
-extern jmethodID g_mid_Double_ctor;\r
-extern jmethodID g_mid_Boolean_ctor;\r
-extern jmethodID g_mid_LinkedList_ctor;\r
-extern jmethodID g_mid_LinkedList_add_object;\r
-extern jmethodID g_mid_Map_entrySet;\r
-extern jmethodID g_mid_MapEntry_getKey;\r
-extern jmethodID g_mid_MapEntry_getValue;\r
-extern jmethodID g_mid_Set_iterator;\r
-extern jmethodID g_mid_Iterator_hasNext;\r
-extern jmethodID g_mid_Iterator_next;\r
-extern jmethodID g_mid_HashMap_ctor;\r
-extern jmethodID g_mid_HashMap_put;\r
-extern jmethodID g_mid_OcException_ctor;\r
-extern jmethodID g_mid_OcException_setNativeExceptionLocation;\r
-extern jmethodID g_mid_OcResource_ctor;\r
-extern jmethodID g_mid_OcRepresentation_N_ctor;\r
-extern jmethodID g_mid_OcRepresentation_N_ctor_bool;\r
-extern jmethodID g_mid_OcResourceRequest_N_ctor;\r
-extern jmethodID g_mid_OcResourceResponse_N_ctor;\r
-extern jmethodID g_mid_OcResourceHandle_N_ctor;\r
-extern jmethodID g_mid_OcPresenceHandle_N_ctor;\r
-extern jmethodID g_mid_OcRequestHandle_N_ctor;\r
-extern jmethodID g_mid_OcHeaderOption_ctor;\r
-extern jmethodID g_mid_OcHeaderOption_get_id;\r
-extern jmethodID g_mid_OcHeaderOption_get_data;\r
-extern jmethodID g_mid_ObservationInfo_N_ctor;\r
-extern jmethodID g_mid_OcPresenceStatus_get;\r
-extern jmethodID g_mid_OcResourceIdentifier_N_ctor;\r
-\r
-typedef void(*RemoveListenerCallback)(JNIEnv* env, jobject jListener);\r
-\r
-static jfieldID GetHandleField(JNIEnv *env, jobject jobj)\r
-{\r
-    jclass cls = env->GetObjectClass(jobj);\r
-    return env->GetFieldID(cls, "mNativeHandle", "J");\r
-}\r
-\r
-template <typename T>\r
-static T *GetHandle(JNIEnv *env, jobject jobj)\r
-{\r
-    jlong handle = env->GetLongField(jobj, GetHandleField(env, jobj));\r
-    return reinterpret_cast<T *>(handle);\r
-}\r
-\r
-template <typename T>\r
-static void SetHandle(JNIEnv *env, jobject jobj, T *type)\r
-{\r
-    jlong handle = reinterpret_cast<jlong>(type);\r
-\r
-    env->SetLongField(jobj, GetHandleField(env, jobj), handle);\r
-}\r
-\r
-static JNIEnv* GetJNIEnv(jint& ret)\r
-{\r
-    JNIEnv *env = NULL;\r
-\r
-    ret = g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION);\r
-    switch (ret) {\r
-    case JNI_OK:\r
-        return env;\r
-    case JNI_EDETACHED:\r
-        if (g_jvm->AttachCurrentThread(&env, NULL) < 0)\r
-        {\r
-            LOGE("Failed to get the environment");\r
-            return nullptr;\r
-        }\r
-        else\r
-        {\r
-            return env;\r
-        }\r
-\r
-    case JNI_EVERSION:\r
-        LOGE("JNI version not supported");\r
-    default:\r
-        LOGE("Failed to get the environment");\r
-        return nullptr;\r
-    }\r
-}\r
-\r
-static void DuplicateString(char ** targetString, std::string sourceString)\r
-{\r
-    *targetString = new char[sourceString.length() + 1];\r
-    strncpy(*targetString, sourceString.c_str(), (sourceString.length() + 1));\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 <jni.h>
+#include <android/log.h>
+#include "OCApi.h"
+
+#ifndef _Included_org_iotivity_base_ocstack
+#define _Included_org_iotivity_base_ocstack
+
+#define TAG "OIC-JNI"
+
+#define JNI_CURRENT_VERSION JNI_VERSION_1_6
+
+#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__)
+#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__)
+#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__)
+
+#define JNI_EXCEPTION 1000
+#define JNI_NO_NATIVE_POINTER 1001
+#define JNI_INVALID_VALUE 1002
+#define JNI_NO_SUCH_KEY 1003
+
+jobject getOcException(JNIEnv* env, const char* file, const char* functionName, const int line,
+    const int code, const char* message);
+void throwOcException(JNIEnv* env, jobject ex);
+#define GetOcException(code, message) getOcException (env,__FILE__,__func__,__LINE__,code,message)
+#define ThrowOcException(code, message) throwOcException (env, GetOcException(code, message))
+
+extern JavaVM* g_jvm;
+
+extern jclass g_cls_Integer;
+extern jclass g_cls_int1DArray;
+extern jclass g_cls_int2DArray;
+extern jclass g_cls_Double;
+extern jclass g_cls_double1DArray;
+extern jclass g_cls_double2DArray;
+extern jclass g_cls_Boolean;
+extern jclass g_cls_boolean1DArray;
+extern jclass g_cls_boolean2DArray;
+extern jclass g_cls_String;
+extern jclass g_cls_String1DArray;
+extern jclass g_cls_String2DArray;
+extern jclass g_cls_LinkedList;
+extern jclass g_cls_Map;
+extern jclass g_cls_MapEntry;
+extern jclass g_cls_Set;
+extern jclass g_cls_Iterator;
+extern jclass g_cls_HashMap;
+extern jclass g_cls_OcException;
+extern jclass g_cls_OcResource;
+extern jclass g_cls_OcRepresentation;
+extern jclass g_cls_OcRepresentation1DArray;
+extern jclass g_cls_OcRepresentation2DArray;
+extern jclass g_cls_OcResourceRequest;
+extern jclass g_cls_OcResourceResponse;
+extern jclass g_cls_OcResourceHandle;
+extern jclass g_cls_OcPresenceHandle;
+extern jclass g_cls_OcRequestHandle;
+extern jclass g_cls_OcPresenceStatus;
+extern jclass g_cls_OcHeaderOption;
+extern jclass g_cls_ObservationInfo;
+extern jclass g_cls_OcResourceIdentifier;
+
+extern jmethodID g_mid_Integer_ctor;
+extern jmethodID g_mid_Double_ctor;
+extern jmethodID g_mid_Boolean_ctor;
+extern jmethodID g_mid_LinkedList_ctor;
+extern jmethodID g_mid_LinkedList_add_object;
+extern jmethodID g_mid_Map_entrySet;
+extern jmethodID g_mid_MapEntry_getKey;
+extern jmethodID g_mid_MapEntry_getValue;
+extern jmethodID g_mid_Set_iterator;
+extern jmethodID g_mid_Iterator_hasNext;
+extern jmethodID g_mid_Iterator_next;
+extern jmethodID g_mid_HashMap_ctor;
+extern jmethodID g_mid_HashMap_put;
+extern jmethodID g_mid_OcException_ctor;
+extern jmethodID g_mid_OcException_setNativeExceptionLocation;
+extern jmethodID g_mid_OcResource_ctor;
+extern jmethodID g_mid_OcRepresentation_N_ctor;
+extern jmethodID g_mid_OcRepresentation_N_ctor_bool;
+extern jmethodID g_mid_OcResourceRequest_N_ctor;
+extern jmethodID g_mid_OcResourceResponse_N_ctor;
+extern jmethodID g_mid_OcResourceHandle_N_ctor;
+extern jmethodID g_mid_OcPresenceHandle_N_ctor;
+extern jmethodID g_mid_OcRequestHandle_N_ctor;
+extern jmethodID g_mid_OcHeaderOption_ctor;
+extern jmethodID g_mid_OcHeaderOption_get_id;
+extern jmethodID g_mid_OcHeaderOption_get_data;
+extern jmethodID g_mid_ObservationInfo_N_ctor;
+extern jmethodID g_mid_OcPresenceStatus_get;
+extern jmethodID g_mid_OcResourceIdentifier_N_ctor;
+
+typedef void(*RemoveListenerCallback)(JNIEnv* env, jobject jListener);
+
+static jfieldID GetHandleField(JNIEnv *env, jobject jobj)
+{
+    jclass cls = env->GetObjectClass(jobj);
+    return env->GetFieldID(cls, "mNativeHandle", "J");
+}
+
+template <typename T>
+static T *GetHandle(JNIEnv *env, jobject jobj)
+{
+    jlong handle = env->GetLongField(jobj, GetHandleField(env, jobj));
+    return reinterpret_cast<T *>(handle);
+}
+
+template <typename T>
+static void SetHandle(JNIEnv *env, jobject jobj, T *type)
+{
+    jlong handle = reinterpret_cast<jlong>(type);
+
+    env->SetLongField(jobj, GetHandleField(env, jobj), handle);
+}
+
+static JNIEnv* GetJNIEnv(jint& ret)
+{
+    JNIEnv *env = NULL;
+
+    ret = g_jvm->GetEnv((void **)&env, JNI_CURRENT_VERSION);
+    switch (ret) {
+    case JNI_OK:
+        return env;
+    case JNI_EDETACHED:
+        if (g_jvm->AttachCurrentThread(&env, NULL) < 0)
+        {
+            LOGE("Failed to get the environment");
+            return nullptr;
+        }
+        else
+        {
+            return env;
+        }
+
+    case JNI_EVERSION:
+        LOGE("JNI version not supported");
+    default:
+        LOGE("Failed to get the environment");
+        return nullptr;
+    }
+}
+
+static void DuplicateString(char ** targetString, std::string sourceString)
+{
+    *targetString = new char[sourceString.length() + 1];
+    strncpy(*targetString, sourceString.c_str(), (sourceString.length() + 1));
+}
+
 #endif // _Included_org_iotivity_base_ocstack
\ No newline at end of file
index ed39e3b..ce2b3f8 100644 (file)
-/*\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
-\r
-#include "JniOnDeleteListener.h"\r
-#include "JniOcResource.h"\r
-#include "JniUtils.h"\r
-\r
-JniOnDeleteListener::JniOnDeleteListener(JNIEnv *env, jobject jListener, JniOcResource* owner)\r
-    : m_ownerResource(owner)\r
-{\r
-    m_jwListener = env->NewWeakGlobalRef(jListener);\r
-}\r
-\r
-JniOnDeleteListener::~JniOnDeleteListener()\r
-{\r
-    if (m_jwListener)\r
-    {\r
-        jint ret;\r
-        JNIEnv *env = GetJNIEnv(ret);\r
-        if (NULL == env) return;\r
-        env->DeleteWeakGlobalRef(m_jwListener);\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-    }\r
-}\r
-\r
-void JniOnDeleteListener::onDeleteCallback(const HeaderOptions& headerOptions, const int eCode)\r
-{\r
-    jint envRet;\r
-    JNIEnv *env = GetJNIEnv(envRet);\r
-    if (NULL == env) return;\r
-\r
-    jobject jListener = env->NewLocalRef(m_jwListener);\r
-    if (!jListener)\r
-    {\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-    jclass clsL = env->GetObjectClass(jListener);\r
-    if (!clsL)\r
-    {\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-\r
-    if (OC_STACK_RESOURCE_DELETED != eCode)\r
-    {\r
-        jobject ex = GetOcException(eCode, "stack error in onDeleteCallback");\r
-        if (!ex)\r
-        {\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-        jmethodID midL = env->GetMethodID(clsL, "onDeleteFailed", "(Ljava/lang/Throwable;)V");\r
-        if (!midL)\r
-        {\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-        env->CallVoidMethod(jListener, midL, ex);\r
-    }\r
-    else\r
-    {\r
-        jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions);\r
-        if (!jHeaderOptionList)\r
-        {\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-\r
-        jmethodID midL = env->GetMethodID(clsL, "onDeleteCompleted", "(Ljava/util/List;)V");\r
-        if (!midL)\r
-        {\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-        env->CallVoidMethod(jListener, midL, jHeaderOptionList);\r
-    }\r
-\r
-    checkExAndRemoveListener(env);\r
-    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-}\r
-\r
-void JniOnDeleteListener::checkExAndRemoveListener(JNIEnv* env)\r
-{\r
-    if (env->ExceptionCheck())\r
-    {\r
-        jthrowable ex = env->ExceptionOccurred();\r
-        env->ExceptionClear();\r
-        m_ownerResource->removeOnDeleteListener(env, m_jwListener);\r
-        env->Throw((jthrowable)ex);\r
-    }\r
-    else\r
-    {\r
-        m_ownerResource->removeOnDeleteListener(env, m_jwListener);\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 "JniOnDeleteListener.h"
+#include "JniOcResource.h"
+#include "JniUtils.h"
+
+JniOnDeleteListener::JniOnDeleteListener(JNIEnv *env, jobject jListener, JniOcResource* owner)
+    : m_ownerResource(owner)
+{
+    m_jwListener = env->NewWeakGlobalRef(jListener);
+}
+
+JniOnDeleteListener::~JniOnDeleteListener()
+{
+    if (m_jwListener)
+    {
+        jint ret;
+        JNIEnv *env = GetJNIEnv(ret);
+        if (NULL == env) return;
+        env->DeleteWeakGlobalRef(m_jwListener);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+    }
+}
+
+void JniOnDeleteListener::onDeleteCallback(const HeaderOptions& headerOptions, const int eCode)
+{
+    jint envRet;
+    JNIEnv *env = GetJNIEnv(envRet);
+    if (NULL == env) return;
+
+    jobject jListener = env->NewLocalRef(m_jwListener);
+    if (!jListener)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return;
+    }
+    jclass clsL = env->GetObjectClass(jListener);
+    if (!clsL)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    if (OC_STACK_RESOURCE_DELETED != eCode)
+    {
+        jobject ex = GetOcException(eCode, "stack error in onDeleteCallback");
+        if (!ex)
+        {
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+        jmethodID midL = env->GetMethodID(clsL, "onDeleteFailed", "(Ljava/lang/Throwable;)V");
+        if (!midL)
+        {
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+        env->CallVoidMethod(jListener, midL, ex);
+    }
+    else
+    {
+        jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions);
+        if (!jHeaderOptionList)
+        {
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+
+        jmethodID midL = env->GetMethodID(clsL, "onDeleteCompleted", "(Ljava/util/List;)V");
+        if (!midL)
+        {
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+        env->CallVoidMethod(jListener, midL, jHeaderOptionList);
+    }
+
+    checkExAndRemoveListener(env);
+    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+}
+
+void JniOnDeleteListener::checkExAndRemoveListener(JNIEnv* env)
+{
+    if (env->ExceptionCheck())
+    {
+        jthrowable ex = env->ExceptionOccurred();
+        env->ExceptionClear();
+        m_ownerResource->removeOnDeleteListener(env, m_jwListener);
+        env->Throw((jthrowable)ex);
+    }
+    else
+    {
+        m_ownerResource->removeOnDeleteListener(env, m_jwListener);
+    }
 }
\ No newline at end of file
index 45ae34b..20de33f 100644 (file)
@@ -1,45 +1,45 @@
-/*\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 "JniOcStack.h"\r
-\r
-#ifndef _Included_org_iotivity_base_OcResource_OnDeleteListener\r
-#define _Included_org_iotivity_base_OcResource_OnDeleteListener\r
-\r
-using namespace OC;\r
-\r
-class JniOcResource;\r
-\r
-class JniOnDeleteListener\r
-{\r
-public:\r
-    JniOnDeleteListener(JNIEnv *env, jobject jListener, JniOcResource* owner);\r
-    ~JniOnDeleteListener();\r
-\r
-    void onDeleteCallback(const HeaderOptions&, const int eCode);\r
-\r
-private:\r
-    jweak m_jwListener;\r
-    JniOcResource* m_ownerResource;\r
-    void checkExAndRemoveListener(JNIEnv *env);\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 "JniOcStack.h"
+
+#ifndef _Included_org_iotivity_base_OcResource_OnDeleteListener
+#define _Included_org_iotivity_base_OcResource_OnDeleteListener
+
+using namespace OC;
+
+class JniOcResource;
+
+class JniOnDeleteListener
+{
+public:
+    JniOnDeleteListener(JNIEnv *env, jobject jListener, JniOcResource* owner);
+    ~JniOnDeleteListener();
+
+    void onDeleteCallback(const HeaderOptions&, const int eCode);
+
+private:
+    jweak m_jwListener;
+    JniOcResource* m_ownerResource;
+    void checkExAndRemoveListener(JNIEnv *env);
+};
+
 #endif
\ No newline at end of file
index 483fac6..6dcb5a9 100644 (file)
-/*\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 "JniOnDeviceInfoListener.h"\r
-#include "JniOcRepresentation.h"\r
-\r
-JniOnDeviceInfoListener::JniOnDeviceInfoListener(JNIEnv *env, jobject jListener,\r
-    RemoveListenerCallback removeListenerCallback)\r
-{\r
-    m_jwListener = env->NewWeakGlobalRef(jListener);\r
-    m_removeListenerCallback = removeListenerCallback;\r
-}\r
-\r
-JniOnDeviceInfoListener::~JniOnDeviceInfoListener()\r
-{\r
-    LOGI("~JniOnDeviceInfoListener");\r
-    if (m_jwListener)\r
-    {\r
-        jint ret;\r
-        JNIEnv *env = GetJNIEnv(ret);\r
-        if (NULL == env) return;\r
-        env->DeleteWeakGlobalRef(m_jwListener);\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-    }\r
-}\r
-\r
-void JniOnDeviceInfoListener::foundDeviceCallback(const OC::OCRepresentation& ocRepresentation)\r
-{\r
-    jint ret;\r
-    JNIEnv *env = GetJNIEnv(ret);\r
-    if (NULL == env) return;\r
-\r
-    jobject jListener = env->NewLocalRef(m_jwListener);\r
-    if (!jListener)\r
-    {\r
-        LOGI("Java onDeviceInfoListener object is already destroyed, quiting");\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-\r
-    OCRepresentation* rep = new OCRepresentation(ocRepresentation);\r
-    jlong handle = reinterpret_cast<jlong>(rep);\r
-    jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,\r
-        handle, true);\r
-    if (!jRepresentation)\r
-    {\r
-        delete rep;\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-\r
-    jclass clsL = env->GetObjectClass(jListener);\r
-    if (!clsL)\r
-    {\r
-        delete rep;\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-    jmethodID midL = env->GetMethodID(clsL, "onDeviceFound", "(Lorg/iotivity/base/OcRepresentation;)V");\r
-    if (!midL)\r
-    {\r
-        delete rep;\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-\r
-    env->CallVoidMethod(jListener, midL, jRepresentation);\r
-    if (env->ExceptionCheck())\r
-    {\r
-        LOGE("Java exception is thrown");\r
-        delete rep;\r
-        checkExAndRemoveListener(env);\r
-    }\r
-\r
-    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-}\r
-\r
-void JniOnDeviceInfoListener::checkExAndRemoveListener(JNIEnv* env)\r
-{\r
-    if (env->ExceptionCheck())\r
-    {\r
-        jthrowable ex = env->ExceptionOccurred();\r
-        env->ExceptionClear();\r
-        m_removeListenerCallback(env, m_jwListener);\r
-        env->Throw((jthrowable)ex);\r
-    }\r
-    else\r
-    {\r
-        m_removeListenerCallback(env, m_jwListener);\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 "JniOnDeviceInfoListener.h"
+#include "JniOcRepresentation.h"
+
+JniOnDeviceInfoListener::JniOnDeviceInfoListener(JNIEnv *env, jobject jListener,
+    RemoveListenerCallback removeListenerCallback)
+{
+    m_jwListener = env->NewWeakGlobalRef(jListener);
+    m_removeListenerCallback = removeListenerCallback;
+}
+
+JniOnDeviceInfoListener::~JniOnDeviceInfoListener()
+{
+    LOGI("~JniOnDeviceInfoListener");
+    if (m_jwListener)
+    {
+        jint ret;
+        JNIEnv *env = GetJNIEnv(ret);
+        if (NULL == env) return;
+        env->DeleteWeakGlobalRef(m_jwListener);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+    }
+}
+
+void JniOnDeviceInfoListener::foundDeviceCallback(const OC::OCRepresentation& ocRepresentation)
+{
+    jint ret;
+    JNIEnv *env = GetJNIEnv(ret);
+    if (NULL == env) return;
+
+    jobject jListener = env->NewLocalRef(m_jwListener);
+    if (!jListener)
+    {
+        LOGI("Java onDeviceInfoListener object is already destroyed, quiting");
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    OCRepresentation* rep = new OCRepresentation(ocRepresentation);
+    jlong handle = reinterpret_cast<jlong>(rep);
+    jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,
+        handle, true);
+    if (!jRepresentation)
+    {
+        delete rep;
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    jclass clsL = env->GetObjectClass(jListener);
+    if (!clsL)
+    {
+        delete rep;
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+    jmethodID midL = env->GetMethodID(clsL, "onDeviceFound", "(Lorg/iotivity/base/OcRepresentation;)V");
+    if (!midL)
+    {
+        delete rep;
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    env->CallVoidMethod(jListener, midL, jRepresentation);
+    if (env->ExceptionCheck())
+    {
+        LOGE("Java exception is thrown");
+        delete rep;
+        checkExAndRemoveListener(env);
+    }
+
+    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+}
+
+void JniOnDeviceInfoListener::checkExAndRemoveListener(JNIEnv* env)
+{
+    if (env->ExceptionCheck())
+    {
+        jthrowable ex = env->ExceptionOccurred();
+        env->ExceptionClear();
+        m_removeListenerCallback(env, m_jwListener);
+        env->Throw((jthrowable)ex);
+    }
+    else
+    {
+        m_removeListenerCallback(env, m_jwListener);
+    }
 }
\ No newline at end of file
index 152ca8c..8bc5bc7 100644 (file)
@@ -1,42 +1,42 @@
-/*\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 <jni.h>\r
-#include "JniOcStack.h"\r
-\r
-#ifndef _Included_org_iotivity_base_OcPlatform_OnDeviceFoundListener\r
-#define _Included_org_iotivity_base_OcPlatform_OnDeviceFoundListener\r
-\r
-class JniOnDeviceInfoListener\r
-{\r
-public:\r
-    JniOnDeviceInfoListener(JNIEnv *env, jobject jListener, RemoveListenerCallback removeListener);\r
-    ~JniOnDeviceInfoListener();\r
-\r
-    void foundDeviceCallback(const OC::OCRepresentation& ocRepresentation);\r
-\r
-private:\r
-    jweak m_jwListener;\r
-    RemoveListenerCallback m_removeListenerCallback;\r
-    void checkExAndRemoveListener(JNIEnv* env);\r
-};\r
-\r
-#endif\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 <jni.h>
+#include "JniOcStack.h"
+
+#ifndef _Included_org_iotivity_base_OcPlatform_OnDeviceFoundListener
+#define _Included_org_iotivity_base_OcPlatform_OnDeviceFoundListener
+
+class JniOnDeviceInfoListener
+{
+public:
+    JniOnDeviceInfoListener(JNIEnv *env, jobject jListener, RemoveListenerCallback removeListener);
+    ~JniOnDeviceInfoListener();
+
+    void foundDeviceCallback(const OC::OCRepresentation& ocRepresentation);
+
+private:
+    jweak m_jwListener;
+    RemoveListenerCallback m_removeListenerCallback;
+    void checkExAndRemoveListener(JNIEnv* env);
+};
+
+#endif
index 4ac19bc..e2e4484 100644 (file)
-/*\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 "JniOnGetListener.h"\r
-#include "JniOcResource.h"\r
-#include "JniOcRepresentation.h"\r
-#include "JniUtils.h"\r
-\r
-JniOnGetListener::JniOnGetListener(JNIEnv *env, jobject jListener, JniOcResource* owner)\r
-    : m_ownerResource(owner)\r
-{\r
-    m_jwListener = env->NewWeakGlobalRef(jListener);\r
-}\r
-\r
-JniOnGetListener::~JniOnGetListener()\r
-{\r
-    if (m_jwListener)\r
-    {\r
-        jint ret;\r
-        JNIEnv *env = GetJNIEnv(ret);\r
-        if (NULL == env) return;\r
-\r
-        env->DeleteWeakGlobalRef(m_jwListener);\r
-\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-    }\r
-}\r
-\r
-void JniOnGetListener::onGetCallback(const HeaderOptions& headerOptions,\r
-    const OCRepresentation& ocRepresentation, const int eCode)\r
-{\r
-    jint envRet;\r
-    JNIEnv *env = GetJNIEnv(envRet);\r
-    if (NULL == env) return;\r
-\r
-    jobject jListener = env->NewLocalRef(m_jwListener);\r
-    if (!jListener)\r
-    {\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-    jclass clsL = env->GetObjectClass(jListener);\r
-\r
-    if (!clsL)\r
-    {\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-\r
-    if (OC_STACK_OK != eCode)\r
-    {\r
-        jobject ex = GetOcException(eCode, "stack error in onGetCallback");\r
-        if (!ex)\r
-        {\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-        jmethodID midL = env->GetMethodID(clsL, "onGetFailed", "(Ljava/lang/Throwable;)V");\r
-        if (!midL)\r
-        {\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-        env->CallVoidMethod(jListener, midL, ex);\r
-    }\r
-    else\r
-    {\r
-        jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions);\r
-        if (!jHeaderOptionList)\r
-        {\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-\r
-        OCRepresentation* rep = new OCRepresentation(ocRepresentation);\r
-        jlong handle = reinterpret_cast<jlong>(rep);\r
-        jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,\r
-            handle, true);\r
-        if (!jRepresentation)\r
-        {\r
-            delete rep;\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-\r
-        jmethodID midL = env->GetMethodID(clsL, "onGetCompleted",\r
-            "(Ljava/util/List;Lorg/iotivity/base/OcRepresentation;)V");\r
-        if (!midL)\r
-        {\r
-            delete rep;\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-        env->CallVoidMethod(jListener, midL, jHeaderOptionList, jRepresentation);\r
-        if (env->ExceptionCheck())\r
-        {\r
-            LOGE("Java exception is thrown");\r
-            delete rep;\r
-        }\r
-    }\r
-\r
-    checkExAndRemoveListener(env);\r
-    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-}\r
-\r
-void JniOnGetListener::checkExAndRemoveListener(JNIEnv* env)\r
-{\r
-    if (env->ExceptionCheck())\r
-    {\r
-        jthrowable ex = env->ExceptionOccurred();\r
-        env->ExceptionClear();\r
-        m_ownerResource->removeOnGetListener(env, m_jwListener);\r
-        env->Throw((jthrowable)ex);\r
-    }\r
-    else\r
-    {\r
-        m_ownerResource->removeOnGetListener(env, m_jwListener);\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 "JniOnGetListener.h"
+#include "JniOcResource.h"
+#include "JniOcRepresentation.h"
+#include "JniUtils.h"
+
+JniOnGetListener::JniOnGetListener(JNIEnv *env, jobject jListener, JniOcResource* owner)
+    : m_ownerResource(owner)
+{
+    m_jwListener = env->NewWeakGlobalRef(jListener);
+}
+
+JniOnGetListener::~JniOnGetListener()
+{
+    if (m_jwListener)
+    {
+        jint ret;
+        JNIEnv *env = GetJNIEnv(ret);
+        if (NULL == env) return;
+
+        env->DeleteWeakGlobalRef(m_jwListener);
+
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+    }
+}
+
+void JniOnGetListener::onGetCallback(const HeaderOptions& headerOptions,
+    const OCRepresentation& ocRepresentation, const int eCode)
+{
+    jint envRet;
+    JNIEnv *env = GetJNIEnv(envRet);
+    if (NULL == env) return;
+
+    jobject jListener = env->NewLocalRef(m_jwListener);
+    if (!jListener)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return;
+    }
+    jclass clsL = env->GetObjectClass(jListener);
+
+    if (!clsL)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    if (OC_STACK_OK != eCode)
+    {
+        jobject ex = GetOcException(eCode, "stack error in onGetCallback");
+        if (!ex)
+        {
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+        jmethodID midL = env->GetMethodID(clsL, "onGetFailed", "(Ljava/lang/Throwable;)V");
+        if (!midL)
+        {
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+        env->CallVoidMethod(jListener, midL, ex);
+    }
+    else
+    {
+        jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions);
+        if (!jHeaderOptionList)
+        {
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+
+        OCRepresentation* rep = new OCRepresentation(ocRepresentation);
+        jlong handle = reinterpret_cast<jlong>(rep);
+        jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,
+            handle, true);
+        if (!jRepresentation)
+        {
+            delete rep;
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+
+        jmethodID midL = env->GetMethodID(clsL, "onGetCompleted",
+            "(Ljava/util/List;Lorg/iotivity/base/OcRepresentation;)V");
+        if (!midL)
+        {
+            delete rep;
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+        env->CallVoidMethod(jListener, midL, jHeaderOptionList, jRepresentation);
+        if (env->ExceptionCheck())
+        {
+            LOGE("Java exception is thrown");
+            delete rep;
+        }
+    }
+
+    checkExAndRemoveListener(env);
+    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+}
+
+void JniOnGetListener::checkExAndRemoveListener(JNIEnv* env)
+{
+    if (env->ExceptionCheck())
+    {
+        jthrowable ex = env->ExceptionOccurred();
+        env->ExceptionClear();
+        m_ownerResource->removeOnGetListener(env, m_jwListener);
+        env->Throw((jthrowable)ex);
+    }
+    else
+    {
+        m_ownerResource->removeOnGetListener(env, m_jwListener);
+    }
 }
\ No newline at end of file
index af69f1b..a37b423 100644 (file)
@@ -1,43 +1,43 @@
-/*\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 "JniOcStack.h"\r
-\r
-#ifndef _Included_org_iotivity_base_OcResource_OnGetListener\r
-#define _Included_org_iotivity_base_OcResource_OnGetListener\r
-\r
-using namespace OC;\r
-\r
-class JniOcResource;\r
-\r
-class JniOnGetListener\r
-{\r
-public:\r
-    JniOnGetListener(JNIEnv *env, jobject listener, JniOcResource* resource);\r
-    ~JniOnGetListener();\r
-    void onGetCallback(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode);\r
-private:\r
-    jweak m_jwListener;\r
-    JniOcResource* m_ownerResource;\r
-    void checkExAndRemoveListener(JNIEnv *env);\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 "JniOcStack.h"
+
+#ifndef _Included_org_iotivity_base_OcResource_OnGetListener
+#define _Included_org_iotivity_base_OcResource_OnGetListener
+
+using namespace OC;
+
+class JniOcResource;
+
+class JniOnGetListener
+{
+public:
+    JniOnGetListener(JNIEnv *env, jobject listener, JniOcResource* resource);
+    ~JniOnGetListener();
+    void onGetCallback(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode);
+private:
+    jweak m_jwListener;
+    JniOcResource* m_ownerResource;
+    void checkExAndRemoveListener(JNIEnv *env);
+};
+
 #endif
\ No newline at end of file
index 7afb1e1..934755f 100644 (file)
-/*\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 "JniOnObserveListener.h"\r
-#include "JniOcResource.h"\r
-#include "JniOcRepresentation.h"\r
-#include "JniUtils.h"\r
-\r
-JniOnObserveListener::JniOnObserveListener(JNIEnv *env, jobject jListener, JniOcResource* owner)\r
-    : m_ownerResource(owner)\r
-{\r
-    m_jwListener = env->NewWeakGlobalRef(jListener);\r
-}\r
-\r
-JniOnObserveListener::~JniOnObserveListener()\r
-{\r
-    if (m_jwListener)\r
-    {\r
-        jint ret;\r
-        JNIEnv *env = GetJNIEnv(ret);\r
-        if (NULL == env) return;\r
-\r
-        env->DeleteWeakGlobalRef(m_jwListener);\r
-\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-    }\r
-}\r
-\r
-void JniOnObserveListener::onObserveCallback(const HeaderOptions headerOptions,\r
-    const OCRepresentation& ocRepresentation, const int& eCode, const int& sequenceNumber)\r
-{\r
-    jint envRet;\r
-    JNIEnv *env = GetJNIEnv(envRet);\r
-    if (NULL == env) return;\r
-\r
-    jobject jListener = env->NewLocalRef(m_jwListener);\r
-    if (!jListener)\r
-    {\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-    jclass clsL = env->GetObjectClass(jListener);\r
-    if (!clsL)\r
-    {\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-\r
-    if (OC_STACK_OK != eCode && OC_STACK_RESOURCE_CREATED != eCode && OC_STACK_RESOURCE_DELETED != eCode)\r
-    {\r
-        jobject ex = GetOcException(eCode, "stack error in onObserveCallback");\r
-        if (!ex)\r
-        {\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-        jmethodID midL = env->GetMethodID(clsL, "onObserveFailed", "(Ljava/lang/Throwable;)V");\r
-        if (!midL)\r
-        {\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-        env->CallVoidMethod(jListener, midL, ex);\r
-    }\r
-    else\r
-    {\r
-        jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions);\r
-        if (!jHeaderOptionList)\r
-        {\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-\r
-        OCRepresentation * rep = new OCRepresentation(ocRepresentation);\r
-        jlong handle = reinterpret_cast<jlong>(rep);\r
-        jobject jRepresentation = env->NewObject(g_cls_OcRepresentation,\r
-            g_mid_OcRepresentation_N_ctor_bool, handle, true);\r
-        if (!jRepresentation)\r
-        {\r
-            delete rep;\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-\r
-        jmethodID midL = env->GetMethodID(clsL, "onObserveCompleted",\r
-            "(Ljava/util/List;Lorg/iotivity/base/OcRepresentation;I)V");\r
-        if (!midL)\r
-        {\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-\r
-        env->CallVoidMethod(jListener, midL, jHeaderOptionList, jRepresentation,\r
-            static_cast<jint>(sequenceNumber));\r
-        if (env->ExceptionCheck())\r
-        {\r
-            LOGE("Java exception is thrown");\r
-            delete rep;\r
-            jthrowable ex = env->ExceptionOccurred();\r
-            env->ExceptionClear();\r
-            m_ownerResource->removeOnObserveListener(env, m_jwListener);\r
-            env->Throw((jthrowable)ex);\r
-        }\r
-    }\r
-\r
-    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-}\r
-\r
-void JniOnObserveListener::checkExAndRemoveListener(JNIEnv* env)\r
-{\r
-    if (env->ExceptionCheck())\r
-    {\r
-        jthrowable ex = env->ExceptionOccurred();\r
-        env->ExceptionClear();\r
-        m_ownerResource->removeOnObserveListener(env, m_jwListener);\r
-        env->Throw((jthrowable)ex);\r
-    }\r
-    else\r
-    {\r
-        m_ownerResource->removeOnObserveListener(env, m_jwListener);\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 "JniOnObserveListener.h"
+#include "JniOcResource.h"
+#include "JniOcRepresentation.h"
+#include "JniUtils.h"
+
+JniOnObserveListener::JniOnObserveListener(JNIEnv *env, jobject jListener, JniOcResource* owner)
+    : m_ownerResource(owner)
+{
+    m_jwListener = env->NewWeakGlobalRef(jListener);
+}
+
+JniOnObserveListener::~JniOnObserveListener()
+{
+    if (m_jwListener)
+    {
+        jint ret;
+        JNIEnv *env = GetJNIEnv(ret);
+        if (NULL == env) return;
+
+        env->DeleteWeakGlobalRef(m_jwListener);
+
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+    }
+}
+
+void JniOnObserveListener::onObserveCallback(const HeaderOptions headerOptions,
+    const OCRepresentation& ocRepresentation, const int& eCode, const int& sequenceNumber)
+{
+    jint envRet;
+    JNIEnv *env = GetJNIEnv(envRet);
+    if (NULL == env) return;
+
+    jobject jListener = env->NewLocalRef(m_jwListener);
+    if (!jListener)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return;
+    }
+    jclass clsL = env->GetObjectClass(jListener);
+    if (!clsL)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    if (OC_STACK_OK != eCode && OC_STACK_RESOURCE_CREATED != eCode && OC_STACK_RESOURCE_DELETED != eCode)
+    {
+        jobject ex = GetOcException(eCode, "stack error in onObserveCallback");
+        if (!ex)
+        {
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+        jmethodID midL = env->GetMethodID(clsL, "onObserveFailed", "(Ljava/lang/Throwable;)V");
+        if (!midL)
+        {
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+        env->CallVoidMethod(jListener, midL, ex);
+    }
+    else
+    {
+        jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions);
+        if (!jHeaderOptionList)
+        {
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+
+        OCRepresentation * rep = new OCRepresentation(ocRepresentation);
+        jlong handle = reinterpret_cast<jlong>(rep);
+        jobject jRepresentation = env->NewObject(g_cls_OcRepresentation,
+            g_mid_OcRepresentation_N_ctor_bool, handle, true);
+        if (!jRepresentation)
+        {
+            delete rep;
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+
+        jmethodID midL = env->GetMethodID(clsL, "onObserveCompleted",
+            "(Ljava/util/List;Lorg/iotivity/base/OcRepresentation;I)V");
+        if (!midL)
+        {
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+
+        env->CallVoidMethod(jListener, midL, jHeaderOptionList, jRepresentation,
+            static_cast<jint>(sequenceNumber));
+        if (env->ExceptionCheck())
+        {
+            LOGE("Java exception is thrown");
+            delete rep;
+            jthrowable ex = env->ExceptionOccurred();
+            env->ExceptionClear();
+            m_ownerResource->removeOnObserveListener(env, m_jwListener);
+            env->Throw((jthrowable)ex);
+        }
+    }
+
+    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+}
+
+void JniOnObserveListener::checkExAndRemoveListener(JNIEnv* env)
+{
+    if (env->ExceptionCheck())
+    {
+        jthrowable ex = env->ExceptionOccurred();
+        env->ExceptionClear();
+        m_ownerResource->removeOnObserveListener(env, m_jwListener);
+        env->Throw((jthrowable)ex);
+    }
+    else
+    {
+        m_ownerResource->removeOnObserveListener(env, m_jwListener);
+    }
 }
\ No newline at end of file
index ae1d042..38f9aae 100644 (file)
@@ -1,44 +1,44 @@
-/*\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 "JniOcStack.h"\r
-\r
-#ifndef _Included_org_iotivity_base_OcResource_OnObserveListener\r
-#define _Included_org_iotivity_base_OcResource_OnObserveListener\r
-\r
-using namespace OC;\r
-\r
-class JniOcResource;\r
-\r
-class JniOnObserveListener\r
-{\r
-public:\r
-    JniOnObserveListener(JNIEnv *env, jobject jListener, JniOcResource* owner);\r
-    ~JniOnObserveListener();\r
-    void onObserveCallback(const HeaderOptions headerOptions, const OCRepresentation& rep,\r
-        const int& eCode, const int& sequenceNumber);\r
-private:\r
-    jweak m_jwListener;\r
-    JniOcResource* m_ownerResource;\r
-    void checkExAndRemoveListener(JNIEnv *env);\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 "JniOcStack.h"
+
+#ifndef _Included_org_iotivity_base_OcResource_OnObserveListener
+#define _Included_org_iotivity_base_OcResource_OnObserveListener
+
+using namespace OC;
+
+class JniOcResource;
+
+class JniOnObserveListener
+{
+public:
+    JniOnObserveListener(JNIEnv *env, jobject jListener, JniOcResource* owner);
+    ~JniOnObserveListener();
+    void onObserveCallback(const HeaderOptions headerOptions, const OCRepresentation& rep,
+        const int& eCode, const int& sequenceNumber);
+private:
+    jweak m_jwListener;
+    JniOcResource* m_ownerResource;
+    void checkExAndRemoveListener(JNIEnv *env);
+};
+
 #endif
\ No newline at end of file
index b9eb997..549120b 100644 (file)
-/*\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 "JniOnPostListener.h"\r
-#include "JniOcResource.h"\r
-#include "JniOcRepresentation.h"\r
-#include "JniUtils.h"\r
-\r
-JniOnPostListener::JniOnPostListener(JNIEnv *env, jobject jListener, JniOcResource* owner)\r
-    : m_ownerResource(owner)\r
-{\r
-    m_jwListener = env->NewWeakGlobalRef(jListener);\r
-}\r
-\r
-JniOnPostListener::~JniOnPostListener()\r
-{\r
-    if (m_jwListener)\r
-    {\r
-        jint ret;\r
-        JNIEnv *env = GetJNIEnv(ret);\r
-        if (NULL == env) return;\r
-\r
-        env->DeleteWeakGlobalRef(m_jwListener);\r
-\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-    }\r
-}\r
-\r
-void JniOnPostListener::onPostCallback(const HeaderOptions& headerOptions,\r
-    const OCRepresentation& ocRepresentation, const int eCode)\r
-{\r
-    jint envRet;\r
-    JNIEnv *env = GetJNIEnv(envRet);\r
-    if (NULL == env) return;\r
-\r
-    jobject jListener = env->NewLocalRef(m_jwListener);\r
-    if (!jListener)\r
-    {\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-    jclass clsL = env->GetObjectClass(jListener);\r
-    if (!clsL)\r
-    {\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-\r
-    if (OC_STACK_OK != eCode && OC_STACK_RESOURCE_CREATED != eCode)\r
-    {\r
-        jobject ex = GetOcException(eCode, "stack error in onPostCallback");\r
-        if (!ex)\r
-        {\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-        jmethodID midL = env->GetMethodID(clsL, "onPostFailed", "(Ljava/lang/Throwable;)V");\r
-        if (!midL)\r
-        {\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-        env->CallVoidMethod(jListener, midL, ex);\r
-    }\r
-    else\r
-    {\r
-        jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions);\r
-        if (!jHeaderOptionList)\r
-        {\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-\r
-        OCRepresentation * rep = new OCRepresentation(ocRepresentation);\r
-        jlong handle = reinterpret_cast<jlong>(rep);\r
-        jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,\r
-            handle, true);\r
-        if (!jRepresentation)\r
-        {\r
-            delete rep;\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-\r
-        jmethodID midL = env->GetMethodID(clsL, "onPostCompleted",\r
-            "(Ljava/util/List;Lorg/iotivity/base/OcRepresentation;)V");\r
-        if (!midL)\r
-        {\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-\r
-        env->CallVoidMethod(jListener, midL, jHeaderOptionList, jRepresentation);\r
-        if (env->ExceptionCheck())\r
-        {\r
-            LOGE("Java exception is thrown");\r
-            delete rep;\r
-        }\r
-    }\r
-\r
-    checkExAndRemoveListener(env);\r
-    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-}\r
-\r
-void JniOnPostListener::checkExAndRemoveListener(JNIEnv* env)\r
-{\r
-    if (env->ExceptionCheck())\r
-    {\r
-        jthrowable ex = env->ExceptionOccurred();\r
-        env->ExceptionClear();\r
-        m_ownerResource->removeOnPostListener(env, m_jwListener);\r
-        env->Throw((jthrowable)ex);\r
-    }\r
-    else\r
-    {\r
-        m_ownerResource->removeOnPostListener(env, m_jwListener);\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 "JniOnPostListener.h"
+#include "JniOcResource.h"
+#include "JniOcRepresentation.h"
+#include "JniUtils.h"
+
+JniOnPostListener::JniOnPostListener(JNIEnv *env, jobject jListener, JniOcResource* owner)
+    : m_ownerResource(owner)
+{
+    m_jwListener = env->NewWeakGlobalRef(jListener);
+}
+
+JniOnPostListener::~JniOnPostListener()
+{
+    if (m_jwListener)
+    {
+        jint ret;
+        JNIEnv *env = GetJNIEnv(ret);
+        if (NULL == env) return;
+
+        env->DeleteWeakGlobalRef(m_jwListener);
+
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+    }
+}
+
+void JniOnPostListener::onPostCallback(const HeaderOptions& headerOptions,
+    const OCRepresentation& ocRepresentation, const int eCode)
+{
+    jint envRet;
+    JNIEnv *env = GetJNIEnv(envRet);
+    if (NULL == env) return;
+
+    jobject jListener = env->NewLocalRef(m_jwListener);
+    if (!jListener)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return;
+    }
+    jclass clsL = env->GetObjectClass(jListener);
+    if (!clsL)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    if (OC_STACK_OK != eCode && OC_STACK_RESOURCE_CREATED != eCode)
+    {
+        jobject ex = GetOcException(eCode, "stack error in onPostCallback");
+        if (!ex)
+        {
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+        jmethodID midL = env->GetMethodID(clsL, "onPostFailed", "(Ljava/lang/Throwable;)V");
+        if (!midL)
+        {
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+        env->CallVoidMethod(jListener, midL, ex);
+    }
+    else
+    {
+        jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions);
+        if (!jHeaderOptionList)
+        {
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+
+        OCRepresentation * rep = new OCRepresentation(ocRepresentation);
+        jlong handle = reinterpret_cast<jlong>(rep);
+        jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,
+            handle, true);
+        if (!jRepresentation)
+        {
+            delete rep;
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+
+        jmethodID midL = env->GetMethodID(clsL, "onPostCompleted",
+            "(Ljava/util/List;Lorg/iotivity/base/OcRepresentation;)V");
+        if (!midL)
+        {
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+
+        env->CallVoidMethod(jListener, midL, jHeaderOptionList, jRepresentation);
+        if (env->ExceptionCheck())
+        {
+            LOGE("Java exception is thrown");
+            delete rep;
+        }
+    }
+
+    checkExAndRemoveListener(env);
+    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+}
+
+void JniOnPostListener::checkExAndRemoveListener(JNIEnv* env)
+{
+    if (env->ExceptionCheck())
+    {
+        jthrowable ex = env->ExceptionOccurred();
+        env->ExceptionClear();
+        m_ownerResource->removeOnPostListener(env, m_jwListener);
+        env->Throw((jthrowable)ex);
+    }
+    else
+    {
+        m_ownerResource->removeOnPostListener(env, m_jwListener);
+    }
 }
\ No newline at end of file
index 9090507..5dfe525 100644 (file)
@@ -1,45 +1,45 @@
-/*\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 "JniOcStack.h"\r
-\r
-#ifndef _Included_org_iotivity_base_OcResource_OnPostListener\r
-#define _Included_org_iotivity_base_OcResource_OnPostListener\r
-\r
-using namespace OC;\r
-\r
-class JniOcResource;\r
-\r
-class JniOnPostListener\r
-{\r
-public:\r
-    JniOnPostListener(JNIEnv *env, jobject jListener, JniOcResource* owner);\r
-    ~JniOnPostListener();\r
-\r
-    void onPostCallback(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode);\r
-\r
-private:\r
-    jweak m_jwListener;\r
-    JniOcResource* m_ownerResource;\r
-    void checkExAndRemoveListener(JNIEnv *env);\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 "JniOcStack.h"
+
+#ifndef _Included_org_iotivity_base_OcResource_OnPostListener
+#define _Included_org_iotivity_base_OcResource_OnPostListener
+
+using namespace OC;
+
+class JniOcResource;
+
+class JniOnPostListener
+{
+public:
+    JniOnPostListener(JNIEnv *env, jobject jListener, JniOcResource* owner);
+    ~JniOnPostListener();
+
+    void onPostCallback(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode);
+
+private:
+    jweak m_jwListener;
+    JniOcResource* m_ownerResource;
+    void checkExAndRemoveListener(JNIEnv *env);
+};
+
 #endif
\ No newline at end of file
index 7c99445..27fad2f 100644 (file)
-/*\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 "JniOnPresenceListener.h"\r
-#include "JniUtils.h"\r
-\r
-JniOnPresenceListener::JniOnPresenceListener(JNIEnv *env, jobject jListener,\r
-    RemoveListenerCallback removeListenerCallback)\r
-{\r
-    m_jwListener = env->NewWeakGlobalRef(jListener);\r
-    m_removeListenerCallback = removeListenerCallback;\r
-}\r
-\r
-JniOnPresenceListener::~JniOnPresenceListener()\r
-{\r
-    LOGD("~JniOnPresenceListener");\r
-    if (m_jwListener)\r
-    {\r
-        jint ret;\r
-        JNIEnv *env = GetJNIEnv(ret);\r
-        if (NULL == env) return;\r
-        env->DeleteWeakGlobalRef(m_jwListener);\r
-        m_jwListener = nullptr;\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-    }\r
-}\r
-\r
-void JniOnPresenceListener::onPresenceCallback(OCStackResult result, const unsigned int nonce,\r
-    const std::string& hostAddress)\r
-{\r
-    LOGI("JniOnPresenceListener::onPresenceCallback");\r
-    if (!m_jwListener) return;\r
-\r
-    jint ret;\r
-    JNIEnv *env = GetJNIEnv(ret);\r
-    if (NULL == env) return;\r
-\r
-    if (OC_STACK_OK != result && OC_STACK_PRESENCE_STOPPED != result &&\r
-        OC_STACK_PRESENCE_TIMEOUT != result &&  OC_STACK_PRESENCE_DO_NOT_HANDLE != result)\r
-    {\r
-        ThrowOcException(result, "onPresenceCallback: stack failure");\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-\r
-    std::string enumField = JniUtils::stackResultToStr(result);\r
-    if (enumField.empty())\r
-    {\r
-        ThrowOcException(JNI_INVALID_VALUE, "Unexpected OCStackResult value");\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-\r
-    jobject jPresenceStatus = env->CallStaticObjectMethod(g_cls_OcPresenceStatus,\r
-        g_mid_OcPresenceStatus_get, env->NewStringUTF(enumField.c_str()));\r
-    if (!jPresenceStatus)\r
-    {\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-\r
-    jobject jListener = env->NewLocalRef(m_jwListener);\r
-    if (!jListener)\r
-    {\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-\r
-    jclass clsL = env->GetObjectClass(jListener);\r
-    if (!clsL)\r
-    {\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-    jmethodID midL = env->GetMethodID(clsL, "onPresence",\r
-        "(Lorg/iotivity/base/OcPresenceStatus;ILjava/lang/String;)V");\r
-    if (!midL)\r
-    {\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-\r
-    env->CallVoidMethod(jListener, midL, jPresenceStatus,\r
-        (jint)nonce, env->NewStringUTF(hostAddress.c_str()));\r
-    if (env->ExceptionCheck())\r
-    {\r
-        LOGE("Java exception is thrown");\r
-        checkExAndRemoveListener(env);\r
-    }\r
-    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-}\r
-\r
-void JniOnPresenceListener::checkExAndRemoveListener(JNIEnv* env)\r
-{\r
-    if (env->ExceptionCheck())\r
-    {\r
-        jthrowable ex = env->ExceptionOccurred();\r
-        env->ExceptionClear();\r
-        m_removeListenerCallback(env, m_jwListener);\r
-        env->Throw((jthrowable)ex);\r
-    }\r
-    else\r
-    {\r
-        m_removeListenerCallback(env, m_jwListener);\r
-    }\r
-}\r
-\r
-jweak JniOnPresenceListener::getJWListener()\r
-{\r
-    return this->m_jwListener;\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 "JniOnPresenceListener.h"
+#include "JniUtils.h"
+
+JniOnPresenceListener::JniOnPresenceListener(JNIEnv *env, jobject jListener,
+    RemoveListenerCallback removeListenerCallback)
+{
+    m_jwListener = env->NewWeakGlobalRef(jListener);
+    m_removeListenerCallback = removeListenerCallback;
+}
+
+JniOnPresenceListener::~JniOnPresenceListener()
+{
+    LOGD("~JniOnPresenceListener");
+    if (m_jwListener)
+    {
+        jint ret;
+        JNIEnv *env = GetJNIEnv(ret);
+        if (NULL == env) return;
+        env->DeleteWeakGlobalRef(m_jwListener);
+        m_jwListener = nullptr;
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+    }
+}
+
+void JniOnPresenceListener::onPresenceCallback(OCStackResult result, const unsigned int nonce,
+    const std::string& hostAddress)
+{
+    LOGI("JniOnPresenceListener::onPresenceCallback");
+    if (!m_jwListener) return;
+
+    jint ret;
+    JNIEnv *env = GetJNIEnv(ret);
+    if (NULL == env) return;
+
+    if (OC_STACK_OK != result && OC_STACK_PRESENCE_STOPPED != result &&
+        OC_STACK_PRESENCE_TIMEOUT != result &&  OC_STACK_PRESENCE_DO_NOT_HANDLE != result)
+    {
+        ThrowOcException(result, "onPresenceCallback: stack failure");
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    std::string enumField = JniUtils::stackResultToStr(result);
+    if (enumField.empty())
+    {
+        ThrowOcException(JNI_INVALID_VALUE, "Unexpected OCStackResult value");
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    jobject jPresenceStatus = env->CallStaticObjectMethod(g_cls_OcPresenceStatus,
+        g_mid_OcPresenceStatus_get, env->NewStringUTF(enumField.c_str()));
+    if (!jPresenceStatus)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    jobject jListener = env->NewLocalRef(m_jwListener);
+    if (!jListener)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    jclass clsL = env->GetObjectClass(jListener);
+    if (!clsL)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+    jmethodID midL = env->GetMethodID(clsL, "onPresence",
+        "(Lorg/iotivity/base/OcPresenceStatus;ILjava/lang/String;)V");
+    if (!midL)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    env->CallVoidMethod(jListener, midL, jPresenceStatus,
+        (jint)nonce, env->NewStringUTF(hostAddress.c_str()));
+    if (env->ExceptionCheck())
+    {
+        LOGE("Java exception is thrown");
+        checkExAndRemoveListener(env);
+    }
+    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+}
+
+void JniOnPresenceListener::checkExAndRemoveListener(JNIEnv* env)
+{
+    if (env->ExceptionCheck())
+    {
+        jthrowable ex = env->ExceptionOccurred();
+        env->ExceptionClear();
+        m_removeListenerCallback(env, m_jwListener);
+        env->Throw((jthrowable)ex);
+    }
+    else
+    {
+        m_removeListenerCallback(env, m_jwListener);
+    }
+}
+
+jweak JniOnPresenceListener::getJWListener()
+{
+    return this->m_jwListener;
 }
\ No newline at end of file
index 7cea026..957ef85 100644 (file)
@@ -1,43 +1,43 @@
-/*\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 "JniOcStack.h"\r
-#include <mutex>\r
-\r
-#ifndef _Included_org_iotivity_base_OcPlatform_OnPresenceListener\r
-#define _Included_org_iotivity_base_OcPlatform_OnPresenceListener\r
-\r
-class JniOnPresenceListener\r
-{\r
-public:\r
-    JniOnPresenceListener(JNIEnv *env, jobject jListener, RemoveListenerCallback removeListener);\r
-    ~JniOnPresenceListener();\r
-\r
-    void onPresenceCallback(OCStackResult result, const unsigned int nonce, const std::string& hostAddress);\r
-    jweak getJWListener();\r
-\r
-private:\r
-    RemoveListenerCallback m_removeListenerCallback;\r
-    jweak m_jwListener;\r
-    void checkExAndRemoveListener(JNIEnv* env);\r
-};\r
-\r
-#endif\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 "JniOcStack.h"
+#include <mutex>
+
+#ifndef _Included_org_iotivity_base_OcPlatform_OnPresenceListener
+#define _Included_org_iotivity_base_OcPlatform_OnPresenceListener
+
+class JniOnPresenceListener
+{
+public:
+    JniOnPresenceListener(JNIEnv *env, jobject jListener, RemoveListenerCallback removeListener);
+    ~JniOnPresenceListener();
+
+    void onPresenceCallback(OCStackResult result, const unsigned int nonce, const std::string& hostAddress);
+    jweak getJWListener();
+
+private:
+    RemoveListenerCallback m_removeListenerCallback;
+    jweak m_jwListener;
+    void checkExAndRemoveListener(JNIEnv* env);
+};
+
+#endif
index df18490..651db29 100644 (file)
-/*\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 "JniOnPutListener.h"\r
-#include "JniOcResource.h"\r
-#include "JniOcRepresentation.h"\r
-#include "JniUtils.h"\r
-\r
-JniOnPutListener::JniOnPutListener(JNIEnv *env, jobject jListener, JniOcResource* owner)\r
-    : m_ownerResource(owner)\r
-{\r
-    m_jwListener = env->NewWeakGlobalRef(jListener);\r
-}\r
-\r
-JniOnPutListener::~JniOnPutListener()\r
-{\r
-    if (m_jwListener)\r
-    {\r
-        jint ret;\r
-        JNIEnv *env = GetJNIEnv(ret);\r
-        if (NULL == env) return;\r
-\r
-        env->DeleteWeakGlobalRef(m_jwListener);\r
-\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-    }\r
-}\r
-\r
-void JniOnPutListener::onPutCallback(const HeaderOptions& headerOptions,\r
-    const OCRepresentation& ocRepresentation, const int eCode)\r
-{\r
-    jint envRet;\r
-    JNIEnv *env = GetJNIEnv(envRet);\r
-    if (NULL == env) return;\r
-\r
-    jobject jListener = env->NewLocalRef(m_jwListener);\r
-    if (!jListener)\r
-    {\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-    jclass clsL = env->GetObjectClass(jListener);\r
-    if (!clsL)\r
-    {\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-\r
-    if (OC_STACK_OK != eCode)\r
-    {\r
-        jobject ex = GetOcException(eCode, "stack error in onPutCallback");\r
-        if (!ex)\r
-        {\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-        jmethodID midL = env->GetMethodID(clsL, "onPutFailed", "(Ljava/lang/Throwable;)V");\r
-        if (!midL)\r
-        {\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-        env->CallVoidMethod(jListener, midL, ex);\r
-    }\r
-    else\r
-    {\r
-        jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions);\r
-        if (!jHeaderOptionList)\r
-        {\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-\r
-        OCRepresentation * rep = new OCRepresentation(ocRepresentation);\r
-        jlong handle = reinterpret_cast<jlong>(rep);\r
-        jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,\r
-            handle, true);\r
-        if (!jRepresentation)\r
-        {\r
-            delete rep;\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-\r
-        jmethodID midL = env->GetMethodID(clsL, "onPutCompleted",\r
-            "(Ljava/util/List;Lorg/iotivity/base/OcRepresentation;)V");\r
-\r
-        if (!midL)\r
-        {\r
-            checkExAndRemoveListener(env);\r
-            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-            return;\r
-        }\r
-\r
-        env->CallVoidMethod(jListener, midL, jHeaderOptionList, jRepresentation);\r
-        if (env->ExceptionCheck())\r
-        {\r
-            LOGE("Java exception is thrown");\r
-            delete rep;\r
-        }\r
-    }\r
-\r
-    checkExAndRemoveListener(env);\r
-    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();\r
-}\r
-\r
-void JniOnPutListener::checkExAndRemoveListener(JNIEnv* env)\r
-{\r
-    if (env->ExceptionCheck())\r
-    {\r
-        jthrowable ex = env->ExceptionOccurred();\r
-        env->ExceptionClear();\r
-        m_ownerResource->removeOnPutListener(env, m_jwListener);\r
-        env->Throw((jthrowable)ex);\r
-    }\r
-    else\r
-    {\r
-        m_ownerResource->removeOnPutListener(env, m_jwListener);\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 "JniOnPutListener.h"
+#include "JniOcResource.h"
+#include "JniOcRepresentation.h"
+#include "JniUtils.h"
+
+JniOnPutListener::JniOnPutListener(JNIEnv *env, jobject jListener, JniOcResource* owner)
+    : m_ownerResource(owner)
+{
+    m_jwListener = env->NewWeakGlobalRef(jListener);
+}
+
+JniOnPutListener::~JniOnPutListener()
+{
+    if (m_jwListener)
+    {
+        jint ret;
+        JNIEnv *env = GetJNIEnv(ret);
+        if (NULL == env) return;
+
+        env->DeleteWeakGlobalRef(m_jwListener);
+
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+    }
+}
+
+void JniOnPutListener::onPutCallback(const HeaderOptions& headerOptions,
+    const OCRepresentation& ocRepresentation, const int eCode)
+{
+    jint envRet;
+    JNIEnv *env = GetJNIEnv(envRet);
+    if (NULL == env) return;
+
+    jobject jListener = env->NewLocalRef(m_jwListener);
+    if (!jListener)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return;
+    }
+    jclass clsL = env->GetObjectClass(jListener);
+    if (!clsL)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    if (OC_STACK_OK != eCode)
+    {
+        jobject ex = GetOcException(eCode, "stack error in onPutCallback");
+        if (!ex)
+        {
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+        jmethodID midL = env->GetMethodID(clsL, "onPutFailed", "(Ljava/lang/Throwable;)V");
+        if (!midL)
+        {
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+        env->CallVoidMethod(jListener, midL, ex);
+    }
+    else
+    {
+        jobject jHeaderOptionList = JniUtils::convertHeaderOptionsVectorToJavaList(env, headerOptions);
+        if (!jHeaderOptionList)
+        {
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+
+        OCRepresentation * rep = new OCRepresentation(ocRepresentation);
+        jlong handle = reinterpret_cast<jlong>(rep);
+        jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,
+            handle, true);
+        if (!jRepresentation)
+        {
+            delete rep;
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+
+        jmethodID midL = env->GetMethodID(clsL, "onPutCompleted",
+            "(Ljava/util/List;Lorg/iotivity/base/OcRepresentation;)V");
+
+        if (!midL)
+        {
+            checkExAndRemoveListener(env);
+            if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+            return;
+        }
+
+        env->CallVoidMethod(jListener, midL, jHeaderOptionList, jRepresentation);
+        if (env->ExceptionCheck())
+        {
+            LOGE("Java exception is thrown");
+            delete rep;
+        }
+    }
+
+    checkExAndRemoveListener(env);
+    if (JNI_EDETACHED == envRet) g_jvm->DetachCurrentThread();
+}
+
+void JniOnPutListener::checkExAndRemoveListener(JNIEnv* env)
+{
+    if (env->ExceptionCheck())
+    {
+        jthrowable ex = env->ExceptionOccurred();
+        env->ExceptionClear();
+        m_ownerResource->removeOnPutListener(env, m_jwListener);
+        env->Throw((jthrowable)ex);
+    }
+    else
+    {
+        m_ownerResource->removeOnPutListener(env, m_jwListener);
+    }
 }
\ No newline at end of file
index f29e43f..80057e1 100644 (file)
@@ -1,45 +1,45 @@
-/*\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 "JniOcStack.h"\r
-\r
-#ifndef _Included_org_iotivity_base_OcResource_OnPutListener\r
-#define _Included_org_iotivity_base_OcResource_OnPutListener\r
-\r
-using namespace OC;\r
-\r
-class JniOcResource;\r
-\r
-class JniOnPutListener\r
-{\r
-public:\r
-    JniOnPutListener(JNIEnv *env, jobject jListener, JniOcResource* resource);\r
-    ~JniOnPutListener();\r
-\r
-    void onPutCallback(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode);\r
-\r
-private:\r
-    jweak m_jwListener;\r
-    JniOcResource* m_ownerResource;\r
-    void checkExAndRemoveListener(JNIEnv *env);\r
-};\r
-\r
-#endif\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 "JniOcStack.h"
+
+#ifndef _Included_org_iotivity_base_OcResource_OnPutListener
+#define _Included_org_iotivity_base_OcResource_OnPutListener
+
+using namespace OC;
+
+class JniOcResource;
+
+class JniOnPutListener
+{
+public:
+    JniOnPutListener(JNIEnv *env, jobject jListener, JniOcResource* resource);
+    ~JniOnPutListener();
+
+    void onPutCallback(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode);
+
+private:
+    jweak m_jwListener;
+    JniOcResource* m_ownerResource;
+    void checkExAndRemoveListener(JNIEnv *env);
+};
+
+#endif
index 652e0cb..db20c01 100644 (file)
-/*\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 "JniOnResourceFoundListener.h"\r
-#include "JniOcResource.h"\r
-\r
-JniOnResourceFoundListener::JniOnResourceFoundListener(JNIEnv *env, jobject jListener,\r
-    RemoveListenerCallback removeListenerCallback)\r
-{\r
-    m_jwListener = env->NewWeakGlobalRef(jListener);\r
-    m_removeListenerCallback = removeListenerCallback;\r
-}\r
-\r
-JniOnResourceFoundListener::~JniOnResourceFoundListener()\r
-{\r
-    LOGI("~JniOnResourceFoundListener()");\r
-    if (m_jwListener)\r
-    {\r
-        jint ret;\r
-        JNIEnv *env = GetJNIEnv(ret);\r
-        if (NULL == env) return;\r
-        env->DeleteWeakGlobalRef(m_jwListener);\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-    }\r
-}\r
-\r
-void JniOnResourceFoundListener::foundResourceCallback(std::shared_ptr<OC::OCResource> resource)\r
-{\r
-    jint ret;\r
-    JNIEnv *env = GetJNIEnv(ret);\r
-    if (NULL == env) return;\r
-\r
-    jobject jListener = env->NewLocalRef(m_jwListener);\r
-    if (!jListener)\r
-    {\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-\r
-    jobject jResource = env->NewObject(g_cls_OcResource, g_mid_OcResource_ctor);\r
-    if (!jResource)\r
-    {\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-\r
-    JniOcResource *jniOcResource = new JniOcResource(resource);\r
-    SetHandle<JniOcResource>(env, jResource, jniOcResource);\r
-    if (env->ExceptionCheck())\r
-    {\r
-        delete jniOcResource;\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-    jclass clsL = env->GetObjectClass(jListener);\r
-    if (!clsL)\r
-    {\r
-        delete jniOcResource;\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-    jmethodID midL = env->GetMethodID(clsL, "onResourceFound", "(Lorg/iotivity/base/OcResource;)V");\r
-    if (!midL)\r
-    {\r
-        delete jniOcResource;\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-    env->CallVoidMethod(jListener, midL, jResource);\r
-    if (env->ExceptionCheck())\r
-    {\r
-        LOGE("Java exception is thrown");\r
-        delete jniOcResource;\r
-        checkExAndRemoveListener(env);\r
-        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-        return;\r
-    }\r
-\r
-    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();\r
-}\r
-\r
-void JniOnResourceFoundListener::checkExAndRemoveListener(JNIEnv* env)\r
-{\r
-    if (env->ExceptionCheck())\r
-    {\r
-        jthrowable ex = env->ExceptionOccurred();\r
-        env->ExceptionClear();\r
-        m_removeListenerCallback(env, m_jwListener);\r
-        env->Throw((jthrowable)ex);\r
-    }\r
-    else\r
-    {\r
-        m_removeListenerCallback(env, m_jwListener);\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 "JniOnResourceFoundListener.h"
+#include "JniOcResource.h"
+
+JniOnResourceFoundListener::JniOnResourceFoundListener(JNIEnv *env, jobject jListener,
+    RemoveListenerCallback removeListenerCallback)
+{
+    m_jwListener = env->NewWeakGlobalRef(jListener);
+    m_removeListenerCallback = removeListenerCallback;
+}
+
+JniOnResourceFoundListener::~JniOnResourceFoundListener()
+{
+    LOGI("~JniOnResourceFoundListener()");
+    if (m_jwListener)
+    {
+        jint ret;
+        JNIEnv *env = GetJNIEnv(ret);
+        if (NULL == env) return;
+        env->DeleteWeakGlobalRef(m_jwListener);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+    }
+}
+
+void JniOnResourceFoundListener::foundResourceCallback(std::shared_ptr<OC::OCResource> resource)
+{
+    jint ret;
+    JNIEnv *env = GetJNIEnv(ret);
+    if (NULL == env) return;
+
+    jobject jListener = env->NewLocalRef(m_jwListener);
+    if (!jListener)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    jobject jResource = env->NewObject(g_cls_OcResource, g_mid_OcResource_ctor);
+    if (!jResource)
+    {
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    JniOcResource *jniOcResource = new JniOcResource(resource);
+    SetHandle<JniOcResource>(env, jResource, jniOcResource);
+    if (env->ExceptionCheck())
+    {
+        delete jniOcResource;
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+    jclass clsL = env->GetObjectClass(jListener);
+    if (!clsL)
+    {
+        delete jniOcResource;
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+    jmethodID midL = env->GetMethodID(clsL, "onResourceFound", "(Lorg/iotivity/base/OcResource;)V");
+    if (!midL)
+    {
+        delete jniOcResource;
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+    env->CallVoidMethod(jListener, midL, jResource);
+    if (env->ExceptionCheck())
+    {
+        LOGE("Java exception is thrown");
+        delete jniOcResource;
+        checkExAndRemoveListener(env);
+        if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+        return;
+    }
+
+    if (JNI_EDETACHED == ret) g_jvm->DetachCurrentThread();
+}
+
+void JniOnResourceFoundListener::checkExAndRemoveListener(JNIEnv* env)
+{
+    if (env->ExceptionCheck())
+    {
+        jthrowable ex = env->ExceptionOccurred();
+        env->ExceptionClear();
+        m_removeListenerCallback(env, m_jwListener);
+        env->Throw((jthrowable)ex);
+    }
+    else
+    {
+        m_removeListenerCallback(env, m_jwListener);
+    }
 }
\ No newline at end of file
index 2cb9749..909cc4e 100644 (file)
@@ -1,43 +1,43 @@
-/*\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 <jni.h>\r
-#include "JniOcStack.h"\r
-\r
-#ifndef _Included_org_iotivity_base_OcPlatform_OnResourceFoundListener\r
-#define _Included_org_iotivity_base_OcPlatform_OnResourceFoundListener\r
-\r
-class JniOnResourceFoundListener\r
-{\r
-public:\r
-    JniOnResourceFoundListener(JNIEnv *env, jobject jListener,\r
-        RemoveListenerCallback removeListenerCallback);\r
-    ~JniOnResourceFoundListener();\r
-\r
-    void foundResourceCallback(std::shared_ptr<OC::OCResource> resource);\r
-\r
-private:\r
-    RemoveListenerCallback m_removeListenerCallback;\r
-    jweak m_jwListener;\r
-    void checkExAndRemoveListener(JNIEnv* env);\r
-};\r
-\r
-#endif\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 <jni.h>
+#include "JniOcStack.h"
+
+#ifndef _Included_org_iotivity_base_OcPlatform_OnResourceFoundListener
+#define _Included_org_iotivity_base_OcPlatform_OnResourceFoundListener
+
+class JniOnResourceFoundListener
+{
+public:
+    JniOnResourceFoundListener(JNIEnv *env, jobject jListener,
+        RemoveListenerCallback removeListenerCallback);
+    ~JniOnResourceFoundListener();
+
+    void foundResourceCallback(std::shared_ptr<OC::OCResource> resource);
+
+private:
+    RemoveListenerCallback m_removeListenerCallback;
+    jweak m_jwListener;
+    void checkExAndRemoveListener(JNIEnv* env);
+};
+
+#endif
index 6ec806c..38d22a3 100644 (file)
-/*\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
-\r
-#include "JniUtils.h"\r
-#include "JniOcRepresentation.h"\r
-\r
-jobject JniUtils::convertStrVectorToJavaStrList(JNIEnv *env, std::vector<std::string> &vector)\r
-{\r
-    jobject jList = env->NewObject(g_cls_LinkedList, g_mid_LinkedList_ctor);\r
-    if (!jList) return nullptr;\r
-    for (size_t i = 0; i < vector.size(); ++i)\r
-    {\r
-        jstring jStr = env->NewStringUTF(vector[i].c_str());\r
-        if (!jStr) return nullptr;\r
-        env->CallBooleanMethod(jList, g_mid_LinkedList_add_object, jStr);\r
-        if (env->ExceptionCheck()) return nullptr;\r
-        env->DeleteLocalRef(jStr);\r
-    }\r
-    return jList;\r
-}\r
-\r
-void JniUtils::convertJavaStrArrToStrVector(JNIEnv *env, jobjectArray jStrArr, std::vector<std::string> &vector)\r
-{\r
-    if (!jStrArr) return;\r
-\r
-    jsize len = env->GetArrayLength(jStrArr);\r
-    for (jsize i = 0; i < len; ++i)\r
-    {\r
-        jstring jStr = (jstring)env->GetObjectArrayElement(jStrArr, i);\r
-        if (!jStr) return;\r
-        vector.push_back(env->GetStringUTFChars(jStr, NULL));\r
-        if (env->ExceptionCheck()) return;\r
-        env->DeleteLocalRef(jStr);\r
-    }\r
-}\r
-\r
-void JniUtils::convertJavaHeaderOptionsArrToVector(JNIEnv *env, jobjectArray jHeaderOptions,\r
-    OC::HeaderOptions &headerOptions)\r
-{\r
-    if (!jHeaderOptions) return;\r
-\r
-    jsize len = env->GetArrayLength(jHeaderOptions);\r
-    for (jsize i = 0; i < len; ++i)\r
-    {\r
-        jobject header = env->GetObjectArrayElement(jHeaderOptions, i);\r
-        if (!header) nullptr;\r
-        jint jId = env->CallIntMethod(header, g_mid_OcHeaderOption_get_id);\r
-        jstring jData = (jstring)env->CallObjectMethod(header, g_mid_OcHeaderOption_get_data);\r
-        if (jData) return;\r
-\r
-        OC::HeaderOption::OCHeaderOption hopt(\r
-            static_cast<int>(jId),\r
-            env->GetStringUTFChars(jData, NULL));\r
-\r
-        headerOptions.push_back(hopt);\r
-\r
-        if (env->ExceptionCheck()) return;\r
-        env->DeleteLocalRef(header);\r
-        env->DeleteLocalRef(jData);\r
-    }\r
-}\r
-\r
-jobject JniUtils::convertHeaderOptionsVectorToJavaList(JNIEnv *env, const OC::HeaderOptions& headerOptions)\r
-{\r
-    jobject jHeaderOptionList = env->NewObject(g_cls_LinkedList, g_mid_LinkedList_ctor);\r
-    if (!jHeaderOptionList) return nullptr;\r
-\r
-    for (size_t i = 0; i < headerOptions.size(); ++i)\r
-    {\r
-        jobject jHeaderOption = env->NewObject(\r
-            g_cls_OcHeaderOption,\r
-            g_mid_OcHeaderOption_ctor,\r
-            static_cast<jint>(headerOptions[i].getOptionID()),\r
-            env->NewStringUTF(headerOptions[i].getOptionData().c_str())\r
-            );\r
-        if (!jHeaderOption) return nullptr;\r
-\r
-        env->CallBooleanMethod(jHeaderOptionList, g_mid_LinkedList_add_object, jHeaderOption);\r
-        if (env->ExceptionCheck()) return nullptr;\r
-        env->DeleteLocalRef(jHeaderOption);\r
-    }\r
-\r
-    return jHeaderOptionList;\r
-}\r
-\r
-void JniUtils::convertJavaMapToQueryParamsMap(JNIEnv *env, jobject hashMap, OC::QueryParamsMap &map)\r
-{\r
-    if (!hashMap) return;\r
-\r
-    jobject jEntrySet = env->CallObjectMethod(hashMap, g_mid_Map_entrySet);\r
-    jobject jIterator = env->CallObjectMethod(jEntrySet, g_mid_Set_iterator);\r
-    if (!jEntrySet || !jIterator || env->ExceptionCheck()) return;\r
-\r
-    while (env->CallBooleanMethod(jIterator, g_mid_Iterator_hasNext))\r
-    {\r
-        jobject jEntry = env->CallObjectMethod(jIterator, g_mid_Iterator_next);\r
-        if (!jEntry) return;\r
-        jstring jKey = (jstring)env->CallObjectMethod(jEntry, g_mid_MapEntry_getKey);\r
-        if (!jKey) return;\r
-        jstring jValue = (jstring)env->CallObjectMethod(jEntry, g_mid_MapEntry_getValue);\r
-        if (!jValue) return;\r
-\r
-        map.insert(std::make_pair(env->GetStringUTFChars(jKey, NULL),\r
-            env->GetStringUTFChars(jValue, NULL)));\r
-\r
-        if (env->ExceptionCheck()) return;\r
-        env->DeleteLocalRef(jEntry);\r
-        env->DeleteLocalRef(jKey);\r
-        env->DeleteLocalRef(jValue);\r
-    }\r
-}\r
-\r
-jobject JniUtils::convertQueryParamsMapToJavaMap(JNIEnv *env, const OC::QueryParamsMap &map)\r
-{\r
-    jobject hashMap = env->NewObject(g_cls_HashMap, g_mid_HashMap_ctor);\r
-    if (!hashMap) return nullptr;\r
-\r
-    for (auto it = map.begin(); it != map.end(); ++it)\r
-    {\r
-        std::string key = it->first;\r
-        std::string value = it->second;\r
-\r
-        env->CallObjectMethod(hashMap,\r
-            g_mid_HashMap_put,\r
-            env->NewStringUTF(key.c_str()),\r
-            env->NewStringUTF(value.c_str()));\r
-        if (env->ExceptionCheck()) return nullptr;\r
-    }\r
-\r
-    return hashMap;\r
-}\r
-\r
-void JniUtils::convertJavaRepresentationArrToVector(JNIEnv *env,\r
-    jobjectArray jRepresentationArray,\r
-    std::vector<OC::OCRepresentation>& representationVector)\r
-{\r
-    if (!jRepresentationArray) return;\r
-    jsize len = env->GetArrayLength(jRepresentationArray);\r
-\r
-    for (jsize i = 0; i < len; ++i)\r
-    {\r
-        jobject jRep = env->GetObjectArrayElement(jRepresentationArray, i);\r
-        if (!jRep) return;\r
-        OC::OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, jRep);\r
-        representationVector.push_back(*rep);\r
-        if (env->ExceptionCheck()) return;\r
-        env->DeleteLocalRef(jRep);\r
-    }\r
-}\r
-\r
-jobjectArray JniUtils::convertRepresentationVectorToJavaArray(JNIEnv *env,\r
-    const std::vector<OC::OCRepresentation>& representationVector)\r
-{\r
-    jsize len = static_cast<jsize>(representationVector.size());\r
-    jobjectArray repArr = env->NewObjectArray(len, g_cls_OcRepresentation, NULL);\r
-    if (!repArr) return nullptr;\r
-    for (jsize i = 0; i < len; ++i)\r
-    {\r
-        OCRepresentation* rep = new OCRepresentation(representationVector[i]);\r
-        jlong handle = reinterpret_cast<jlong>(rep);\r
-        jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,\r
-            handle, true);\r
-        if (!jRepresentation)\r
-        {\r
-            delete rep;\r
-            return nullptr;\r
-        }\r
-        env->SetObjectArrayElement(repArr, i, jRepresentation);\r
-        if (env->ExceptionCheck()) return nullptr;\r
-        env->DeleteLocalRef(jRepresentation);\r
-    }\r
-\r
-    return repArr;\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 "JniUtils.h"
+#include "JniOcRepresentation.h"
+
+jobject JniUtils::convertStrVectorToJavaStrList(JNIEnv *env, std::vector<std::string> &vector)
+{
+    jobject jList = env->NewObject(g_cls_LinkedList, g_mid_LinkedList_ctor);
+    if (!jList) return nullptr;
+    for (size_t i = 0; i < vector.size(); ++i)
+    {
+        jstring jStr = env->NewStringUTF(vector[i].c_str());
+        if (!jStr) return nullptr;
+        env->CallBooleanMethod(jList, g_mid_LinkedList_add_object, jStr);
+        if (env->ExceptionCheck()) return nullptr;
+        env->DeleteLocalRef(jStr);
+    }
+    return jList;
+}
+
+void JniUtils::convertJavaStrArrToStrVector(JNIEnv *env, jobjectArray jStrArr, std::vector<std::string> &vector)
+{
+    if (!jStrArr) return;
+
+    jsize len = env->GetArrayLength(jStrArr);
+    for (jsize i = 0; i < len; ++i)
+    {
+        jstring jStr = (jstring)env->GetObjectArrayElement(jStrArr, i);
+        if (!jStr) return;
+        vector.push_back(env->GetStringUTFChars(jStr, NULL));
+        if (env->ExceptionCheck()) return;
+        env->DeleteLocalRef(jStr);
+    }
+}
+
+void JniUtils::convertJavaHeaderOptionsArrToVector(JNIEnv *env, jobjectArray jHeaderOptions,
+    OC::HeaderOptions &headerOptions)
+{
+    if (!jHeaderOptions) return;
+
+    jsize len = env->GetArrayLength(jHeaderOptions);
+    for (jsize i = 0; i < len; ++i)
+    {
+        jobject header = env->GetObjectArrayElement(jHeaderOptions, i);
+        if (!header) nullptr;
+        jint jId = env->CallIntMethod(header, g_mid_OcHeaderOption_get_id);
+        jstring jData = (jstring)env->CallObjectMethod(header, g_mid_OcHeaderOption_get_data);
+        if (jData) return;
+
+        OC::HeaderOption::OCHeaderOption hopt(
+            static_cast<int>(jId),
+            env->GetStringUTFChars(jData, NULL));
+
+        headerOptions.push_back(hopt);
+
+        if (env->ExceptionCheck()) return;
+        env->DeleteLocalRef(header);
+        env->DeleteLocalRef(jData);
+    }
+}
+
+jobject JniUtils::convertHeaderOptionsVectorToJavaList(JNIEnv *env, const OC::HeaderOptions& headerOptions)
+{
+    jobject jHeaderOptionList = env->NewObject(g_cls_LinkedList, g_mid_LinkedList_ctor);
+    if (!jHeaderOptionList) return nullptr;
+
+    for (size_t i = 0; i < headerOptions.size(); ++i)
+    {
+        jobject jHeaderOption = env->NewObject(
+            g_cls_OcHeaderOption,
+            g_mid_OcHeaderOption_ctor,
+            static_cast<jint>(headerOptions[i].getOptionID()),
+            env->NewStringUTF(headerOptions[i].getOptionData().c_str())
+            );
+        if (!jHeaderOption) return nullptr;
+
+        env->CallBooleanMethod(jHeaderOptionList, g_mid_LinkedList_add_object, jHeaderOption);
+        if (env->ExceptionCheck()) return nullptr;
+        env->DeleteLocalRef(jHeaderOption);
+    }
+
+    return jHeaderOptionList;
+}
+
+void JniUtils::convertJavaMapToQueryParamsMap(JNIEnv *env, jobject hashMap, OC::QueryParamsMap &map)
+{
+    if (!hashMap) return;
+
+    jobject jEntrySet = env->CallObjectMethod(hashMap, g_mid_Map_entrySet);
+    jobject jIterator = env->CallObjectMethod(jEntrySet, g_mid_Set_iterator);
+    if (!jEntrySet || !jIterator || env->ExceptionCheck()) return;
+
+    while (env->CallBooleanMethod(jIterator, g_mid_Iterator_hasNext))
+    {
+        jobject jEntry = env->CallObjectMethod(jIterator, g_mid_Iterator_next);
+        if (!jEntry) return;
+        jstring jKey = (jstring)env->CallObjectMethod(jEntry, g_mid_MapEntry_getKey);
+        if (!jKey) return;
+        jstring jValue = (jstring)env->CallObjectMethod(jEntry, g_mid_MapEntry_getValue);
+        if (!jValue) return;
+
+        map.insert(std::make_pair(env->GetStringUTFChars(jKey, NULL),
+            env->GetStringUTFChars(jValue, NULL)));
+
+        if (env->ExceptionCheck()) return;
+        env->DeleteLocalRef(jEntry);
+        env->DeleteLocalRef(jKey);
+        env->DeleteLocalRef(jValue);
+    }
+}
+
+jobject JniUtils::convertQueryParamsMapToJavaMap(JNIEnv *env, const OC::QueryParamsMap &map)
+{
+    jobject hashMap = env->NewObject(g_cls_HashMap, g_mid_HashMap_ctor);
+    if (!hashMap) return nullptr;
+
+    for (auto it = map.begin(); it != map.end(); ++it)
+    {
+        std::string key = it->first;
+        std::string value = it->second;
+
+        env->CallObjectMethod(hashMap,
+            g_mid_HashMap_put,
+            env->NewStringUTF(key.c_str()),
+            env->NewStringUTF(value.c_str()));
+        if (env->ExceptionCheck()) return nullptr;
+    }
+
+    return hashMap;
+}
+
+void JniUtils::convertJavaRepresentationArrToVector(JNIEnv *env,
+    jobjectArray jRepresentationArray,
+    std::vector<OC::OCRepresentation>& representationVector)
+{
+    if (!jRepresentationArray) return;
+    jsize len = env->GetArrayLength(jRepresentationArray);
+
+    for (jsize i = 0; i < len; ++i)
+    {
+        jobject jRep = env->GetObjectArrayElement(jRepresentationArray, i);
+        if (!jRep) return;
+        OC::OCRepresentation *rep = JniOcRepresentation::getOCRepresentationPtr(env, jRep);
+        representationVector.push_back(*rep);
+        if (env->ExceptionCheck()) return;
+        env->DeleteLocalRef(jRep);
+    }
+}
+
+jobjectArray JniUtils::convertRepresentationVectorToJavaArray(JNIEnv *env,
+    const std::vector<OC::OCRepresentation>& representationVector)
+{
+    jsize len = static_cast<jsize>(representationVector.size());
+    jobjectArray repArr = env->NewObjectArray(len, g_cls_OcRepresentation, NULL);
+    if (!repArr) return nullptr;
+    for (jsize i = 0; i < len; ++i)
+    {
+        OCRepresentation* rep = new OCRepresentation(representationVector[i]);
+        jlong handle = reinterpret_cast<jlong>(rep);
+        jobject jRepresentation = env->NewObject(g_cls_OcRepresentation, g_mid_OcRepresentation_N_ctor_bool,
+            handle, true);
+        if (!jRepresentation)
+        {
+            delete rep;
+            return nullptr;
+        }
+        env->SetObjectArrayElement(repArr, i, jRepresentation);
+        if (env->ExceptionCheck()) return nullptr;
+        env->DeleteLocalRef(jRepresentation);
+    }
+
+    return repArr;
 }
\ No newline at end of file
index 92f2aa9..0d9d1a7 100644 (file)
-/*\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
-\r
-#include "JniOcStack.h"\r
-#include "OCRepresentation.h"\r
-\r
-class JniUtils\r
-{\r
-public:\r
-    static void convertJavaMapToQueryParamsMap(JNIEnv *env, jobject hashMap,\r
-        OC::QueryParamsMap &map);\r
-    static jobject convertQueryParamsMapToJavaMap(JNIEnv *env, const OC::QueryParamsMap &map);\r
-\r
-    static jobject convertStrVectorToJavaStrList(JNIEnv *env, std::vector<std::string> &vector);\r
-    static void convertJavaStrArrToStrVector(JNIEnv *env, jobjectArray jStrArr,\r
-        std::vector<std::string> &vector);\r
-\r
-    static void convertJavaHeaderOptionsArrToVector(JNIEnv *env, jobjectArray jHeaderOptions,\r
-        OC::HeaderOptions& headerOptions);\r
-    static jobject convertHeaderOptionsVectorToJavaList(JNIEnv *env,\r
-        const OC::HeaderOptions& headerOptions);\r
-\r
-    static void convertJavaRepresentationArrToVector(JNIEnv *env,\r
-        jobjectArray jRepresentationArray,\r
-        std::vector<OC::OCRepresentation>& representationVector);\r
-    static jobjectArray convertRepresentationVectorToJavaArray(JNIEnv *env,\r
-        const std::vector<OC::OCRepresentation>& representationVector);\r
-\r
-    static OC::ServiceType getServiceType(JNIEnv *env, int type)\r
-    {\r
-        switch (type) {\r
-        case 0:\r
-            return OC::ServiceType::InProc;\r
-        case 1:\r
-            return OC::ServiceType::OutOfProc;\r
-        default:\r
-            ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected service type");\r
-            return OC::ServiceType::OutOfProc;\r
-        };\r
-    }\r
-\r
-    static OC::ModeType getModeType(JNIEnv *env, int type)\r
-    {\r
-        switch (type) {\r
-        case 0:\r
-            return OC::ModeType::Server;\r
-        case 1:\r
-            return OC::ModeType::Client;\r
-        case 2:\r
-            return OC::ModeType::Both;\r
-        default:\r
-            ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected mode type");\r
-            return OC::ModeType::Both;\r
-        };\r
-    }\r
-\r
-    static OC::QualityOfService getQOS(JNIEnv *env, int type)\r
-    {\r
-        switch (type) {\r
-        case 0:\r
-            return OC::QualityOfService::LowQos;\r
-        case 1:\r
-            return OC::QualityOfService::MidQos;\r
-        case 2:\r
-            return OC::QualityOfService::HighQos;\r
-        case 3:\r
-            return OC::QualityOfService::NaQos;\r
-        default:\r
-            ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected quality of service");\r
-            return OC::QualityOfService::NaQos;\r
-        };\r
-    }\r
-\r
-    static OC::ObserveType getObserveType(JNIEnv *env, int type)\r
-    {\r
-        switch (type) {\r
-        case 0:\r
-            return OC::ObserveType::Observe;\r
-        case 1:\r
-            return OC::ObserveType::ObserveAll;\r
-        default:\r
-            ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected observe type");\r
-            return OC::ObserveType::ObserveAll;\r
-        };\r
-    }\r
-\r
-    static OCEntityHandlerResult getOCEntityHandlerResult(JNIEnv *env, int type)\r
-    {\r
-        switch (type) {\r
-        case 0:\r
-            return OCEntityHandlerResult::OC_EH_OK;\r
-        case 1:\r
-            return OCEntityHandlerResult::OC_EH_ERROR;\r
-        case 2:\r
-            return OCEntityHandlerResult::OC_EH_RESOURCE_CREATED;\r
-        case 3:\r
-            return OCEntityHandlerResult::OC_EH_RESOURCE_DELETED;\r
-        case 4:\r
-            return OCEntityHandlerResult::OC_EH_SLOW;\r
-        case 5:\r
-            return OCEntityHandlerResult::OC_EH_FORBIDDEN;\r
-        default:\r
-            ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected OCEntityHandlerResult");\r
-            return OCEntityHandlerResult::OC_EH_ERROR;\r
-        };\r
-    }\r
-\r
-    static OCConnectivityType getConnectivityType(JNIEnv *env, int type)\r
-    {\r
-        switch (type) {\r
-        case 0:\r
-            return OCConnectivityType::CT_DEFAULT;\r
-        case 1:\r
-            return OCConnectivityType::CT_ADAPTER_IP;\r
-        case 2:\r
-            return OCConnectivityType::CT_ADAPTER_RFCOMM_BTEDR;\r
-        case 3:\r
-            return OCConnectivityType::CT_ADAPTER_GATT_BTLE;\r
-        default:\r
-            ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected connectivity type");\r
-            return OCConnectivityType::CT_DEFAULT;\r
-        };\r
-    }\r
-\r
-    static std::string stackResultToStr(const int result)\r
-    {\r
-        switch (result)\r
-        {\r
-        case OC_STACK_OK:\r
-            return "OK";\r
-        case OC_STACK_RESOURCE_CREATED:\r
-            return "RESOURCE_CREATED";\r
-        case OC_STACK_RESOURCE_DELETED:\r
-            return "RESOURCE_DELETED";\r
-        case OC_STACK_CONTINUE:\r
-            return "CONTINUE";\r
-            /* Success status code - END HERE */\r
-            /* Error status code - START HERE */\r
-        case OC_STACK_INVALID_URI:\r
-            return "INVALID_URI";\r
-        case OC_STACK_INVALID_QUERY:\r
-            return "INVALID_QUERY";\r
-        case OC_STACK_INVALID_IP:\r
-            return "INVALID_IP";\r
-\r
-        case OC_STACK_INVALID_PORT:\r
-            return "INVALID_PORT";\r
-        case OC_STACK_INVALID_CALLBACK:\r
-            return "INVALID_CALLBACK";\r
-        case OC_STACK_INVALID_METHOD:\r
-            return "INVALID_METHOD";\r
-        case OC_STACK_INVALID_PARAM:\r
-            return "INVALID_PARAM";\r
-        case OC_STACK_INVALID_OBSERVE_PARAM:\r
-            return "INVALID_OBSERVE_PARAM";\r
-        case OC_STACK_NO_MEMORY:\r
-            return "NO_MEMORY";\r
-        case OC_STACK_COMM_ERROR:\r
-            return "COMM_ERROR";\r
-        case OC_STACK_NOTIMPL:\r
-            return "NOTIMPL";\r
-        case OC_STACK_NO_RESOURCE:\r
-            return "NO_RESOURCE";\r
-        case  OC_STACK_RESOURCE_ERROR:\r
-            return "RESOURCE_ERROR";\r
-        case OC_STACK_SLOW_RESOURCE:\r
-            return "SLOW_RESOURCE";\r
-            //case OC_STACK_DUPLICATE_REQUEST:\r
-            //    return "DUPLICATE_REQUEST";\r
-        case OC_STACK_NO_OBSERVERS:\r
-            return "NO_OBSERVERS";\r
-        case OC_STACK_OBSERVER_NOT_FOUND:\r
-            return "OBSERVER_NOT_FOUND";\r
-        case OC_STACK_VIRTUAL_DO_NOT_HANDLE:\r
-            return "VIRTUAL_DO_NOT_HANDLE";\r
-        case OC_STACK_INVALID_OPTION:\r
-            return "INVALID_OPTION";\r
-        case OC_STACK_MALFORMED_RESPONSE:\r
-            return "MALFORMED_RESPONSE";\r
-        case OC_STACK_PERSISTENT_BUFFER_REQUIRED:\r
-            return "PERSISTENT_BUFFER_REQUIRED";\r
-        case OC_STACK_INVALID_REQUEST_HANDLE:\r
-            return "INVALID_REQUEST_HANDLE";\r
-        case OC_STACK_INVALID_DEVICE_INFO:\r
-            return "INVALID_DEVICE_INFO";\r
-            //case OC_STACK_INVALID_JSON:\r
-            //    return "INVALID_JSON";\r
-\r
-        case OC_STACK_PRESENCE_STOPPED:\r
-            return "PRESENCE_STOPPED";\r
-        case OC_STACK_PRESENCE_TIMEOUT:\r
-            return "PRESENCE_TIMEOUT";\r
-        case OC_STACK_PRESENCE_DO_NOT_HANDLE:\r
-            return "PRESENCE_DO_NOT_HANDLE";\r
-\r
-        case OC_STACK_ERROR:\r
-            return "ERROR";\r
-\r
-        case JNI_EXCEPTION:\r
-            return "JNI_EXCEPTION";\r
-        case JNI_NO_NATIVE_POINTER:\r
-            return "JNI_NO_NATIVE_POINTER";\r
-        case JNI_INVALID_VALUE:\r
-            return "JNI_INVALID_VALUE";\r
-        default:\r
-            return "";\r
-        }\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 "JniOcStack.h"
+#include "OCRepresentation.h"
+
+class JniUtils
+{
+public:
+    static void convertJavaMapToQueryParamsMap(JNIEnv *env, jobject hashMap,
+        OC::QueryParamsMap &map);
+    static jobject convertQueryParamsMapToJavaMap(JNIEnv *env, const OC::QueryParamsMap &map);
+
+    static jobject convertStrVectorToJavaStrList(JNIEnv *env, std::vector<std::string> &vector);
+    static void convertJavaStrArrToStrVector(JNIEnv *env, jobjectArray jStrArr,
+        std::vector<std::string> &vector);
+
+    static void convertJavaHeaderOptionsArrToVector(JNIEnv *env, jobjectArray jHeaderOptions,
+        OC::HeaderOptions& headerOptions);
+    static jobject convertHeaderOptionsVectorToJavaList(JNIEnv *env,
+        const OC::HeaderOptions& headerOptions);
+
+    static void convertJavaRepresentationArrToVector(JNIEnv *env,
+        jobjectArray jRepresentationArray,
+        std::vector<OC::OCRepresentation>& representationVector);
+    static jobjectArray convertRepresentationVectorToJavaArray(JNIEnv *env,
+        const std::vector<OC::OCRepresentation>& representationVector);
+
+    static OC::ServiceType getServiceType(JNIEnv *env, int type)
+    {
+        switch (type) {
+        case 0:
+            return OC::ServiceType::InProc;
+        case 1:
+            return OC::ServiceType::OutOfProc;
+        default:
+            ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected service type");
+            return OC::ServiceType::OutOfProc;
+        };
+    }
+
+    static OC::ModeType getModeType(JNIEnv *env, int type)
+    {
+        switch (type) {
+        case 0:
+            return OC::ModeType::Server;
+        case 1:
+            return OC::ModeType::Client;
+        case 2:
+            return OC::ModeType::Both;
+        default:
+            ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected mode type");
+            return OC::ModeType::Both;
+        };
+    }
+
+    static OC::QualityOfService getQOS(JNIEnv *env, int type)
+    {
+        switch (type) {
+        case 0:
+            return OC::QualityOfService::LowQos;
+        case 1:
+            return OC::QualityOfService::MidQos;
+        case 2:
+            return OC::QualityOfService::HighQos;
+        case 3:
+            return OC::QualityOfService::NaQos;
+        default:
+            ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected quality of service");
+            return OC::QualityOfService::NaQos;
+        };
+    }
+
+    static OC::ObserveType getObserveType(JNIEnv *env, int type)
+    {
+        switch (type) {
+        case 0:
+            return OC::ObserveType::Observe;
+        case 1:
+            return OC::ObserveType::ObserveAll;
+        default:
+            ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected observe type");
+            return OC::ObserveType::ObserveAll;
+        };
+    }
+
+    static OCEntityHandlerResult getOCEntityHandlerResult(JNIEnv *env, int type)
+    {
+        switch (type) {
+        case 0:
+            return OCEntityHandlerResult::OC_EH_OK;
+        case 1:
+            return OCEntityHandlerResult::OC_EH_ERROR;
+        case 2:
+            return OCEntityHandlerResult::OC_EH_RESOURCE_CREATED;
+        case 3:
+            return OCEntityHandlerResult::OC_EH_RESOURCE_DELETED;
+        case 4:
+            return OCEntityHandlerResult::OC_EH_SLOW;
+        case 5:
+            return OCEntityHandlerResult::OC_EH_FORBIDDEN;
+        default:
+            ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected OCEntityHandlerResult");
+            return OCEntityHandlerResult::OC_EH_ERROR;
+        };
+    }
+
+    static OCConnectivityType getConnectivityType(JNIEnv *env, int type)
+    {
+        switch (type) {
+        case 0:
+            return OCConnectivityType::CT_DEFAULT;
+        case 1:
+            return OCConnectivityType::CT_ADAPTER_IP;
+        case 2:
+            return OCConnectivityType::CT_ADAPTER_RFCOMM_BTEDR;
+        case 3:
+            return OCConnectivityType::CT_ADAPTER_GATT_BTLE;
+        default:
+            ThrowOcException(OC_STACK_INVALID_PARAM, "Unexpected connectivity type");
+            return OCConnectivityType::CT_DEFAULT;
+        };
+    }
+
+    static std::string stackResultToStr(const int result)
+    {
+        switch (result)
+        {
+        case OC_STACK_OK:
+            return "OK";
+        case OC_STACK_RESOURCE_CREATED:
+            return "RESOURCE_CREATED";
+        case OC_STACK_RESOURCE_DELETED:
+            return "RESOURCE_DELETED";
+        case OC_STACK_CONTINUE:
+            return "CONTINUE";
+            /* Success status code - END HERE */
+            /* Error status code - START HERE */
+        case OC_STACK_INVALID_URI:
+            return "INVALID_URI";
+        case OC_STACK_INVALID_QUERY:
+            return "INVALID_QUERY";
+        case OC_STACK_INVALID_IP:
+            return "INVALID_IP";
+
+        case OC_STACK_INVALID_PORT:
+            return "INVALID_PORT";
+        case OC_STACK_INVALID_CALLBACK:
+            return "INVALID_CALLBACK";
+        case OC_STACK_INVALID_METHOD:
+            return "INVALID_METHOD";
+        case OC_STACK_INVALID_PARAM:
+            return "INVALID_PARAM";
+        case OC_STACK_INVALID_OBSERVE_PARAM:
+            return "INVALID_OBSERVE_PARAM";
+        case OC_STACK_NO_MEMORY:
+            return "NO_MEMORY";
+        case OC_STACK_COMM_ERROR:
+            return "COMM_ERROR";
+        case OC_STACK_NOTIMPL:
+            return "NOTIMPL";
+        case OC_STACK_NO_RESOURCE:
+            return "NO_RESOURCE";
+        case  OC_STACK_RESOURCE_ERROR:
+            return "RESOURCE_ERROR";
+        case OC_STACK_SLOW_RESOURCE:
+            return "SLOW_RESOURCE";
+            //case OC_STACK_DUPLICATE_REQUEST:
+            //    return "DUPLICATE_REQUEST";
+        case OC_STACK_NO_OBSERVERS:
+            return "NO_OBSERVERS";
+        case OC_STACK_OBSERVER_NOT_FOUND:
+            return "OBSERVER_NOT_FOUND";
+        case OC_STACK_VIRTUAL_DO_NOT_HANDLE:
+            return "VIRTUAL_DO_NOT_HANDLE";
+        case OC_STACK_INVALID_OPTION:
+            return "INVALID_OPTION";
+        case OC_STACK_MALFORMED_RESPONSE:
+            return "MALFORMED_RESPONSE";
+        case OC_STACK_PERSISTENT_BUFFER_REQUIRED:
+            return "PERSISTENT_BUFFER_REQUIRED";
+        case OC_STACK_INVALID_REQUEST_HANDLE:
+            return "INVALID_REQUEST_HANDLE";
+        case OC_STACK_INVALID_DEVICE_INFO:
+            return "INVALID_DEVICE_INFO";
+            //case OC_STACK_INVALID_JSON:
+            //    return "INVALID_JSON";
+
+        case OC_STACK_PRESENCE_STOPPED:
+            return "PRESENCE_STOPPED";
+        case OC_STACK_PRESENCE_TIMEOUT:
+            return "PRESENCE_TIMEOUT";
+        case OC_STACK_PRESENCE_DO_NOT_HANDLE:
+            return "PRESENCE_DO_NOT_HANDLE";
+
+        case OC_STACK_ERROR:
+            return "ERROR";
+
+        case JNI_EXCEPTION:
+            return "JNI_EXCEPTION";
+        case JNI_NO_NATIVE_POINTER:
+            return "JNI_NO_NATIVE_POINTER";
+        case JNI_INVALID_VALUE:
+            return "JNI_INVALID_VALUE";
+        default:
+            return "";
+        }
+    }
+};
old mode 100755 (executable)
new mode 100644 (file)
index 183e674..61bc68e
@@ -1,35 +1,35 @@
-<!--\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
-\r
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"\r
-    package="org.iotivity.base">\r
-    <uses-permission android:name="android.permission.BLUETOOTH" />\r
-    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />\r
-    <uses-permission android:name="android.permission.INTERNET" />\r
-    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />\r
-    <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />\r
-    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />\r
-    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />\r
-    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />\r
-\r
-    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21" />\r
-</manifest>\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.
+  ~ //
+  ~ //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+  -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="org.iotivity.base">
+    <uses-permission android:name="android.permission.BLUETOOTH" />
+    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+
+    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21" />
+</manifest>
index 0834201..27191df 100644 (file)
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-import android.test.InstrumentationTestCase;\r
-\r
-import java.security.InvalidParameterException;\r
-import java.util.Arrays;\r
-import java.util.LinkedList;\r
-import java.util.List;\r
-\r
-public class OcRepresentationTest extends InstrumentationTestCase {\r
-\r
-    private static final String TAG = "OcRepresentationTest";\r
-\r
-    @Override\r
-    protected void setUp() throws Exception {\r
-        super.setUp();\r
-    }\r
-\r
-    public void testChildrenManagement() throws OcException {\r
-        OcRepresentation representation = new OcRepresentation();\r
-\r
-        List<OcRepresentation> emptyList = representation.getChildren();\r
-        assertTrue(emptyList.isEmpty());\r
-\r
-        OcRepresentation child1 = new OcRepresentation();\r
-        OcRepresentation child2 = new OcRepresentation();\r
-        String key = "key";\r
-        int value = 75;\r
-\r
-        child1.setValue(key, value);\r
-        child2.setValue(key, value);\r
-        representation.addChild(child1);\r
-        representation.addChild(child2);\r
-        List<OcRepresentation> twoChildren = representation.getChildren();\r
-        assertEquals(2, twoChildren.size());\r
-        for (OcRepresentation rep : twoChildren) {\r
-            assertEquals(value, rep.getValue(key));\r
-        }\r
-\r
-        representation.clearChildren();\r
-        emptyList = representation.getChildren();\r
-        assertTrue(emptyList.isEmpty());\r
-    }\r
-\r
-    public void testUriGetSet() {\r
-        OcRepresentation representation = new OcRepresentation();\r
-\r
-        String emptyUri = representation.getUri();\r
-        assertTrue(emptyUri.isEmpty());\r
-\r
-        String expected = "a/resource/uri";\r
-        representation.setUri(expected);\r
-        String actual = representation.getUri();\r
-        assertEquals(expected, actual);\r
-    }\r
-\r
-    public void testJSONRepresentation() throws OcException {\r
-        OcRepresentation representation = new OcRepresentation();\r
-        String key = "key";\r
-        int value = 75;\r
-\r
-        String emptyJson1 = representation.getJSONRepresentation();\r
-        representation.setValue(key, value);\r
-        String intValue1 = representation.getJSONRepresentation();\r
-        representation.remove(key);\r
-        String emptyJson2 = representation.getJSONRepresentation();\r
-        assertEquals(emptyJson1, emptyJson2);\r
-        representation.setValue(key, value);\r
-        String intValue2 = representation.getJSONRepresentation();\r
-        assertEquals(intValue1, intValue2);\r
-    }\r
-\r
-    public void testResourceTypesGetSet() {\r
-        OcRepresentation representation = new OcRepresentation();\r
-\r
-        List<String> emptyResourceTypeList = representation.getResourceTypes();\r
-        assertTrue(emptyResourceTypeList.isEmpty());\r
-\r
-        representation.setResourceTypes(emptyResourceTypeList);\r
-        emptyResourceTypeList = representation.getResourceTypes();\r
-        assertTrue(emptyResourceTypeList.isEmpty());\r
-\r
-        List<String> resourceTypeListExpected = new LinkedList<String>();\r
-        resourceTypeListExpected.add("type1");\r
-        resourceTypeListExpected.add("type2");\r
-        resourceTypeListExpected.add("type3");\r
-\r
-        representation.setResourceTypes(resourceTypeListExpected);\r
-        List<String> resourceTypeListActual = representation.getResourceTypes();\r
-        assertEquals(resourceTypeListExpected.size(), resourceTypeListActual.size());\r
-        for (int i = 0; i < resourceTypeListExpected.size(); i++) {\r
-            assertEquals(resourceTypeListExpected.get(i), resourceTypeListActual.get(i));\r
-        }\r
-\r
-        boolean thrown = false;\r
-        try {\r
-            representation.setResourceTypes(null);\r
-        } catch (InvalidParameterException e) {\r
-            thrown = true;\r
-        }\r
-        assertTrue(thrown);\r
-    }\r
-\r
-    public void testResourceInterfacesGetSet() {\r
-        OcRepresentation representation = new OcRepresentation();\r
-\r
-        List<String> emptyResourceInterfaceList = representation.getResourceInterfaces();\r
-        assertTrue(emptyResourceInterfaceList.isEmpty());\r
-\r
-        representation.setResourceInterfaces(emptyResourceInterfaceList);\r
-        emptyResourceInterfaceList = representation.getResourceInterfaces();\r
-        assertTrue(emptyResourceInterfaceList.isEmpty());\r
-\r
-        List<String> resourceInterfaceListExpected = new LinkedList<String>();\r
-        resourceInterfaceListExpected.add("Interface1");\r
-        resourceInterfaceListExpected.add("Interface2");\r
-        resourceInterfaceListExpected.add("Interface3");\r
-\r
-        representation.setResourceInterfaces(resourceInterfaceListExpected);\r
-        List<String> resourceInterfaceListActual = representation.getResourceInterfaces();\r
-        assertEquals(resourceInterfaceListExpected.size(), resourceInterfaceListActual.size());\r
-        for (int i = 0; i < resourceInterfaceListExpected.size(); i++) {\r
-            assertEquals(resourceInterfaceListExpected.get(i), resourceInterfaceListActual.get(i));\r
-        }\r
-\r
-        boolean thrown = false;\r
-        try {\r
-            representation.setResourceInterfaces(null);\r
-        } catch (InvalidParameterException e) {\r
-            thrown = true;\r
-        }\r
-        assertTrue(thrown);\r
-    }\r
-\r
-    public void testAttributeManagement() {\r
-        OcRepresentation representation = new OcRepresentation();\r
-\r
-        assertTrue(representation.isEmpty());\r
-        assertEquals(0, representation.size());\r
-\r
-        try {\r
-            String integerKey = "integerKey";\r
-            int integerValue = 75;\r
-            representation.setValue(integerKey, integerValue);\r
-            assertFalse(representation.isEmpty());\r
-            assertEquals(1, representation.size());\r
-\r
-            int actualIntValue = representation.getValue(integerKey);\r
-            assertEquals(integerValue, actualIntValue);\r
-\r
-            String stringKey = "stringKey";\r
-            String stringValue = "stringValue";\r
-            representation.setValue(stringKey, stringValue);\r
-            assertEquals(2, representation.size());\r
-\r
-            assertTrue(representation.hasAttribute(integerKey));\r
-            representation.remove(integerKey);\r
-            assertFalse(representation.hasAttribute(integerKey));\r
-            assertEquals(1, representation.size());\r
-\r
-            representation.setValue(integerKey, integerValue);\r
-            assertFalse(representation.isNull(integerKey));\r
-            representation.setNull(integerKey);\r
-            assertTrue(representation.isNull(integerKey));\r
-        } catch (OcException e) {\r
-            assertTrue(false);\r
-        }\r
-\r
-        String nonexistentKey = "nonexistentKey";\r
-        assertFalse(representation.hasAttribute(nonexistentKey));\r
-        representation.setNull(nonexistentKey);\r
-        assertTrue(representation.isNull(nonexistentKey));\r
-\r
-        String nonexistentKey2 = "nonexistentKey2";\r
-        boolean thrown = false;\r
-        try {\r
-            boolean nonexistentValue = representation.getValue(nonexistentKey2);\r
-        } catch (OcException e) {\r
-            thrown = true;\r
-        }\r
-        assertTrue(thrown);\r
-    }\r
-\r
-    public void testAttributeAccessByType() throws OcException {\r
-        OcRepresentation rep = new OcRepresentation();\r
-\r
-        //integer\r
-        String intK = "intK";\r
-        int intV = 4;\r
-        rep.setValue(intK, intV);\r
-        int intVa = rep.getValue(intK);\r
-        assertEquals(intV, intVa);\r
-\r
-        //double\r
-        String doubleK = "doubleK";\r
-        double doubleV = 4.5;\r
-        rep.setValue(doubleK, doubleV);\r
-        double doubleVa = rep.getValue(doubleK);\r
-        assertEquals(doubleV, doubleVa);\r
-\r
-        //boolean\r
-        String booleanK = "booleanK";\r
-        boolean booleanV = true;\r
-        rep.setValue(booleanK, booleanV);\r
-        boolean booleanVa = rep.getValue(booleanK);\r
-        assertEquals(booleanV, booleanVa);\r
-\r
-        //String\r
-        String stringK = "stringK";\r
-        String stringV = "stringV";\r
-        rep.setValue(stringK, stringV);\r
-        String stringVa = rep.getValue(stringK);\r
-        assertEquals(stringV, stringVa);\r
-\r
-        //OcRepresentation\r
-        String repK = "repK";\r
-        OcRepresentation repV = new OcRepresentation();\r
-        repV.setValue(intK, intV);\r
-        rep.setValue(repK, repV);\r
-        OcRepresentation repVa = rep.getValue(repK);\r
-        assertEquals(intV, repVa.getValue(intK));\r
-    }\r
-\r
-    public void testAttributeAccessBySequenceType() throws OcException {\r
-        OcRepresentation rep = new OcRepresentation();\r
-\r
-        //integer\r
-        String intK = "intK";\r
-        int[] intArrV = {1, 2, 3, 4};\r
-        rep.setValue(intK, intArrV);\r
-        int[] intArrVa = rep.getValue(intK);\r
-        assertTrue(Arrays.equals(intArrV, intArrVa));\r
-\r
-        int[] intArrVEmpty = {};\r
-        rep.setValue(intK, intArrVEmpty);\r
-        int[] intArrVEmptyA = rep.getValue(intK);\r
-        assertTrue(Arrays.equals(intArrVEmpty, intArrVEmptyA));\r
-\r
-        //double\r
-        String doubleK = "doubleK";\r
-        double[] doubleArrV = {1.1, 2.2, 3.3, 4.4};\r
-        rep.setValue(doubleK, doubleArrV);\r
-        double[] doubleArrVa = rep.getValue(doubleK);\r
-        assertTrue(Arrays.equals(doubleArrV, doubleArrVa));\r
-\r
-        double[] doubleArrVEmpty = {};\r
-        rep.setValue(doubleK, doubleArrVEmpty);\r
-        double[] doubleArrVEmptyA = rep.getValue(doubleK);\r
-        assertTrue(Arrays.equals(doubleArrVEmpty, doubleArrVEmptyA));\r
-\r
-        //boolean\r
-        String booleanK = "booleanK";\r
-        boolean[] booleanArrV = {true, false, true, false};\r
-        rep.setValue(booleanK, booleanArrV);\r
-        boolean[] booleanArrVa = rep.getValue(booleanK);\r
-        assertTrue(Arrays.equals(booleanArrV, booleanArrVa));\r
-\r
-        boolean[] booleanArrVEmpty = {};\r
-        rep.setValue(booleanK, booleanArrVEmpty);\r
-        boolean[] booleanArrVEmptyA = rep.getValue(booleanK);\r
-        assertTrue(Arrays.equals(booleanArrVEmpty, booleanArrVEmptyA));\r
-\r
-        //String\r
-        String stringK = "stringK";\r
-        String[] stringArrV = {"aaa", "bbb", "ccc", "ddd"};\r
-        rep.setValue(stringK, stringArrV);\r
-        String[] stringArrVa = rep.getValue(stringK);\r
-        assertTrue(Arrays.equals(stringArrV, stringArrVa));\r
-\r
-        String[] stringArrVEmpty = {};\r
-        rep.setValue(stringK, stringArrVEmpty);\r
-        String[] stringArrVEmptyA = rep.getValue(stringK);\r
-        assertTrue(Arrays.equals(stringArrVEmpty, stringArrVEmptyA));\r
-\r
-        //OcRepresentation\r
-        String representationK = "representationK";\r
-        OcRepresentation[] representationArrV = {\r
-                new OcRepresentation(),\r
-                new OcRepresentation(),\r
-                new OcRepresentation(),\r
-                new OcRepresentation()};\r
-        representationArrV[0].setValue(intK, 0);\r
-        representationArrV[1].setValue(intK, 1);\r
-        representationArrV[2].setValue(intK, 2);\r
-        representationArrV[3].setValue(intK, 3);\r
-\r
-        rep.setValue(representationK, representationArrV);\r
-        OcRepresentation[] representationArrVa = rep.getValue(representationK);\r
-\r
-        assertEquals(representationArrV.length, representationArrVa.length);\r
-        for (int i = 0; i < representationArrV.length; ++i) {\r
-            assertEquals(representationArrV[i].getValue(intK),\r
-                    representationArrVa[i].getValue(intK));\r
-        }\r
-\r
-        OcRepresentation[] representationArrVEmpty = {};\r
-        rep.setValue(representationK, representationArrVEmpty);\r
-        OcRepresentation[] representationArrVEmptyA = rep.getValue(representationK);\r
-        assertEquals(representationArrVEmpty.length, representationArrVEmptyA.length);\r
-    }\r
-\r
-    public void testAttributeAccessBy2DType() throws OcException {\r
-        OcRepresentation rep = new OcRepresentation();\r
-        //integer\r
-        String int2DK = "int2DK";\r
-        int[] intArrV1 = {1, 2, 3, 4};\r
-        int[] intArrV2 = {5, 6, 7, 8};\r
-        int[][] int2DArrV = {intArrV1, intArrV2};\r
-        rep.setValue(int2DK, int2DArrV);\r
-        int[][] int2DArrVa = rep.getValue(int2DK);\r
-        for (int i = 0; i < int2DArrV.length; i++) {\r
-            assertTrue(Arrays.equals(int2DArrV[i], int2DArrVa[i]));\r
-        }\r
-        //double\r
-        String double2DK = "double2DK";\r
-        double[] doubleArrV1 = {1.1, 2.2, 3.3, 4.4};\r
-        double[] doubleArrV2 = {5, 6, 7, 8};\r
-        double[][] double2DArrV = {doubleArrV1, doubleArrV2};\r
-        rep.setValue(double2DK, double2DArrV);\r
-        double[][] double2DArrVa = rep.getValue(double2DK);\r
-        for (int i = 0; i < double2DArrV.length; i++) {\r
-            assertTrue(Arrays.equals(double2DArrV[i], double2DArrVa[i]));\r
-        }\r
-        double[][] double2DArrVEmpty = {{}};\r
-        rep.setValue(double2DK, double2DArrVEmpty);\r
-        double[][] double2DArrVEmptyA = rep.getValue(double2DK);\r
-        for (int i = 0; i < double2DArrVEmpty.length; i++) {\r
-            assertTrue(Arrays.equals(double2DArrVEmpty[i], double2DArrVEmptyA[i]));\r
-        }\r
-        //boolean\r
-        String boolean2DK = "boolean2DK";\r
-        boolean[] booleanArrV1 = {true, true, false};\r
-        boolean[] booleanArrV2 = {true, false, false, true};\r
-        boolean[][] boolean2DArrV = {booleanArrV1, booleanArrV2};\r
-        rep.setValue(boolean2DK, boolean2DArrV);\r
-        boolean[][] boolean2DArrVa = rep.getValue(boolean2DK);\r
-        for (int i = 0; i < boolean2DArrV.length; i++) {\r
-            assertTrue(Arrays.equals(boolean2DArrV[i], boolean2DArrVa[i]));\r
-        }\r
-        boolean[][] boolean2DArrVEmpty = {{}};\r
-        rep.setValue(boolean2DK, boolean2DArrVEmpty);\r
-        boolean[][] boolean2DArrVEmptyA = rep.getValue(boolean2DK);\r
-        for (int i = 0; i < boolean2DArrVEmpty.length; i++) {\r
-            assertTrue(Arrays.equals(boolean2DArrVEmpty[i], boolean2DArrVEmptyA[i]));\r
-        }\r
-\r
-        //String\r
-        String string2DK = "string2DK";\r
-        String[] stringArrV1 = {"aaa", "bbb", "ccc"};\r
-        String[] stringArrV2 = {"111", "222", "333", "444"};\r
-        String[][] string2DArrV = {stringArrV1, stringArrV2};\r
-        rep.setValue(string2DK, string2DArrV);\r
-        String[][] string2DArrVa = rep.getValue(string2DK);\r
-        for (int i = 0; i < string2DArrV.length; i++) {\r
-            assertTrue(Arrays.equals(string2DArrV[i], string2DArrVa[i]));\r
-        }\r
-        String[][] string2DArrVEmpty = {{}};\r
-        rep.setValue(string2DK, string2DArrVEmpty);\r
-        String[][] string2DArrVEmptyA = rep.getValue(string2DK);\r
-        for (int i = 0; i < string2DArrVEmpty.length; i++) {\r
-            assertTrue(Arrays.equals(string2DArrVEmpty[i], string2DArrVEmptyA[i]));\r
-        }\r
-\r
-        //OcRepresentation\r
-        String intK = "intK";\r
-        String representation2DK = "representation2DK";\r
-        OcRepresentation[] representation2DArrV1 = {\r
-                new OcRepresentation(),\r
-                new OcRepresentation(),\r
-                new OcRepresentation(),\r
-                new OcRepresentation()};\r
-        representation2DArrV1[0].setValue(intK, 0);\r
-        representation2DArrV1[1].setValue(intK, 1);\r
-        representation2DArrV1[2].setValue(intK, 2);\r
-        representation2DArrV1[3].setValue(intK, 3);\r
-\r
-        OcRepresentation[] representation2DArrV2 = {\r
-                new OcRepresentation(),\r
-                new OcRepresentation(),\r
-                new OcRepresentation(),\r
-                new OcRepresentation()};\r
-        representation2DArrV2[0].setValue(intK, 4);\r
-        representation2DArrV2[1].setValue(intK, 5);\r
-        representation2DArrV2[2].setValue(intK, 6);\r
-        representation2DArrV2[3].setValue(intK, 7);\r
-\r
-        OcRepresentation[][] representation2DArrV = {representation2DArrV1, representation2DArrV2};\r
-        rep.setValue(representation2DK, representation2DArrV);\r
-        OcRepresentation[][] representation2DArrVa = rep.getValue(representation2DK);\r
-        assertEquals(representation2DArrV.length, representation2DArrVa.length);\r
-        for (int i = 0; i < representation2DArrV.length; ++i) {\r
-            OcRepresentation[] repArrV = representation2DArrV[i];\r
-            OcRepresentation[] repArrVa = representation2DArrVa[i];\r
-            assertEquals(repArrV.length, repArrVa.length);\r
-            for (int j = 0; j < representation2DArrV.length; ++j) {\r
-                assertEquals(repArrV[j].getValue(intK),\r
-                        repArrVa[j].getValue(intK));\r
-            }\r
-        }\r
-\r
-        OcRepresentation[][] representation2DArrVEmpty = {{}};\r
-        rep.setValue(representation2DK, representation2DArrVEmpty);\r
-        OcRepresentation[][] representation2DArrVEmptyA = rep.getValue(representation2DK);\r
-        assertEquals(representation2DArrVEmpty.length, representation2DArrVEmptyA.length);\r
-    }\r
-\r
-    public void testAttributeAccessBy3DType() throws OcException {\r
-        OcRepresentation rep = new OcRepresentation();\r
-        //integer\r
-        String int3DK = "int3DK";\r
-        int[] intArrV1 = {0, 1, 2, 3, 4};\r
-        int[] intArrV2 = {5, 6, 7, 8};\r
-        int[][] int2DArrV1 = {intArrV1, intArrV2};\r
-        int[] intArrV3 = {9, 10};\r
-        int[] intArrV4 = {11};\r
-        int[][] int2DArrV2 = {intArrV3, intArrV4};\r
-        int[][][] int3DArrV = {int2DArrV1, int2DArrV2};\r
-        rep.setValue(int3DK, int3DArrV);\r
-        int[][][] int3DArrVa = rep.getValue(int3DK);\r
-        assertEquals(int3DArrV.length, int3DArrVa.length);\r
-        for (int i = 0; i < int3DArrV.length; i++) {\r
-            int[][] int2DT = int3DArrV[i];\r
-            int[][] int2DTa = int3DArrVa[i];\r
-            assertEquals(int2DT.length, int2DTa.length);\r
-            for (int j = 0; j < int2DT.length; j++) {\r
-                assertTrue(Arrays.equals(int2DT[j], int2DTa[j]));\r
-            }\r
-        }\r
-        //double\r
-        String double3DK = "double3DK";\r
-        double[] doubleArrV1 = {0.0, 1.1, 2.2, 3.3, 4.4};\r
-        double[] doubleArrV2 = {5.5, 6.6, 7.7, 8.8};\r
-        double[][] double2DArrV1 = {doubleArrV1, doubleArrV2};\r
-        double[] doubleArrV3 = {9.9, 10.1};\r
-        double[] doubleArrV4 = {11.1};\r
-        double[][] double2DArrV2 = {doubleArrV3, doubleArrV4};\r
-        double[][][] double3DArrV = {double2DArrV1, double2DArrV2};\r
-        rep.setValue(double3DK, double3DArrV);\r
-        double[][][] double3DArrVa = rep.getValue(double3DK);\r
-        assertEquals(double3DArrV.length, double3DArrVa.length);\r
-        for (int i = 0; i < double3DArrV.length; i++) {\r
-            double[][] double2DT = double3DArrV[i];\r
-            double[][] double2DTa = double3DArrVa[i];\r
-            assertEquals(double2DT.length, double2DTa.length);\r
-            for (int j = 0; j < double2DT.length; j++) {\r
-                assertTrue(Arrays.equals(double2DT[j], double2DTa[j]));\r
-            }\r
-        }\r
-        double[][][] double3DArrVEmpty = {};\r
-        rep.setValue(double3DK, double3DArrVEmpty);\r
-        double[][][] double3DArrVEmptyA = rep.getValue(double3DK);\r
-        assertEquals(double3DArrVEmpty.length, double3DArrVEmptyA.length);\r
-        for (int i = 0; i < double3DArrVEmpty.length; i++) {\r
-            double[][] double2DT = double3DArrVEmpty[i];\r
-            double[][] double2DTa = double3DArrVEmptyA[i];\r
-            assertEquals(double2DT.length, double2DTa.length);\r
-            for (int j = 0; j < double2DT.length; j++) {\r
-                assertTrue(Arrays.equals(double2DT[j], double2DTa[j]));\r
-            }\r
-        }\r
-\r
-        //boolean\r
-        String boolean3DK = "boolean3DK";\r
-        boolean[] booleanArrV1 = {true, false, true, true, false};\r
-        boolean[] booleanArrV2 = {false, false, false, true};\r
-        boolean[][] boolean2DArrV1 = {booleanArrV1, booleanArrV2};\r
-        boolean[] booleanArrV3 = {true, true};\r
-        boolean[] booleanArrV4 = {false};\r
-        boolean[][] boolean2DArrV2 = {booleanArrV3, booleanArrV4};\r
-        boolean[][][] boolean3DArrV = {boolean2DArrV1, boolean2DArrV2};\r
-        rep.setValue(boolean3DK, boolean3DArrV);\r
-        boolean[][][] boolean3DArrVa = rep.getValue(boolean3DK);\r
-        assertEquals(boolean3DArrV.length, boolean3DArrVa.length);\r
-        for (int i = 0; i < boolean3DArrV.length; i++) {\r
-            boolean[][] boolean2DT = boolean3DArrV[i];\r
-            boolean[][] boolean2DTa = boolean3DArrVa[i];\r
-            assertEquals(boolean2DT.length, boolean2DTa.length);\r
-            for (int j = 0; j < boolean2DT.length; j++) {\r
-                assertTrue(Arrays.equals(boolean2DT[j], boolean2DTa[j]));\r
-            }\r
-        }\r
-        boolean[][][] boolean3DArrVEmpty = {};\r
-        rep.setValue(boolean3DK, boolean3DArrVEmpty);\r
-        boolean[][][] boolean3DArrVEmptyA = rep.getValue(boolean3DK);\r
-        assertEquals(boolean3DArrVEmpty.length, boolean3DArrVEmptyA.length);\r
-        for (int i = 0; i < boolean3DArrVEmpty.length; i++) {\r
-            boolean[][] boolean2DT = boolean3DArrVEmpty[i];\r
-            boolean[][] boolean2DTa = boolean3DArrVEmptyA[i];\r
-            assertEquals(boolean2DT.length, boolean2DTa.length);\r
-            for (int j = 0; j < boolean2DT.length; j++) {\r
-                assertTrue(Arrays.equals(boolean2DT[j], boolean2DTa[j]));\r
-            }\r
-        }\r
-\r
-        //String\r
-        String string3DK = "string3DK";\r
-        String[] stringArrV1 = {"a", "bb", "ccc", "dddd", "eeee"};\r
-        String[] stringArrV2 = {"f", "gg", "hhh", "ii"};\r
-        String[][] string2DArrV1 = {stringArrV1, stringArrV2};\r
-        String[] stringArrV3 = {"j", "jj"};\r
-        String[] stringArrV4 = {"jjj"};\r
-        String[][] string2DArrV2 = {stringArrV3, stringArrV4};\r
-        String[][][] string3DArrV = {string2DArrV1, string2DArrV2};\r
-        rep.setValue(string3DK, string3DArrV);\r
-        String[][][] string3DArrVa = rep.getValue(string3DK);\r
-        assertEquals(string3DArrV.length, string3DArrVa.length);\r
-        for (int i = 0; i < string3DArrV.length; i++) {\r
-            String[][] string2DT = string3DArrV[i];\r
-            String[][] string2DTa = string3DArrVa[i];\r
-            assertEquals(string2DT.length, string2DTa.length);\r
-            for (int j = 0; j < string2DT.length; j++) {\r
-                assertTrue(Arrays.equals(string2DT[j], string2DTa[j]));\r
-            }\r
-        }\r
-        String[][][] string3DArrVEmpty = {};\r
-        rep.setValue(string3DK, string3DArrVEmpty);\r
-        String[][][] string3DArrVEmptyA = rep.getValue(string3DK);\r
-        assertEquals(string3DArrVEmpty.length, string3DArrVEmptyA.length);\r
-        for (int i = 0; i < string3DArrVEmpty.length; i++) {\r
-            String[][] string2DT = string3DArrVEmpty[i];\r
-            String[][] string2DTa = string3DArrVEmptyA[i];\r
-            assertEquals(string2DT.length, string2DTa.length);\r
-            for (int j = 0; j < string2DT.length; j++) {\r
-                assertTrue(Arrays.equals(string2DT[j], string2DTa[j]));\r
-            }\r
-        }\r
-\r
-        //OcRepresentation\r
-        String intK = "intK";\r
-        String representation3DK = "representation3DK";\r
-        OcRepresentation[] representation2DArrV1 = {\r
-                new OcRepresentation(),\r
-                new OcRepresentation(),\r
-                new OcRepresentation(),\r
-                new OcRepresentation()};\r
-        representation2DArrV1[0].setValue(intK, 0);\r
-        representation2DArrV1[1].setValue(intK, 1);\r
-        representation2DArrV1[2].setValue(intK, 2);\r
-        representation2DArrV1[3].setValue(intK, 3);\r
-\r
-        OcRepresentation[] representation2DArrV2 = {\r
-                new OcRepresentation(),\r
-                new OcRepresentation(),\r
-                new OcRepresentation(),\r
-                new OcRepresentation()};\r
-        representation2DArrV2[0].setValue(intK, 4);\r
-        representation2DArrV2[1].setValue(intK, 5);\r
-        representation2DArrV2[2].setValue(intK, 6);\r
-        representation2DArrV2[3].setValue(intK, 7);\r
-\r
-        OcRepresentation[][] representation2DArrV = {representation2DArrV1, representation2DArrV2};\r
-        OcRepresentation[][][] representation3DArrV = {representation2DArrV, representation2DArrV};\r
-\r
-        rep.setValue(representation3DK, representation3DArrV);\r
-        OcRepresentation[][][] representation3DArrVa = rep.getValue(representation3DK);\r
-        assertEquals(representation3DArrV.length, representation3DArrVa.length);\r
-        for (int i = 0; i < representation3DArrV.length; ++i) {\r
-            OcRepresentation[][] repArr2V = representation3DArrV[i];\r
-            OcRepresentation[][] repArr2Va = representation3DArrVa[i];\r
-            assertEquals(repArr2V.length, repArr2Va.length);\r
-            for (int j = 0; j < repArr2V.length; ++j) {\r
-                OcRepresentation[] repArrV = repArr2V[j];\r
-                OcRepresentation[] repArrVa = repArr2Va[j];\r
-                assertEquals(repArrV.length, repArrVa.length);\r
-                for (int k = 0; k < repArrV.length; ++k) {\r
-                    assertEquals(repArrV[k].getValue(intK), repArrVa[k].getValue(intK));\r
-                }\r
-            }\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+import android.test.InstrumentationTestCase;
+
+import java.security.InvalidParameterException;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+public class OcRepresentationTest extends InstrumentationTestCase {
+
+    private static final String TAG = "OcRepresentationTest";
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    public void testChildrenManagement() throws OcException {
+        OcRepresentation representation = new OcRepresentation();
+
+        List<OcRepresentation> emptyList = representation.getChildren();
+        assertTrue(emptyList.isEmpty());
+
+        OcRepresentation child1 = new OcRepresentation();
+        OcRepresentation child2 = new OcRepresentation();
+        String key = "key";
+        int value = 75;
+
+        child1.setValue(key, value);
+        child2.setValue(key, value);
+        representation.addChild(child1);
+        representation.addChild(child2);
+        List<OcRepresentation> twoChildren = representation.getChildren();
+        assertEquals(2, twoChildren.size());
+        for (OcRepresentation rep : twoChildren) {
+            assertEquals(value, rep.getValue(key));
+        }
+
+        representation.clearChildren();
+        emptyList = representation.getChildren();
+        assertTrue(emptyList.isEmpty());
+    }
+
+    public void testUriGetSet() {
+        OcRepresentation representation = new OcRepresentation();
+
+        String emptyUri = representation.getUri();
+        assertTrue(emptyUri.isEmpty());
+
+        String expected = "a/resource/uri";
+        representation.setUri(expected);
+        String actual = representation.getUri();
+        assertEquals(expected, actual);
+    }
+
+    public void testJSONRepresentation() throws OcException {
+        OcRepresentation representation = new OcRepresentation();
+        String key = "key";
+        int value = 75;
+
+        String emptyJson1 = representation.getJSONRepresentation();
+        representation.setValue(key, value);
+        String intValue1 = representation.getJSONRepresentation();
+        representation.remove(key);
+        String emptyJson2 = representation.getJSONRepresentation();
+        assertEquals(emptyJson1, emptyJson2);
+        representation.setValue(key, value);
+        String intValue2 = representation.getJSONRepresentation();
+        assertEquals(intValue1, intValue2);
+    }
+
+    public void testResourceTypesGetSet() {
+        OcRepresentation representation = new OcRepresentation();
+
+        List<String> emptyResourceTypeList = representation.getResourceTypes();
+        assertTrue(emptyResourceTypeList.isEmpty());
+
+        representation.setResourceTypes(emptyResourceTypeList);
+        emptyResourceTypeList = representation.getResourceTypes();
+        assertTrue(emptyResourceTypeList.isEmpty());
+
+        List<String> resourceTypeListExpected = new LinkedList<String>();
+        resourceTypeListExpected.add("type1");
+        resourceTypeListExpected.add("type2");
+        resourceTypeListExpected.add("type3");
+
+        representation.setResourceTypes(resourceTypeListExpected);
+        List<String> resourceTypeListActual = representation.getResourceTypes();
+        assertEquals(resourceTypeListExpected.size(), resourceTypeListActual.size());
+        for (int i = 0; i < resourceTypeListExpected.size(); i++) {
+            assertEquals(resourceTypeListExpected.get(i), resourceTypeListActual.get(i));
+        }
+
+        boolean thrown = false;
+        try {
+            representation.setResourceTypes(null);
+        } catch (InvalidParameterException e) {
+            thrown = true;
+        }
+        assertTrue(thrown);
+    }
+
+    public void testResourceInterfacesGetSet() {
+        OcRepresentation representation = new OcRepresentation();
+
+        List<String> emptyResourceInterfaceList = representation.getResourceInterfaces();
+        assertTrue(emptyResourceInterfaceList.isEmpty());
+
+        representation.setResourceInterfaces(emptyResourceInterfaceList);
+        emptyResourceInterfaceList = representation.getResourceInterfaces();
+        assertTrue(emptyResourceInterfaceList.isEmpty());
+
+        List<String> resourceInterfaceListExpected = new LinkedList<String>();
+        resourceInterfaceListExpected.add("Interface1");
+        resourceInterfaceListExpected.add("Interface2");
+        resourceInterfaceListExpected.add("Interface3");
+
+        representation.setResourceInterfaces(resourceInterfaceListExpected);
+        List<String> resourceInterfaceListActual = representation.getResourceInterfaces();
+        assertEquals(resourceInterfaceListExpected.size(), resourceInterfaceListActual.size());
+        for (int i = 0; i < resourceInterfaceListExpected.size(); i++) {
+            assertEquals(resourceInterfaceListExpected.get(i), resourceInterfaceListActual.get(i));
+        }
+
+        boolean thrown = false;
+        try {
+            representation.setResourceInterfaces(null);
+        } catch (InvalidParameterException e) {
+            thrown = true;
+        }
+        assertTrue(thrown);
+    }
+
+    public void testAttributeManagement() {
+        OcRepresentation representation = new OcRepresentation();
+
+        assertTrue(representation.isEmpty());
+        assertEquals(0, representation.size());
+
+        try {
+            String integerKey = "integerKey";
+            int integerValue = 75;
+            representation.setValue(integerKey, integerValue);
+            assertFalse(representation.isEmpty());
+            assertEquals(1, representation.size());
+
+            int actualIntValue = representation.getValue(integerKey);
+            assertEquals(integerValue, actualIntValue);
+
+            String stringKey = "stringKey";
+            String stringValue = "stringValue";
+            representation.setValue(stringKey, stringValue);
+            assertEquals(2, representation.size());
+
+            assertTrue(representation.hasAttribute(integerKey));
+            representation.remove(integerKey);
+            assertFalse(representation.hasAttribute(integerKey));
+            assertEquals(1, representation.size());
+
+            representation.setValue(integerKey, integerValue);
+            assertFalse(representation.isNull(integerKey));
+            representation.setNull(integerKey);
+            assertTrue(representation.isNull(integerKey));
+        } catch (OcException e) {
+            assertTrue(false);
+        }
+
+        String nonexistentKey = "nonexistentKey";
+        assertFalse(representation.hasAttribute(nonexistentKey));
+        representation.setNull(nonexistentKey);
+        assertTrue(representation.isNull(nonexistentKey));
+
+        String nonexistentKey2 = "nonexistentKey2";
+        boolean thrown = false;
+        try {
+            boolean nonexistentValue = representation.getValue(nonexistentKey2);
+        } catch (OcException e) {
+            thrown = true;
+        }
+        assertTrue(thrown);
+    }
+
+    public void testAttributeAccessByType() throws OcException {
+        OcRepresentation rep = new OcRepresentation();
+
+        //integer
+        String intK = "intK";
+        int intV = 4;
+        rep.setValue(intK, intV);
+        int intVa = rep.getValue(intK);
+        assertEquals(intV, intVa);
+
+        //double
+        String doubleK = "doubleK";
+        double doubleV = 4.5;
+        rep.setValue(doubleK, doubleV);
+        double doubleVa = rep.getValue(doubleK);
+        assertEquals(doubleV, doubleVa);
+
+        //boolean
+        String booleanK = "booleanK";
+        boolean booleanV = true;
+        rep.setValue(booleanK, booleanV);
+        boolean booleanVa = rep.getValue(booleanK);
+        assertEquals(booleanV, booleanVa);
+
+        //String
+        String stringK = "stringK";
+        String stringV = "stringV";
+        rep.setValue(stringK, stringV);
+        String stringVa = rep.getValue(stringK);
+        assertEquals(stringV, stringVa);
+
+        //OcRepresentation
+        String repK = "repK";
+        OcRepresentation repV = new OcRepresentation();
+        repV.setValue(intK, intV);
+        rep.setValue(repK, repV);
+        OcRepresentation repVa = rep.getValue(repK);
+        assertEquals(intV, repVa.getValue(intK));
+    }
+
+    public void testAttributeAccessBySequenceType() throws OcException {
+        OcRepresentation rep = new OcRepresentation();
+
+        //integer
+        String intK = "intK";
+        int[] intArrV = {1, 2, 3, 4};
+        rep.setValue(intK, intArrV);
+        int[] intArrVa = rep.getValue(intK);
+        assertTrue(Arrays.equals(intArrV, intArrVa));
+
+        int[] intArrVEmpty = {};
+        rep.setValue(intK, intArrVEmpty);
+        int[] intArrVEmptyA = rep.getValue(intK);
+        assertTrue(Arrays.equals(intArrVEmpty, intArrVEmptyA));
+
+        //double
+        String doubleK = "doubleK";
+        double[] doubleArrV = {1.1, 2.2, 3.3, 4.4};
+        rep.setValue(doubleK, doubleArrV);
+        double[] doubleArrVa = rep.getValue(doubleK);
+        assertTrue(Arrays.equals(doubleArrV, doubleArrVa));
+
+        double[] doubleArrVEmpty = {};
+        rep.setValue(doubleK, doubleArrVEmpty);
+        double[] doubleArrVEmptyA = rep.getValue(doubleK);
+        assertTrue(Arrays.equals(doubleArrVEmpty, doubleArrVEmptyA));
+
+        //boolean
+        String booleanK = "booleanK";
+        boolean[] booleanArrV = {true, false, true, false};
+        rep.setValue(booleanK, booleanArrV);
+        boolean[] booleanArrVa = rep.getValue(booleanK);
+        assertTrue(Arrays.equals(booleanArrV, booleanArrVa));
+
+        boolean[] booleanArrVEmpty = {};
+        rep.setValue(booleanK, booleanArrVEmpty);
+        boolean[] booleanArrVEmptyA = rep.getValue(booleanK);
+        assertTrue(Arrays.equals(booleanArrVEmpty, booleanArrVEmptyA));
+
+        //String
+        String stringK = "stringK";
+        String[] stringArrV = {"aaa", "bbb", "ccc", "ddd"};
+        rep.setValue(stringK, stringArrV);
+        String[] stringArrVa = rep.getValue(stringK);
+        assertTrue(Arrays.equals(stringArrV, stringArrVa));
+
+        String[] stringArrVEmpty = {};
+        rep.setValue(stringK, stringArrVEmpty);
+        String[] stringArrVEmptyA = rep.getValue(stringK);
+        assertTrue(Arrays.equals(stringArrVEmpty, stringArrVEmptyA));
+
+        //OcRepresentation
+        String representationK = "representationK";
+        OcRepresentation[] representationArrV = {
+                new OcRepresentation(),
+                new OcRepresentation(),
+                new OcRepresentation(),
+                new OcRepresentation()};
+        representationArrV[0].setValue(intK, 0);
+        representationArrV[1].setValue(intK, 1);
+        representationArrV[2].setValue(intK, 2);
+        representationArrV[3].setValue(intK, 3);
+
+        rep.setValue(representationK, representationArrV);
+        OcRepresentation[] representationArrVa = rep.getValue(representationK);
+
+        assertEquals(representationArrV.length, representationArrVa.length);
+        for (int i = 0; i < representationArrV.length; ++i) {
+            assertEquals(representationArrV[i].getValue(intK),
+                    representationArrVa[i].getValue(intK));
+        }
+
+        OcRepresentation[] representationArrVEmpty = {};
+        rep.setValue(representationK, representationArrVEmpty);
+        OcRepresentation[] representationArrVEmptyA = rep.getValue(representationK);
+        assertEquals(representationArrVEmpty.length, representationArrVEmptyA.length);
+    }
+
+    public void testAttributeAccessBy2DType() throws OcException {
+        OcRepresentation rep = new OcRepresentation();
+        //integer
+        String int2DK = "int2DK";
+        int[] intArrV1 = {1, 2, 3, 4};
+        int[] intArrV2 = {5, 6, 7, 8};
+        int[][] int2DArrV = {intArrV1, intArrV2};
+        rep.setValue(int2DK, int2DArrV);
+        int[][] int2DArrVa = rep.getValue(int2DK);
+        for (int i = 0; i < int2DArrV.length; i++) {
+            assertTrue(Arrays.equals(int2DArrV[i], int2DArrVa[i]));
+        }
+        //double
+        String double2DK = "double2DK";
+        double[] doubleArrV1 = {1.1, 2.2, 3.3, 4.4};
+        double[] doubleArrV2 = {5, 6, 7, 8};
+        double[][] double2DArrV = {doubleArrV1, doubleArrV2};
+        rep.setValue(double2DK, double2DArrV);
+        double[][] double2DArrVa = rep.getValue(double2DK);
+        for (int i = 0; i < double2DArrV.length; i++) {
+            assertTrue(Arrays.equals(double2DArrV[i], double2DArrVa[i]));
+        }
+        double[][] double2DArrVEmpty = {{}};
+        rep.setValue(double2DK, double2DArrVEmpty);
+        double[][] double2DArrVEmptyA = rep.getValue(double2DK);
+        for (int i = 0; i < double2DArrVEmpty.length; i++) {
+            assertTrue(Arrays.equals(double2DArrVEmpty[i], double2DArrVEmptyA[i]));
+        }
+        //boolean
+        String boolean2DK = "boolean2DK";
+        boolean[] booleanArrV1 = {true, true, false};
+        boolean[] booleanArrV2 = {true, false, false, true};
+        boolean[][] boolean2DArrV = {booleanArrV1, booleanArrV2};
+        rep.setValue(boolean2DK, boolean2DArrV);
+        boolean[][] boolean2DArrVa = rep.getValue(boolean2DK);
+        for (int i = 0; i < boolean2DArrV.length; i++) {
+            assertTrue(Arrays.equals(boolean2DArrV[i], boolean2DArrVa[i]));
+        }
+        boolean[][] boolean2DArrVEmpty = {{}};
+        rep.setValue(boolean2DK, boolean2DArrVEmpty);
+        boolean[][] boolean2DArrVEmptyA = rep.getValue(boolean2DK);
+        for (int i = 0; i < boolean2DArrVEmpty.length; i++) {
+            assertTrue(Arrays.equals(boolean2DArrVEmpty[i], boolean2DArrVEmptyA[i]));
+        }
+
+        //String
+        String string2DK = "string2DK";
+        String[] stringArrV1 = {"aaa", "bbb", "ccc"};
+        String[] stringArrV2 = {"111", "222", "333", "444"};
+        String[][] string2DArrV = {stringArrV1, stringArrV2};
+        rep.setValue(string2DK, string2DArrV);
+        String[][] string2DArrVa = rep.getValue(string2DK);
+        for (int i = 0; i < string2DArrV.length; i++) {
+            assertTrue(Arrays.equals(string2DArrV[i], string2DArrVa[i]));
+        }
+        String[][] string2DArrVEmpty = {{}};
+        rep.setValue(string2DK, string2DArrVEmpty);
+        String[][] string2DArrVEmptyA = rep.getValue(string2DK);
+        for (int i = 0; i < string2DArrVEmpty.length; i++) {
+            assertTrue(Arrays.equals(string2DArrVEmpty[i], string2DArrVEmptyA[i]));
+        }
+
+        //OcRepresentation
+        String intK = "intK";
+        String representation2DK = "representation2DK";
+        OcRepresentation[] representation2DArrV1 = {
+                new OcRepresentation(),
+                new OcRepresentation(),
+                new OcRepresentation(),
+                new OcRepresentation()};
+        representation2DArrV1[0].setValue(intK, 0);
+        representation2DArrV1[1].setValue(intK, 1);
+        representation2DArrV1[2].setValue(intK, 2);
+        representation2DArrV1[3].setValue(intK, 3);
+
+        OcRepresentation[] representation2DArrV2 = {
+                new OcRepresentation(),
+                new OcRepresentation(),
+                new OcRepresentation(),
+                new OcRepresentation()};
+        representation2DArrV2[0].setValue(intK, 4);
+        representation2DArrV2[1].setValue(intK, 5);
+        representation2DArrV2[2].setValue(intK, 6);
+        representation2DArrV2[3].setValue(intK, 7);
+
+        OcRepresentation[][] representation2DArrV = {representation2DArrV1, representation2DArrV2};
+        rep.setValue(representation2DK, representation2DArrV);
+        OcRepresentation[][] representation2DArrVa = rep.getValue(representation2DK);
+        assertEquals(representation2DArrV.length, representation2DArrVa.length);
+        for (int i = 0; i < representation2DArrV.length; ++i) {
+            OcRepresentation[] repArrV = representation2DArrV[i];
+            OcRepresentation[] repArrVa = representation2DArrVa[i];
+            assertEquals(repArrV.length, repArrVa.length);
+            for (int j = 0; j < representation2DArrV.length; ++j) {
+                assertEquals(repArrV[j].getValue(intK),
+                        repArrVa[j].getValue(intK));
+            }
+        }
+
+        OcRepresentation[][] representation2DArrVEmpty = {{}};
+        rep.setValue(representation2DK, representation2DArrVEmpty);
+        OcRepresentation[][] representation2DArrVEmptyA = rep.getValue(representation2DK);
+        assertEquals(representation2DArrVEmpty.length, representation2DArrVEmptyA.length);
+    }
+
+    public void testAttributeAccessBy3DType() throws OcException {
+        OcRepresentation rep = new OcRepresentation();
+        //integer
+        String int3DK = "int3DK";
+        int[] intArrV1 = {0, 1, 2, 3, 4};
+        int[] intArrV2 = {5, 6, 7, 8};
+        int[][] int2DArrV1 = {intArrV1, intArrV2};
+        int[] intArrV3 = {9, 10};
+        int[] intArrV4 = {11};
+        int[][] int2DArrV2 = {intArrV3, intArrV4};
+        int[][][] int3DArrV = {int2DArrV1, int2DArrV2};
+        rep.setValue(int3DK, int3DArrV);
+        int[][][] int3DArrVa = rep.getValue(int3DK);
+        assertEquals(int3DArrV.length, int3DArrVa.length);
+        for (int i = 0; i < int3DArrV.length; i++) {
+            int[][] int2DT = int3DArrV[i];
+            int[][] int2DTa = int3DArrVa[i];
+            assertEquals(int2DT.length, int2DTa.length);
+            for (int j = 0; j < int2DT.length; j++) {
+                assertTrue(Arrays.equals(int2DT[j], int2DTa[j]));
+            }
+        }
+        //double
+        String double3DK = "double3DK";
+        double[] doubleArrV1 = {0.0, 1.1, 2.2, 3.3, 4.4};
+        double[] doubleArrV2 = {5.5, 6.6, 7.7, 8.8};
+        double[][] double2DArrV1 = {doubleArrV1, doubleArrV2};
+        double[] doubleArrV3 = {9.9, 10.1};
+        double[] doubleArrV4 = {11.1};
+        double[][] double2DArrV2 = {doubleArrV3, doubleArrV4};
+        double[][][] double3DArrV = {double2DArrV1, double2DArrV2};
+        rep.setValue(double3DK, double3DArrV);
+        double[][][] double3DArrVa = rep.getValue(double3DK);
+        assertEquals(double3DArrV.length, double3DArrVa.length);
+        for (int i = 0; i < double3DArrV.length; i++) {
+            double[][] double2DT = double3DArrV[i];
+            double[][] double2DTa = double3DArrVa[i];
+            assertEquals(double2DT.length, double2DTa.length);
+            for (int j = 0; j < double2DT.length; j++) {
+                assertTrue(Arrays.equals(double2DT[j], double2DTa[j]));
+            }
+        }
+        double[][][] double3DArrVEmpty = {};
+        rep.setValue(double3DK, double3DArrVEmpty);
+        double[][][] double3DArrVEmptyA = rep.getValue(double3DK);
+        assertEquals(double3DArrVEmpty.length, double3DArrVEmptyA.length);
+        for (int i = 0; i < double3DArrVEmpty.length; i++) {
+            double[][] double2DT = double3DArrVEmpty[i];
+            double[][] double2DTa = double3DArrVEmptyA[i];
+            assertEquals(double2DT.length, double2DTa.length);
+            for (int j = 0; j < double2DT.length; j++) {
+                assertTrue(Arrays.equals(double2DT[j], double2DTa[j]));
+            }
+        }
+
+        //boolean
+        String boolean3DK = "boolean3DK";
+        boolean[] booleanArrV1 = {true, false, true, true, false};
+        boolean[] booleanArrV2 = {false, false, false, true};
+        boolean[][] boolean2DArrV1 = {booleanArrV1, booleanArrV2};
+        boolean[] booleanArrV3 = {true, true};
+        boolean[] booleanArrV4 = {false};
+        boolean[][] boolean2DArrV2 = {booleanArrV3, booleanArrV4};
+        boolean[][][] boolean3DArrV = {boolean2DArrV1, boolean2DArrV2};
+        rep.setValue(boolean3DK, boolean3DArrV);
+        boolean[][][] boolean3DArrVa = rep.getValue(boolean3DK);
+        assertEquals(boolean3DArrV.length, boolean3DArrVa.length);
+        for (int i = 0; i < boolean3DArrV.length; i++) {
+            boolean[][] boolean2DT = boolean3DArrV[i];
+            boolean[][] boolean2DTa = boolean3DArrVa[i];
+            assertEquals(boolean2DT.length, boolean2DTa.length);
+            for (int j = 0; j < boolean2DT.length; j++) {
+                assertTrue(Arrays.equals(boolean2DT[j], boolean2DTa[j]));
+            }
+        }
+        boolean[][][] boolean3DArrVEmpty = {};
+        rep.setValue(boolean3DK, boolean3DArrVEmpty);
+        boolean[][][] boolean3DArrVEmptyA = rep.getValue(boolean3DK);
+        assertEquals(boolean3DArrVEmpty.length, boolean3DArrVEmptyA.length);
+        for (int i = 0; i < boolean3DArrVEmpty.length; i++) {
+            boolean[][] boolean2DT = boolean3DArrVEmpty[i];
+            boolean[][] boolean2DTa = boolean3DArrVEmptyA[i];
+            assertEquals(boolean2DT.length, boolean2DTa.length);
+            for (int j = 0; j < boolean2DT.length; j++) {
+                assertTrue(Arrays.equals(boolean2DT[j], boolean2DTa[j]));
+            }
+        }
+
+        //String
+        String string3DK = "string3DK";
+        String[] stringArrV1 = {"a", "bb", "ccc", "dddd", "eeee"};
+        String[] stringArrV2 = {"f", "gg", "hhh", "ii"};
+        String[][] string2DArrV1 = {stringArrV1, stringArrV2};
+        String[] stringArrV3 = {"j", "jj"};
+        String[] stringArrV4 = {"jjj"};
+        String[][] string2DArrV2 = {stringArrV3, stringArrV4};
+        String[][][] string3DArrV = {string2DArrV1, string2DArrV2};
+        rep.setValue(string3DK, string3DArrV);
+        String[][][] string3DArrVa = rep.getValue(string3DK);
+        assertEquals(string3DArrV.length, string3DArrVa.length);
+        for (int i = 0; i < string3DArrV.length; i++) {
+            String[][] string2DT = string3DArrV[i];
+            String[][] string2DTa = string3DArrVa[i];
+            assertEquals(string2DT.length, string2DTa.length);
+            for (int j = 0; j < string2DT.length; j++) {
+                assertTrue(Arrays.equals(string2DT[j], string2DTa[j]));
+            }
+        }
+        String[][][] string3DArrVEmpty = {};
+        rep.setValue(string3DK, string3DArrVEmpty);
+        String[][][] string3DArrVEmptyA = rep.getValue(string3DK);
+        assertEquals(string3DArrVEmpty.length, string3DArrVEmptyA.length);
+        for (int i = 0; i < string3DArrVEmpty.length; i++) {
+            String[][] string2DT = string3DArrVEmpty[i];
+            String[][] string2DTa = string3DArrVEmptyA[i];
+            assertEquals(string2DT.length, string2DTa.length);
+            for (int j = 0; j < string2DT.length; j++) {
+                assertTrue(Arrays.equals(string2DT[j], string2DTa[j]));
+            }
+        }
+
+        //OcRepresentation
+        String intK = "intK";
+        String representation3DK = "representation3DK";
+        OcRepresentation[] representation2DArrV1 = {
+                new OcRepresentation(),
+                new OcRepresentation(),
+                new OcRepresentation(),
+                new OcRepresentation()};
+        representation2DArrV1[0].setValue(intK, 0);
+        representation2DArrV1[1].setValue(intK, 1);
+        representation2DArrV1[2].setValue(intK, 2);
+        representation2DArrV1[3].setValue(intK, 3);
+
+        OcRepresentation[] representation2DArrV2 = {
+                new OcRepresentation(),
+                new OcRepresentation(),
+                new OcRepresentation(),
+                new OcRepresentation()};
+        representation2DArrV2[0].setValue(intK, 4);
+        representation2DArrV2[1].setValue(intK, 5);
+        representation2DArrV2[2].setValue(intK, 6);
+        representation2DArrV2[3].setValue(intK, 7);
+
+        OcRepresentation[][] representation2DArrV = {representation2DArrV1, representation2DArrV2};
+        OcRepresentation[][][] representation3DArrV = {representation2DArrV, representation2DArrV};
+
+        rep.setValue(representation3DK, representation3DArrV);
+        OcRepresentation[][][] representation3DArrVa = rep.getValue(representation3DK);
+        assertEquals(representation3DArrV.length, representation3DArrVa.length);
+        for (int i = 0; i < representation3DArrV.length; ++i) {
+            OcRepresentation[][] repArr2V = representation3DArrV[i];
+            OcRepresentation[][] repArr2Va = representation3DArrVa[i];
+            assertEquals(repArr2V.length, repArr2Va.length);
+            for (int j = 0; j < repArr2V.length; ++j) {
+                OcRepresentation[] repArrV = repArr2V[j];
+                OcRepresentation[] repArrVa = repArr2Va[j];
+                assertEquals(repArrV.length, repArrVa.length);
+                for (int k = 0; k < repArrV.length; ++k) {
+                    assertEquals(repArrV[k].getValue(intK), repArrVa[k].getValue(intK));
+                }
+            }
+        }
+    }
 }
\ No newline at end of file
old mode 100755 (executable)
new mode 100644 (file)
index 183e674..61bc68e
@@ -1,35 +1,35 @@
-<!--\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
-\r
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"\r
-    package="org.iotivity.base">\r
-    <uses-permission android:name="android.permission.BLUETOOTH" />\r
-    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />\r
-    <uses-permission android:name="android.permission.INTERNET" />\r
-    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />\r
-    <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />\r
-    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />\r
-    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />\r
-    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />\r
-\r
-    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21" />\r
-</manifest>\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.
+  ~ //
+  ~ //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+  -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="org.iotivity.base">
+    <uses-permission android:name="android.permission.BLUETOOTH" />
+    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+
+    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21" />
+</manifest>
index d8ed2fb..676919d 100644 (file)
@@ -1,42 +1,42 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-public enum EntityHandlerResult {\r
-    OK(0),\r
-    ERROR(1),\r
-    RESOURCE_CREATED(2),\r
-    RESOURCE_DELETED(3),\r
-    SLOW(4),\r
-    FORBIDDEN(5);\r
-\r
-    private int value;\r
-\r
-    private EntityHandlerResult(int value) {\r
-        this.value = value;\r
-    }\r
-\r
-    public int getValue() {\r
-        return this.value;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+public enum EntityHandlerResult {
+    OK(0),
+    ERROR(1),
+    RESOURCE_CREATED(2),
+    RESOURCE_DELETED(3),
+    SLOW(4),
+    FORBIDDEN(5);
+
+    private int value;
+
+    private EntityHandlerResult(int value) {
+        this.value = value;
+    }
+
+    public int getValue() {
+        return this.value;
+    }
+}
index 81ea7c7..70a69a5 100644 (file)
@@ -1,39 +1,39 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-public enum ModeType {\r
-    SERVER(0),\r
-    CLIENT(1),\r
-    CLIENT_SERVER(2),;\r
-\r
-    private int value;\r
-\r
-    private ModeType(int value) {\r
-        this.value = value;\r
-    }\r
-\r
-    public int getValue() {\r
-        return this.value;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+public enum ModeType {
+    SERVER(0),
+    CLIENT(1),
+    CLIENT_SERVER(2),;
+
+    private int value;
+
+    private ModeType(int value) {
+        this.value = value;
+    }
+
+    public int getValue() {
+        return this.value;
+    }
+}
index 483d4cb..89876e1 100644 (file)
@@ -1,55 +1,55 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-public class ObservationInfo {\r
-\r
-    private ObserveAction mObserveAction;\r
-    private byte mOcObservationId;\r
-\r
-    private ObservationInfo(int observationAction, byte observationId) {\r
-        this.mObserveAction = ObserveAction.get(observationAction);\r
-        this.mOcObservationId = observationId;\r
-    }\r
-\r
-    public ObservationInfo(ObserveAction observeAction, byte observationId) {\r
-        this.mObserveAction = observeAction;\r
-        this.mOcObservationId = observationId;\r
-    }\r
-\r
-    public ObserveAction getObserveAction() {\r
-        return mObserveAction;\r
-    }\r
-\r
-    public void setObserveAction(ObserveAction observeAction) {\r
-        this.mObserveAction = observeAction;\r
-    }\r
-\r
-    public byte getOcObservationId() {\r
-        return mOcObservationId;\r
-    }\r
-\r
-    public void setOcObservationId(byte ocObservationId) {\r
-        this.mOcObservationId = ocObservationId;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+public class ObservationInfo {
+
+    private ObserveAction mObserveAction;
+    private byte mOcObservationId;
+
+    private ObservationInfo(int observationAction, byte observationId) {
+        this.mObserveAction = ObserveAction.get(observationAction);
+        this.mOcObservationId = observationId;
+    }
+
+    public ObservationInfo(ObserveAction observeAction, byte observationId) {
+        this.mObserveAction = observeAction;
+        this.mOcObservationId = observationId;
+    }
+
+    public ObserveAction getObserveAction() {
+        return mObserveAction;
+    }
+
+    public void setObserveAction(ObserveAction observeAction) {
+        this.mObserveAction = observeAction;
+    }
+
+    public byte getOcObservationId() {
+        return mOcObservationId;
+    }
+
+    public void setOcObservationId(byte ocObservationId) {
+        this.mOcObservationId = ocObservationId;
+    }
+}
index 3e7c5ec..085ddf3 100644 (file)
@@ -1,47 +1,47 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-public enum ObserveAction {\r
-    REGISTER(0),\r
-    UNREGISTER(1),;\r
-\r
-    private int value;\r
-\r
-    private ObserveAction(int value) {\r
-        this.value = value;\r
-    }\r
-\r
-    public int getValue() {\r
-        return this.value;\r
-    }\r
-\r
-    public static ObserveAction get(int val) {\r
-        for (ObserveAction observeAction : ObserveAction.values()) {\r
-            if (observeAction.getValue() == val)\r
-                return observeAction;\r
-        }\r
-\r
-        throw new IllegalArgumentException("Unexpected ObserveAction value");\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+public enum ObserveAction {
+    REGISTER(0),
+    UNREGISTER(1),;
+
+    private int value;
+
+    private ObserveAction(int value) {
+        this.value = value;
+    }
+
+    public int getValue() {
+        return this.value;
+    }
+
+    public static ObserveAction get(int val) {
+        for (ObserveAction observeAction : ObserveAction.values()) {
+            if (observeAction.getValue() == val)
+                return observeAction;
+        }
+
+        throw new IllegalArgumentException("Unexpected ObserveAction value");
+    }
+}
index 3432a47..13b5b18 100644 (file)
@@ -1,38 +1,38 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-public enum ObserveType {\r
-    OBSERVE(0),\r
-    OBSERVE_ALL(1),;\r
-\r
-    private int value;\r
-\r
-    private ObserveType(int value) {\r
-        this.value = value;\r
-    }\r
-\r
-    public int getValue() {\r
-        return this.value;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+public enum ObserveType {
+    OBSERVE(0),
+    OBSERVE_ALL(1),;
+
+    private int value;
+
+    private ObserveType(int value) {
+        this.value = value;
+    }
+
+    public int getValue() {
+        return this.value;
+    }
+}
index 99d8c7c..2cb794b 100644 (file)
@@ -1,48 +1,48 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-public class OcDeviceInfo {\r
-\r
-    private String deviceName;\r
-\r
-    public OcDeviceInfo() {\r
-\r
-        deviceName = "";\r
-    }\r
-\r
-    public OcDeviceInfo(String deviceName) {\r
-\r
-        this.deviceName = deviceName;\r
-    }\r
-\r
-    public String getDeviceName() {\r
-\r
-        return deviceName;\r
-    }\r
-\r
-    public void setDeviceName(String deviceName) {\r
-\r
-        this.deviceName = deviceName;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+public class OcDeviceInfo {
+
+    private String deviceName;
+
+    public OcDeviceInfo() {
+
+        deviceName = "";
+    }
+
+    public OcDeviceInfo(String deviceName) {
+
+        this.deviceName = deviceName;
+    }
+
+    public String getDeviceName() {
+
+        return deviceName;
+    }
+
+    public void setDeviceName(String deviceName) {
+
+        this.deviceName = deviceName;
+    }
+}
index f83bf6c..1d56947 100644 (file)
@@ -1,58 +1,58 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-public class OcException extends Exception {\r
-\r
-    private ErrorCode errorCode;\r
-\r
-    public OcException(ErrorCode errorCode, String errMessage) {\r
-        super(errMessage + " " + errorCode.toString());\r
-        this.errorCode = errorCode;\r
-    }\r
-\r
-    private OcException(String error, String errMessage) {\r
-        super(errMessage + " " + error);\r
-        this.errorCode = ErrorCode.get(error);\r
-    }\r
-\r
-    public ErrorCode getErrorCode() {\r
-        return errorCode;\r
-    }\r
-\r
-    private static void addStackTrace(Throwable throwable,\r
-                                      String file,\r
-                                      String functionName,\r
-                                      int line) {\r
-        StackTraceElement[] stack = throwable.getStackTrace();\r
-        StackTraceElement[] newStack = new StackTraceElement[stack.length + 1];\r
-\r
-        System.arraycopy(stack, 0, newStack, 1, stack.length);\r
-        newStack[0] = new StackTraceElement("<native>", functionName, file, line);\r
-        throwable.setStackTrace(newStack);\r
-    }\r
-\r
-    private void setNativeExceptionLocation(String file, String functionName, int line) {\r
-        OcException.addStackTrace(this, file, functionName, line);\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+public class OcException extends Exception {
+
+    private ErrorCode errorCode;
+
+    public OcException(ErrorCode errorCode, String errMessage) {
+        super(errMessage + " " + errorCode.toString());
+        this.errorCode = errorCode;
+    }
+
+    private OcException(String error, String errMessage) {
+        super(errMessage + " " + error);
+        this.errorCode = ErrorCode.get(error);
+    }
+
+    public ErrorCode getErrorCode() {
+        return errorCode;
+    }
+
+    private static void addStackTrace(Throwable throwable,
+                                      String file,
+                                      String functionName,
+                                      int line) {
+        StackTraceElement[] stack = throwable.getStackTrace();
+        StackTraceElement[] newStack = new StackTraceElement[stack.length + 1];
+
+        System.arraycopy(stack, 0, newStack, 1, stack.length);
+        newStack[0] = new StackTraceElement("<native>", functionName, file, line);
+        throwable.setStackTrace(newStack);
+    }
+
+    private void setNativeExceptionLocation(String file, String functionName, int line) {
+        OcException.addStackTrace(this, file, functionName, line);
+    }
+}
index 984bc27..d672bf0 100644 (file)
@@ -1,70 +1,70 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-import java.security.InvalidParameterException;\r
-\r
-/**\r
- * OcHeaderOption class allows to create instances which comprises optionId\r
- * and optionData as members. These are used in setting Header options.\r
- * After creating instances of OcHeaderOptions, use setHeaderOptions API\r
- * (in OcResource) to set header Options.\r
- * NOTE: optionId  is an integer value which MUST be within\r
- * range of 2048 to 3000 inclusive of lower and upper bound.\r
- * HeaderOption instance creation fails if above condition is not satisfied.\r
- */\r
-public class OcHeaderOption {\r
-\r
-    public static final int MIN_HEADER_OPTION_ID = 2048;\r
-    public static final int MAX_HEADER_OPTION_ID = 3000;\r
-\r
-    private int mOptionId;\r
-    private String mOptionData;\r
-\r
-    public OcHeaderOption(int optionId, String optionData) {\r
-        if (!(optionId >= MIN_HEADER_OPTION_ID && optionId <= MAX_HEADER_OPTION_ID)) {\r
-            throw new InvalidParameterException("Option ID range is invalid");\r
-        }\r
-\r
-        this.mOptionId = optionId;\r
-        this.mOptionData = optionData;\r
-    }\r
-\r
-    /**\r
-     * API to get Option ID\r
-     *\r
-     * @return option ID\r
-     */\r
-    public int getOptionId() {\r
-        return mOptionId;\r
-    }\r
-\r
-    /**\r
-     * API to get Option data\r
-     *\r
-     * @return option data\r
-     */\r
-    public String getOptionData() {\r
-        return mOptionData;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+import java.security.InvalidParameterException;
+
+/**
+ * OcHeaderOption class allows to create instances which comprises optionId
+ * and optionData as members. These are used in setting Header options.
+ * After creating instances of OcHeaderOptions, use setHeaderOptions API
+ * (in OcResource) to set header Options.
+ * NOTE: optionId  is an integer value which MUST be within
+ * range of 2048 to 3000 inclusive of lower and upper bound.
+ * HeaderOption instance creation fails if above condition is not satisfied.
+ */
+public class OcHeaderOption {
+
+    public static final int MIN_HEADER_OPTION_ID = 2048;
+    public static final int MAX_HEADER_OPTION_ID = 3000;
+
+    private int mOptionId;
+    private String mOptionData;
+
+    public OcHeaderOption(int optionId, String optionData) {
+        if (!(optionId >= MIN_HEADER_OPTION_ID && optionId <= MAX_HEADER_OPTION_ID)) {
+            throw new InvalidParameterException("Option ID range is invalid");
+        }
+
+        this.mOptionId = optionId;
+        this.mOptionData = optionData;
+    }
+
+    /**
+     * API to get Option ID
+     *
+     * @return option ID
+     */
+    public int getOptionId() {
+        return mOptionId;
+    }
+
+    /**
+     * API to get Option data
+     *
+     * @return option data
+     */
+    public String getOptionData() {
+        return mOptionData;
+    }
+}
index 46dedf2..9c54d7d 100644 (file)
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-import org.iotivity.ca.CaInterface;\r
-\r
-import java.util.EnumSet;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-\r
-/**\r
- * Contains the main entrance/functionality of the product. To set a custom configuration, the\r
- * implementer must make a call to OcPlatform.Configure before the first usage of a function in this\r
- * class.\r
- */\r
-public final class OcPlatform {\r
-\r
-    static {\r
-        System.loadLibrary("oc_logger");\r
-        System.loadLibrary("octbstack");\r
-        System.loadLibrary("connectivity_abstraction");\r
-        System.loadLibrary("oc");\r
-        System.loadLibrary("ocstack-jni");\r
-    }\r
-\r
-    /**\r
-     * Default interface\r
-     */\r
-    public static final String DEFAULT_INTERFACE = "oic.if.baseline";\r
-\r
-    /**\r
-     * Used in discovering (GET) links to other resources of a collection\r
-     */\r
-    public static final String LINK_INTERFACE = "oic.if.ll";\r
-\r
-    /**\r
-     * Used in GET, PUT, POST, DELETE methods on links to other resources of a collection\r
-     */\r
-    public static final String BATCH_INTERFACE = "oic.if.b";\r
-\r
-    /**\r
-     * Used in GET, PUT, POST methods on links to other remote resources of a group\r
-     */\r
-    public static final String GROUP_INTERFACE = "oic.mi.grp";\r
-\r
-    public static final String WELL_KNOWN_QUERY = "224.0.1.187:5683/oic/res";\r
-    public static final String MULTICAST_PREFIX = "224.0.1.187:5683";\r
-    public static final String MULTICAST_IP = "224.0.1.187";\r
-    public static final int MULTICAST_PORT = 5683;\r
-    public static final int DEFAULT_PRESENCE_TTL = 60;\r
-    public static final String DEVICE_URI = "/oic/d";\r
-    public static final String PRESENCE_URI = "/oic/ad";\r
-\r
-    private static volatile boolean sIsPlatformInitialized = false;\r
-\r
-    private OcPlatform() {\r
-    }\r
-\r
-    /**\r
-     * API for setting the configuration of the OcPlatform.\r
-     * Note: Any calls made to this AFTER the first call to OcPlatform.Configure will have no affect\r
-     *\r
-     * @param platformConfig platform configuration\r
-     */\r
-    public synchronized static void Configure(PlatformConfig platformConfig) {\r
-        if (!sIsPlatformInitialized) {\r
-            CaInterface.initialize(platformConfig.getContext());\r
-\r
-            OcPlatform.configure(\r
-                    platformConfig.getServiceType().getValue(),\r
-                    platformConfig.getModeType().getValue(),\r
-                    platformConfig.getIpAddress(),\r
-                    platformConfig.getPort(),\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+import org.iotivity.ca.CaInterface;
+
+import java.util.EnumSet;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Contains the main entrance/functionality of the product. To set a custom configuration, the
+ * implementer must make a call to OcPlatform.Configure before the first usage of a function in this
+ * class.
+ */
+public final class OcPlatform {
+
+    static {
+        System.loadLibrary("oc_logger");
+        System.loadLibrary("octbstack");
+        System.loadLibrary("connectivity_abstraction");
+        System.loadLibrary("oc");
+        System.loadLibrary("ocstack-jni");
+    }
+
+    /**
+     * Default interface
+     */
+    public static final String DEFAULT_INTERFACE = "oic.if.baseline";
+
+    /**
+     * Used in discovering (GET) links to other resources of a collection
+     */
+    public static final String LINK_INTERFACE = "oic.if.ll";
+
+    /**
+     * Used in GET, PUT, POST, DELETE methods on links to other resources of a collection
+     */
+    public static final String BATCH_INTERFACE = "oic.if.b";
+
+    /**
+     * Used in GET, PUT, POST methods on links to other remote resources of a group
+     */
+    public static final String GROUP_INTERFACE = "oic.mi.grp";
+
+    public static final String WELL_KNOWN_QUERY = "224.0.1.187:5683/oic/res";
+    public static final String MULTICAST_PREFIX = "224.0.1.187:5683";
+    public static final String MULTICAST_IP = "224.0.1.187";
+    public static final int MULTICAST_PORT = 5683;
+    public static final int DEFAULT_PRESENCE_TTL = 60;
+    public static final String DEVICE_URI = "/oic/d";
+    public static final String PRESENCE_URI = "/oic/ad";
+
+    private static volatile boolean sIsPlatformInitialized = false;
+
+    private OcPlatform() {
+    }
+
+    /**
+     * API for setting the configuration of the OcPlatform.
+     * Note: Any calls made to this AFTER the first call to OcPlatform.Configure will have no affect
+     *
+     * @param platformConfig platform configuration
+     */
+    public synchronized static void Configure(PlatformConfig platformConfig) {
+        if (!sIsPlatformInitialized) {
+            CaInterface.initialize(platformConfig.getContext());
+
+            OcPlatform.configure(
+                    platformConfig.getServiceType().getValue(),
+                    platformConfig.getModeType().getValue(),
+                    platformConfig.getIpAddress(),
+                    platformConfig.getPort(),
                     platformConfig.getQualityOfService().getValue(),
                     platformConfig.getSvrDbPath()
-            );\r
-\r
-            sIsPlatformInitialized = true;\r
-        }\r
-    }\r
-\r
-    private static native void configure(int serviceType,\r
-                                         int modeType,\r
-                                         String ipAddress,\r
-                                         int port,\r
+            );
+
+            sIsPlatformInitialized = true;
+        }
+    }
+
+    private static native void configure(int serviceType,
+                                         int modeType,
+                                         String ipAddress,
+                                         int port,
                                          int qualityOfService,
                                          String dbPath);
-\r
-    /**\r
-     * API for notifying base that resource's attributes have changed.\r
-     *\r
-     * @param ocResourceHandle resource handle of the resource\r
-     * @throws OcException\r
-     */\r
-    public static void notifyAllObservers(\r
-            OcResourceHandle ocResourceHandle) throws OcException {\r
-        OcPlatform.initCheck();\r
-        OcPlatform.notifyAllObservers0(ocResourceHandle);\r
-    }\r
-\r
-    private static native void notifyAllObservers0(\r
-            OcResourceHandle ocResourceHandle) throws OcException;\r
-\r
-    /**\r
-     * API for notifying base that resource's attributes have changed.\r
-     *\r
-     * @param ocResourceHandle resource handle of the resource\r
-     * @param qualityOfService the quality of communication\r
-     * @throws OcException\r
-     */\r
-    public static void notifyAllObservers(\r
-            OcResourceHandle ocResourceHandle,\r
-            QualityOfService qualityOfService) throws OcException {\r
-        OcPlatform.initCheck();\r
-        OcPlatform.notifyAllObservers1(ocResourceHandle, qualityOfService.getValue());\r
-    }\r
-\r
-    private static native void notifyAllObservers1(\r
-            OcResourceHandle ocResourceHandle,\r
-            int qualityOfService) throws OcException;\r
-\r
-    /**\r
-     * API for notifying only specific clients that resource's attributes have changed.\r
-     *\r
-     * @param ocResourceHandle    resource handle of the resource\r
-     * @param ocObservationIdList These set of ids are ones which which will be notified upon\r
-     *                            resource change.\r
-     * @param ocResourceResponse  OcResourceResponse object used by app to fill the response for\r
-     *                            this resource change\r
-     * @throws OcException\r
-     */\r
-    public static void notifyListOfObservers(\r
-            OcResourceHandle ocResourceHandle,\r
-            List<Byte> ocObservationIdList,\r
-            OcResourceResponse ocResourceResponse) throws OcException {\r
-        OcPlatform.initCheck();\r
-\r
-        byte[] idArr = new byte[ocObservationIdList.size()];\r
-        Iterator<Byte> it = ocObservationIdList.iterator();\r
-        int i = 0;\r
-        while (it.hasNext()) {\r
-            idArr[i++] = (byte) it.next();\r
-        }\r
-\r
-        OcPlatform.notifyListOfObservers2(\r
-                ocResourceHandle,\r
-                idArr,\r
-                ocResourceResponse);\r
-    }\r
-\r
-    private static native void notifyListOfObservers2(\r
-            OcResourceHandle ocResourceHandle,\r
-            byte[] ocObservationIdArray,\r
-            OcResourceResponse ocResourceResponse) throws OcException;\r
-\r
-    /**\r
-     * API for notifying only specific clients that resource's attributes have changed.\r
-     *\r
-     * @param ocResourceHandle    resource handle of the resource\r
-     * @param ocObservationIdList These set of ids are ones which which will be notified upon\r
-     *                            resource change.\r
-     * @param ocResourceResponse  OcResourceResponse object used by app to fill the response for\r
-     *                            this resource change\r
-     * @param qualityOfService    the quality of communication\r
-     * @throws OcException\r
-     */\r
-    public static void notifyListOfObservers(\r
-            OcResourceHandle ocResourceHandle,\r
-            List<Byte> ocObservationIdList,\r
-            OcResourceResponse ocResourceResponse,\r
-            QualityOfService qualityOfService) throws OcException {\r
-        OcPlatform.initCheck();\r
-\r
-        byte[] idArr = new byte[ocObservationIdList.size()];\r
-        Iterator<Byte> it = ocObservationIdList.iterator();\r
-        int i = 0;\r
-        while (it.hasNext()) {\r
-            idArr[i++] = (byte) it.next();\r
-        }\r
-\r
-        OcPlatform.notifyListOfObservers3(\r
-                ocResourceHandle,\r
-                idArr,\r
-                ocResourceResponse,\r
-                qualityOfService.getValue()\r
-        );\r
-    }\r
-\r
-    private static native void notifyListOfObservers3(\r
-            OcResourceHandle ocResourceHandle,\r
-            byte[] ocObservationIdArray,\r
-            OcResourceResponse ocResourceResponse,\r
-            int qualityOfService) throws OcException;\r
-\r
-    /**\r
-     * API for Service and Resource Discovery. NOTE: This API applies to client side only\r
-     *\r
-     * @param host                    Host IP Address of a service to direct resource discovery query.\r
-     *                                If empty, performs multicast resource discovery query\r
-     * @param resourceUri             name of the resource. If null or empty, performs search for all\r
-     *                                resource names\r
-     * @param connectivityType        a type of connectivity indicating the interface. Example: IPV4,\r
-     *                                IPV6, ALL\r
-     * @param onResourceFoundListener Handles events, success states and failure states.\r
-     * @throws OcException\r
-     */\r
-    public static void findResource(\r
-            String host,\r
-            String resourceUri,\r
-            OcConnectivityType connectivityType,\r
-            OnResourceFoundListener onResourceFoundListener) throws OcException {\r
-        OcPlatform.initCheck();\r
-        OcPlatform.findResource0(\r
-                host,\r
-                resourceUri,\r
-                connectivityType.getValue(),\r
-                onResourceFoundListener\r
-        );\r
-    }\r
-\r
-    private static native void findResource0(\r
-            String host,\r
-            String resourceUri,\r
-            int connectivityType,\r
-            OnResourceFoundListener onResourceFoundListener) throws OcException;\r
-\r
-    /**\r
-     * API for Service and Resource Discovery. NOTE: This API applies to client side only\r
-     *\r
-     * @param host                    Host IP Address of a service to direct resource discovery query.\r
-     *                                If empty, performs multicast resource discovery query\r
-     * @param resourceUri             name of the resource. If null or empty, performs search for all\r
-     *                                resource names\r
-     * @param connectivityType        a type of connectivity indicating the interface. Example: IPV4,\r
-     *                                IPV6, ALL\r
-     * @param onResourceFoundListener Handles events, success states and failure states.\r
-     * @param qualityOfService        the quality of communication\r
-     * @throws OcException\r
-     */\r
-    public static void findResource(\r
-            String host,\r
-            String resourceUri,\r
-            OcConnectivityType connectivityType,\r
-            OnResourceFoundListener onResourceFoundListener,\r
-            QualityOfService qualityOfService) throws OcException {\r
-        OcPlatform.initCheck();\r
-        OcPlatform.findResource1(host,\r
-                resourceUri,\r
-                connectivityType.getValue(),\r
-                onResourceFoundListener,\r
-                qualityOfService.getValue()\r
-        );\r
-    }\r
-\r
-    private static native void findResource1(\r
-            String host,\r
-            String resourceUri,\r
-            int connectivityType,\r
-            OnResourceFoundListener onResourceFoundListener,\r
-            int qualityOfService) throws OcException;\r
-\r
-    /**\r
-     * API for Device Discovery\r
-     *\r
-     * @param host                  Host IP Address. If null or empty, Multicast is performed.\r
-     * @param deviceUri             Uri containing address to the virtual device\r
-     * @param connectivityType      a type of connectivity indicating the interface. Example: IPV4,\r
-     *                              IPV6, ALL\r
-     * @param onDeviceFoundListener Handles events, success states and failure states.\r
-     * @throws OcException\r
-     */\r
-    public static void getDeviceInfo(\r
-            String host,\r
-            String deviceUri,\r
-            OcConnectivityType connectivityType,\r
-            OnDeviceFoundListener onDeviceFoundListener) throws OcException {\r
-        OcPlatform.initCheck();\r
-        OcPlatform.getDeviceInfo0(\r
-                host,\r
-                deviceUri,\r
-                connectivityType.getValue(),\r
-                onDeviceFoundListener\r
-        );\r
-    }\r
-\r
-    private static native void getDeviceInfo0(\r
-            String host,\r
-            String deviceUri,\r
-            int connectivityType,\r
-            OnDeviceFoundListener onDeviceFoundListener) throws OcException;\r
-\r
-    /**\r
-     * API for Device Discovery\r
-     *\r
-     * @param host                  Host IP Address. If null or empty, Multicast is performed.\r
-     * @param deviceUri             Uri containing address to the virtual device\r
-     * @param connectivityType      a type of connectivity indicating the interface. Example: IPV4,\r
-     *                              IPV6, ALL\r
-     * @param onDeviceFoundListener Handles events, success states and failure states.\r
-     * @param qualityOfService      the quality of communication\r
-     * @throws OcException\r
-     */\r
-    public static void getDeviceInfo(\r
-            String host,\r
-            String deviceUri,\r
-            OcConnectivityType connectivityType,\r
-            OnDeviceFoundListener onDeviceFoundListener,\r
-            QualityOfService qualityOfService) throws OcException {\r
-        OcPlatform.initCheck();\r
-        OcPlatform.getDeviceInfo1(\r
-                host,\r
-                deviceUri,\r
-                connectivityType.getValue(),\r
-                onDeviceFoundListener,\r
-                qualityOfService.getValue()\r
-        );\r
-    }\r
-\r
-    private static native void getDeviceInfo1(\r
-            String host,\r
-            String deviceUri,\r
-            int connectivityType,\r
-            OnDeviceFoundListener onDeviceFoundListener,\r
+
+    /**
+     * API for notifying base that resource's attributes have changed.
+     *
+     * @param ocResourceHandle resource handle of the resource
+     * @throws OcException
+     */
+    public static void notifyAllObservers(
+            OcResourceHandle ocResourceHandle) throws OcException {
+        OcPlatform.initCheck();
+        OcPlatform.notifyAllObservers0(ocResourceHandle);
+    }
+
+    private static native void notifyAllObservers0(
+            OcResourceHandle ocResourceHandle) throws OcException;
+
+    /**
+     * API for notifying base that resource's attributes have changed.
+     *
+     * @param ocResourceHandle resource handle of the resource
+     * @param qualityOfService the quality of communication
+     * @throws OcException
+     */
+    public static void notifyAllObservers(
+            OcResourceHandle ocResourceHandle,
+            QualityOfService qualityOfService) throws OcException {
+        OcPlatform.initCheck();
+        OcPlatform.notifyAllObservers1(ocResourceHandle, qualityOfService.getValue());
+    }
+
+    private static native void notifyAllObservers1(
+            OcResourceHandle ocResourceHandle,
+            int qualityOfService) throws OcException;
+
+    /**
+     * API for notifying only specific clients that resource's attributes have changed.
+     *
+     * @param ocResourceHandle    resource handle of the resource
+     * @param ocObservationIdList These set of ids are ones which which will be notified upon
+     *                            resource change.
+     * @param ocResourceResponse  OcResourceResponse object used by app to fill the response for
+     *                            this resource change
+     * @throws OcException
+     */
+    public static void notifyListOfObservers(
+            OcResourceHandle ocResourceHandle,
+            List<Byte> ocObservationIdList,
+            OcResourceResponse ocResourceResponse) throws OcException {
+        OcPlatform.initCheck();
+
+        byte[] idArr = new byte[ocObservationIdList.size()];
+        Iterator<Byte> it = ocObservationIdList.iterator();
+        int i = 0;
+        while (it.hasNext()) {
+            idArr[i++] = (byte) it.next();
+        }
+
+        OcPlatform.notifyListOfObservers2(
+                ocResourceHandle,
+                idArr,
+                ocResourceResponse);
+    }
+
+    private static native void notifyListOfObservers2(
+            OcResourceHandle ocResourceHandle,
+            byte[] ocObservationIdArray,
+            OcResourceResponse ocResourceResponse) throws OcException;
+
+    /**
+     * API for notifying only specific clients that resource's attributes have changed.
+     *
+     * @param ocResourceHandle    resource handle of the resource
+     * @param ocObservationIdList These set of ids are ones which which will be notified upon
+     *                            resource change.
+     * @param ocResourceResponse  OcResourceResponse object used by app to fill the response for
+     *                            this resource change
+     * @param qualityOfService    the quality of communication
+     * @throws OcException
+     */
+    public static void notifyListOfObservers(
+            OcResourceHandle ocResourceHandle,
+            List<Byte> ocObservationIdList,
+            OcResourceResponse ocResourceResponse,
+            QualityOfService qualityOfService) throws OcException {
+        OcPlatform.initCheck();
+
+        byte[] idArr = new byte[ocObservationIdList.size()];
+        Iterator<Byte> it = ocObservationIdList.iterator();
+        int i = 0;
+        while (it.hasNext()) {
+            idArr[i++] = (byte) it.next();
+        }
+
+        OcPlatform.notifyListOfObservers3(
+                ocResourceHandle,
+                idArr,
+                ocResourceResponse,
+                qualityOfService.getValue()
+        );
+    }
+
+    private static native void notifyListOfObservers3(
+            OcResourceHandle ocResourceHandle,
+            byte[] ocObservationIdArray,
+            OcResourceResponse ocResourceResponse,
+            int qualityOfService) throws OcException;
+
+    /**
+     * API for Service and Resource Discovery. NOTE: This API applies to client side only
+     *
+     * @param host                    Host IP Address of a service to direct resource discovery query.
+     *                                If empty, performs multicast resource discovery query
+     * @param resourceUri             name of the resource. If null or empty, performs search for all
+     *                                resource names
+     * @param connectivityType        a type of connectivity indicating the interface. Example: IPV4,
+     *                                IPV6, ALL
+     * @param onResourceFoundListener Handles events, success states and failure states.
+     * @throws OcException
+     */
+    public static void findResource(
+            String host,
+            String resourceUri,
+            OcConnectivityType connectivityType,
+            OnResourceFoundListener onResourceFoundListener) throws OcException {
+        OcPlatform.initCheck();
+        OcPlatform.findResource0(
+                host,
+                resourceUri,
+                connectivityType.getValue(),
+                onResourceFoundListener
+        );
+    }
+
+    private static native void findResource0(
+            String host,
+            String resourceUri,
+            int connectivityType,
+            OnResourceFoundListener onResourceFoundListener) throws OcException;
+
+    /**
+     * API for Service and Resource Discovery. NOTE: This API applies to client side only
+     *
+     * @param host                    Host IP Address of a service to direct resource discovery query.
+     *                                If empty, performs multicast resource discovery query
+     * @param resourceUri             name of the resource. If null or empty, performs search for all
+     *                                resource names
+     * @param connectivityType        a type of connectivity indicating the interface. Example: IPV4,
+     *                                IPV6, ALL
+     * @param onResourceFoundListener Handles events, success states and failure states.
+     * @param qualityOfService        the quality of communication
+     * @throws OcException
+     */
+    public static void findResource(
+            String host,
+            String resourceUri,
+            OcConnectivityType connectivityType,
+            OnResourceFoundListener onResourceFoundListener,
+            QualityOfService qualityOfService) throws OcException {
+        OcPlatform.initCheck();
+        OcPlatform.findResource1(host,
+                resourceUri,
+                connectivityType.getValue(),
+                onResourceFoundListener,
+                qualityOfService.getValue()
+        );
+    }
+
+    private static native void findResource1(
+            String host,
+            String resourceUri,
+            int connectivityType,
+            OnResourceFoundListener onResourceFoundListener,
+            int qualityOfService) throws OcException;
+
+    /**
+     * API for Device Discovery
+     *
+     * @param host                  Host IP Address. If null or empty, Multicast is performed.
+     * @param deviceUri             Uri containing address to the virtual device
+     * @param connectivityType      a type of connectivity indicating the interface. Example: IPV4,
+     *                              IPV6, ALL
+     * @param onDeviceFoundListener Handles events, success states and failure states.
+     * @throws OcException
+     */
+    public static void getDeviceInfo(
+            String host,
+            String deviceUri,
+            OcConnectivityType connectivityType,
+            OnDeviceFoundListener onDeviceFoundListener) throws OcException {
+        OcPlatform.initCheck();
+        OcPlatform.getDeviceInfo0(
+                host,
+                deviceUri,
+                connectivityType.getValue(),
+                onDeviceFoundListener
+        );
+    }
+
+    private static native void getDeviceInfo0(
+            String host,
+            String deviceUri,
+            int connectivityType,
+            OnDeviceFoundListener onDeviceFoundListener) throws OcException;
+
+    /**
+     * API for Device Discovery
+     *
+     * @param host                  Host IP Address. If null or empty, Multicast is performed.
+     * @param deviceUri             Uri containing address to the virtual device
+     * @param connectivityType      a type of connectivity indicating the interface. Example: IPV4,
+     *                              IPV6, ALL
+     * @param onDeviceFoundListener Handles events, success states and failure states.
+     * @param qualityOfService      the quality of communication
+     * @throws OcException
+     */
+    public static void getDeviceInfo(
+            String host,
+            String deviceUri,
+            OcConnectivityType connectivityType,
+            OnDeviceFoundListener onDeviceFoundListener,
+            QualityOfService qualityOfService) throws OcException {
+        OcPlatform.initCheck();
+        OcPlatform.getDeviceInfo1(
+                host,
+                deviceUri,
+                connectivityType.getValue(),
+                onDeviceFoundListener,
+                qualityOfService.getValue()
+        );
+    }
+
+    private static native void getDeviceInfo1(
+            String host,
+            String deviceUri,
+            int connectivityType,
+            OnDeviceFoundListener onDeviceFoundListener,
             int qualityOfService) throws OcException;
 
     /**
@@ -407,83 +407,83 @@ public final class OcPlatform {
             String platformUri,
             int connectivityType,
             OnPlatformFoundListener onPlatformFoundListener,
-            int qualityOfService) throws OcException;\r
-\r
-    /**\r
-     * This API registers a resource with the server NOTE: This API applies to server side only.\r
-     *\r
-     * @param ocResource The instance of OcResource with all data filled\r
-     * @return resource handle\r
-     * @throws OcException\r
-     */\r
-    public static OcResourceHandle registerResource(\r
-            OcResource ocResource) throws OcException {\r
-        OcPlatform.initCheck();\r
-        return OcPlatform.registerResource0(ocResource);\r
-    }\r
-\r
-    private static native OcResourceHandle registerResource0(\r
-            OcResource ocResource) throws OcException;\r
-\r
-    /**\r
-     * This API registers a resource with the server NOTE: This API applies to server side only.\r
-     *\r
-     * @param resourceUri         The URI of the resource. Example: "a/light"\r
-     * @param resourceTypeName    The resource type. Example: "light"\r
-     * @param resourceInterface   The resource interface (whether it is collection etc).\r
-     * @param entityHandler       entity handler.\r
-     * @param resourcePropertySet indicates the property of the resource\r
-     * @return resource handle\r
-     * @throws OcException\r
-     */\r
-    public static OcResourceHandle registerResource(\r
-            String resourceUri,\r
-            String resourceTypeName,\r
-            String resourceInterface,\r
-            EntityHandler entityHandler,\r
-            EnumSet<ResourceProperty> resourcePropertySet) throws OcException {\r
-        OcPlatform.initCheck();\r
-\r
-        int resProperty = 0;\r
-\r
-        for (ResourceProperty prop : ResourceProperty.values()) {\r
-            if (resourcePropertySet.contains(prop))\r
-                resProperty |= prop.getValue();\r
-        }\r
-\r
-        return OcPlatform.registerResource1(resourceUri,\r
-                resourceTypeName,\r
-                resourceInterface,\r
-                entityHandler,\r
-                resProperty);\r
-    }\r
-\r
-    private static native OcResourceHandle registerResource1(\r
-            String resourceUri,\r
-            String resourceTypeName,\r
-            String resourceInterface,\r
-            EntityHandler entityHandler,\r
-            int resourceProperty) throws OcException;\r
-\r
-    /**\r
-     * Register Device Info\r
-     *\r
-     * @param ocDeviceInfo object containing all the device specific information\r
-     * @throws OcException\r
-     */\r
-    public static void registerDeviceInfo(\r
-            OcDeviceInfo ocDeviceInfo) throws OcException {\r
-        OcPlatform.initCheck();\r
-        OcPlatform.registerDeviceInfo0(\r
-                ocDeviceInfo.getDeviceName()\r
-        );\r
-    }\r
-\r
-    private static native void registerDeviceInfo0(\r
-            String deviceName\r
-            ) throws OcException;\r
-\r
-    /**\r
+            int qualityOfService) throws OcException;
+
+    /**
+     * This API registers a resource with the server NOTE: This API applies to server side only.
+     *
+     * @param ocResource The instance of OcResource with all data filled
+     * @return resource handle
+     * @throws OcException
+     */
+    public static OcResourceHandle registerResource(
+            OcResource ocResource) throws OcException {
+        OcPlatform.initCheck();
+        return OcPlatform.registerResource0(ocResource);
+    }
+
+    private static native OcResourceHandle registerResource0(
+            OcResource ocResource) throws OcException;
+
+    /**
+     * This API registers a resource with the server NOTE: This API applies to server side only.
+     *
+     * @param resourceUri         The URI of the resource. Example: "a/light"
+     * @param resourceTypeName    The resource type. Example: "light"
+     * @param resourceInterface   The resource interface (whether it is collection etc).
+     * @param entityHandler       entity handler.
+     * @param resourcePropertySet indicates the property of the resource
+     * @return resource handle
+     * @throws OcException
+     */
+    public static OcResourceHandle registerResource(
+            String resourceUri,
+            String resourceTypeName,
+            String resourceInterface,
+            EntityHandler entityHandler,
+            EnumSet<ResourceProperty> resourcePropertySet) throws OcException {
+        OcPlatform.initCheck();
+
+        int resProperty = 0;
+
+        for (ResourceProperty prop : ResourceProperty.values()) {
+            if (resourcePropertySet.contains(prop))
+                resProperty |= prop.getValue();
+        }
+
+        return OcPlatform.registerResource1(resourceUri,
+                resourceTypeName,
+                resourceInterface,
+                entityHandler,
+                resProperty);
+    }
+
+    private static native OcResourceHandle registerResource1(
+            String resourceUri,
+            String resourceTypeName,
+            String resourceInterface,
+            EntityHandler entityHandler,
+            int resourceProperty) throws OcException;
+
+    /**
+     * Register Device Info
+     *
+     * @param ocDeviceInfo object containing all the device specific information
+     * @throws OcException
+     */
+    public static void registerDeviceInfo(
+            OcDeviceInfo ocDeviceInfo) throws OcException {
+        OcPlatform.initCheck();
+        OcPlatform.registerDeviceInfo0(
+                ocDeviceInfo.getDeviceName()
+        );
+    }
+
+    private static native void registerDeviceInfo0(
+            String deviceName
+            ) throws OcException;
+
+    /**
      * Register Platform Info
      *
      * @param ocPlatformInfo object containing all the platform specific information
@@ -515,320 +515,320 @@ public final class OcPlatform {
     ) throws OcException;
 
     /**
-     * This API unregisters a resource with the server NOTE: This API applies to server side only.\r
-     *\r
-     * @param ocResourceHandle This is the resource handle which we which to unregister from the\r
-     *                         server\r
-     * @throws OcException\r
-     */\r
-    public static void unregisterResource(\r
-            OcResourceHandle ocResourceHandle) throws OcException {\r
-        OcPlatform.initCheck();\r
-        OcPlatform.unregisterResource0(ocResourceHandle);\r
-    }\r
-\r
-    private static native void unregisterResource0(\r
-            OcResourceHandle ocResourceHandle) throws OcException;\r
-\r
-\r
-    /**\r
-     * Add a resource to a collection resource\r
-     *\r
-     * @param ocResourceCollectionHandle handle to the collection resource\r
-     * @param ocResourceHandle           handle to resource to be added to the collection resource\r
-     * @throws OcException\r
-     */\r
-    public static void bindResource(\r
-            OcResourceHandle ocResourceCollectionHandle,\r
-            OcResourceHandle ocResourceHandle) throws OcException {\r
-        OcPlatform.initCheck();\r
-        OcPlatform.bindResource0(ocResourceCollectionHandle, ocResourceHandle);\r
-    }\r
-\r
-    private static native void bindResource0(\r
-            OcResourceHandle ocResourceCollectionHandle,\r
-            OcResourceHandle ocResourceHandle) throws OcException;\r
-\r
-    /**\r
-     * Add multiple resources to a collection resource.\r
-     *\r
-     * @param ocResourceCollectionHandle handle to the collection resource\r
-     * @param ocResourceHandleList       reference to list of resource handles to be added to the\r
-     *                                   collection resource\r
-     * @throws OcException\r
-     */\r
-    public static void bindResources(\r
-            OcResourceHandle ocResourceCollectionHandle,\r
-            List<OcResourceHandle> ocResourceHandleList) throws OcException {\r
-        OcPlatform.initCheck();\r
-        OcPlatform.bindResources0(\r
-                ocResourceCollectionHandle,\r
-                ocResourceHandleList.toArray(\r
-                        new OcResourceHandle[ocResourceHandleList.size()])\r
-        );\r
-    }\r
-\r
-    private static native void bindResources0(\r
-            OcResourceHandle ocResourceCollectionHandle,\r
-            OcResourceHandle[] ocResourceHandleArray) throws OcException;\r
-\r
-    /**\r
-     * Unbind a resource from a collection resource.\r
-     *\r
-     * @param ocResourceCollectionHandle handle to the collection resource\r
-     * @param ocResourceHandle           resource handle to be unbound from the collection resource\r
-     * @throws OcException\r
-     */\r
-    public static void unbindResource(\r
-            OcResourceHandle ocResourceCollectionHandle,\r
-            OcResourceHandle ocResourceHandle) throws OcException {\r
-        OcPlatform.initCheck();\r
-        OcPlatform.unbindResource0(ocResourceCollectionHandle, ocResourceHandle);\r
-    }\r
-\r
-    private static native void unbindResource0(\r
-            OcResourceHandle ocResourceCollectionHandle,\r
-            OcResourceHandle ocResourceHandle) throws OcException;\r
-\r
-    /**\r
-     * Unbind resources from a collection resource.\r
-     *\r
-     * @param ocResourceCollectionHandle Handle to the collection resource\r
-     * @param ocResourceHandleList       List of resource handles to be unbound from the collection\r
-     *                                   resource\r
-     * @throws OcException\r
-     */\r
-    public static void unbindResources(\r
-            OcResourceHandle ocResourceCollectionHandle,\r
-            List<OcResourceHandle> ocResourceHandleList) throws OcException {\r
-        OcPlatform.initCheck();\r
-        OcPlatform.unbindResources0(\r
-                ocResourceCollectionHandle,\r
-                ocResourceHandleList.toArray(\r
-                        new OcResourceHandle[ocResourceHandleList.size()])\r
-        );\r
-    }\r
-\r
-    private static native void unbindResources0(\r
-            OcResourceHandle ocResourceCollectionHandle,\r
-            OcResourceHandle[] ocResourceHandleArray) throws OcException;\r
-\r
-    /**\r
-     * Binds a type to a particular resource\r
-     *\r
-     * @param ocResourceHandle handle to the resource\r
-     * @param resourceTypeName new typename to bind to the resource\r
-     * @throws OcException\r
-     */\r
-    public static void bindTypeToResource(\r
-            OcResourceHandle ocResourceHandle,\r
-            String resourceTypeName) throws OcException {\r
-        OcPlatform.initCheck();\r
-        OcPlatform.bindTypeToResource0(ocResourceHandle, resourceTypeName);\r
-    }\r
-\r
-    private static native void bindTypeToResource0(\r
-            OcResourceHandle ocResourceHandle,\r
-            String resourceTypeName) throws OcException;\r
-\r
-    /**\r
-     * Binds an interface to a particular resource\r
-     *\r
-     * @param ocResourceHandle      handle to the resource\r
-     * @param resourceInterfaceName new interface to bind to the resource\r
-     * @throws OcException\r
-     */\r
-    public static void bindInterfaceToResource(\r
-            OcResourceHandle ocResourceHandle,\r
-            String resourceInterfaceName) throws OcException {\r
-        OcPlatform.initCheck();\r
-        OcPlatform.bindInterfaceToResource0(ocResourceHandle, resourceInterfaceName);\r
-    }\r
-\r
-    private static native void bindInterfaceToResource0(\r
-            OcResourceHandle ocResourceHandle,\r
-            String resourceInterfaceName) throws OcException;\r
-\r
-    /**\r
-     * Start Presence announcements.\r
-     *\r
-     * @param ttl time to live in seconds\r
-     * @throws OcException\r
-     */\r
-    public static void startPresence(int ttl) throws OcException {\r
-        OcPlatform.initCheck();\r
-        OcPlatform.startPresence0(ttl);\r
-    }\r
-\r
-    private static native void startPresence0(int ttl) throws OcException;\r
-\r
-    /**\r
-     * Stop Presence announcements.\r
-     *\r
-     * @throws OcException\r
-     */\r
-    public static void stopPresence() throws OcException {\r
-        OcPlatform.initCheck();\r
-        OcPlatform.stopPresence0();\r
-    }\r
-\r
-    private static native void stopPresence0() throws OcException;\r
-\r
-    /**\r
-     * Subscribes to a server's presence change events. By making this subscription, every time a\r
-     * server adds/removes/alters a resource, starts or is intentionally stopped\r
-     *\r
-     * @param host               The IP address/addressable name of the server to subscribe to\r
-     * @param connectivityType   a type of connectivity indicating the interface. Example: IPV4,\r
-     *                           IPV6, ALL\r
-     * @param onPresenceListener listener that will receive notifications/subscription events\r
-     * @return a handle object that can be used to identify this subscription request. It can be\r
-     * used to unsubscribe from these events in the future\r
-     * @throws OcException\r
-     */\r
-    public static OcPresenceHandle subscribePresence(\r
-            String host,\r
-            OcConnectivityType connectivityType,\r
-            OnPresenceListener onPresenceListener) throws OcException {\r
-        OcPlatform.initCheck();\r
-        return OcPlatform.subscribePresence0(\r
-                host,\r
-                connectivityType.getValue(),\r
-                onPresenceListener\r
-        );\r
-    }\r
-\r
-    private static native OcPresenceHandle subscribePresence0(\r
-            String host,\r
-            int connectivityType,\r
-            OnPresenceListener onPresenceListener) throws OcException;\r
-\r
-    /**\r
-     * Subscribes to a server's presence change events. By making this subscription, every time a\r
-     * server adds/removes/alters a resource, starts or is intentionally stopped\r
-     *\r
-     * @param host               The IP address/addressable name of the server to subscribe to\r
-     * @param resourceType       a resource type specified as a filter for subscription events.\r
-     * @param connectivityType   a type of connectivity indicating the interface. Example: IPV4,\r
-     *                           IPV6, ALL\r
-     * @param onPresenceListener listener that will receive notifications/subscription events\r
-     * @return a handle object that can be used to identify this subscription request. It can be\r
-     * used to unsubscribe from these events in the future\r
-     * @throws OcException\r
-     */\r
-    public static OcPresenceHandle subscribePresence(\r
-            String host,\r
-            String resourceType,\r
-            OcConnectivityType connectivityType,\r
-            OnPresenceListener onPresenceListener) throws OcException {\r
-        OcPlatform.initCheck();\r
-        return OcPlatform.subscribePresence1(\r
-                host,\r
-                resourceType,\r
-                connectivityType.getValue(),\r
-                onPresenceListener);\r
-    }\r
-\r
-    private static native OcPresenceHandle subscribePresence1(\r
-            String host,\r
-            String resourceType,\r
-            int connectivityType,\r
-            OnPresenceListener onPresenceListener) throws OcException;\r
-\r
-    /**\r
-     * Unsubscribes from a previously subscribed server's presence events. Note that you may for\r
-     * a short time still receive events from the server since it may take time for the\r
-     * unsubscribe to take effect.\r
-     *\r
-     * @param ocPresenceHandle the handle object provided by the subscribePresence call that\r
-     *                         identifies this subscription\r
-     * @throws OcException\r
-     */\r
-    public static void unsubscribePresence(\r
-            OcPresenceHandle ocPresenceHandle) throws OcException {\r
-        OcPlatform.initCheck();\r
-        OcPlatform.unsubscribePresence0(ocPresenceHandle);\r
-    }\r
-\r
-    private static native void unsubscribePresence0(\r
-            OcPresenceHandle ocPresenceHandle) throws OcException;\r
-\r
-    /**\r
-     * Creates a resource proxy object so that get/put/observe functionality can be used without\r
-     * discovering the object in advance. Note that the consumer of this method needs to provide\r
-     * all of the details required to correctly contact and observe the object. If the consumer\r
-     * lacks any of this information, they should discover the resource object normally.\r
-     * Additionally, you can only create this object if OcPlatform was initialized to be a Client\r
-     * or Client/Server.\r
-     *\r
-     * @param host             a string containing a resolvable host address of the server holding\r
-     *                         the resource\r
-     * @param uri              the rest of the resource's URI that will permit messages to be\r
-     *                         properly routed.\r
-     *                         Example: /a/light\r
-     * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,\r
-     *                         IPV6, ALL\r
-     * @param isObservable     a boolean containing whether the resource supports observation\r
-     * @param resourceTypeList a collection of resource types implemented by the resource\r
-     * @param interfaceList    a collection of interfaces that the resource supports/implements\r
-     * @return new resource object\r
-     * @throws OcException\r
-     */\r
-    public static OcResource constructResourceObject(\r
-            String host,\r
-            String uri,\r
-            OcConnectivityType connectivityType,\r
-            boolean isObservable,\r
-            List<String> resourceTypeList,\r
-            List<String> interfaceList) throws OcException {\r
-        OcPlatform.initCheck();\r
-        return OcPlatform.constructResourceObject0(\r
-                host,\r
-                uri,\r
-                connectivityType.getValue(),\r
-                isObservable,\r
-                resourceTypeList.toArray(new String[resourceTypeList.size()]),\r
-                interfaceList.toArray(new String[interfaceList.size()])\r
-        );\r
-    }\r
-\r
-    private static native OcResource constructResourceObject0(\r
-            String host,\r
-            String uri,\r
-            int connectivityType,\r
-            boolean isObservable,\r
-            String[] resourceTypes,\r
-            String[] interfaces) throws OcException;\r
-\r
-    /**\r
-     * Allows application entity handler to send response to an incoming request.\r
-     *\r
-     * @param ocResourceResponse resource response\r
-     * @throws OcException\r
-     */\r
-    public static void sendResponse(OcResourceResponse ocResourceResponse)\r
-            throws OcException {\r
-        OcPlatform.initCheck();\r
-        OcPlatform.sendResponse0(ocResourceResponse);\r
-    }\r
-\r
-    private static native void sendResponse0(OcResourceResponse ocResourceResponse)\r
-            throws OcException;\r
-\r
-    /**\r
-     * An OnResourceFoundListener can be registered via the OcPlatform.findResource call.\r
-     * Event listeners are notified asynchronously\r
-     */\r
-    public interface OnResourceFoundListener {\r
-        public void onResourceFound(OcResource resource);\r
-    }\r
-\r
-    /**\r
-     * An OnDeviceFoundListener can be registered via the OcPlatform.getDeviceInfo call.\r
-     * Event listeners are notified asynchronously\r
-     */\r
-    public interface OnDeviceFoundListener {\r
-        public void onDeviceFound(OcRepresentation ocRepresentation);\r
+     * This API unregisters a resource with the server NOTE: This API applies to server side only.
+     *
+     * @param ocResourceHandle This is the resource handle which we which to unregister from the
+     *                         server
+     * @throws OcException
+     */
+    public static void unregisterResource(
+            OcResourceHandle ocResourceHandle) throws OcException {
+        OcPlatform.initCheck();
+        OcPlatform.unregisterResource0(ocResourceHandle);
+    }
+
+    private static native void unregisterResource0(
+            OcResourceHandle ocResourceHandle) throws OcException;
+
+
+    /**
+     * Add a resource to a collection resource
+     *
+     * @param ocResourceCollectionHandle handle to the collection resource
+     * @param ocResourceHandle           handle to resource to be added to the collection resource
+     * @throws OcException
+     */
+    public static void bindResource(
+            OcResourceHandle ocResourceCollectionHandle,
+            OcResourceHandle ocResourceHandle) throws OcException {
+        OcPlatform.initCheck();
+        OcPlatform.bindResource0(ocResourceCollectionHandle, ocResourceHandle);
+    }
+
+    private static native void bindResource0(
+            OcResourceHandle ocResourceCollectionHandle,
+            OcResourceHandle ocResourceHandle) throws OcException;
+
+    /**
+     * Add multiple resources to a collection resource.
+     *
+     * @param ocResourceCollectionHandle handle to the collection resource
+     * @param ocResourceHandleList       reference to list of resource handles to be added to the
+     *                                   collection resource
+     * @throws OcException
+     */
+    public static void bindResources(
+            OcResourceHandle ocResourceCollectionHandle,
+            List<OcResourceHandle> ocResourceHandleList) throws OcException {
+        OcPlatform.initCheck();
+        OcPlatform.bindResources0(
+                ocResourceCollectionHandle,
+                ocResourceHandleList.toArray(
+                        new OcResourceHandle[ocResourceHandleList.size()])
+        );
+    }
+
+    private static native void bindResources0(
+            OcResourceHandle ocResourceCollectionHandle,
+            OcResourceHandle[] ocResourceHandleArray) throws OcException;
+
+    /**
+     * Unbind a resource from a collection resource.
+     *
+     * @param ocResourceCollectionHandle handle to the collection resource
+     * @param ocResourceHandle           resource handle to be unbound from the collection resource
+     * @throws OcException
+     */
+    public static void unbindResource(
+            OcResourceHandle ocResourceCollectionHandle,
+            OcResourceHandle ocResourceHandle) throws OcException {
+        OcPlatform.initCheck();
+        OcPlatform.unbindResource0(ocResourceCollectionHandle, ocResourceHandle);
+    }
+
+    private static native void unbindResource0(
+            OcResourceHandle ocResourceCollectionHandle,
+            OcResourceHandle ocResourceHandle) throws OcException;
+
+    /**
+     * Unbind resources from a collection resource.
+     *
+     * @param ocResourceCollectionHandle Handle to the collection resource
+     * @param ocResourceHandleList       List of resource handles to be unbound from the collection
+     *                                   resource
+     * @throws OcException
+     */
+    public static void unbindResources(
+            OcResourceHandle ocResourceCollectionHandle,
+            List<OcResourceHandle> ocResourceHandleList) throws OcException {
+        OcPlatform.initCheck();
+        OcPlatform.unbindResources0(
+                ocResourceCollectionHandle,
+                ocResourceHandleList.toArray(
+                        new OcResourceHandle[ocResourceHandleList.size()])
+        );
+    }
+
+    private static native void unbindResources0(
+            OcResourceHandle ocResourceCollectionHandle,
+            OcResourceHandle[] ocResourceHandleArray) throws OcException;
+
+    /**
+     * Binds a type to a particular resource
+     *
+     * @param ocResourceHandle handle to the resource
+     * @param resourceTypeName new typename to bind to the resource
+     * @throws OcException
+     */
+    public static void bindTypeToResource(
+            OcResourceHandle ocResourceHandle,
+            String resourceTypeName) throws OcException {
+        OcPlatform.initCheck();
+        OcPlatform.bindTypeToResource0(ocResourceHandle, resourceTypeName);
+    }
+
+    private static native void bindTypeToResource0(
+            OcResourceHandle ocResourceHandle,
+            String resourceTypeName) throws OcException;
+
+    /**
+     * Binds an interface to a particular resource
+     *
+     * @param ocResourceHandle      handle to the resource
+     * @param resourceInterfaceName new interface to bind to the resource
+     * @throws OcException
+     */
+    public static void bindInterfaceToResource(
+            OcResourceHandle ocResourceHandle,
+            String resourceInterfaceName) throws OcException {
+        OcPlatform.initCheck();
+        OcPlatform.bindInterfaceToResource0(ocResourceHandle, resourceInterfaceName);
+    }
+
+    private static native void bindInterfaceToResource0(
+            OcResourceHandle ocResourceHandle,
+            String resourceInterfaceName) throws OcException;
+
+    /**
+     * Start Presence announcements.
+     *
+     * @param ttl time to live in seconds
+     * @throws OcException
+     */
+    public static void startPresence(int ttl) throws OcException {
+        OcPlatform.initCheck();
+        OcPlatform.startPresence0(ttl);
+    }
+
+    private static native void startPresence0(int ttl) throws OcException;
+
+    /**
+     * Stop Presence announcements.
+     *
+     * @throws OcException
+     */
+    public static void stopPresence() throws OcException {
+        OcPlatform.initCheck();
+        OcPlatform.stopPresence0();
+    }
+
+    private static native void stopPresence0() throws OcException;
+
+    /**
+     * Subscribes to a server's presence change events. By making this subscription, every time a
+     * server adds/removes/alters a resource, starts or is intentionally stopped
+     *
+     * @param host               The IP address/addressable name of the server to subscribe to
+     * @param connectivityType   a type of connectivity indicating the interface. Example: IPV4,
+     *                           IPV6, ALL
+     * @param onPresenceListener listener that will receive notifications/subscription events
+     * @return a handle object that can be used to identify this subscription request. It can be
+     * used to unsubscribe from these events in the future
+     * @throws OcException
+     */
+    public static OcPresenceHandle subscribePresence(
+            String host,
+            OcConnectivityType connectivityType,
+            OnPresenceListener onPresenceListener) throws OcException {
+        OcPlatform.initCheck();
+        return OcPlatform.subscribePresence0(
+                host,
+                connectivityType.getValue(),
+                onPresenceListener
+        );
+    }
+
+    private static native OcPresenceHandle subscribePresence0(
+            String host,
+            int connectivityType,
+            OnPresenceListener onPresenceListener) throws OcException;
+
+    /**
+     * Subscribes to a server's presence change events. By making this subscription, every time a
+     * server adds/removes/alters a resource, starts or is intentionally stopped
+     *
+     * @param host               The IP address/addressable name of the server to subscribe to
+     * @param resourceType       a resource type specified as a filter for subscription events.
+     * @param connectivityType   a type of connectivity indicating the interface. Example: IPV4,
+     *                           IPV6, ALL
+     * @param onPresenceListener listener that will receive notifications/subscription events
+     * @return a handle object that can be used to identify this subscription request. It can be
+     * used to unsubscribe from these events in the future
+     * @throws OcException
+     */
+    public static OcPresenceHandle subscribePresence(
+            String host,
+            String resourceType,
+            OcConnectivityType connectivityType,
+            OnPresenceListener onPresenceListener) throws OcException {
+        OcPlatform.initCheck();
+        return OcPlatform.subscribePresence1(
+                host,
+                resourceType,
+                connectivityType.getValue(),
+                onPresenceListener);
+    }
+
+    private static native OcPresenceHandle subscribePresence1(
+            String host,
+            String resourceType,
+            int connectivityType,
+            OnPresenceListener onPresenceListener) throws OcException;
+
+    /**
+     * Unsubscribes from a previously subscribed server's presence events. Note that you may for
+     * a short time still receive events from the server since it may take time for the
+     * unsubscribe to take effect.
+     *
+     * @param ocPresenceHandle the handle object provided by the subscribePresence call that
+     *                         identifies this subscription
+     * @throws OcException
+     */
+    public static void unsubscribePresence(
+            OcPresenceHandle ocPresenceHandle) throws OcException {
+        OcPlatform.initCheck();
+        OcPlatform.unsubscribePresence0(ocPresenceHandle);
+    }
+
+    private static native void unsubscribePresence0(
+            OcPresenceHandle ocPresenceHandle) throws OcException;
+
+    /**
+     * Creates a resource proxy object so that get/put/observe functionality can be used without
+     * discovering the object in advance. Note that the consumer of this method needs to provide
+     * all of the details required to correctly contact and observe the object. If the consumer
+     * lacks any of this information, they should discover the resource object normally.
+     * Additionally, you can only create this object if OcPlatform was initialized to be a Client
+     * or Client/Server.
+     *
+     * @param host             a string containing a resolvable host address of the server holding
+     *                         the resource
+     * @param uri              the rest of the resource's URI that will permit messages to be
+     *                         properly routed.
+     *                         Example: /a/light
+     * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
+     *                         IPV6, ALL
+     * @param isObservable     a boolean containing whether the resource supports observation
+     * @param resourceTypeList a collection of resource types implemented by the resource
+     * @param interfaceList    a collection of interfaces that the resource supports/implements
+     * @return new resource object
+     * @throws OcException
+     */
+    public static OcResource constructResourceObject(
+            String host,
+            String uri,
+            OcConnectivityType connectivityType,
+            boolean isObservable,
+            List<String> resourceTypeList,
+            List<String> interfaceList) throws OcException {
+        OcPlatform.initCheck();
+        return OcPlatform.constructResourceObject0(
+                host,
+                uri,
+                connectivityType.getValue(),
+                isObservable,
+                resourceTypeList.toArray(new String[resourceTypeList.size()]),
+                interfaceList.toArray(new String[interfaceList.size()])
+        );
+    }
+
+    private static native OcResource constructResourceObject0(
+            String host,
+            String uri,
+            int connectivityType,
+            boolean isObservable,
+            String[] resourceTypes,
+            String[] interfaces) throws OcException;
+
+    /**
+     * Allows application entity handler to send response to an incoming request.
+     *
+     * @param ocResourceResponse resource response
+     * @throws OcException
+     */
+    public static void sendResponse(OcResourceResponse ocResourceResponse)
+            throws OcException {
+        OcPlatform.initCheck();
+        OcPlatform.sendResponse0(ocResourceResponse);
+    }
+
+    private static native void sendResponse0(OcResourceResponse ocResourceResponse)
+            throws OcException;
+
+    /**
+     * An OnResourceFoundListener can be registered via the OcPlatform.findResource call.
+     * Event listeners are notified asynchronously
+     */
+    public interface OnResourceFoundListener {
+        public void onResourceFound(OcResource resource);
+    }
+
+    /**
+     * An OnDeviceFoundListener can be registered via the OcPlatform.getDeviceInfo call.
+     * Event listeners are notified asynchronously
+     */
+    public interface OnDeviceFoundListener {
+        public void onDeviceFound(OcRepresentation ocRepresentation);
     }
 
     /**
@@ -837,28 +837,28 @@ public final class OcPlatform {
      */
     public interface OnPlatformFoundListener {
         public void onPlatformFound(OcRepresentation ocRepresentation);
-    }\r
-\r
-    /**\r
-     * An OnPresenceListener can be registered via the OcPlatform.subscribePresence call.\r
-     * Event listeners are notified asynchronously\r
-     */\r
-    public interface OnPresenceListener {\r
-        public void onPresence(OcPresenceStatus ocPresenceStatus, int nonce, String hostAddress);\r
-    }\r
-\r
-    /**\r
-     * An EntityHandler can be registered via the OcPlatform.registerResource call.\r
-     * Event listeners are notified asynchronously\r
-     */\r
-    public interface EntityHandler {\r
-        public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest);\r
-    }\r
-\r
-    private static void initCheck() {\r
-        if (!sIsPlatformInitialized) {\r
-            throw new IllegalStateException("OcPlatform must be configured by making a call to " +\r
-                    "OcPlatform.Configure before any other API calls are permitted");\r
-        }\r
-    }\r
-}\r
+    }
+
+    /**
+     * An OnPresenceListener can be registered via the OcPlatform.subscribePresence call.
+     * Event listeners are notified asynchronously
+     */
+    public interface OnPresenceListener {
+        public void onPresence(OcPresenceStatus ocPresenceStatus, int nonce, String hostAddress);
+    }
+
+    /**
+     * An EntityHandler can be registered via the OcPlatform.registerResource call.
+     * Event listeners are notified asynchronously
+     */
+    public interface EntityHandler {
+        public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest);
+    }
+
+    private static void initCheck() {
+        if (!sIsPlatformInitialized) {
+            throw new IllegalStateException("OcPlatform must be configured by making a call to " +
+                    "OcPlatform.Configure before any other API calls are permitted");
+        }
+    }
+}
index 4ef76da..9addbf7 100644 (file)
@@ -1,39 +1,39 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-\r
-public enum OcPlatformStatus {\r
-    UP(0),\r
-    DOWN(1),;\r
-\r
-    private int value;\r
-\r
-    private OcPlatformStatus(int value) {\r
-        this.value = value;\r
-    }\r
-\r
-    public int getValue() {\r
-        return this.value;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+
+public enum OcPlatformStatus {
+    UP(0),
+    DOWN(1),;
+
+    private int value;
+
+    private OcPlatformStatus(int value) {
+        this.value = value;
+    }
+
+    public int getValue() {
+        return this.value;
+    }
+}
index 184be8f..ae7ed15 100644 (file)
@@ -1,41 +1,41 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-public class OcPresenceHandle {\r
-\r
-    private OcPresenceHandle(long nativeHandle) {\r
-        this.mNativeHandle = nativeHandle;\r
-    }\r
-\r
-    @Override\r
-    protected void finalize() throws Throwable {\r
-        super.finalize();\r
-\r
-        dispose();\r
-    }\r
-\r
-    private native void dispose();\r
-\r
-    private long mNativeHandle;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+public class OcPresenceHandle {
+
+    private OcPresenceHandle(long nativeHandle) {
+        this.mNativeHandle = nativeHandle;
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        super.finalize();
+
+        dispose();
+    }
+
+    private native void dispose();
+
+    private long mNativeHandle;
+}
index ff2c7dc..02b774f 100644 (file)
@@ -1,50 +1,50 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-import java.security.InvalidParameterException;\r
-\r
-public enum OcPresenceStatus {\r
-    OK("OK"),\r
-    STOPPED("PRESENCE_STOPPED"),\r
-    TIMEOUT("PRESENCE_TIMEOUT"),\r
-    DO_NOT_HANDLE("PRESENCE_DO_NOT_HANDLE");\r
-\r
-    private String value;\r
-\r
-    private OcPresenceStatus(String value) {\r
-        this.value = value;\r
-    }\r
-\r
-    public static OcPresenceStatus get(String val) {\r
-        for (OcPresenceStatus v : OcPresenceStatus.values()) {\r
-            if (v.getValue().equals(val))\r
-                return v;\r
-        }\r
-        throw new InvalidParameterException("Unexpected OcPresenceStatus value");\r
-    }\r
-\r
-    public String getValue() {\r
-        return this.value;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+import java.security.InvalidParameterException;
+
+public enum OcPresenceStatus {
+    OK("OK"),
+    STOPPED("PRESENCE_STOPPED"),
+    TIMEOUT("PRESENCE_TIMEOUT"),
+    DO_NOT_HANDLE("PRESENCE_DO_NOT_HANDLE");
+
+    private String value;
+
+    private OcPresenceStatus(String value) {
+        this.value = value;
+    }
+
+    public static OcPresenceStatus get(String val) {
+        for (OcPresenceStatus v : OcPresenceStatus.values()) {
+            if (v.getValue().equals(val))
+                return v;
+        }
+        throw new InvalidParameterException("Unexpected OcPresenceStatus value");
+    }
+
+    public String getValue() {
+        return this.value;
+    }
+}
index 23daba0..8dca1cc 100644 (file)
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-import java.security.InvalidParameterException;\r
-import java.util.Arrays;\r
-import java.util.List;\r
-\r
-/**\r
- *\r
- */\r
-public class OcRepresentation {\r
-\r
-    static {\r
-        System.loadLibrary("oc");\r
-        System.loadLibrary("ocstack-jni");\r
-    }\r
-\r
-    public OcRepresentation() {\r
-        create();\r
-        //Native OCRepresentation object was created using "new" and needs to be deleted\r
-        this.mNativeNeedsDelete = true;\r
-    }\r
-\r
-    private OcRepresentation(long nativeHandle) {\r
-        this.mNativeHandle = nativeHandle;\r
-        this.mNativeNeedsDelete = false;\r
-    }\r
-\r
-    private OcRepresentation(long nativeHandle, boolean nativeNeedsDelete) {\r
-        this.mNativeHandle = nativeHandle;\r
-        this.mNativeNeedsDelete = nativeNeedsDelete;\r
-    }\r
-\r
-    public <T> T getValue(String key) throws OcException {\r
-        Object obj = this.getValueN(key);\r
-        @SuppressWarnings("unchecked")\r
-        T t = (T) obj;\r
-        return t;\r
-    }\r
-\r
-    private native Object getValueN(String key);\r
-\r
-    public void setValue(String key, int value) throws OcException {\r
-        this.setValueInteger(key, value);\r
-    }\r
-\r
-    public void setValue(String key, double value) throws OcException {\r
-        this.setValueDouble(key, value);\r
-    }\r
-\r
-    public void setValue(String key, boolean value) throws OcException {\r
-        this.setValueBoolean(key, value);\r
-    }\r
-\r
-    public void setValue(String key, String value) throws OcException {\r
-        this.setValueStringN(key, value);\r
-    }\r
-\r
-    public void setValue(String key, OcRepresentation value) throws OcException {\r
-        this.setValueRepresentation(key, value);\r
-    }\r
-\r
-    public void setValue(String key, int[] value) throws OcException {\r
-        this.setValueIntegerArray(key, value);\r
-    }\r
-\r
-    public void setValue(String key, int[][] value) throws OcException {\r
-        this.setValueInteger2DArray(key, value);\r
-    }\r
-\r
-    public void setValue(String key, int[][][] value) throws OcException {\r
-        this.setValueInteger3DArray(key, value);\r
-    }\r
-\r
-    public void setValue(String key, double[] value) throws OcException {\r
-        this.setValueDoubleArray(key, value);\r
-    }\r
-\r
-    public void setValue(String key, double[][] value) throws OcException {\r
-        this.setValueDouble2DArray(key, value);\r
-    }\r
-\r
-    public void setValue(String key, double[][][] value) throws OcException {\r
-        this.setValueDouble3DArray(key, value);\r
-    }\r
-\r
-    public void setValue(String key, boolean[] value) throws OcException {\r
-        this.setValueBooleanArray(key, value);\r
-    }\r
-\r
-    public void setValue(String key, boolean[][] value) throws OcException {\r
-        this.setValueBoolean2DArray(key, value);\r
-    }\r
-\r
-    public void setValue(String key, boolean[][][] value) throws OcException {\r
-        this.setValueBoolean3DArray(key, value);\r
-    }\r
-\r
-    public void setValue(String key, String[] value) throws OcException {\r
-        this.setValueStringArray(key, value);\r
-    }\r
-\r
-    public void setValue(String key, String[][] value) throws OcException {\r
-        this.setValueString2DArray(key, value);\r
-    }\r
-\r
-    public void setValue(String key, String[][][] value) throws OcException {\r
-        this.setValueString3DArray(key, value);\r
-    }\r
-\r
-    public void setValue(String key, OcRepresentation[] value) throws OcException {\r
-        this.setValueRepresentationArray(key, value);\r
-    }\r
-\r
-    public void setValue(String key, OcRepresentation[][] value) throws OcException {\r
-        this.setValueRepresentation2DArray(key, value);\r
-    }\r
-\r
-    public void setValue(String key, OcRepresentation[][][] value) throws OcException {\r
-        this.setValueRepresentation3DArray(key, value);\r
-    }\r
-\r
-    private native void setValueInteger(String key, int value) throws OcException;\r
-\r
-    private native void setValueDouble(String key, double value) throws OcException;\r
-\r
-    private native void setValueBoolean(String key, boolean value) throws OcException;\r
-\r
-    private native void setValueStringN(String key, String value) throws OcException;\r
-\r
-    private native void setValueRepresentation(String key, OcRepresentation value) throws OcException;\r
-\r
-    private native void setValueIntegerArray(String key, int[] value) throws OcException;\r
-\r
-    private native void setValueInteger2DArray(String key, int[][] value) throws OcException;\r
-\r
-    private native void setValueInteger3DArray(String key, int[][][] value) throws OcException;\r
-\r
-    private native void setValueDoubleArray(String key, double[] value) throws OcException;\r
-\r
-    private native void setValueDouble2DArray(String key, double[][] value) throws OcException;\r
-\r
-    private native void setValueDouble3DArray(String key, double[][][] value) throws OcException;\r
-\r
-    private native void setValueBooleanArray(String key, boolean[] value) throws OcException;\r
-\r
-    private native void setValueBoolean2DArray(String key, boolean[][] value) throws OcException;\r
-\r
-    private native void setValueBoolean3DArray(String key, boolean[][][] value) throws OcException;\r
-\r
-    private native void setValueStringArray(String key, String[] value) throws OcException;\r
-\r
-    private native void setValueString2DArray(String key, String[][] value) throws OcException;\r
-\r
-    private native void setValueString3DArray(String key, String[][][] value) throws OcException;\r
-\r
-    private native void setValueRepresentationArray(String key, OcRepresentation[] value) throws OcException;\r
-\r
-    private native void setValueRepresentation2DArray(String key, OcRepresentation[][] value) throws OcException;\r
-\r
-    private native void setValueRepresentation3DArray(String key, OcRepresentation[][][] value) throws OcException;\r
-\r
-    /**\r
-     * @deprecated use {@link #getValue(String key)} instead.\r
-     */\r
-    @Deprecated\r
-    public int getValueInt(String key) {\r
-        Integer value = 0;\r
-        try {\r
-            value = this.getValue(key);\r
-        } catch (OcException e) {\r
-            //simply catching here for the deprecated APIs, so the older usages don't have to handle\r
-            //it in the code\r
-        }\r
-        return value;\r
-    }\r
-\r
-    /**\r
-     * @deprecated use {@link #getValue(String key)} instead.\r
-     */\r
-    @Deprecated\r
-    public boolean getValueBool(String key) {\r
-        Boolean value = false;\r
-        try {\r
-            value = this.getValue(key);\r
-        } catch (OcException e) {\r
-            //simply catching here for the deprecated APIs, so the older usages don't have to handle\r
-            //it in the code\r
-        }\r
-        return value;\r
-    }\r
-\r
-    /**\r
-     * @deprecated use {@link #getValue(String key)} instead.\r
-     */\r
-    @Deprecated\r
-    public String getValueString(String key) {\r
-        String value = "";\r
-        try {\r
-            value = this.getValue(key);\r
-        } catch (OcException e) {\r
-            //simply catching here for the deprecated APIs, so the older usages don't have to handle\r
-            //it in the code\r
-        }\r
-        return value;\r
-    }\r
-\r
-    /**\r
-     * @deprecated use {@link #setValue(String key, int value)} instead.\r
-     */\r
-    @Deprecated\r
-    public void setValueInt(String key, int value) {\r
-        try {\r
-            this.setValue(key, value);\r
-        } catch (OcException e) {\r
-            //simply catching here for the deprecated APIs, so the older usages don't have to handle\r
-            //it in the code\r
-        }\r
-    }\r
-\r
-    /**\r
-     * @deprecated use {@link #setValue(String key, boolean value)} instead.\r
-     */\r
-    @Deprecated\r
-    public void setValueBool(String key, boolean value) {\r
-        try {\r
-            this.setValue(key, value);\r
-        } catch (OcException e) {\r
-            //simply catching here for the deprecated APIs, so the older usages don't have to handle\r
-            //it in the code\r
-        }\r
-    }\r
-\r
-    /**\r
-     * @deprecated use {@link #setValue(String key, String value)} instead.\r
-     */\r
-    @Deprecated\r
-    public void setValueString(String key, String value) {\r
-        try {\r
-            this.setValue(key, value);\r
-        } catch (OcException e) {\r
-            //simply catching here for the deprecated APIs, so the older usages don't have to handle\r
-            //it in the code\r
-        }\r
-    }\r
-\r
-    public native String getJSONRepresentation();\r
-\r
-    public native void addChild(OcRepresentation representation);\r
-\r
-    public native void clearChildren();\r
-\r
-    public List<OcRepresentation> getChildren() {\r
-        return Arrays.asList(\r
-                getChildrenArray());\r
-    }\r
-\r
-    private native OcRepresentation[] getChildrenArray();\r
-\r
-    public native String getUri();\r
-\r
-    public native void setUri(String uri);\r
-\r
-    /**\r
-     * Method to get the list of resource types\r
-     *\r
-     * @return List of resource types\r
-     */\r
-    public native List<String> getResourceTypes();\r
-\r
-    /**\r
-     * Method to set the list of resource types\r
-     *\r
-     * @param resourceTypeList list of resources\r
-     */\r
-    public void setResourceTypes(List<String> resourceTypeList) {\r
-        if (null == resourceTypeList) {\r
-            throw new InvalidParameterException("resourceTypeList cannot be null");\r
-        }\r
-\r
-        this.setResourceTypeArray(\r
-                resourceTypeList.toArray(\r
-                        new String[resourceTypeList.size()]));\r
-    }\r
-\r
-    private native void setResourceTypeArray(String[] resourceTypeArray);\r
-\r
-    /**\r
-     * Method to get the list of resource interfaces\r
-     *\r
-     * @return List of resource interface\r
-     */\r
-    public native List<String> getResourceInterfaces();\r
-\r
-    /**\r
-     * Method to set the list of resource interfaces\r
-     *\r
-     * @param resourceInterfaceList list of interfaces\r
-     */\r
-    public void setResourceInterfaces(List<String> resourceInterfaceList) {\r
-        if (null == resourceInterfaceList) {\r
-            throw new InvalidParameterException("resourceInterfaceList cannot be null");\r
-        }\r
-\r
-        this.setResourceInterfaceArray(\r
-                resourceInterfaceList.toArray(\r
-                        new String[resourceInterfaceList.size()]));\r
-    }\r
-\r
-    private native void setResourceInterfaceArray(String[] resourceInterfaceArray);\r
-\r
-    public native boolean isEmpty();\r
-\r
-    public native int size();\r
-\r
-    public native boolean remove(String key);\r
-\r
-    public native boolean hasAttribute(String key);\r
-\r
-    public native void setNull(String key);\r
-\r
-    public native boolean isNull(String key);\r
-\r
-    @Override\r
-    protected void finalize() throws Throwable {\r
-        super.finalize();\r
-\r
-        dispose(this.mNativeNeedsDelete);\r
-    }\r
-\r
-    private native void create();\r
-\r
-    private native void dispose(boolean needsDelete);\r
-\r
-    private long mNativeHandle;\r
-    private boolean mNativeNeedsDelete;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+import java.security.InvalidParameterException;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ *
+ */
+public class OcRepresentation {
+
+    static {
+        System.loadLibrary("oc");
+        System.loadLibrary("ocstack-jni");
+    }
+
+    public OcRepresentation() {
+        create();
+        //Native OCRepresentation object was created using "new" and needs to be deleted
+        this.mNativeNeedsDelete = true;
+    }
+
+    private OcRepresentation(long nativeHandle) {
+        this.mNativeHandle = nativeHandle;
+        this.mNativeNeedsDelete = false;
+    }
+
+    private OcRepresentation(long nativeHandle, boolean nativeNeedsDelete) {
+        this.mNativeHandle = nativeHandle;
+        this.mNativeNeedsDelete = nativeNeedsDelete;
+    }
+
+    public <T> T getValue(String key) throws OcException {
+        Object obj = this.getValueN(key);
+        @SuppressWarnings("unchecked")
+        T t = (T) obj;
+        return t;
+    }
+
+    private native Object getValueN(String key);
+
+    public void setValue(String key, int value) throws OcException {
+        this.setValueInteger(key, value);
+    }
+
+    public void setValue(String key, double value) throws OcException {
+        this.setValueDouble(key, value);
+    }
+
+    public void setValue(String key, boolean value) throws OcException {
+        this.setValueBoolean(key, value);
+    }
+
+    public void setValue(String key, String value) throws OcException {
+        this.setValueStringN(key, value);
+    }
+
+    public void setValue(String key, OcRepresentation value) throws OcException {
+        this.setValueRepresentation(key, value);
+    }
+
+    public void setValue(String key, int[] value) throws OcException {
+        this.setValueIntegerArray(key, value);
+    }
+
+    public void setValue(String key, int[][] value) throws OcException {
+        this.setValueInteger2DArray(key, value);
+    }
+
+    public void setValue(String key, int[][][] value) throws OcException {
+        this.setValueInteger3DArray(key, value);
+    }
+
+    public void setValue(String key, double[] value) throws OcException {
+        this.setValueDoubleArray(key, value);
+    }
+
+    public void setValue(String key, double[][] value) throws OcException {
+        this.setValueDouble2DArray(key, value);
+    }
+
+    public void setValue(String key, double[][][] value) throws OcException {
+        this.setValueDouble3DArray(key, value);
+    }
+
+    public void setValue(String key, boolean[] value) throws OcException {
+        this.setValueBooleanArray(key, value);
+    }
+
+    public void setValue(String key, boolean[][] value) throws OcException {
+        this.setValueBoolean2DArray(key, value);
+    }
+
+    public void setValue(String key, boolean[][][] value) throws OcException {
+        this.setValueBoolean3DArray(key, value);
+    }
+
+    public void setValue(String key, String[] value) throws OcException {
+        this.setValueStringArray(key, value);
+    }
+
+    public void setValue(String key, String[][] value) throws OcException {
+        this.setValueString2DArray(key, value);
+    }
+
+    public void setValue(String key, String[][][] value) throws OcException {
+        this.setValueString3DArray(key, value);
+    }
+
+    public void setValue(String key, OcRepresentation[] value) throws OcException {
+        this.setValueRepresentationArray(key, value);
+    }
+
+    public void setValue(String key, OcRepresentation[][] value) throws OcException {
+        this.setValueRepresentation2DArray(key, value);
+    }
+
+    public void setValue(String key, OcRepresentation[][][] value) throws OcException {
+        this.setValueRepresentation3DArray(key, value);
+    }
+
+    private native void setValueInteger(String key, int value) throws OcException;
+
+    private native void setValueDouble(String key, double value) throws OcException;
+
+    private native void setValueBoolean(String key, boolean value) throws OcException;
+
+    private native void setValueStringN(String key, String value) throws OcException;
+
+    private native void setValueRepresentation(String key, OcRepresentation value) throws OcException;
+
+    private native void setValueIntegerArray(String key, int[] value) throws OcException;
+
+    private native void setValueInteger2DArray(String key, int[][] value) throws OcException;
+
+    private native void setValueInteger3DArray(String key, int[][][] value) throws OcException;
+
+    private native void setValueDoubleArray(String key, double[] value) throws OcException;
+
+    private native void setValueDouble2DArray(String key, double[][] value) throws OcException;
+
+    private native void setValueDouble3DArray(String key, double[][][] value) throws OcException;
+
+    private native void setValueBooleanArray(String key, boolean[] value) throws OcException;
+
+    private native void setValueBoolean2DArray(String key, boolean[][] value) throws OcException;
+
+    private native void setValueBoolean3DArray(String key, boolean[][][] value) throws OcException;
+
+    private native void setValueStringArray(String key, String[] value) throws OcException;
+
+    private native void setValueString2DArray(String key, String[][] value) throws OcException;
+
+    private native void setValueString3DArray(String key, String[][][] value) throws OcException;
+
+    private native void setValueRepresentationArray(String key, OcRepresentation[] value) throws OcException;
+
+    private native void setValueRepresentation2DArray(String key, OcRepresentation[][] value) throws OcException;
+
+    private native void setValueRepresentation3DArray(String key, OcRepresentation[][][] value) throws OcException;
+
+    /**
+     * @deprecated use {@link #getValue(String key)} instead.
+     */
+    @Deprecated
+    public int getValueInt(String key) {
+        Integer value = 0;
+        try {
+            value = this.getValue(key);
+        } catch (OcException e) {
+            //simply catching here for the deprecated APIs, so the older usages don't have to handle
+            //it in the code
+        }
+        return value;
+    }
+
+    /**
+     * @deprecated use {@link #getValue(String key)} instead.
+     */
+    @Deprecated
+    public boolean getValueBool(String key) {
+        Boolean value = false;
+        try {
+            value = this.getValue(key);
+        } catch (OcException e) {
+            //simply catching here for the deprecated APIs, so the older usages don't have to handle
+            //it in the code
+        }
+        return value;
+    }
+
+    /**
+     * @deprecated use {@link #getValue(String key)} instead.
+     */
+    @Deprecated
+    public String getValueString(String key) {
+        String value = "";
+        try {
+            value = this.getValue(key);
+        } catch (OcException e) {
+            //simply catching here for the deprecated APIs, so the older usages don't have to handle
+            //it in the code
+        }
+        return value;
+    }
+
+    /**
+     * @deprecated use {@link #setValue(String key, int value)} instead.
+     */
+    @Deprecated
+    public void setValueInt(String key, int value) {
+        try {
+            this.setValue(key, value);
+        } catch (OcException e) {
+            //simply catching here for the deprecated APIs, so the older usages don't have to handle
+            //it in the code
+        }
+    }
+
+    /**
+     * @deprecated use {@link #setValue(String key, boolean value)} instead.
+     */
+    @Deprecated
+    public void setValueBool(String key, boolean value) {
+        try {
+            this.setValue(key, value);
+        } catch (OcException e) {
+            //simply catching here for the deprecated APIs, so the older usages don't have to handle
+            //it in the code
+        }
+    }
+
+    /**
+     * @deprecated use {@link #setValue(String key, String value)} instead.
+     */
+    @Deprecated
+    public void setValueString(String key, String value) {
+        try {
+            this.setValue(key, value);
+        } catch (OcException e) {
+            //simply catching here for the deprecated APIs, so the older usages don't have to handle
+            //it in the code
+        }
+    }
+
+    public native String getJSONRepresentation();
+
+    public native void addChild(OcRepresentation representation);
+
+    public native void clearChildren();
+
+    public List<OcRepresentation> getChildren() {
+        return Arrays.asList(
+                getChildrenArray());
+    }
+
+    private native OcRepresentation[] getChildrenArray();
+
+    public native String getUri();
+
+    public native void setUri(String uri);
+
+    /**
+     * Method to get the list of resource types
+     *
+     * @return List of resource types
+     */
+    public native List<String> getResourceTypes();
+
+    /**
+     * Method to set the list of resource types
+     *
+     * @param resourceTypeList list of resources
+     */
+    public void setResourceTypes(List<String> resourceTypeList) {
+        if (null == resourceTypeList) {
+            throw new InvalidParameterException("resourceTypeList cannot be null");
+        }
+
+        this.setResourceTypeArray(
+                resourceTypeList.toArray(
+                        new String[resourceTypeList.size()]));
+    }
+
+    private native void setResourceTypeArray(String[] resourceTypeArray);
+
+    /**
+     * Method to get the list of resource interfaces
+     *
+     * @return List of resource interface
+     */
+    public native List<String> getResourceInterfaces();
+
+    /**
+     * Method to set the list of resource interfaces
+     *
+     * @param resourceInterfaceList list of interfaces
+     */
+    public void setResourceInterfaces(List<String> resourceInterfaceList) {
+        if (null == resourceInterfaceList) {
+            throw new InvalidParameterException("resourceInterfaceList cannot be null");
+        }
+
+        this.setResourceInterfaceArray(
+                resourceInterfaceList.toArray(
+                        new String[resourceInterfaceList.size()]));
+    }
+
+    private native void setResourceInterfaceArray(String[] resourceInterfaceArray);
+
+    public native boolean isEmpty();
+
+    public native int size();
+
+    public native boolean remove(String key);
+
+    public native boolean hasAttribute(String key);
+
+    public native void setNull(String key);
+
+    public native boolean isNull(String key);
+
+    @Override
+    protected void finalize() throws Throwable {
+        super.finalize();
+
+        dispose(this.mNativeNeedsDelete);
+    }
+
+    private native void create();
+
+    private native void dispose(boolean needsDelete);
+
+    private long mNativeHandle;
+    private boolean mNativeNeedsDelete;
 }
\ No newline at end of file
index 73cd14b..7e021dc 100644 (file)
@@ -1,41 +1,41 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-public class OcRequestHandle {\r
-\r
-    private OcRequestHandle(long nativeHandle) {\r
-        this.mNativeHandle = nativeHandle;\r
-    }\r
-\r
-    @Override\r
-    protected void finalize() throws Throwable {\r
-        super.finalize();\r
-\r
-        dispose();\r
-    }\r
-\r
-    private native void dispose();\r
-\r
-    private long mNativeHandle;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+public class OcRequestHandle {
+
+    private OcRequestHandle(long nativeHandle) {
+        this.mNativeHandle = nativeHandle;
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        super.finalize();
+
+        dispose();
+    }
+
+    private native void dispose();
+
+    private long mNativeHandle;
+}
index 3bab82f..b55ce65 100644 (file)
@@ -1,41 +1,41 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-public class OcResourceHandle {\r
-\r
-    private OcResourceHandle(long nativeHandle) {\r
-        this.mNativeHandle = nativeHandle;\r
-    }\r
-\r
-    @Override\r
-    protected void finalize() throws Throwable {\r
-        super.finalize();\r
-\r
-        dispose();\r
-    }\r
-\r
-    private native void dispose();\r
-\r
-    private long mNativeHandle;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+public class OcResourceHandle {
+
+    private OcResourceHandle(long nativeHandle) {
+        this.mNativeHandle = nativeHandle;
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        super.finalize();
+
+        dispose();
+    }
+
+    private native void dispose();
+
+    private long mNativeHandle;
+}
index a1de037..6725b16 100644 (file)
@@ -1,51 +1,51 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-public class OcResourceIdentifier {\r
-    private OcResourceIdentifier(long nativeHandle) {\r
-        this.mNativeHandle = nativeHandle;\r
-    }\r
-\r
-    @Override\r
-    protected void finalize() throws Throwable {\r
-        super.finalize();\r
-\r
-        dispose();\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (!(obj instanceof OcResourceIdentifier)) {\r
-            return false;\r
-        }\r
-        OcResourceIdentifier other = (OcResourceIdentifier) obj;\r
-        return equalsN(other);\r
-    }\r
-\r
-    private native boolean equalsN(OcResourceIdentifier other);\r
-\r
-    private native void dispose();\r
-\r
-    private long mNativeHandle;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+public class OcResourceIdentifier {
+    private OcResourceIdentifier(long nativeHandle) {
+        this.mNativeHandle = nativeHandle;
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        super.finalize();
+
+        dispose();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof OcResourceIdentifier)) {
+            return false;
+        }
+        OcResourceIdentifier other = (OcResourceIdentifier) obj;
+        return equalsN(other);
+    }
+
+    private native boolean equalsN(OcResourceIdentifier other);
+
+    private native void dispose();
+
+    private long mNativeHandle;
+}
index 5a24b02..7e0367f 100644 (file)
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-import java.util.EnumSet;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-/**\r
- * OcResourceRequest provides APIs to extract details from a request\r
- */\r
-public class OcResourceRequest {\r
-\r
-    private OcResourceRequest(long nativeHandle) {\r
-        this.mNativeHandle = nativeHandle;\r
-    }\r
-\r
-    /**\r
-     * Retrieves the type of request for the entity handler function to operate\r
-     *\r
-     * @return request type. This could be 'GET'/'PUT'/'POST'/'DELETE'\r
-     */\r
-    public RequestType getRequestType() {\r
-        return RequestType.get(getRequestTypeNative());\r
-    }\r
-\r
-    private native String getRequestTypeNative();\r
-\r
-    /**\r
-     * Retrieves the query parameters from the request\r
-     *\r
-     * @return parameters in the request\r
-     */\r
-    public native Map<String, String> getQueryParameters();\r
-\r
-    /**\r
-     * Retrieves the request handler flag set. This can be INIT flag and/or REQUEST flag and/or\r
-     * OBSERVE flag.\r
-     * NOTE:\r
-     * INIT indicates that the vendor's entity handler should go and perform\r
-     * initialization operations\r
-     * REQUEST indicates that it is a request of certain type (GET/PUT/POST/DELETE) and entity\r
-     * handler needs to perform corresponding operations\r
-     * OBSERVE indicates that the request is of type Observe and entity handler needs to perform\r
-     * corresponding operations\r
-     *\r
-     * @return Set of handler flags\r
-     */\r
-    public EnumSet<RequestHandlerFlag> getRequestHandlerFlagSet() {\r
-        return RequestHandlerFlag.convertToEnumSet(getRequestHandlerFlagNative());\r
-    }\r
-\r
-    private native int getRequestHandlerFlagNative();\r
-\r
-    /**\r
-     * Provides the entire resource attribute representation\r
-     *\r
-     * @return OcRepresentation object containing the name value pairs representing\r
-     * the resource's attributes\r
-     */\r
-    public native OcRepresentation getResourceRepresentation();\r
-\r
-    /**\r
-     * Object provides observation information\r
-     *\r
-     * @return observation information\r
-     */\r
-    public native ObservationInfo getObservationInfo();\r
-\r
-    /**\r
-     * Specifies the resource uri\r
-     *\r
-     * @param resourceUri resource uri\r
-     */\r
-    public native void setResourceUri(String resourceUri);\r
-\r
-    /**\r
-     * Gets the resource URI\r
-     *\r
-     * @return resource URI\r
-     */\r
-    public native String getResourceUri();\r
-\r
-    /**\r
-     * This API retrieves a list of headerOptions which was sent from a client\r
-     *\r
-     * @return List of header options\r
-     */\r
-    public native List<OcHeaderOption> getHeaderOptions();\r
-\r
-    /**\r
-     * This API retrieves the request handle\r
-     *\r
-     * @return request handle\r
-     */\r
-    public native OcRequestHandle getRequestHandle();\r
-\r
-    /**\r
-     * This API retrieves the resource handle\r
-     *\r
-     * @return resource handle\r
-     */\r
-    public native OcResourceHandle getResourceHandle();\r
-\r
-    @Override\r
-    protected void finalize() throws Throwable {\r
-        super.finalize();\r
-\r
-        dispose();\r
-    }\r
-\r
-    private native void dispose();\r
-\r
-    private long mNativeHandle;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * OcResourceRequest provides APIs to extract details from a request
+ */
+public class OcResourceRequest {
+
+    private OcResourceRequest(long nativeHandle) {
+        this.mNativeHandle = nativeHandle;
+    }
+
+    /**
+     * Retrieves the type of request for the entity handler function to operate
+     *
+     * @return request type. This could be 'GET'/'PUT'/'POST'/'DELETE'
+     */
+    public RequestType getRequestType() {
+        return RequestType.get(getRequestTypeNative());
+    }
+
+    private native String getRequestTypeNative();
+
+    /**
+     * Retrieves the query parameters from the request
+     *
+     * @return parameters in the request
+     */
+    public native Map<String, String> getQueryParameters();
+
+    /**
+     * Retrieves the request handler flag set. This can be INIT flag and/or REQUEST flag and/or
+     * OBSERVE flag.
+     * NOTE:
+     * INIT indicates that the vendor's entity handler should go and perform
+     * initialization operations
+     * REQUEST indicates that it is a request of certain type (GET/PUT/POST/DELETE) and entity
+     * handler needs to perform corresponding operations
+     * OBSERVE indicates that the request is of type Observe and entity handler needs to perform
+     * corresponding operations
+     *
+     * @return Set of handler flags
+     */
+    public EnumSet<RequestHandlerFlag> getRequestHandlerFlagSet() {
+        return RequestHandlerFlag.convertToEnumSet(getRequestHandlerFlagNative());
+    }
+
+    private native int getRequestHandlerFlagNative();
+
+    /**
+     * Provides the entire resource attribute representation
+     *
+     * @return OcRepresentation object containing the name value pairs representing
+     * the resource's attributes
+     */
+    public native OcRepresentation getResourceRepresentation();
+
+    /**
+     * Object provides observation information
+     *
+     * @return observation information
+     */
+    public native ObservationInfo getObservationInfo();
+
+    /**
+     * Specifies the resource uri
+     *
+     * @param resourceUri resource uri
+     */
+    public native void setResourceUri(String resourceUri);
+
+    /**
+     * Gets the resource URI
+     *
+     * @return resource URI
+     */
+    public native String getResourceUri();
+
+    /**
+     * This API retrieves a list of headerOptions which was sent from a client
+     *
+     * @return List of header options
+     */
+    public native List<OcHeaderOption> getHeaderOptions();
+
+    /**
+     * This API retrieves the request handle
+     *
+     * @return request handle
+     */
+    public native OcRequestHandle getRequestHandle();
+
+    /**
+     * This API retrieves the resource handle
+     *
+     * @return resource handle
+     */
+    public native OcResourceHandle getResourceHandle();
+
+    @Override
+    protected void finalize() throws Throwable {
+        super.finalize();
+
+        dispose();
+    }
+
+    private native void dispose();
+
+    private long mNativeHandle;
+}
index 263de42..0356b85 100644 (file)
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-import java.util.List;\r
-\r
-/**\r
- * OcResourceResponse provides APIs to set the response details\r
- */\r
-public class OcResourceResponse {\r
-\r
-    static {\r
-        System.loadLibrary("oc");\r
-        System.loadLibrary("ocstack-jni");\r
-    }\r
-\r
-    public OcResourceResponse() {\r
-        super();\r
-\r
-        create();\r
-    }\r
-\r
-    private OcResourceResponse(long nativeHandle) {\r
-        this.mNativeHandle = nativeHandle;\r
-    }\r
-\r
-    /**\r
-     * This API sets the error code for this response\r
-     *\r
-     * @param eCode error code to set\r
-     */\r
-    public native void setErrorCode(int eCode);\r
-\r
-    /**\r
-     * Gets new resource uri\r
-     *\r
-     * @return new resource uri\r
-     */\r
-    public native String getNewResourceUri();\r
-\r
-    /**\r
-     * Sets new resource uri\r
-     *\r
-     * @param newResourceUri new resource uri\r
-     */\r
-    public native void setNewResourceUri(String newResourceUri);\r
-\r
-    /**\r
-     * This API allows to set headerOptions in the response\r
-     *\r
-     * @param headerOptionList List of HeaderOption entries\r
-     */\r
-    public void setHeaderOptions(List<OcHeaderOption> headerOptionList) {\r
-        this.setHeaderOptions(headerOptionList.toArray(\r
-                        new OcHeaderOption[headerOptionList.size()])\r
-        );\r
-    }\r
-\r
-    private native void setHeaderOptions(OcHeaderOption[] headerOptionList);\r
-\r
-    /**\r
-     * This API allows to set request handle\r
-     *\r
-     * @param ocRequestHandle request handle\r
-     */\r
-    public native void setRequestHandle(OcRequestHandle ocRequestHandle);\r
-\r
-    /**\r
-     * This API allows to set the resource handle\r
-     *\r
-     * @param ocResourceHandle resource handle\r
-     */\r
-    public native void setResourceHandle(OcResourceHandle ocResourceHandle);\r
-\r
-    /**\r
-     * This API allows to set the EntityHandler response result\r
-     *\r
-     * @param responseResult OcEntityHandlerResult type to set the result value\r
-     */\r
-    public void setResponseResult(EntityHandlerResult responseResult) {\r
-        this.setResponseResult(responseResult.getValue());\r
-    }\r
-\r
-    private native void setResponseResult(int responseResult);\r
-\r
-    /**\r
-     * API to set the entire resource attribute representation\r
-     *\r
-     * @param ocRepresentation the name value pairs representing the resource's attributes\r
-     * @param interfaceStr     specifies the interface\r
-     */\r
-    public native void setResourceRepresentation(OcRepresentation ocRepresentation,\r
-                                                 String interfaceStr);\r
-\r
-    /**\r
-     * API to set the entire resource attribute representation\r
-     *\r
-     * @param representation object containing the name value pairs representing the\r
-     *                       resource's attributes\r
-     */\r
-    public void setResourceRepresentation(OcRepresentation representation) {\r
-        this.setResourceRepresentation1(representation);\r
-    }\r
-\r
-    private native void setResourceRepresentation1(OcRepresentation representation);\r
-\r
-    @Override\r
-    protected void finalize() throws Throwable {\r
-        super.finalize();\r
-\r
-        dispose();\r
-    }\r
-\r
-    private native void create();\r
-\r
-    private native void dispose();\r
-\r
-    private long mNativeHandle;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+import java.util.List;
+
+/**
+ * OcResourceResponse provides APIs to set the response details
+ */
+public class OcResourceResponse {
+
+    static {
+        System.loadLibrary("oc");
+        System.loadLibrary("ocstack-jni");
+    }
+
+    public OcResourceResponse() {
+        super();
+
+        create();
+    }
+
+    private OcResourceResponse(long nativeHandle) {
+        this.mNativeHandle = nativeHandle;
+    }
+
+    /**
+     * This API sets the error code for this response
+     *
+     * @param eCode error code to set
+     */
+    public native void setErrorCode(int eCode);
+
+    /**
+     * Gets new resource uri
+     *
+     * @return new resource uri
+     */
+    public native String getNewResourceUri();
+
+    /**
+     * Sets new resource uri
+     *
+     * @param newResourceUri new resource uri
+     */
+    public native void setNewResourceUri(String newResourceUri);
+
+    /**
+     * This API allows to set headerOptions in the response
+     *
+     * @param headerOptionList List of HeaderOption entries
+     */
+    public void setHeaderOptions(List<OcHeaderOption> headerOptionList) {
+        this.setHeaderOptions(headerOptionList.toArray(
+                        new OcHeaderOption[headerOptionList.size()])
+        );
+    }
+
+    private native void setHeaderOptions(OcHeaderOption[] headerOptionList);
+
+    /**
+     * This API allows to set request handle
+     *
+     * @param ocRequestHandle request handle
+     */
+    public native void setRequestHandle(OcRequestHandle ocRequestHandle);
+
+    /**
+     * This API allows to set the resource handle
+     *
+     * @param ocResourceHandle resource handle
+     */
+    public native void setResourceHandle(OcResourceHandle ocResourceHandle);
+
+    /**
+     * This API allows to set the EntityHandler response result
+     *
+     * @param responseResult OcEntityHandlerResult type to set the result value
+     */
+    public void setResponseResult(EntityHandlerResult responseResult) {
+        this.setResponseResult(responseResult.getValue());
+    }
+
+    private native void setResponseResult(int responseResult);
+
+    /**
+     * API to set the entire resource attribute representation
+     *
+     * @param ocRepresentation the name value pairs representing the resource's attributes
+     * @param interfaceStr     specifies the interface
+     */
+    public native void setResourceRepresentation(OcRepresentation ocRepresentation,
+                                                 String interfaceStr);
+
+    /**
+     * API to set the entire resource attribute representation
+     *
+     * @param representation object containing the name value pairs representing the
+     *                       resource's attributes
+     */
+    public void setResourceRepresentation(OcRepresentation representation) {
+        this.setResourceRepresentation1(representation);
+    }
+
+    private native void setResourceRepresentation1(OcRepresentation representation);
+
+    @Override
+    protected void finalize() throws Throwable {
+        super.finalize();
+
+        dispose();
+    }
+
+    private native void create();
+
+    private native void dispose();
+
+    private long mNativeHandle;
+}
index 70d9df3..4ffacd4 100644 (file)
@@ -1,69 +1,69 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-import android.content.Context;\r
-\r
-/**\r
- * Data structure to provide the configuration.\r
- */\r
-public class PlatformConfig {\r
-\r
-    private Context mContext;\r
-    private ServiceType mServiceType;\r
-    private ModeType mModeType;\r
-    private String mIpAddress;\r
-    private int mPort;\r
-    private QualityOfService mQualityOfService;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+import android.content.Context;
+
+/**
+ * Data structure to provide the configuration.
+ */
+public class PlatformConfig {
+
+    private Context mContext;
+    private ServiceType mServiceType;
+    private ModeType mModeType;
+    private String mIpAddress;
+    private int mPort;
+    private QualityOfService mQualityOfService;
     private String mSvrDbPath; //TODO: Instead of SVRDB file, it should be Persistent Storage.
                               //this is only for 0.9.2
-\r
-    /**\r
-     * @param context          app context\r
-     * @param serviceType      indicate IN_PROC or OUT_OF_PROC\r
-     * @param modeType         indicate whether we want to do server, client or both\r
-     * @param ipAddress        ip address of server\r
-     *                         if you specify 0.0.0.0 : it listens on any interface\r
-     * @param port             port of server\r
-     *                         if you specifiy 0 : next available random port is used\r
-     *                         if you specify 5683 : client discovery can work even if they don't\r
-     *                         specify port\r
-     * @param qualityOfService quality of service\r
+
+    /**
+     * @param context          app context
+     * @param serviceType      indicate IN_PROC or OUT_OF_PROC
+     * @param modeType         indicate whether we want to do server, client or both
+     * @param ipAddress        ip address of server
+     *                         if you specify 0.0.0.0 : it listens on any interface
+     * @param port             port of server
+     *                         if you specifiy 0 : next available random port is used
+     *                         if you specify 5683 : client discovery can work even if they don't
+     *                         specify port
+     * @param qualityOfService quality of service
      * @param dbPath           Persistant storage file for SVR Database.
-     */\r
-    public PlatformConfig(Context context,\r
-                          ServiceType serviceType,\r
-                          ModeType modeType,\r
-                          String ipAddress,\r
-                          int port,\r
+     */
+    public PlatformConfig(Context context,
+                          ServiceType serviceType,
+                          ModeType modeType,
+                          String ipAddress,
+                          int port,
                           QualityOfService qualityOfService,
                           String dbPath) {
-        this.mContext = context;\r
-        this.mServiceType = serviceType;\r
-        this.mModeType = modeType;\r
-        this.mIpAddress = ipAddress;\r
-        this.mPort = port;\r
-        this.mQualityOfService = qualityOfService;\r
+        this.mContext = context;
+        this.mServiceType = serviceType;
+        this.mModeType = modeType;
+        this.mIpAddress = ipAddress;
+        this.mPort = port;
+        this.mQualityOfService = qualityOfService;
         this.mSvrDbPath = dbPath;
     }
 
@@ -87,33 +87,33 @@ public class PlatformConfig {
                           int port,
                           QualityOfService qualityOfService) {
         this(context,serviceType,modeType,ipAddress,port,qualityOfService, "");
-    }\r
-\r
-    public Context getContext() {\r
-        return mContext;\r
-    }\r
-\r
-    public ServiceType getServiceType() {\r
-        return mServiceType;\r
-    }\r
-\r
-    public ModeType getModeType() {\r
-        return mModeType;\r
-    }\r
-\r
-    public String getIpAddress() {\r
-        return mIpAddress;\r
-    }\r
-\r
-    public int getPort() {\r
-        return mPort;\r
-    }\r
-\r
-    public QualityOfService getQualityOfService() {\r
-        return mQualityOfService;\r
+    }
+
+    public Context getContext() {
+        return mContext;
+    }
+
+    public ServiceType getServiceType() {
+        return mServiceType;
+    }
+
+    public ModeType getModeType() {
+        return mModeType;
+    }
+
+    public String getIpAddress() {
+        return mIpAddress;
+    }
+
+    public int getPort() {
+        return mPort;
+    }
+
+    public QualityOfService getQualityOfService() {
+        return mQualityOfService;
     }
 
     public String getSvrDbPath() {
         return mSvrDbPath;
-    }\r
-}\r
+    }
+}
index 4c85981..fe511c4 100644 (file)
@@ -1,42 +1,42 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-/**\r
- */\r
-public enum QualityOfService {\r
-    LOW(0),\r
-    MEDIUM(1),\r
-    HIGH(2),\r
-    NA(3);\r
-\r
-    private int value;\r
-\r
-    private QualityOfService(int value) {\r
-        this.value = value;\r
-    }\r
-\r
-    public int getValue() {\r
-        return this.value;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+/**
+ */
+public enum QualityOfService {
+    LOW(0),
+    MEDIUM(1),
+    HIGH(2),
+    NA(3);
+
+    private int value;
+
+    private QualityOfService(int value) {
+        this.value = value;
+    }
+
+    public int getValue() {
+        return this.value;
+    }
+}
index 5e1f5ee..b67cee8 100644 (file)
@@ -1,61 +1,61 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-import java.util.EnumSet;\r
-\r
-public enum RequestHandlerFlag {\r
-    INIT(1 << 0),\r
-    REQUEST(1 << 1),\r
-    OBSERVER(1 << 2),;\r
-\r
-    private int value;\r
-\r
-    private RequestHandlerFlag(int value) {\r
-        this.value = value;\r
-    }\r
-\r
-    public int getValue() {\r
-        return this.value;\r
-    }\r
-\r
-    public static EnumSet<RequestHandlerFlag> convertToEnumSet(int value) {\r
-        EnumSet<RequestHandlerFlag> flagSet = null;\r
-\r
-        for (RequestHandlerFlag v : values()) {\r
-            if (0 != (value & v.getValue())) {\r
-                if (flagSet == null) {\r
-                    flagSet = EnumSet.of(v);\r
-                } else {\r
-                    flagSet.add(v);\r
-                }\r
-            }\r
-        }\r
-\r
-        if (null == flagSet || flagSet.isEmpty()) {\r
-            throw new IllegalArgumentException("Unexpected RequestHandlerFlag value");\r
-        }\r
-\r
-        return flagSet;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+import java.util.EnumSet;
+
+public enum RequestHandlerFlag {
+    INIT(1 << 0),
+    REQUEST(1 << 1),
+    OBSERVER(1 << 2),;
+
+    private int value;
+
+    private RequestHandlerFlag(int value) {
+        this.value = value;
+    }
+
+    public int getValue() {
+        return this.value;
+    }
+
+    public static EnumSet<RequestHandlerFlag> convertToEnumSet(int value) {
+        EnumSet<RequestHandlerFlag> flagSet = null;
+
+        for (RequestHandlerFlag v : values()) {
+            if (0 != (value & v.getValue())) {
+                if (flagSet == null) {
+                    flagSet = EnumSet.of(v);
+                } else {
+                    flagSet.add(v);
+                }
+            }
+        }
+
+        if (null == flagSet || flagSet.isEmpty()) {
+            throw new IllegalArgumentException("Unexpected RequestHandlerFlag value");
+        }
+
+        return flagSet;
+    }
+}
index 894429d..832c891 100644 (file)
@@ -1,48 +1,48 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-public enum RequestType {\r
-    GET("GET"),\r
-    PUT("PUT"),\r
-    POST("POST"),\r
-    DELETE("DELETE"),;\r
-    private String value;\r
-\r
-    private RequestType(String value) {\r
-        this.value = value;\r
-    }\r
-\r
-    public String getValue() {\r
-        return this.value;\r
-    }\r
-\r
-    public static RequestType get(String value) {\r
-        for (RequestType v : values()) {\r
-            if (v.getValue().equals(value)) {\r
-                return v;\r
-            }\r
-        }\r
-        throw new IllegalArgumentException("Unexpected RequestType value");\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+public enum RequestType {
+    GET("GET"),
+    PUT("PUT"),
+    POST("POST"),
+    DELETE("DELETE"),;
+    private String value;
+
+    private RequestType(String value) {
+        this.value = value;
+    }
+
+    public String getValue() {
+        return this.value;
+    }
+
+    public static RequestType get(String value) {
+        for (RequestType v : values()) {
+            if (v.getValue().equals(value)) {
+                return v;
+            }
+        }
+        throw new IllegalArgumentException("Unexpected RequestType value");
+    }
+}
index 778543d..d35c133 100644 (file)
@@ -1,41 +1,41 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-public enum ResourceProperty {\r
-    DISCOVERABLE(1 << 0),\r
-    OBSERVABLE(1 << 1),\r
-    ACTIVE(1 << 2),\r
-    SLOW(1 << 3),\r
-    SECURE(1 << 4);\r
-\r
-    private int value;\r
-\r
-    private ResourceProperty(int value) {\r
-        this.value = value;\r
-    }\r
-\r
-    public int getValue() {\r
-        return this.value;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+public enum ResourceProperty {
+    DISCOVERABLE(1 << 0),
+    OBSERVABLE(1 << 1),
+    ACTIVE(1 << 2),
+    SLOW(1 << 3),
+    SECURE(1 << 4);
+
+    private int value;
+
+    private ResourceProperty(int value) {
+        this.value = value;
+    }
+
+    public int getValue() {
+        return this.value;
+    }
+}
index 6dc65a7..929c4da 100644 (file)
@@ -1,38 +1,38 @@
-/*\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
-\r
-package org.iotivity.base;\r
-\r
-public enum ServiceType {\r
-    IN_PROC(0),\r
-    OUT_OF_PROC(1),;\r
-\r
-    private int value;\r
-\r
-    private ServiceType(int value) {\r
-        this.value = value;\r
-    }\r
-\r
-    public int getValue() {\r
-        return this.value;\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base;
+
+public enum ServiceType {
+    IN_PROC(0),
+    OUT_OF_PROC(1),;
+
+    private int value;
+
+    private ServiceType(int value) {
+        this.value = value;
+    }
+
+    public int getValue() {
+        return this.value;
+    }
+}
index 81c457c..196fadf 100644 (file)
@@ -1,34 +1,34 @@
-/*\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
-\r
-package org.iotivity.ca;\r
-\r
-import android.content.Context;\r
-\r
-public class CaInterface {\r
-    static {\r
-        System.loadLibrary("connectivity_abstraction");\r
-        System.loadLibrary("ca-interface");\r
-    }\r
-\r
-    public static native void initialize(Context context);\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.ca;
+
+import android.content.Context;
+
+public class CaInterface {
+    static {
+        System.loadLibrary("connectivity_abstraction");
+        System.loadLibrary("ca-interface");
+    }
+
+    public static native void initialize(Context context);
 }
\ No newline at end of file
index 1e807d1..040ebbd 100644 (file)
@@ -1,68 +1,68 @@
-/******************************************************************\r
- *\r
- * Copyright 2014 Samsung Electronics All Rights Reserved.\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
-package org.iotivity.ca;\r
-\r
-import android.content.BroadcastReceiver;\r
-import android.content.Context;\r
-import android.content.Intent;\r
-import android.content.IntentFilter;\r
-import android.net.ConnectivityManager;\r
-import android.net.NetworkInfo;\r
-import android.net.wifi.WifiManager;\r
-\r
-public class CaIpInterface {\r
-    private static Context mContext;\r
-\r
-    private CaIpInterface(Context context) {\r
-        mContext = context;\r
-        registerIpStateReceiver();\r
-    }\r
-\r
-    private void registerIpStateReceiver() {\r
-        IntentFilter intentFilter = new IntentFilter();\r
-        intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);\r
-        intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);\r
-\r
-        mContext.registerReceiver(mReceiver, intentFilter);\r
-    }\r
-\r
-    private static BroadcastReceiver mReceiver = new BroadcastReceiver() {\r
-        @Override\r
-        public void onReceive(Context context, Intent intent) {\r
-            if (intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,\r
-                WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_DISABLED) {\r
-                caIpStateDisabled();\r
-            } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {\r
-                ConnectivityManager manager = (ConnectivityManager)\r
-                        mContext.getSystemService(Context.CONNECTIVITY_SERVICE);\r
-                NetworkInfo nwInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);\r
-\r
-                if(nwInfo.isConnected()) {\r
-                    caIpStateEnabled();\r
-                }\r
-            }\r
-        }\r
-    };\r
-\r
-    private native static void caIpStateEnabled();\r
-\r
-    private native static void caIpStateDisabled();\r
-}\r
+/******************************************************************
+ *
+ * Copyright 2014 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * 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.
+ *
+ ******************************************************************/
+
+package org.iotivity.ca;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.net.wifi.WifiManager;
+
+public class CaIpInterface {
+    private static Context mContext;
+
+    private CaIpInterface(Context context) {
+        mContext = context;
+        registerIpStateReceiver();
+    }
+
+    private void registerIpStateReceiver() {
+        IntentFilter intentFilter = new IntentFilter();
+        intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
+        intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
+
+        mContext.registerReceiver(mReceiver, intentFilter);
+    }
+
+    private static BroadcastReceiver mReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
+                WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_DISABLED) {
+                caIpStateDisabled();
+            } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
+                ConnectivityManager manager = (ConnectivityManager)
+                        mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
+                NetworkInfo nwInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
+
+                if(nwInfo.isConnected()) {
+                    caIpStateEnabled();
+                }
+            }
+        }
+    };
+
+    private native static void caIpStateEnabled();
+
+    private native static void caIpStateDisabled();
+}
index 15cac58..9ec6eb8 100644 (file)
@@ -1,72 +1,72 @@
-/*\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
-\r
-package org.iotivity.ca;\r
-\r
-import android.content.BroadcastReceiver;\r
-import android.content.Context;\r
-import android.content.Intent;\r
-import android.content.IntentFilter;\r
-import android.net.ConnectivityManager;\r
-import android.net.NetworkInfo;\r
-import android.net.wifi.WifiManager;\r
-\r
-public class CaWiFiInterface {\r
-\r
-    private static Context mContext;\r
-\r
-    private CaWiFiInterface(Context context) {\r
-        mContext = context;\r
-        registerWiFiStateReceiver();\r
-    }\r
-\r
-    private void registerWiFiStateReceiver() {\r
-        IntentFilter intentFilter = new IntentFilter();\r
-        intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);\r
-        intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);\r
-\r
-        mContext.registerReceiver(mReceiver, intentFilter);\r
-    }\r
-\r
-    private static BroadcastReceiver mReceiver = new BroadcastReceiver() {\r
-\r
-        @Override\r
-        public void onReceive(Context context, Intent intent) {\r
-            if (intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,\r
-                    WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_DISABLED) {\r
-                CAWiFiStateDisabled();\r
-            } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {\r
-                ConnectivityManager manager = (ConnectivityManager)\r
-                        mContext.getSystemService(Context.CONNECTIVITY_SERVICE);\r
-                NetworkInfo nwInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);\r
-\r
-                if (nwInfo.isConnected()) {\r
-                    CAWiFiStateEnabled();\r
-                }\r
-            }\r
-        }\r
-    };\r
-\r
-    private native static void CAWiFiStateEnabled();\r
-\r
-    private native static void CAWiFiStateDisabled();\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.ca;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.net.wifi.WifiManager;
+
+public class CaWiFiInterface {
+
+    private static Context mContext;
+
+    private CaWiFiInterface(Context context) {
+        mContext = context;
+        registerWiFiStateReceiver();
+    }
+
+    private void registerWiFiStateReceiver() {
+        IntentFilter intentFilter = new IntentFilter();
+        intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
+        intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
+
+        mContext.registerReceiver(mReceiver, intentFilter);
+    }
+
+    private static BroadcastReceiver mReceiver = new BroadcastReceiver() {
+
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
+                    WifiManager.WIFI_STATE_UNKNOWN) == WifiManager.WIFI_STATE_DISABLED) {
+                CAWiFiStateDisabled();
+            } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
+                ConnectivityManager manager = (ConnectivityManager)
+                        mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
+                NetworkInfo nwInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
+
+                if (nwInfo.isConnected()) {
+                    CAWiFiStateEnabled();
+                }
+            }
+        }
+    };
+
+    private native static void CAWiFiStateEnabled();
+
+    private native static void CAWiFiStateDisabled();
 }
\ No newline at end of file
old mode 100755 (executable)
new mode 100644 (file)
index d560e70..a8e40a4
@@ -1,22 +1,22 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"\r
-    xmlns:tools="http://schemas.android.com/tools"\r
-    package="org.iotivity.base.examples.fridgeclient" >\r
-    <uses-sdk tools:overrideLibrary="org.iotivity.base"></uses-sdk>\r
-\r
-    <application\r
-        android:allowBackup="true"\r
-        android:icon="@drawable/ic_launcher"\r
-        android:label="@string/app_name"\r
-        android:theme="@style/AppTheme">\r
-        <activity\r
-            android:name=".FridgeClient"\r
-            android:label="@string/app_name" >\r
-            <intent-filter>\r
-                <action android:name="android.intent.action.MAIN" />\r
-\r
-                <category android:name="android.intent.category.LAUNCHER" />\r
-            </intent-filter>\r
-        </activity>\r
-    </application>\r
-</manifest>\r
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    package="org.iotivity.base.examples.fridgeclient" >
+    <uses-sdk tools:overrideLibrary="org.iotivity.base"></uses-sdk>
+
+    <application
+        android:allowBackup="true"
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name"
+        android:theme="@style/AppTheme">
+        <activity
+            android:name=".FridgeClient"
+            android:label="@string/app_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+</manifest>
index 3c5038b..5d0913b 100644 (file)
-/*\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
-\r
-package org.iotivity.base.examples.fridgeclient;\r
-\r
-import android.app.Activity;\r
-import android.content.BroadcastReceiver;\r
-import android.content.Context;\r
-import android.content.Intent;\r
-import android.content.IntentFilter;\r
-import android.os.Bundle;\r
-import android.os.Message;\r
-import android.support.v4.content.LocalBroadcastManager;\r
-import android.text.method.ScrollingMovementMethod;\r
-import android.util.Log;\r
-import android.view.Menu;\r
-import android.view.MenuItem;\r
-import android.widget.LinearLayout;\r
-import android.widget.TextView;\r
-\r
-import org.iotivity.base.ErrorCode;\r
-import org.iotivity.base.ModeType;\r
-import org.iotivity.base.OcConnectivityType;\r
-import org.iotivity.base.OcException;\r
-import org.iotivity.base.OcHeaderOption;\r
-import org.iotivity.base.OcPlatform;\r
-import org.iotivity.base.OcRepresentation;\r
-import org.iotivity.base.OcResource;\r
-import org.iotivity.base.PlatformConfig;\r
-import org.iotivity.base.QualityOfService;\r
-import org.iotivity.base.ServiceType;\r
-\r
-import java.util.HashMap;\r
-import java.util.LinkedList;\r
-import java.util.List;\r
-\r
-import base.iotivity.org.examples.message.IMessageLogger;\r
-\r
-/**\r
- * FridgeClient\r
- * <p/>\r
- * FridgeClient is a sample client app which should be started after the fridgeServer is started.\r
- * It creates DeviceResource, DoorResource, LightResource and performs a get operation on them.\r
- * This implements IMessageLogger to display messages on the screen\r
- */\r
-public class FridgeClient extends Activity implements\r
-        OcPlatform.OnResourceFoundListener, IMessageLogger {\r
-    private static String TAG = "FridgeClient: ";\r
-\r
-    private MessageReceiver mMessageReceiver = new MessageReceiver();\r
-    private TextView mEventsTextView;\r
-    private String mDeviceName;\r
-    private int mDeviceCode;\r
-    private List<String> ifaces;\r
-    private final List<OcResource> resourceList = new LinkedList<OcResource>();\r
-\r
-    /**\r
-     * configure OIC platform and call findResource\r
-     */\r
-    private void initOICStack() {\r
-        PlatformConfig cfg = new PlatformConfig(\r
-                this,\r
-                ServiceType.IN_PROC,\r
-                ModeType.CLIENT,\r
-                "0.0.0.0", // bind to all available interfaces\r
-                0,\r
-                QualityOfService.LOW);\r
-\r
-        OcPlatform.Configure(cfg);\r
-        try {\r
-            OcPlatform.findResource("", OcPlatform.WELL_KNOWN_QUERY + "?rt=" + "intel.fridge",\r
-                    OcConnectivityType.CT_DEFAULT, this);\r
-        } catch (OcException e) {\r
-            logMessage(TAG + " init Error. " + e.getMessage());\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-    }\r
-\r
-    /**\r
-     * prints out the appropriate messages depending on the device code\r
-     *\r
-     * @param representation representation of the OcResource\r
-     * @param value          clientDeviceCode\r
-     */\r
-    private void getResponse(OcRepresentation representation, int value) {\r
-        switch (value) {\r
-            case 0:\r
-                // Get on device\r
-                try {\r
-                    logMessage(TAG + "Name of device: " +\r
-                            representation.getValue(StringConstants.DEVICE_NAME));\r
-                } catch (OcException e) {\r
-                    Log.e(TAG, e.getMessage());\r
-                }\r
-                break;\r
-            case 1:\r
-                // get on fridge light\r
-                try {\r
-                    boolean lightOn = representation.getValue(StringConstants.ON);\r
-                    logMessage(TAG + "The fridge light is " +\r
-                            (lightOn ? "" : "not " + "on"));\r
-                } catch (OcException e) {\r
-                    Log.e(TAG, e.getMessage());\r
-                }\r
-                break;\r
-            case 2:\r
-            case 3:\r
-                // get on fridge door(s)\r
-                try {\r
-                    boolean doorOpen = representation.getValue(StringConstants.OPEN);\r
-                    logMessage(TAG + "Door is " + (doorOpen ?\r
-                            "open" : "not open") + " and is on the " +\r
-                            representation.getValue(StringConstants.SIDE) + " side");\r
-                } catch (OcException e) {\r
-                    Log.e(TAG, e.getMessage());\r
-                }\r
-                break;\r
-            case 4:\r
-                // get on fridge random door\r
-                try {\r
-                    logMessage("Name of fridge: " +\r
-                            representation.getValue(StringConstants.DEVICE_NAME));\r
-                } catch (OcException e) {\r
-                    Log.e(TAG, e.getMessage());\r
-                }\r
-                break;\r
-            default:\r
-                logMessage("Unexpected State");\r
-                break;\r
-        }\r
-    }\r
-\r
-    /**\r
-     * this method is used to wait for 1 second between calls to different resources.\r
-     * It is added for better readability\r
-     */\r
-    private void doWait() {\r
-        try {\r
-            Thread.sleep(StringConstants.WAIT_TIME);\r
-        } catch (InterruptedException e) {\r
-            logMessage(TAG + "doWait exception: " + e.getMessage());\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-    }\r
-\r
-    @Override\r
-    /**\r
-     *  callback when a resource is found. This method calls getResponse with the correct code\r
-     */\r
-    synchronized public void onResourceFound(OcResource ocResource) {\r
-        // eventHandler for onGetListener\r
-        resourceList.add(ocResource);\r
-        OcResource.OnGetListener onGetListener = new OcResource.OnGetListener() {\r
-            @Override\r
-            public void onGetCompleted(List<OcHeaderOption> headerOptionList, OcRepresentation rep) {\r
-                logMessage(TAG + " Got a response from " + getClientDeviceName());\r
-                getResponse(rep, getClientDeviceCode());\r
-            }\r
-\r
-            @Override\r
-            public void onGetFailed(Throwable throwable) {\r
-                if (throwable instanceof OcException) {\r
-                    OcException ocEx = (OcException) throwable;\r
-                    ErrorCode errCode = ocEx.getErrorCode();\r
-                    //do something based on errorCode\r
-                }\r
-                Log.e(TAG, throwable.toString());\r
-            }\r
-        };\r
-\r
-        if (ocResource.getUri().equals(StringConstants.RESOURCE_URI)) {\r
-            logMessage(TAG + "Discovered a device with \nHost: " + ocResource.getHost() +\r
-                    ", Uri: " + ocResource.getUri());\r
-        }\r
-        List<String> lightTypes = new LinkedList<>();\r
-        lightTypes.add("intel.fridge.light");\r
-        try {\r
-            OcResource light = OcPlatform.constructResourceObject(ocResource.getHost(),\r
-                    StringConstants.LIGHT, OcConnectivityType.CT_DEFAULT, false, lightTypes, ifaces);\r
-\r
-            List<String> doorTypes = new LinkedList<>();\r
-            doorTypes.add("intel.fridge.door");\r
-            OcResource leftDoor = OcPlatform.constructResourceObject(ocResource.getHost(),\r
-                    StringConstants.LEFT_DOOR, OcConnectivityType.CT_DEFAULT, false, doorTypes, ifaces);\r
-\r
-            OcResource rightDoor = OcPlatform.constructResourceObject(ocResource.getHost(),\r
-                    StringConstants.RIGHT_DOOR, OcConnectivityType.CT_DEFAULT, false, doorTypes, ifaces);\r
-\r
-            OcResource randomDoor = OcPlatform.constructResourceObject(ocResource.getHost(),\r
-                    StringConstants.RANDOM_DOOR, OcConnectivityType.CT_DEFAULT, false, doorTypes, ifaces);\r
-\r
-            List<OcHeaderOption> headerOptions = new LinkedList<>();\r
-            OcHeaderOption apiVersion = new OcHeaderOption(StringConstants.API_VERSION_KEY,\r
-                    StringConstants.API_VERSION);\r
-            OcHeaderOption clientToken = new OcHeaderOption(StringConstants.CLIENT_VERSION_KEY,\r
-                    StringConstants.CLIENT_TOKEN);\r
-            headerOptions.add(apiVersion);\r
-            headerOptions.add(clientToken);\r
-            ocResource.setHeaderOptions(headerOptions);\r
-            /**\r
-             *  wait for 1 second before calling get on different resources.\r
-             *  It is done for better readability.\r
-             *  doWait() is called before each call to get\r
-             */\r
-            doWait();\r
-\r
-            setupClientOptions("Device", 0);\r
-            ocResource.get(new HashMap<String, String>(), onGetListener);\r
-            doWait();\r
-\r
-            setupClientOptions("Fridge Light", 1);\r
-            light.get(new HashMap<String, String>(), onGetListener);\r
-            doWait();\r
-\r
-            setupClientOptions("Left Door", 2);\r
-            leftDoor.get(new HashMap<String, String>(), onGetListener);\r
-            doWait();\r
-\r
-            setupClientOptions("Right Door", 3);\r
-            rightDoor.get(new HashMap<String, String>(), onGetListener);\r
-            doWait();\r
-\r
-            setupClientOptions("Random Door", 4);\r
-            randomDoor.get(new HashMap<String, String>(), onGetListener);\r
-            doWait();\r
-\r
-            resourceList.add(leftDoor);\r
-            leftDoor.deleteResource(new OcResource.OnDeleteListener() {\r
-                @Override\r
-                public void onDeleteCompleted(List<OcHeaderOption> ocHeaderOptions) {\r
-                    logMessage(TAG + "Delete resource successful");\r
-                }\r
-\r
-                @Override\r
-                public void onDeleteFailed(Throwable throwable) {\r
-                    if (throwable instanceof OcException) {\r
-                        OcException ocEx = (OcException) throwable;\r
-                        ErrorCode errCode = ocEx.getErrorCode();\r
-                        //do something based on errorCode\r
-                    }\r
-                    Log.e(TAG, throwable.toString());\r
-                }\r
-            });\r
-        } catch (OcException e) {\r
-            logMessage(TAG + "onResourceFound Error. " + e.getMessage());\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-    }\r
-\r
-    @Override\r
-    protected void onCreate(Bundle savedInstanceState) {\r
-        super.onCreate(savedInstanceState);\r
-        setContentView(R.layout.activity_fridge_client);\r
-        registerReceiver(mMessageReceiver, new IntentFilter(StringConstants.INTENT));\r
-\r
-        mEventsTextView = new TextView(this);\r
-        mEventsTextView.setMovementMethod(new ScrollingMovementMethod());\r
-        LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);\r
-        layout.addView(mEventsTextView, new LinearLayout.LayoutParams\r
-                (LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f));\r
-        ifaces = new LinkedList<>();\r
-        ifaces.add(StringConstants.RESOURCE_INTERFACE);\r
-        mDeviceCode = -1;\r
-        mDeviceName = "";\r
-\r
-        initOICStack();\r
-    }\r
-\r
-    public class MessageReceiver extends BroadcastReceiver {\r
-        @Override\r
-        public void onReceive(Context context, Intent intent) {\r
-            final String message = intent.getStringExtra(StringConstants.MESSAGE);\r
-            logMessage(message);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void logMessage(final String text) {\r
-        if (StringConstants.ENABLE_PRINTING) {\r
-            runOnUiThread(new Runnable() {\r
-                public void run() {\r
-                    final Message msg = new Message();\r
-                    msg.obj = text;\r
-                    mEventsTextView.append("\n");\r
-                    mEventsTextView.append(text);\r
-                }\r
-            });\r
-            Log.i(TAG, text);\r
-        }\r
-    }\r
-\r
-\r
-    private void setupClientOptions(String name, int value) {\r
-        mDeviceName = name;\r
-        mDeviceCode = value;\r
-    }\r
-\r
-    private String getClientDeviceName() {\r
-        return mDeviceName;\r
-    }\r
-\r
-    private int getClientDeviceCode() {\r
-        return mDeviceCode;\r
-    }\r
-\r
-\r
-    //method to print the headerOptions received from the server\r
-    void printHeaderOptions(List<OcHeaderOption> headerOptions) {\r
-        for (OcHeaderOption headerOption : headerOptions) {\r
-            if (StringConstants.API_VERSION_KEY == headerOption.getOptionId()) {\r
-                logMessage(TAG + "Server API version in GET response: " +\r
-                        headerOption.getOptionData());\r
-            }\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public boolean onCreateOptionsMenu(Menu menu) {\r
-        getMenuInflater().inflate(R.menu.menu_fridge_client, menu);\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public boolean onOptionsItemSelected(MenuItem item) {\r
-        int id = item.getItemId();\r
-        if (id == R.id.action_settings) {\r
-            return true;\r
-        }\r
-        return super.onOptionsItemSelected(item);\r
-    }\r
-\r
-    @Override\r
-    public void onDestroy() {\r
-        super.onDestroy();\r
-        onStop();\r
-    }\r
-\r
-    @Override\r
-    protected void onStop() {\r
-        LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);\r
-        super.onStop();\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base.examples.fridgeclient;
+
+import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.os.Message;
+import android.support.v4.content.LocalBroadcastManager;
+import android.text.method.ScrollingMovementMethod;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import org.iotivity.base.ErrorCode;
+import org.iotivity.base.ModeType;
+import org.iotivity.base.OcConnectivityType;
+import org.iotivity.base.OcException;
+import org.iotivity.base.OcHeaderOption;
+import org.iotivity.base.OcPlatform;
+import org.iotivity.base.OcRepresentation;
+import org.iotivity.base.OcResource;
+import org.iotivity.base.PlatformConfig;
+import org.iotivity.base.QualityOfService;
+import org.iotivity.base.ServiceType;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+
+import base.iotivity.org.examples.message.IMessageLogger;
+
+/**
+ * FridgeClient
+ * <p/>
+ * FridgeClient is a sample client app which should be started after the fridgeServer is started.
+ * It creates DeviceResource, DoorResource, LightResource and performs a get operation on them.
+ * This implements IMessageLogger to display messages on the screen
+ */
+public class FridgeClient extends Activity implements
+        OcPlatform.OnResourceFoundListener, IMessageLogger {
+    private static String TAG = "FridgeClient: ";
+
+    private MessageReceiver mMessageReceiver = new MessageReceiver();
+    private TextView mEventsTextView;
+    private String mDeviceName;
+    private int mDeviceCode;
+    private List<String> ifaces;
+    private final List<OcResource> resourceList = new LinkedList<OcResource>();
+
+    /**
+     * configure OIC platform and call findResource
+     */
+    private void initOICStack() {
+        PlatformConfig cfg = new PlatformConfig(
+                this,
+                ServiceType.IN_PROC,
+                ModeType.CLIENT,
+                "0.0.0.0", // bind to all available interfaces
+                0,
+                QualityOfService.LOW);
+
+        OcPlatform.Configure(cfg);
+        try {
+            OcPlatform.findResource("", OcPlatform.WELL_KNOWN_QUERY + "?rt=" + "intel.fridge",
+                    OcConnectivityType.CT_DEFAULT, this);
+        } catch (OcException e) {
+            logMessage(TAG + " init Error. " + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        }
+    }
+
+    /**
+     * prints out the appropriate messages depending on the device code
+     *
+     * @param representation representation of the OcResource
+     * @param value          clientDeviceCode
+     */
+    private void getResponse(OcRepresentation representation, int value) {
+        switch (value) {
+            case 0:
+                // Get on device
+                try {
+                    logMessage(TAG + "Name of device: " +
+                            representation.getValue(StringConstants.DEVICE_NAME));
+                } catch (OcException e) {
+                    Log.e(TAG, e.getMessage());
+                }
+                break;
+            case 1:
+                // get on fridge light
+                try {
+                    boolean lightOn = representation.getValue(StringConstants.ON);
+                    logMessage(TAG + "The fridge light is " +
+                            (lightOn ? "" : "not " + "on"));
+                } catch (OcException e) {
+                    Log.e(TAG, e.getMessage());
+                }
+                break;
+            case 2:
+            case 3:
+                // get on fridge door(s)
+                try {
+                    boolean doorOpen = representation.getValue(StringConstants.OPEN);
+                    logMessage(TAG + "Door is " + (doorOpen ?
+                            "open" : "not open") + " and is on the " +
+                            representation.getValue(StringConstants.SIDE) + " side");
+                } catch (OcException e) {
+                    Log.e(TAG, e.getMessage());
+                }
+                break;
+            case 4:
+                // get on fridge random door
+                try {
+                    logMessage("Name of fridge: " +
+                            representation.getValue(StringConstants.DEVICE_NAME));
+                } catch (OcException e) {
+                    Log.e(TAG, e.getMessage());
+                }
+                break;
+            default:
+                logMessage("Unexpected State");
+                break;
+        }
+    }
+
+    /**
+     * this method is used to wait for 1 second between calls to different resources.
+     * It is added for better readability
+     */
+    private void doWait() {
+        try {
+            Thread.sleep(StringConstants.WAIT_TIME);
+        } catch (InterruptedException e) {
+            logMessage(TAG + "doWait exception: " + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        }
+    }
+
+    @Override
+    /**
+     *  callback when a resource is found. This method calls getResponse with the correct code
+     */
+    synchronized public void onResourceFound(OcResource ocResource) {
+        // eventHandler for onGetListener
+        resourceList.add(ocResource);
+        OcResource.OnGetListener onGetListener = new OcResource.OnGetListener() {
+            @Override
+            public void onGetCompleted(List<OcHeaderOption> headerOptionList, OcRepresentation rep) {
+                logMessage(TAG + " Got a response from " + getClientDeviceName());
+                getResponse(rep, getClientDeviceCode());
+            }
+
+            @Override
+            public void onGetFailed(Throwable throwable) {
+                if (throwable instanceof OcException) {
+                    OcException ocEx = (OcException) throwable;
+                    ErrorCode errCode = ocEx.getErrorCode();
+                    //do something based on errorCode
+                }
+                Log.e(TAG, throwable.toString());
+            }
+        };
+
+        if (ocResource.getUri().equals(StringConstants.RESOURCE_URI)) {
+            logMessage(TAG + "Discovered a device with \nHost: " + ocResource.getHost() +
+                    ", Uri: " + ocResource.getUri());
+        }
+        List<String> lightTypes = new LinkedList<>();
+        lightTypes.add("intel.fridge.light");
+        try {
+            OcResource light = OcPlatform.constructResourceObject(ocResource.getHost(),
+                    StringConstants.LIGHT, OcConnectivityType.CT_DEFAULT, false, lightTypes, ifaces);
+
+            List<String> doorTypes = new LinkedList<>();
+            doorTypes.add("intel.fridge.door");
+            OcResource leftDoor = OcPlatform.constructResourceObject(ocResource.getHost(),
+                    StringConstants.LEFT_DOOR, OcConnectivityType.CT_DEFAULT, false, doorTypes, ifaces);
+
+            OcResource rightDoor = OcPlatform.constructResourceObject(ocResource.getHost(),
+                    StringConstants.RIGHT_DOOR, OcConnectivityType.CT_DEFAULT, false, doorTypes, ifaces);
+
+            OcResource randomDoor = OcPlatform.constructResourceObject(ocResource.getHost(),
+                    StringConstants.RANDOM_DOOR, OcConnectivityType.CT_DEFAULT, false, doorTypes, ifaces);
+
+            List<OcHeaderOption> headerOptions = new LinkedList<>();
+            OcHeaderOption apiVersion = new OcHeaderOption(StringConstants.API_VERSION_KEY,
+                    StringConstants.API_VERSION);
+            OcHeaderOption clientToken = new OcHeaderOption(StringConstants.CLIENT_VERSION_KEY,
+                    StringConstants.CLIENT_TOKEN);
+            headerOptions.add(apiVersion);
+            headerOptions.add(clientToken);
+            ocResource.setHeaderOptions(headerOptions);
+            /**
+             *  wait for 1 second before calling get on different resources.
+             *  It is done for better readability.
+             *  doWait() is called before each call to get
+             */
+            doWait();
+
+            setupClientOptions("Device", 0);
+            ocResource.get(new HashMap<String, String>(), onGetListener);
+            doWait();
+
+            setupClientOptions("Fridge Light", 1);
+            light.get(new HashMap<String, String>(), onGetListener);
+            doWait();
+
+            setupClientOptions("Left Door", 2);
+            leftDoor.get(new HashMap<String, String>(), onGetListener);
+            doWait();
+
+            setupClientOptions("Right Door", 3);
+            rightDoor.get(new HashMap<String, String>(), onGetListener);
+            doWait();
+
+            setupClientOptions("Random Door", 4);
+            randomDoor.get(new HashMap<String, String>(), onGetListener);
+            doWait();
+
+            resourceList.add(leftDoor);
+            leftDoor.deleteResource(new OcResource.OnDeleteListener() {
+                @Override
+                public void onDeleteCompleted(List<OcHeaderOption> ocHeaderOptions) {
+                    logMessage(TAG + "Delete resource successful");
+                }
+
+                @Override
+                public void onDeleteFailed(Throwable throwable) {
+                    if (throwable instanceof OcException) {
+                        OcException ocEx = (OcException) throwable;
+                        ErrorCode errCode = ocEx.getErrorCode();
+                        //do something based on errorCode
+                    }
+                    Log.e(TAG, throwable.toString());
+                }
+            });
+        } catch (OcException e) {
+            logMessage(TAG + "onResourceFound Error. " + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        }
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_fridge_client);
+        registerReceiver(mMessageReceiver, new IntentFilter(StringConstants.INTENT));
+
+        mEventsTextView = new TextView(this);
+        mEventsTextView.setMovementMethod(new ScrollingMovementMethod());
+        LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);
+        layout.addView(mEventsTextView, new LinearLayout.LayoutParams
+                (LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f));
+        ifaces = new LinkedList<>();
+        ifaces.add(StringConstants.RESOURCE_INTERFACE);
+        mDeviceCode = -1;
+        mDeviceName = "";
+
+        initOICStack();
+    }
+
+    public class MessageReceiver extends BroadcastReceiver {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            final String message = intent.getStringExtra(StringConstants.MESSAGE);
+            logMessage(message);
+        }
+    }
+
+    @Override
+    public void logMessage(final String text) {
+        if (StringConstants.ENABLE_PRINTING) {
+            runOnUiThread(new Runnable() {
+                public void run() {
+                    final Message msg = new Message();
+                    msg.obj = text;
+                    mEventsTextView.append("\n");
+                    mEventsTextView.append(text);
+                }
+            });
+            Log.i(TAG, text);
+        }
+    }
+
+
+    private void setupClientOptions(String name, int value) {
+        mDeviceName = name;
+        mDeviceCode = value;
+    }
+
+    private String getClientDeviceName() {
+        return mDeviceName;
+    }
+
+    private int getClientDeviceCode() {
+        return mDeviceCode;
+    }
+
+
+    //method to print the headerOptions received from the server
+    void printHeaderOptions(List<OcHeaderOption> headerOptions) {
+        for (OcHeaderOption headerOption : headerOptions) {
+            if (StringConstants.API_VERSION_KEY == headerOption.getOptionId()) {
+                logMessage(TAG + "Server API version in GET response: " +
+                        headerOption.getOptionData());
+            }
+        }
+    }
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        getMenuInflater().inflate(R.menu.menu_fridge_client, menu);
+        return true;
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        int id = item.getItemId();
+        if (id == R.id.action_settings) {
+            return true;
+        }
+        return super.onOptionsItemSelected(item);
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+        onStop();
+    }
+
+    @Override
+    protected void onStop() {
+        LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
+        super.onStop();
+    }
+}
index da88e4d..1fd690f 100644 (file)
@@ -1,33 +1,33 @@
-package org.iotivity.base.examples.fridgeclient;\r
-\r
-import org.iotivity.base.OcPlatform;\r
-\r
-/**\r
- * StringConstant contains the fridgeclient specific constant values.  To add another supported\r
- * Resource or Interface type to this app, begin by adding the new strings here, and then\r
- * find the places throughout the app where Resource-specific case switches occur, and add\r
- * the newly-supported type there.\r
- */\r
-public interface StringConstants {\r
-    public static final String RESOURCE_URI = "/device";\r
-    public static final String DEVICE_NAME = "device_name";\r
-    public static final String LIGHT = "/light";\r
-    public static final String LEFT_DOOR = "/door/left";\r
-    public static final String RIGHT_DOOR = "/door/right";\r
-    public static final String RANDOM_DOOR = "/door/random";\r
-    public static final String MESSAGE = "message";\r
-    public static final String API_VERSION = "v.1.2";\r
-    public static final String CLIENT_TOKEN = "AaBbYyZz";\r
-    public static final String ON = "on";\r
-    public static final String OPEN = "open";\r
-    public static final String SIDE = "side";\r
-    public static final String INTENT = "org.iotivity.base.examples.fridgeclient";\r
-    public static final String RESOURCE_INTERFACE = OcPlatform.DEFAULT_INTERFACE;\r
-\r
-    public static final int WAIT_TIME = 1000;\r
-    public static final int API_VERSION_KEY = 2048;\r
-    public static final int CLIENT_VERSION_KEY = 3000;\r
-\r
-    public static final boolean ENABLE_PRINTING = true; // change to false to disable printing\r
-                                                        // of messages on the console and the screen\r
-}\r
+package org.iotivity.base.examples.fridgeclient;
+
+import org.iotivity.base.OcPlatform;
+
+/**
+ * StringConstant contains the fridgeclient specific constant values.  To add another supported
+ * Resource or Interface type to this app, begin by adding the new strings here, and then
+ * find the places throughout the app where Resource-specific case switches occur, and add
+ * the newly-supported type there.
+ */
+public interface StringConstants {
+    public static final String RESOURCE_URI = "/device";
+    public static final String DEVICE_NAME = "device_name";
+    public static final String LIGHT = "/light";
+    public static final String LEFT_DOOR = "/door/left";
+    public static final String RIGHT_DOOR = "/door/right";
+    public static final String RANDOM_DOOR = "/door/random";
+    public static final String MESSAGE = "message";
+    public static final String API_VERSION = "v.1.2";
+    public static final String CLIENT_TOKEN = "AaBbYyZz";
+    public static final String ON = "on";
+    public static final String OPEN = "open";
+    public static final String SIDE = "side";
+    public static final String INTENT = "org.iotivity.base.examples.fridgeclient";
+    public static final String RESOURCE_INTERFACE = OcPlatform.DEFAULT_INTERFACE;
+
+    public static final int WAIT_TIME = 1000;
+    public static final int API_VERSION_KEY = 2048;
+    public static final int CLIENT_VERSION_KEY = 3000;
+
+    public static final boolean ENABLE_PRINTING = true; // change to false to disable printing
+                                                        // of messages on the console and the screen
+}
old mode 100755 (executable)
new mode 100644 (file)
index d813c8a..fc86964
@@ -1,18 +1,18 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
-    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"\r
-    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"\r
-    android:paddingRight="@dimen/activity_horizontal_margin"\r
-    android:paddingTop="@dimen/activity_vertical_margin"\r
-    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".FridgeClient">\r
-\r
-    <TextView android:text="@string/app_name" android:layout_width="wrap_content"\r
-        android:layout_height="wrap_content" />\r
-\r
-    <LinearLayout\r
-        android:layout_width="fill_parent"\r
-        android:layout_height="fill_parent"\r
-        android:orientation="vertical"\r
-        android:id="@+id/linearLayout" >\r
-    </LinearLayout>\r
-\r
-</RelativeLayout>\r
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
+    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".FridgeClient">
+
+    <TextView android:text="@string/app_name" android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+    <LinearLayout
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent"
+        android:orientation="vertical"
+        android:id="@+id/linearLayout" >
+    </LinearLayout>
+
+</RelativeLayout>
old mode 100755 (executable)
new mode 100644 (file)
index f812805..b495790
@@ -1,6 +1,6 @@
-<menu xmlns:android="http://schemas.android.com/apk/res/android"\r
-    xmlns:app="http://schemas.android.com/apk/res-auto"\r
-    xmlns:tools="http://schemas.android.com/tools" tools:context=".FridgeClient">\r
-    <item android:id="@+id/action_settings" android:title="@string/action_settings"\r
-        android:orderInCategory="100" app:showAsAction="never" />\r
-</menu>\r
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools" tools:context=".FridgeClient">
+    <item android:id="@+id/action_settings" android:title="@string/action_settings"
+        android:orderInCategory="100" app:showAsAction="never" />
+</menu>
old mode 100755 (executable)
new mode 100644 (file)
index 62df187..63fc816
@@ -1,6 +1,6 @@
-<resources>\r
-    <!-- Example customization of dimensions originally defined in res/values/dimens.xml\r
-         (such as screen margins) for screens with more than 820dp of available width. This\r
-         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->\r
-    <dimen name="activity_horizontal_margin">64dp</dimen>\r
-</resources>\r
+<resources>
+    <!-- Example customization of dimensions originally defined in res/values/dimens.xml
+         (such as screen margins) for screens with more than 820dp of available width. This
+         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
+    <dimen name="activity_horizontal_margin">64dp</dimen>
+</resources>
old mode 100755 (executable)
new mode 100644 (file)
index 295b5a9..47c8224
@@ -1,5 +1,5 @@
-<resources>\r
-    <!-- Default screen margins, per the Android Design guidelines. -->\r
-    <dimen name="activity_horizontal_margin">16dp</dimen>\r
-    <dimen name="activity_vertical_margin">16dp</dimen>\r
-</resources>\r
+<resources>
+    <!-- Default screen margins, per the Android Design guidelines. -->
+    <dimen name="activity_horizontal_margin">16dp</dimen>
+    <dimen name="activity_vertical_margin">16dp</dimen>
+</resources>
old mode 100755 (executable)
new mode 100644 (file)
index 152e2c9..3a66c4a
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<resources>\r
-\r
-    <string name="app_name">FridgeClient</string>\r
-    <string name="hello_world">Hello world!</string>\r
-    <string name="action_settings">Settings</string>\r
-\r
-</resources>\r
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="app_name">FridgeClient</string>
+    <string name="hello_world">Hello world!</string>
+    <string name="action_settings">Settings</string>
+
+</resources>
old mode 100755 (executable)
new mode 100644 (file)
index 084b42b..766ab99
@@ -1,8 +1,8 @@
-<resources>\r
-\r
-    <!-- Base application theme. -->\r
-    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">\r
-        <!-- Customize your theme here. -->\r
-    </style>\r
-\r
-</resources>\r
+<resources>
+
+    <!-- Base application theme. -->
+    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+        <!-- Customize your theme here. -->
+    </style>
+
+</resources>
old mode 100755 (executable)
new mode 100644 (file)
index cbcffd9..fddfc88
@@ -1,24 +1,24 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"\r
-    xmlns:tools="http://schemas.android.com/tools"\r
-    package="org.iotivity.base.examples.fridgeserver">\r
-\r
-    <uses-sdk tools:overrideLibrary="org.iotivity.base"></uses-sdk>\r
-\r
-    <application\r
-        android:allowBackup="true"\r
-        android:icon="@drawable/ic_launcher"\r
-        android:label="@string/app_name"\r
-        android:theme="@style/AppTheme" >\r
-        <activity\r
-            android:name=".FridgeServer"\r
-            android:label="@string/app_name" >\r
-            <intent-filter>\r
-                <action android:name="android.intent.action.MAIN" />\r
-\r
-                <category android:name="android.intent.category.LAUNCHER" />\r
-            </intent-filter>\r
-        </activity>\r
-    </application>\r
-\r
-</manifest>\r
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    package="org.iotivity.base.examples.fridgeserver">
+
+    <uses-sdk tools:overrideLibrary="org.iotivity.base"></uses-sdk>
+
+    <application
+        android:allowBackup="true"
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name"
+        android:theme="@style/AppTheme" >
+        <activity
+            android:name=".FridgeServer"
+            android:label="@string/app_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>
index fc33258..fd00402 100644 (file)
-/*\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
-\r
-package org.iotivity.base.examples.fridgeserver;\r
-\r
-import android.content.Context;\r
-import android.content.Intent;\r
-import android.util.Log;\r
-\r
-import org.iotivity.base.EntityHandlerResult;\r
-import org.iotivity.base.OcException;\r
-import org.iotivity.base.OcHeaderOption;\r
-import org.iotivity.base.OcPlatform;\r
-import org.iotivity.base.OcResourceRequest;\r
-import org.iotivity.base.OcResourceResponse;\r
-import org.iotivity.base.RequestHandlerFlag;\r
-import org.iotivity.base.ResourceProperty;\r
-\r
-import java.util.EnumSet;\r
-import java.util.LinkedList;\r
-import java.util.List;\r
-\r
-import base.iotivity.org.examples.message.IMessageLogger;\r
-\r
-/**\r
- * DeviceResource\r
- * <p/>\r
- * Creates a device resource and performs action based on client requests\r
- */\r
-public class DeviceResource extends Resource implements IMessageLogger {\r
-    private Context mContext;\r
-\r
-    private static String TAG = "DeviceResource: ";\r
-\r
-    /**\r
-     * constructor\r
-     *\r
-     * @param context to enable sending of broadcast messages to be displayed on the user screen\r
-     */\r
-    DeviceResource(Context context) {\r
-        mContext = context;\r
-\r
-        // eventHandler for register deviceResource\r
-        OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() {\r
-            @Override\r
-            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {\r
-                // this is where the main logic of DeviceResource is handled\r
-                return entityHandler(ocResourceRequest);\r
-            }\r
-        };\r
-\r
-        try {\r
-            logMessage(TAG + "RegisterDeviceResource " + StringConstants.DEVICE_URI + " : " +\r
-                    StringConstants.RESOURCE_TYPENAME + " : " + StringConstants.RESOURCE_INTERFACE);\r
-            mResourceHandle = OcPlatform.registerResource(StringConstants.DEVICE_URI,\r
-                    StringConstants.RESOURCE_TYPENAME, StringConstants.RESOURCE_INTERFACE,\r
-                    eh, EnumSet.of(ResourceProperty.DISCOVERABLE));\r
-        } catch (OcException e) {\r
-            logMessage(TAG + "registerResource error: " + e.getMessage());\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-    }\r
-\r
-    /**\r
-     * update current state of device\r
-     *\r
-     * @return device representation\r
-     */\r
-    private void updateRepresentationValues() {\r
-        try {\r
-            mRepresentation.setValue(StringConstants.DEVICE_NAME,\r
-                    "Intel Powered 2 door, 1 light refrigerator");\r
-        } catch (OcException e) {\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-    }\r
-\r
-    /**\r
-     * unregister the resource\r
-     */\r
-    private void deleteDeviceResource() {\r
-        try {\r
-            OcPlatform.unregisterResource(mResourceHandle);\r
-            logMessage(TAG + "Unregister DeviceResource successful");\r
-        } catch (OcException e) {\r
-            logMessage(TAG + e.getMessage());\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-    }\r
-\r
-    /**\r
-     * this is the main method which handles different incoming requests appropriately.\r
-     *\r
-     * @param request OcResourceRequest from the client\r
-     * @return EntityHandlerResult depending on whether the request was handled successfully or not\r
-     */\r
-    private EntityHandlerResult entityHandler(OcResourceRequest request) {\r
-        EntityHandlerResult result = EntityHandlerResult.ERROR;\r
-        if (null != request) {\r
-            List<OcHeaderOption> headerOptions = request.getHeaderOptions();\r
-            String clientAPIVersion = "";\r
-            String clientToken = "";\r
-\r
-            // search for header options map and look for API version and client token\r
-            for (OcHeaderOption headerOption : headerOptions) {\r
-                int optionId = headerOption.getOptionId();\r
-                if (StringConstants.API_VERSION_KEY == optionId) {\r
-                    clientAPIVersion = headerOption.getOptionData();\r
-                    logMessage(TAG + " Client API Version: " + clientAPIVersion);\r
-                } else if (StringConstants.CLIENT_VERSION_KEY == optionId) {\r
-                    clientToken = headerOption.getOptionData();\r
-                    logMessage(TAG + " Client Token: " + clientToken);\r
-                }\r
-            }\r
-            if (clientAPIVersion.equals(StringConstants.API_VERSION) &&\r
-                    clientToken.equals(StringConstants.CLIENT_TOKEN)) {\r
-                List<OcHeaderOption> serverHeaderOptions = new LinkedList<>();\r
-                OcHeaderOption apiVersion = new OcHeaderOption(StringConstants.API_VERSION_KEY,\r
-                        StringConstants.API_VERSION);\r
-                serverHeaderOptions.add(apiVersion);\r
-                try {\r
-                    if (request.getRequestHandlerFlagSet().contains(RequestHandlerFlag.REQUEST)) {\r
-                        OcResourceResponse response = new OcResourceResponse();\r
-                        response.setRequestHandle(request.getRequestHandle());\r
-                        response.setResourceHandle(request.getResourceHandle());\r
-                        response.setHeaderOptions(serverHeaderOptions);\r
-\r
-                        switch (request.getRequestType()) {\r
-                            case GET:\r
-                                response.setErrorCode(StringConstants.OK);\r
-                                response.setResponseResult(EntityHandlerResult.OK);\r
-                                updateRepresentationValues();\r
-                                response.setResourceRepresentation(mRepresentation);\r
-                                OcPlatform.sendResponse(response);\r
-                                break;\r
-                            case DELETE:\r
-                                deleteDeviceResource();\r
-                                response.setErrorCode(StringConstants.OK);\r
-                                response.setResponseResult(EntityHandlerResult.OK);\r
-                                break;\r
-                            case POST:\r
-                                response.setResponseResult(EntityHandlerResult.ERROR);\r
-                                OcPlatform.sendResponse(response);\r
-                                break;\r
-                        }\r
-                        result = EntityHandlerResult.OK;\r
-                    }\r
-                } catch (OcException e) {\r
-                    logMessage(TAG + e.getMessage());\r
-                    Log.e(TAG, e.getMessage());\r
-                }\r
-            }\r
-        }\r
-        return result;\r
-    }\r
-\r
-    @Override\r
-    public void logMessage(String msg) {\r
-        logMsg(msg);\r
-        if (StringConstants.ENABLE_PRINTING) {\r
-            Log.i(TAG, msg);\r
-        }\r
-    }\r
-\r
-    public void logMsg(final String text) {\r
-        Intent intent = new Intent(StringConstants.INTENT);\r
-        intent.putExtra("message", text);\r
-        mContext.sendBroadcast(intent);\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base.examples.fridgeserver;
+
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+import org.iotivity.base.EntityHandlerResult;
+import org.iotivity.base.OcException;
+import org.iotivity.base.OcHeaderOption;
+import org.iotivity.base.OcPlatform;
+import org.iotivity.base.OcResourceRequest;
+import org.iotivity.base.OcResourceResponse;
+import org.iotivity.base.RequestHandlerFlag;
+import org.iotivity.base.ResourceProperty;
+
+import java.util.EnumSet;
+import java.util.LinkedList;
+import java.util.List;
+
+import base.iotivity.org.examples.message.IMessageLogger;
+
+/**
+ * DeviceResource
+ * <p/>
+ * Creates a device resource and performs action based on client requests
+ */
+public class DeviceResource extends Resource implements IMessageLogger {
+    private Context mContext;
+
+    private static String TAG = "DeviceResource: ";
+
+    /**
+     * constructor
+     *
+     * @param context to enable sending of broadcast messages to be displayed on the user screen
+     */
+    DeviceResource(Context context) {
+        mContext = context;
+
+        // eventHandler for register deviceResource
+        OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() {
+            @Override
+            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {
+                // this is where the main logic of DeviceResource is handled
+                return entityHandler(ocResourceRequest);
+            }
+        };
+
+        try {
+            logMessage(TAG + "RegisterDeviceResource " + StringConstants.DEVICE_URI + " : " +
+                    StringConstants.RESOURCE_TYPENAME + " : " + StringConstants.RESOURCE_INTERFACE);
+            mResourceHandle = OcPlatform.registerResource(StringConstants.DEVICE_URI,
+                    StringConstants.RESOURCE_TYPENAME, StringConstants.RESOURCE_INTERFACE,
+                    eh, EnumSet.of(ResourceProperty.DISCOVERABLE));
+        } catch (OcException e) {
+            logMessage(TAG + "registerResource error: " + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        }
+    }
+
+    /**
+     * update current state of device
+     *
+     * @return device representation
+     */
+    private void updateRepresentationValues() {
+        try {
+            mRepresentation.setValue(StringConstants.DEVICE_NAME,
+                    "Intel Powered 2 door, 1 light refrigerator");
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+        }
+    }
+
+    /**
+     * unregister the resource
+     */
+    private void deleteDeviceResource() {
+        try {
+            OcPlatform.unregisterResource(mResourceHandle);
+            logMessage(TAG + "Unregister DeviceResource successful");
+        } catch (OcException e) {
+            logMessage(TAG + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        }
+    }
+
+    /**
+     * this is the main method which handles different incoming requests appropriately.
+     *
+     * @param request OcResourceRequest from the client
+     * @return EntityHandlerResult depending on whether the request was handled successfully or not
+     */
+    private EntityHandlerResult entityHandler(OcResourceRequest request) {
+        EntityHandlerResult result = EntityHandlerResult.ERROR;
+        if (null != request) {
+            List<OcHeaderOption> headerOptions = request.getHeaderOptions();
+            String clientAPIVersion = "";
+            String clientToken = "";
+
+            // search for header options map and look for API version and client token
+            for (OcHeaderOption headerOption : headerOptions) {
+                int optionId = headerOption.getOptionId();
+                if (StringConstants.API_VERSION_KEY == optionId) {
+                    clientAPIVersion = headerOption.getOptionData();
+                    logMessage(TAG + " Client API Version: " + clientAPIVersion);
+                } else if (StringConstants.CLIENT_VERSION_KEY == optionId) {
+                    clientToken = headerOption.getOptionData();
+                    logMessage(TAG + " Client Token: " + clientToken);
+                }
+            }
+            if (clientAPIVersion.equals(StringConstants.API_VERSION) &&
+                    clientToken.equals(StringConstants.CLIENT_TOKEN)) {
+                List<OcHeaderOption> serverHeaderOptions = new LinkedList<>();
+                OcHeaderOption apiVersion = new OcHeaderOption(StringConstants.API_VERSION_KEY,
+                        StringConstants.API_VERSION);
+                serverHeaderOptions.add(apiVersion);
+                try {
+                    if (request.getRequestHandlerFlagSet().contains(RequestHandlerFlag.REQUEST)) {
+                        OcResourceResponse response = new OcResourceResponse();
+                        response.setRequestHandle(request.getRequestHandle());
+                        response.setResourceHandle(request.getResourceHandle());
+                        response.setHeaderOptions(serverHeaderOptions);
+
+                        switch (request.getRequestType()) {
+                            case GET:
+                                response.setErrorCode(StringConstants.OK);
+                                response.setResponseResult(EntityHandlerResult.OK);
+                                updateRepresentationValues();
+                                response.setResourceRepresentation(mRepresentation);
+                                OcPlatform.sendResponse(response);
+                                break;
+                            case DELETE:
+                                deleteDeviceResource();
+                                response.setErrorCode(StringConstants.OK);
+                                response.setResponseResult(EntityHandlerResult.OK);
+                                break;
+                            case POST:
+                                response.setResponseResult(EntityHandlerResult.ERROR);
+                                OcPlatform.sendResponse(response);
+                                break;
+                        }
+                        result = EntityHandlerResult.OK;
+                    }
+                } catch (OcException e) {
+                    logMessage(TAG + e.getMessage());
+                    Log.e(TAG, e.getMessage());
+                }
+            }
+        }
+        return result;
+    }
+
+    @Override
+    public void logMessage(String msg) {
+        logMsg(msg);
+        if (StringConstants.ENABLE_PRINTING) {
+            Log.i(TAG, msg);
+        }
+    }
+
+    public void logMsg(final String text) {
+        Intent intent = new Intent(StringConstants.INTENT);
+        intent.putExtra("message", text);
+        mContext.sendBroadcast(intent);
+    }
+}
index 438022b..c819975 100644 (file)
-/*\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
-\r
-package org.iotivity.base.examples.fridgeserver;\r
-\r
-import android.content.Context;\r
-import android.content.Intent;\r
-import android.util.Log;\r
-\r
-import org.iotivity.base.EntityHandlerResult;\r
-import org.iotivity.base.OcException;\r
-import org.iotivity.base.OcPlatform;\r
-import org.iotivity.base.OcRepresentation;\r
-import org.iotivity.base.OcResourceRequest;\r
-import org.iotivity.base.OcResourceResponse;\r
-import org.iotivity.base.RequestHandlerFlag;\r
-import org.iotivity.base.ResourceProperty;\r
-\r
-import java.util.EnumSet;\r
-\r
-import base.iotivity.org.examples.message.IMessageLogger;\r
-\r
-/**\r
- * DoorResource\r
- * <p/>\r
- * Creates a door resource and performs action based on client requests\r
- */\r
-public class DoorResource extends Resource implements IMessageLogger {\r
-    private Context mContext;\r
-\r
-    private static String TAG = "DoorResource: ";\r
-    private String mSide = StringConstants.LEFT;\r
-    private boolean mOpen;\r
-    private String resourceURI;\r
-\r
-    /**\r
-     * Constructor\r
-     *\r
-     * @param side    left or right side of the door\r
-     * @param context to enable sending of broadcast messages to be displayed on the user screen\r
-     */\r
-    DoorResource(String side, Context context) {\r
-        mContext = context;\r
-        mSide = side;\r
-\r
-        resourceURI = StringConstants.DOOR_URI + mSide;\r
-\r
-        // eventHandler for register doorResource\r
-        OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() {\r
-            @Override\r
-            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {\r
-                // this is where the main logic of DoorResource is handled\r
-                return entityHandler(ocResourceRequest);\r
-            }\r
-        };\r
-        try {\r
-            logMessage(TAG + "RegisterDoorResource " + resourceURI + " : " +\r
-                    StringConstants.RESOURCE_TYPEDOOR + " : " + StringConstants.RESOURCE_INTERFACE);\r
-            mResourceHandle = OcPlatform.registerResource(resourceURI,\r
-                    StringConstants.RESOURCE_TYPEDOOR, StringConstants.RESOURCE_INTERFACE,\r
-                    eh, EnumSet.of(ResourceProperty.DISCOVERABLE));\r
-        } catch (OcException e) {\r
-            logMessage(TAG + "DoorResource registerResource error: " + e.getMessage());\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-    }\r
-\r
-    /**\r
-     * updates the current value of the door resource\r
-     *\r
-     * @return door representation\r
-     */\r
-    private void updateRepresentationValues() {\r
-        try {\r
-            mRepresentation.setValue(StringConstants.SIDE, mSide);\r
-            mRepresentation.setValue(StringConstants.OPEN, mOpen);\r
-            mRepresentation.setValue(StringConstants.DEVICE_NAME,\r
-                    "Intel Powered 2 door, 1 light refrigerator");\r
-        } catch (OcException e) {\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-    }\r
-\r
-    /**\r
-     * update the OPEN value of doorResource (door is open/ closed)\r
-     *\r
-     * @param representation get current state of door\r
-     */\r
-    private void put(OcRepresentation representation) {\r
-        try {\r
-            mOpen = representation.getValue(StringConstants.OPEN);\r
-        } catch (OcException e) {\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-        // Note, we won't let the user change the door side!\r
-    }\r
-\r
-    /**\r
-     * this is the main method which handles different incoming requests appropriately.\r
-     *\r
-     * @param request OcResourceRequest from the client\r
-     * @return EntityHandlerResult depending on whether the request was handled successfully or not\r
-     */\r
-    private EntityHandlerResult entityHandler(OcResourceRequest request) {\r
-        EntityHandlerResult result = EntityHandlerResult.ERROR;\r
-        if (null != request) {\r
-            try {\r
-                if (request.getRequestHandlerFlagSet().contains(RequestHandlerFlag.REQUEST)) {\r
-                    OcResourceResponse response = new OcResourceResponse();\r
-                    response.setRequestHandle(request.getRequestHandle());\r
-                    response.setResourceHandle(request.getResourceHandle());\r
-\r
-                    switch (request.getRequestType()) {\r
-                        case GET:\r
-                            response.setErrorCode(StringConstants.OK);\r
-                            updateRepresentationValues();\r
-                            response.setResourceRepresentation(mRepresentation);\r
-                            response.setResponseResult(EntityHandlerResult.OK);\r
-                            OcPlatform.sendResponse(response);\r
-                            break;\r
-                        case PUT:\r
-                            response.setErrorCode(StringConstants.OK);\r
-                            put(request.getResourceRepresentation());\r
-                            updateRepresentationValues();\r
-                            response.setResourceRepresentation(mRepresentation);\r
-                            response.setResponseResult(EntityHandlerResult.OK);\r
-                            OcPlatform.sendResponse(response);\r
-                            break;\r
-                        case DELETE:\r
-                            response.setResponseResult(EntityHandlerResult.RESOURCE_DELETED);\r
-                            response.setErrorCode(204);\r
-                            OcPlatform.sendResponse(response);\r
-                            break;\r
-                    }\r
-                    result = EntityHandlerResult.OK;\r
-                }\r
-            } catch (OcException e) {\r
-                logMessage(TAG + e.getMessage());\r
-                Log.e(TAG, e.getMessage());\r
-                return EntityHandlerResult.ERROR;\r
-            }\r
-        }\r
-        return result;\r
-    }\r
-\r
-    @Override\r
-    public void logMessage(String msg) {\r
-        logMsg(msg);\r
-        if (StringConstants.ENABLE_PRINTING) {\r
-            Log.i(TAG, msg);\r
-        }\r
-    }\r
-\r
-    public void logMsg(final String text) {\r
-        Intent intent = new Intent(StringConstants.INTENT);\r
-        intent.putExtra(StringConstants.MESSAGE, text);\r
-        mContext.sendBroadcast(intent);\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base.examples.fridgeserver;
+
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+import org.iotivity.base.EntityHandlerResult;
+import org.iotivity.base.OcException;
+import org.iotivity.base.OcPlatform;
+import org.iotivity.base.OcRepresentation;
+import org.iotivity.base.OcResourceRequest;
+import org.iotivity.base.OcResourceResponse;
+import org.iotivity.base.RequestHandlerFlag;
+import org.iotivity.base.ResourceProperty;
+
+import java.util.EnumSet;
+
+import base.iotivity.org.examples.message.IMessageLogger;
+
+/**
+ * DoorResource
+ * <p/>
+ * Creates a door resource and performs action based on client requests
+ */
+public class DoorResource extends Resource implements IMessageLogger {
+    private Context mContext;
+
+    private static String TAG = "DoorResource: ";
+    private String mSide = StringConstants.LEFT;
+    private boolean mOpen;
+    private String resourceURI;
+
+    /**
+     * Constructor
+     *
+     * @param side    left or right side of the door
+     * @param context to enable sending of broadcast messages to be displayed on the user screen
+     */
+    DoorResource(String side, Context context) {
+        mContext = context;
+        mSide = side;
+
+        resourceURI = StringConstants.DOOR_URI + mSide;
+
+        // eventHandler for register doorResource
+        OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() {
+            @Override
+            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {
+                // this is where the main logic of DoorResource is handled
+                return entityHandler(ocResourceRequest);
+            }
+        };
+        try {
+            logMessage(TAG + "RegisterDoorResource " + resourceURI + " : " +
+                    StringConstants.RESOURCE_TYPEDOOR + " : " + StringConstants.RESOURCE_INTERFACE);
+            mResourceHandle = OcPlatform.registerResource(resourceURI,
+                    StringConstants.RESOURCE_TYPEDOOR, StringConstants.RESOURCE_INTERFACE,
+                    eh, EnumSet.of(ResourceProperty.DISCOVERABLE));
+        } catch (OcException e) {
+            logMessage(TAG + "DoorResource registerResource error: " + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        }
+    }
+
+    /**
+     * updates the current value of the door resource
+     *
+     * @return door representation
+     */
+    private void updateRepresentationValues() {
+        try {
+            mRepresentation.setValue(StringConstants.SIDE, mSide);
+            mRepresentation.setValue(StringConstants.OPEN, mOpen);
+            mRepresentation.setValue(StringConstants.DEVICE_NAME,
+                    "Intel Powered 2 door, 1 light refrigerator");
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+        }
+    }
+
+    /**
+     * update the OPEN value of doorResource (door is open/ closed)
+     *
+     * @param representation get current state of door
+     */
+    private void put(OcRepresentation representation) {
+        try {
+            mOpen = representation.getValue(StringConstants.OPEN);
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+        }
+        // Note, we won't let the user change the door side!
+    }
+
+    /**
+     * this is the main method which handles different incoming requests appropriately.
+     *
+     * @param request OcResourceRequest from the client
+     * @return EntityHandlerResult depending on whether the request was handled successfully or not
+     */
+    private EntityHandlerResult entityHandler(OcResourceRequest request) {
+        EntityHandlerResult result = EntityHandlerResult.ERROR;
+        if (null != request) {
+            try {
+                if (request.getRequestHandlerFlagSet().contains(RequestHandlerFlag.REQUEST)) {
+                    OcResourceResponse response = new OcResourceResponse();
+                    response.setRequestHandle(request.getRequestHandle());
+                    response.setResourceHandle(request.getResourceHandle());
+
+                    switch (request.getRequestType()) {
+                        case GET:
+                            response.setErrorCode(StringConstants.OK);
+                            updateRepresentationValues();
+                            response.setResourceRepresentation(mRepresentation);
+                            response.setResponseResult(EntityHandlerResult.OK);
+                            OcPlatform.sendResponse(response);
+                            break;
+                        case PUT:
+                            response.setErrorCode(StringConstants.OK);
+                            put(request.getResourceRepresentation());
+                            updateRepresentationValues();
+                            response.setResourceRepresentation(mRepresentation);
+                            response.setResponseResult(EntityHandlerResult.OK);
+                            OcPlatform.sendResponse(response);
+                            break;
+                        case DELETE:
+                            response.setResponseResult(EntityHandlerResult.RESOURCE_DELETED);
+                            response.setErrorCode(204);
+                            OcPlatform.sendResponse(response);
+                            break;
+                    }
+                    result = EntityHandlerResult.OK;
+                }
+            } catch (OcException e) {
+                logMessage(TAG + e.getMessage());
+                Log.e(TAG, e.getMessage());
+                return EntityHandlerResult.ERROR;
+            }
+        }
+        return result;
+    }
+
+    @Override
+    public void logMessage(String msg) {
+        logMsg(msg);
+        if (StringConstants.ENABLE_PRINTING) {
+            Log.i(TAG, msg);
+        }
+    }
+
+    public void logMsg(final String text) {
+        Intent intent = new Intent(StringConstants.INTENT);
+        intent.putExtra(StringConstants.MESSAGE, text);
+        mContext.sendBroadcast(intent);
+    }
+}
index 45971f7..d564b3d 100644 (file)
-/*\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
-\r
-package org.iotivity.base.examples.fridgeserver;\r
-\r
-import android.app.Activity;\r
-import android.content.BroadcastReceiver;\r
-import android.content.Context;\r
-import android.content.Intent;\r
-import android.content.IntentFilter;\r
-import android.os.Bundle;\r
-import android.os.Message;\r
-import android.support.v4.content.LocalBroadcastManager;\r
-import android.text.method.ScrollingMovementMethod;\r
-import android.util.Log;\r
-import android.view.Menu;\r
-import android.view.MenuItem;\r
-import android.widget.LinearLayout;\r
-import android.widget.TextView;\r
-\r
-import org.iotivity.base.ModeType;\r
-import org.iotivity.base.OcPlatform;\r
-import org.iotivity.base.PlatformConfig;\r
-import org.iotivity.base.QualityOfService;\r
-import org.iotivity.base.ServiceType;\r
-\r
-import base.iotivity.org.examples.message.IMessageLogger;\r
-\r
-/**\r
- * FridgeServer\r
- * <p/>\r
- * This is the main fridgeServer class. This instantiates Refrigerator object\r
- * which has different resources (DeviceResource, LightResource, DoorResource).\r
- */\r
-public class FridgeServer extends Activity implements IMessageLogger {\r
-    private Context mContext;\r
-    private static String TAG = "FridgeServer: ";\r
-    private TextView mEventsTextView;\r
-    private MessageReceiver mMessageReceiver = new MessageReceiver();\r
-    private Refrigerator refrigerator;\r
-\r
-    /**\r
-     * configure OIC platform and call findResource\r
-     */\r
-    private void initOICStack() {\r
-        //create platform config\r
-        PlatformConfig cfg = new PlatformConfig(\r
-                this,\r
-                ServiceType.IN_PROC,\r
-                ModeType.SERVER,\r
-                "0.0.0.0", // bind to all available interfaces\r
-                0,\r
-                QualityOfService.LOW);\r
-        OcPlatform.Configure(cfg);\r
-        logMessage(TAG + "Creating refrigerator resources");\r
-\r
-        refrigerator = new Refrigerator(mContext);\r
-    }\r
-\r
-    @Override\r
-    protected void onCreate(Bundle savedInstanceState) {\r
-        super.onCreate(savedInstanceState);\r
-        setContentView(R.layout.activity_fridge_server);\r
-        registerReceiver(mMessageReceiver, new IntentFilter(StringConstants.INTENT));\r
-\r
-        mEventsTextView = new TextView(this);\r
-        mEventsTextView.setMovementMethod(new ScrollingMovementMethod());\r
-        LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);\r
-        layout.addView(mEventsTextView, new LinearLayout.LayoutParams\r
-                (LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f));\r
-        mContext = this;\r
-\r
-        initOICStack();\r
-    }\r
-\r
-    public class MessageReceiver extends BroadcastReceiver {\r
-        @Override\r
-        public void onReceive(Context context, Intent intent) {\r
-            final String message = intent.getStringExtra(StringConstants.MESSAGE);\r
-            logMessage(message);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void logMessage(final String text) {\r
-        if (StringConstants.ENABLE_PRINTING) {\r
-            runOnUiThread(new Runnable() {\r
-                public void run() {\r
-                    final Message msg = new Message();\r
-                    msg.obj = text;\r
-                    mEventsTextView.append("\n");\r
-                    mEventsTextView.append(text);\r
-                }\r
-            });\r
-            Log.i(TAG, text);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public boolean onCreateOptionsMenu(Menu menu) {\r
-        // Inflate the menu; this adds items to the action bar if it is present.\r
-        getMenuInflater().inflate(R.menu.menu_fridge_server, menu);\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public boolean onOptionsItemSelected(MenuItem item) {\r
-        int id = item.getItemId();\r
-        if (id == R.id.action_settings) {\r
-            return true;\r
-        }\r
-        return super.onOptionsItemSelected(item);\r
-    }\r
-\r
-    @Override\r
-    public void onDestroy() {\r
-        super.onDestroy();\r
-        onStop();\r
-    }\r
-\r
-    @Override\r
-    protected void onStop() {\r
-        LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);\r
-        super.onStop();\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base.examples.fridgeserver;
+
+import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.os.Message;
+import android.support.v4.content.LocalBroadcastManager;
+import android.text.method.ScrollingMovementMethod;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import org.iotivity.base.ModeType;
+import org.iotivity.base.OcPlatform;
+import org.iotivity.base.PlatformConfig;
+import org.iotivity.base.QualityOfService;
+import org.iotivity.base.ServiceType;
+
+import base.iotivity.org.examples.message.IMessageLogger;
+
+/**
+ * FridgeServer
+ * <p/>
+ * This is the main fridgeServer class. This instantiates Refrigerator object
+ * which has different resources (DeviceResource, LightResource, DoorResource).
+ */
+public class FridgeServer extends Activity implements IMessageLogger {
+    private Context mContext;
+    private static String TAG = "FridgeServer: ";
+    private TextView mEventsTextView;
+    private MessageReceiver mMessageReceiver = new MessageReceiver();
+    private Refrigerator refrigerator;
+
+    /**
+     * configure OIC platform and call findResource
+     */
+    private void initOICStack() {
+        //create platform config
+        PlatformConfig cfg = new PlatformConfig(
+                this,
+                ServiceType.IN_PROC,
+                ModeType.SERVER,
+                "0.0.0.0", // bind to all available interfaces
+                0,
+                QualityOfService.LOW);
+        OcPlatform.Configure(cfg);
+        logMessage(TAG + "Creating refrigerator resources");
+
+        refrigerator = new Refrigerator(mContext);
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_fridge_server);
+        registerReceiver(mMessageReceiver, new IntentFilter(StringConstants.INTENT));
+
+        mEventsTextView = new TextView(this);
+        mEventsTextView.setMovementMethod(new ScrollingMovementMethod());
+        LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);
+        layout.addView(mEventsTextView, new LinearLayout.LayoutParams
+                (LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f));
+        mContext = this;
+
+        initOICStack();
+    }
+
+    public class MessageReceiver extends BroadcastReceiver {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            final String message = intent.getStringExtra(StringConstants.MESSAGE);
+            logMessage(message);
+        }
+    }
+
+    @Override
+    public void logMessage(final String text) {
+        if (StringConstants.ENABLE_PRINTING) {
+            runOnUiThread(new Runnable() {
+                public void run() {
+                    final Message msg = new Message();
+                    msg.obj = text;
+                    mEventsTextView.append("\n");
+                    mEventsTextView.append(text);
+                }
+            });
+            Log.i(TAG, text);
+        }
+    }
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        // Inflate the menu; this adds items to the action bar if it is present.
+        getMenuInflater().inflate(R.menu.menu_fridge_server, menu);
+        return true;
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        int id = item.getItemId();
+        if (id == R.id.action_settings) {
+            return true;
+        }
+        return super.onOptionsItemSelected(item);
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+        onStop();
+    }
+
+    @Override
+    protected void onStop() {
+        LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
+        super.onStop();
+    }
+}
index 09b7f43..e0c783f 100644 (file)
-/*\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
-\r
-package org.iotivity.base.examples.fridgeserver;\r
-\r
-import android.content.Context;\r
-import android.content.Intent;\r
-import android.util.Log;\r
-\r
-import org.iotivity.base.EntityHandlerResult;\r
-import org.iotivity.base.OcException;\r
-import org.iotivity.base.OcPlatform;\r
-import org.iotivity.base.OcRepresentation;\r
-import org.iotivity.base.OcResourceRequest;\r
-import org.iotivity.base.OcResourceResponse;\r
-import org.iotivity.base.RequestHandlerFlag;\r
-import org.iotivity.base.ResourceProperty;\r
-\r
-import java.util.EnumSet;\r
-\r
-import base.iotivity.org.examples.message.IMessageLogger;\r
-\r
-/**\r
- * LightResource\r
- * <p/>\r
- * Creates a light resource and performs action based on client requests\r
- */\r
-public class LightResource extends Resource implements IMessageLogger {\r
-    private Context mContext;\r
-\r
-    private static String TAG = "LightResource: ";\r
-\r
-    private boolean mIsOn = false;\r
-\r
-    /**\r
-     * constructor\r
-     *\r
-     * @param context to enable sending of broadcast messages to be displayed on the user screen\r
-     */\r
-    LightResource(Context context) {\r
-        mContext = context;\r
-        //eventHandler for register lightResource\r
-        OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() {\r
-            @Override\r
-            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {\r
-                // this is where the main logic of LightResource is handled\r
-                return entityHandler(ocResourceRequest);\r
-            }\r
-        };\r
-        try {\r
-            logMessage(TAG + "RegisterLightResource " + StringConstants.LIGHT_URI + " : " +\r
-                    StringConstants.RESOURCE_TYPELIGHT + " : " + StringConstants.RESOURCE_INTERFACE);\r
-            mResourceHandle = OcPlatform.registerResource(StringConstants.LIGHT_URI,\r
-                    StringConstants.RESOURCE_TYPELIGHT, StringConstants.RESOURCE_INTERFACE,\r
-                    eh, EnumSet.of(ResourceProperty.DISCOVERABLE));\r
-        } catch (OcException e) {\r
-            logMessage(TAG + "LightResource registerResource error: " + e.getMessage());\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-    }\r
-\r
-    /**\r
-     * updates the current state of the light (on/ off)\r
-     *\r
-     * @return light is on or off\r
-     */\r
-    private void updateRepresentationValues() {\r
-        try {\r
-            mRepresentation.setValue(StringConstants.ON, mIsOn);\r
-        } catch (OcException e) {\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-    }\r
-\r
-    /**\r
-     * update the value of mIsOn from the representation\r
-     *\r
-     * @param representation get current state of light\r
-     */\r
-    private void put(OcRepresentation representation) {\r
-        try {\r
-            mIsOn = representation.getValue(StringConstants.ON);\r
-        } catch (OcException e) {\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-    }\r
-\r
-    /**\r
-     * this is the main method which handles different incoming requests appropriately.\r
-     *\r
-     * @param request OcResourceRequest from the client\r
-     * @return EntityHandlerResult depending on whether the request was handled successfully or not\r
-     */\r
-    private EntityHandlerResult entityHandler(OcResourceRequest request) {\r
-        EntityHandlerResult result = EntityHandlerResult.ERROR;\r
-        if (null != request) {\r
-            try {\r
-                if (request.getRequestHandlerFlagSet().contains(RequestHandlerFlag.REQUEST)) {\r
-                    OcResourceResponse response = new OcResourceResponse();\r
-                    response.setRequestHandle(request.getRequestHandle());\r
-                    response.setResourceHandle(request.getResourceHandle());\r
-\r
-                    switch (request.getRequestType()) {\r
-                        case GET:\r
-                            response.setErrorCode(StringConstants.OK);\r
-                            updateRepresentationValues();\r
-                            response.setResourceRepresentation(mRepresentation);\r
-                            response.setResponseResult(EntityHandlerResult.OK);\r
-                            OcPlatform.sendResponse(response);\r
-                            result = EntityHandlerResult.OK;\r
-                            break;\r
-                        case PUT:\r
-                            response.setErrorCode(StringConstants.OK);\r
-                            put(request.getResourceRepresentation());\r
-                            updateRepresentationValues();\r
-                            response.setResourceRepresentation(mRepresentation);\r
-                            response.setResponseResult(EntityHandlerResult.OK);\r
-                            OcPlatform.sendResponse(response);\r
-                            result = EntityHandlerResult.OK;\r
-                            break;\r
-                    }\r
-                }\r
-            } catch (OcException e) {\r
-                logMessage(TAG + e.getMessage());\r
-                Log.e(TAG, e.getMessage());\r
-                return EntityHandlerResult.ERROR;\r
-            }\r
-        }\r
-        return result;\r
-    }\r
-\r
-    @Override\r
-    public void logMessage(String msg) {\r
-        logMsg(msg);\r
-        if (StringConstants.ENABLE_PRINTING) {\r
-            Log.i(TAG, msg);\r
-        }\r
-    }\r
-\r
-    public void logMsg(final String text) {\r
-        Intent intent = new Intent(StringConstants.INTENT);\r
-        intent.putExtra(StringConstants.MESSAGE, text);\r
-        mContext.sendBroadcast(intent);\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base.examples.fridgeserver;
+
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+import org.iotivity.base.EntityHandlerResult;
+import org.iotivity.base.OcException;
+import org.iotivity.base.OcPlatform;
+import org.iotivity.base.OcRepresentation;
+import org.iotivity.base.OcResourceRequest;
+import org.iotivity.base.OcResourceResponse;
+import org.iotivity.base.RequestHandlerFlag;
+import org.iotivity.base.ResourceProperty;
+
+import java.util.EnumSet;
+
+import base.iotivity.org.examples.message.IMessageLogger;
+
+/**
+ * LightResource
+ * <p/>
+ * Creates a light resource and performs action based on client requests
+ */
+public class LightResource extends Resource implements IMessageLogger {
+    private Context mContext;
+
+    private static String TAG = "LightResource: ";
+
+    private boolean mIsOn = false;
+
+    /**
+     * constructor
+     *
+     * @param context to enable sending of broadcast messages to be displayed on the user screen
+     */
+    LightResource(Context context) {
+        mContext = context;
+        //eventHandler for register lightResource
+        OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() {
+            @Override
+            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {
+                // this is where the main logic of LightResource is handled
+                return entityHandler(ocResourceRequest);
+            }
+        };
+        try {
+            logMessage(TAG + "RegisterLightResource " + StringConstants.LIGHT_URI + " : " +
+                    StringConstants.RESOURCE_TYPELIGHT + " : " + StringConstants.RESOURCE_INTERFACE);
+            mResourceHandle = OcPlatform.registerResource(StringConstants.LIGHT_URI,
+                    StringConstants.RESOURCE_TYPELIGHT, StringConstants.RESOURCE_INTERFACE,
+                    eh, EnumSet.of(ResourceProperty.DISCOVERABLE));
+        } catch (OcException e) {
+            logMessage(TAG + "LightResource registerResource error: " + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        }
+    }
+
+    /**
+     * updates the current state of the light (on/ off)
+     *
+     * @return light is on or off
+     */
+    private void updateRepresentationValues() {
+        try {
+            mRepresentation.setValue(StringConstants.ON, mIsOn);
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+        }
+    }
+
+    /**
+     * update the value of mIsOn from the representation
+     *
+     * @param representation get current state of light
+     */
+    private void put(OcRepresentation representation) {
+        try {
+            mIsOn = representation.getValue(StringConstants.ON);
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+        }
+    }
+
+    /**
+     * this is the main method which handles different incoming requests appropriately.
+     *
+     * @param request OcResourceRequest from the client
+     * @return EntityHandlerResult depending on whether the request was handled successfully or not
+     */
+    private EntityHandlerResult entityHandler(OcResourceRequest request) {
+        EntityHandlerResult result = EntityHandlerResult.ERROR;
+        if (null != request) {
+            try {
+                if (request.getRequestHandlerFlagSet().contains(RequestHandlerFlag.REQUEST)) {
+                    OcResourceResponse response = new OcResourceResponse();
+                    response.setRequestHandle(request.getRequestHandle());
+                    response.setResourceHandle(request.getResourceHandle());
+
+                    switch (request.getRequestType()) {
+                        case GET:
+                            response.setErrorCode(StringConstants.OK);
+                            updateRepresentationValues();
+                            response.setResourceRepresentation(mRepresentation);
+                            response.setResponseResult(EntityHandlerResult.OK);
+                            OcPlatform.sendResponse(response);
+                            result = EntityHandlerResult.OK;
+                            break;
+                        case PUT:
+                            response.setErrorCode(StringConstants.OK);
+                            put(request.getResourceRepresentation());
+                            updateRepresentationValues();
+                            response.setResourceRepresentation(mRepresentation);
+                            response.setResponseResult(EntityHandlerResult.OK);
+                            OcPlatform.sendResponse(response);
+                            result = EntityHandlerResult.OK;
+                            break;
+                    }
+                }
+            } catch (OcException e) {
+                logMessage(TAG + e.getMessage());
+                Log.e(TAG, e.getMessage());
+                return EntityHandlerResult.ERROR;
+            }
+        }
+        return result;
+    }
+
+    @Override
+    public void logMessage(String msg) {
+        logMsg(msg);
+        if (StringConstants.ENABLE_PRINTING) {
+            Log.i(TAG, msg);
+        }
+    }
+
+    public void logMsg(final String text) {
+        Intent intent = new Intent(StringConstants.INTENT);
+        intent.putExtra(StringConstants.MESSAGE, text);
+        mContext.sendBroadcast(intent);
+    }
+}
index 4432755..66f0e0b 100644 (file)
@@ -1,57 +1,57 @@
-/*\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
-\r
-package org.iotivity.base.examples.fridgeserver;\r
-\r
-import android.content.Context;\r
-\r
-/**\r
- * Refrigerator\r
- * <p/>\r
- * Refrigerator class has different objects (resources) which are instantiated when a\r
- * Refrigerator object is created. Operations are performed on each of the individual resources.\r
- */\r
-public class Refrigerator {\r
-    private Context mContext;\r
-\r
-    private LightResource mLight;\r
-    private DeviceResource mDevice;\r
-    private DoorResource mLeftDoor;\r
-    private DoorResource mRightDoor;\r
-    private DoorResource mRandomDoor;\r
-\r
-    /**\r
-     * constructor\r
-     *\r
-     * @param context needed by individual resources to be able to send broadcast\r
-     *                messages to be displayed on the user screen\r
-     */\r
-    Refrigerator(Context context) {\r
-        mContext = context;\r
-        mLight = new LightResource(context);\r
-        mDevice = new DeviceResource(context);\r
-        mLeftDoor = new DoorResource(StringConstants.LEFT, context);\r
-        mRightDoor = new DoorResource(StringConstants.RIGHT, context);\r
-        mRandomDoor = new DoorResource(StringConstants.RANDOM, context);\r
-    }\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base.examples.fridgeserver;
+
+import android.content.Context;
+
+/**
+ * Refrigerator
+ * <p/>
+ * Refrigerator class has different objects (resources) which are instantiated when a
+ * Refrigerator object is created. Operations are performed on each of the individual resources.
+ */
+public class Refrigerator {
+    private Context mContext;
+
+    private LightResource mLight;
+    private DeviceResource mDevice;
+    private DoorResource mLeftDoor;
+    private DoorResource mRightDoor;
+    private DoorResource mRandomDoor;
+
+    /**
+     * constructor
+     *
+     * @param context needed by individual resources to be able to send broadcast
+     *                messages to be displayed on the user screen
+     */
+    Refrigerator(Context context) {
+        mContext = context;
+        mLight = new LightResource(context);
+        mDevice = new DeviceResource(context);
+        mLeftDoor = new DoorResource(StringConstants.LEFT, context);
+        mRightDoor = new DoorResource(StringConstants.RIGHT, context);
+        mRandomDoor = new DoorResource(StringConstants.RANDOM, context);
+    }
+
+}
index 350cee0..4559a2d 100644 (file)
@@ -1,41 +1,41 @@
-/*\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
-\r
-package org.iotivity.base.examples.fridgeserver;\r
-\r
-import org.iotivity.base.OcRepresentation;\r
-import org.iotivity.base.OcResourceHandle;\r
-\r
-/**\r
- * Resource\r
- * <p/>\r
- * Each of the other resource classes (DeviceResource, DoorResource and LightResource extend Resource\r
- */\r
-public class Resource {\r
-    protected OcResourceHandle mResourceHandle;\r
-    protected OcRepresentation mRepresentation;\r
-\r
-    Resource() {\r
-        mResourceHandle = null;\r
-        mRepresentation = new OcRepresentation();\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base.examples.fridgeserver;
+
+import org.iotivity.base.OcRepresentation;
+import org.iotivity.base.OcResourceHandle;
+
+/**
+ * Resource
+ * <p/>
+ * Each of the other resource classes (DeviceResource, DoorResource and LightResource extend Resource
+ */
+public class Resource {
+    protected OcResourceHandle mResourceHandle;
+    protected OcRepresentation mRepresentation;
+
+    Resource() {
+        mResourceHandle = null;
+        mRepresentation = new OcRepresentation();
+    }
 }
\ No newline at end of file
index 1afe25b..4402c51 100644 (file)
@@ -1,37 +1,37 @@
-package org.iotivity.base.examples.fridgeserver;\r
-\r
-import org.iotivity.base.OcPlatform;\r
-\r
-/**\r
- * StringConstant contains the fridgeserver specific constant values.  To add another supported\r
- * Resource or Interface type to this app, begin by adding the new strings here, and then\r
- * find the places throughout the app where Resource-specific case switches occur, and add\r
- * the newly-supported type there.\r
- */\r
-public interface StringConstants {\r
-    public static final String DEVICE_URI = "/device";\r
-    public static final String LIGHT_URI = "/light";\r
-    public static final String DOOR_URI = "/door/";\r
-    public static final String DEVICE_NAME = "device_name";\r
-    public static final String RESOURCE_TYPENAME = "intel.fridge";\r
-    public static final String RESOURCE_TYPEDOOR = "intel.fridge.door";\r
-    public static final String RESOURCE_TYPELIGHT = "intel.fridge.light";\r
-    public static final String API_VERSION = "v.1.2";\r
-    public static final String CLIENT_TOKEN = "AaBbYyZz";\r
-    public static final String SIDE = "side";\r
-    public static final String OPEN = "open";\r
-    public static final String MESSAGE = "message";\r
-    public static final String LEFT = "left";\r
-    public static final String RIGHT = "right";\r
-    public static final String RANDOM = "random";\r
-    public static final String ON = "on";\r
-    public static final String INTENT = "org.iotivity.base.examples.fridgeserver";\r
-    public static final String RESOURCE_INTERFACE = OcPlatform.DEFAULT_INTERFACE;\r
-\r
-    public static final int API_VERSION_KEY = 2048;\r
-    public static final int CLIENT_VERSION_KEY = 3000;\r
-    public static final int OK = 200;\r
-\r
-    public static final boolean ENABLE_PRINTING = true; // change to false to disable printing\r
-                                                        // of messages on the console and the screen\r
-}\r
+package org.iotivity.base.examples.fridgeserver;
+
+import org.iotivity.base.OcPlatform;
+
+/**
+ * StringConstant contains the fridgeserver specific constant values.  To add another supported
+ * Resource or Interface type to this app, begin by adding the new strings here, and then
+ * find the places throughout the app where Resource-specific case switches occur, and add
+ * the newly-supported type there.
+ */
+public interface StringConstants {
+    public static final String DEVICE_URI = "/device";
+    public static final String LIGHT_URI = "/light";
+    public static final String DOOR_URI = "/door/";
+    public static final String DEVICE_NAME = "device_name";
+    public static final String RESOURCE_TYPENAME = "intel.fridge";
+    public static final String RESOURCE_TYPEDOOR = "intel.fridge.door";
+    public static final String RESOURCE_TYPELIGHT = "intel.fridge.light";
+    public static final String API_VERSION = "v.1.2";
+    public static final String CLIENT_TOKEN = "AaBbYyZz";
+    public static final String SIDE = "side";
+    public static final String OPEN = "open";
+    public static final String MESSAGE = "message";
+    public static final String LEFT = "left";
+    public static final String RIGHT = "right";
+    public static final String RANDOM = "random";
+    public static final String ON = "on";
+    public static final String INTENT = "org.iotivity.base.examples.fridgeserver";
+    public static final String RESOURCE_INTERFACE = OcPlatform.DEFAULT_INTERFACE;
+
+    public static final int API_VERSION_KEY = 2048;
+    public static final int CLIENT_VERSION_KEY = 3000;
+    public static final int OK = 200;
+
+    public static final boolean ENABLE_PRINTING = true; // change to false to disable printing
+                                                        // of messages on the console and the screen
+}
old mode 100755 (executable)
new mode 100644 (file)
index 39362b3..b89205c
@@ -1,18 +1,18 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
-    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"\r
-    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"\r
-    android:paddingRight="@dimen/activity_horizontal_margin"\r
-    android:paddingTop="@dimen/activity_vertical_margin"\r
-    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".FridgeServer">\r
-\r
-    <TextView android:text="@string/app_name" android:layout_width="wrap_content"\r
-        android:layout_height="wrap_content" />\r
-\r
-    <LinearLayout\r
-        android:layout_width="fill_parent"\r
-        android:layout_height="fill_parent"\r
-        android:orientation="vertical"\r
-        android:id="@+id/linearLayout" >\r
-    </LinearLayout>\r
-\r
-</RelativeLayout>\r
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
+    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".FridgeServer">
+
+    <TextView android:text="@string/app_name" android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+    <LinearLayout
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent"
+        android:orientation="vertical"
+        android:id="@+id/linearLayout" >
+    </LinearLayout>
+
+</RelativeLayout>
old mode 100755 (executable)
new mode 100644 (file)
index 2895144..9bd3653
@@ -1,6 +1,6 @@
-<menu xmlns:android="http://schemas.android.com/apk/res/android"\r
-    xmlns:app="http://schemas.android.com/apk/res-auto"\r
-    xmlns:tools="http://schemas.android.com/tools" tools:context=".FridgeServer">\r
-    <item android:id="@+id/action_settings" android:title="@string/action_settings"\r
-        android:orderInCategory="100" app:showAsAction="never" />\r
-</menu>\r
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools" tools:context=".FridgeServer">
+    <item android:id="@+id/action_settings" android:title="@string/action_settings"
+        android:orderInCategory="100" app:showAsAction="never" />
+</menu>
old mode 100755 (executable)
new mode 100644 (file)
index 62df187..63fc816
@@ -1,6 +1,6 @@
-<resources>\r
-    <!-- Example customization of dimensions originally defined in res/values/dimens.xml\r
-         (such as screen margins) for screens with more than 820dp of available width. This\r
-         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->\r
-    <dimen name="activity_horizontal_margin">64dp</dimen>\r
-</resources>\r
+<resources>
+    <!-- Example customization of dimensions originally defined in res/values/dimens.xml
+         (such as screen margins) for screens with more than 820dp of available width. This
+         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
+    <dimen name="activity_horizontal_margin">64dp</dimen>
+</resources>
old mode 100755 (executable)
new mode 100644 (file)
index 295b5a9..47c8224
@@ -1,5 +1,5 @@
-<resources>\r
-    <!-- Default screen margins, per the Android Design guidelines. -->\r
-    <dimen name="activity_horizontal_margin">16dp</dimen>\r
-    <dimen name="activity_vertical_margin">16dp</dimen>\r
-</resources>\r
+<resources>
+    <!-- Default screen margins, per the Android Design guidelines. -->
+    <dimen name="activity_horizontal_margin">16dp</dimen>
+    <dimen name="activity_vertical_margin">16dp</dimen>
+</resources>
old mode 100755 (executable)
new mode 100644 (file)
index 3e317da..0b5920e
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<resources>\r
-\r
-    <string name="app_name">FridgeServer</string>\r
-    <string name="hello_world">Hello world!</string>\r
-    <string name="action_settings">Settings</string>\r
-\r
-</resources>\r
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="app_name">FridgeServer</string>
+    <string name="hello_world">Hello world!</string>
+    <string name="action_settings">Settings</string>
+
+</resources>
old mode 100755 (executable)
new mode 100644 (file)
index 084b42b..766ab99
@@ -1,8 +1,8 @@
-<resources>\r
-\r
-    <!-- Base application theme. -->\r
-    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">\r
-        <!-- Customize your theme here. -->\r
-    </style>\r
-\r
-</resources>\r
+<resources>
+
+    <!-- Base application theme. -->
+    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+        <!-- Customize your theme here. -->
+    </style>
+
+</resources>
index a2ebdda..375b158 100644 (file)
@@ -64,7 +64,7 @@ public class MainActivity
     private List<OcResourceInfo> mResourceList;
 
     /**
-     * The custom adapter for displaying the ResourceListItem List 
+     * The custom adapter for displaying the ResourceListItem List
      */
     private ExpandableResourceListAdapter mResourceListAdapter;
 
old mode 100755 (executable)
new mode 100644 (file)
index 9922f58..59ca00e
@@ -1,9 +1,9 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"\r
-    package="base.iotivity.org.examples.message"\r
-    xmlns:tools="http://schemas.android.com/tools">\r
-\r
-    <uses-sdk tools:overrideLibrary="org.iotivity.base"></uses-sdk>\r
-\r
-    <application android:allowBackup="true" ></application>\r
-\r
-</manifest>\r
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="base.iotivity.org.examples.message"
+    xmlns:tools="http://schemas.android.com/tools">
+
+    <uses-sdk tools:overrideLibrary="org.iotivity.base"></uses-sdk>
+
+    <application android:allowBackup="true" ></application>
+
+</manifest>
index 7ecd6b3..4e5fbcf 100644 (file)
@@ -1,27 +1,27 @@
-/*\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
-\r
-package base.iotivity.org.examples.message;\r
-\r
-public interface IMessageLogger {\r
-    public void logMessage(String msg);\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package base.iotivity.org.examples.message;
+
+public interface IMessageLogger {
+    public void logMessage(String msg);
+}
old mode 100755 (executable)
new mode 100644 (file)
index 86dd253..fa9a5e0
@@ -1,26 +1,26 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"\r
-    package="org.iotivity.base.examples.simpleclient"\r
-    xmlns:tools="http://schemas.android.com/tools">\r
-\r
-    <uses-sdk tools:overrideLibrary="org.iotivity.base"></uses-sdk>\r
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="org.iotivity.base.examples.simpleclient"
+    xmlns:tools="http://schemas.android.com/tools">
+
+    <uses-sdk tools:overrideLibrary="org.iotivity.base"></uses-sdk>
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
-\r
-    <application\r
-        android:allowBackup="true"\r
-        android:icon="@drawable/ic_launcher"\r
-        android:label="@string/app_name"\r
-        android:theme="@style/AppTheme" >\r
-        <activity\r
-            android:name=".SimpleClient"\r
-            android:label="@string/app_name" >\r
-            <intent-filter>\r
-                <action android:name="android.intent.action.MAIN" />\r
-\r
-                <category android:name="android.intent.category.LAUNCHER" />\r
-            </intent-filter>\r
-        </activity>\r
-    </application>\r
-\r
-</manifest>\r
+
+    <application
+        android:allowBackup="true"
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name"
+        android:theme="@style/AppTheme" >
+        <activity
+            android:name=".SimpleClient"
+            android:label="@string/app_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>
index 2f981b3..f09c39b 100644 (file)
@@ -1,65 +1,65 @@
-/*\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
-\r
-package org.iotivity.base.examples.simpleclient;\r
-\r
-/**\r
- * Light\r
- *\r
- * This class is used by simpleclient to create an object and update the values depending on the server response\r
- */\r
-public class Light {\r
-    private boolean mState;\r
-    private int mPower;\r
-    private String mName;\r
-\r
-    // constructor\r
-    Light() {\r
-        mState = false;\r
-        mPower = 0;\r
-        mName = "";\r
-    }\r
-\r
-    // accessor methods\r
-    public boolean getState() {\r
-        return mState;\r
-    }\r
-    void setState(boolean state) {\r
-        mState = state;\r
-    }\r
-    int getPower() {\r
-        return mPower;\r
-    }\r
-    void setPower(int power) {\r
-        mPower = power;\r
-    }\r
-    String getName() {\r
-        return mName;\r
-    }\r
-    void setName(String name) {\r
-        mName = name;\r
-    }\r
-}\r
-\r
-\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base.examples.simpleclient;
+
+/**
+ * Light
+ *
+ * This class is used by simpleclient to create an object and update the values depending on the server response
+ */
+public class Light {
+    private boolean mState;
+    private int mPower;
+    private String mName;
+
+    // constructor
+    Light() {
+        mState = false;
+        mPower = 0;
+        mName = "";
+    }
+
+    // accessor methods
+    public boolean getState() {
+        return mState;
+    }
+    void setState(boolean state) {
+        mState = state;
+    }
+    int getPower() {
+        return mPower;
+    }
+    void setPower(int power) {
+        mPower = power;
+    }
+    String getName() {
+        return mName;
+    }
+    void setName(String name) {
+        mName = name;
+    }
+}
+
+
+
+
index dafe16a..90c287b 100644 (file)
-/*\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
-\r
-package org.iotivity.base.examples.simpleclient;\r
-\r
-import android.app.Activity;\r
-import android.content.BroadcastReceiver;\r
-import android.content.Context;\r
-import android.content.Intent;\r
-import android.content.SharedPreferences;\r
-import android.content.res.AssetManager;\r
-import android.os.Bundle;\r
-import android.os.Message;\r
-import android.preference.PreferenceManager;\r
-import android.text.method.ScrollingMovementMethod;\r
-import android.util.Log;\r
-import android.widget.LinearLayout;\r
-import android.widget.TextView;\r
-\r
-import org.iotivity.base.ErrorCode;\r
-import org.iotivity.base.ModeType;\r
-import org.iotivity.base.ObserveType;\r
-import org.iotivity.base.OcConnectivityType;\r
-import org.iotivity.base.OcException;\r
-import org.iotivity.base.OcHeaderOption;\r
-import org.iotivity.base.OcPlatform;\r
-import org.iotivity.base.OcRepresentation;\r
-import org.iotivity.base.OcResource;\r
-import org.iotivity.base.PlatformConfig;\r
-import org.iotivity.base.QualityOfService;\r
-import org.iotivity.base.ServiceType;\r
-\r
-import java.io.File;\r
-import java.io.FileNotFoundException;\r
-import java.io.FileOutputStream;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.io.OutputStream;\r
-import java.util.HashMap;\r
-import java.util.List;\r
-\r
-import base.iotivity.org.examples.message.IMessageLogger;\r
-\r
-/**\r
- * SimpleClient\r
- * <p/>\r
- * SimpleClient is a sample client app which should be started after the simpleServer is started.\r
- * It finds resources advertised by the server and calls different operations on it (GET, PUT,\r
- * POST and OBSERVE).\r
- * This implements IMessageLogger to display messages on the screen\r
- */\r
-public class SimpleClient extends Activity implements OcPlatform.OnResourceFoundListener,\r
-        IMessageLogger {\r
-    private static final String TAG = "SimpleClient: ";\r
-\r
-    private static final int BUFFER_SIZE = 1024;\r
-    private String filePath = "";\r
-    private Light myLight;\r
-    private OcResource curResource;\r
-\r
-    //for display\r
-    private TextView mEventsTextView;\r
-    private static boolean printOnce = true;\r
-\r
-    /**\r
-     * configure OIC platform and call findResource\r
-     */\r
-    private void initOICStack() {\r
-        //create platform config\r
-        PlatformConfig cfg = new PlatformConfig(\r
-                this,\r
-                ServiceType.IN_PROC,\r
-                ModeType.CLIENT_SERVER,\r
-                "0.0.0.0", // bind to all available interfaces\r
-                0,\r
-                QualityOfService.LOW, filePath + StringConstants.OIC_CLIENT_JSON_DB_FILE);\r
-        OcPlatform.Configure(cfg);\r
-        try {\r
-            /**\r
-             * find all resources\r
-             */\r
-            OcPlatform.findResource("", OcPlatform.WELL_KNOWN_QUERY + "?rt=" + "core.light",\r
-                    OcConnectivityType.CT_DEFAULT, this);\r
-        } catch (OcException e) {\r
-            logMessage(TAG + "findResource error: " + e.getMessage());\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-    }\r
-\r
-    @Override\r
-    /**\r
-     *  callback when a resource is found. This method calls doGetLightRepresentation to get the\r
-     *  current values of myLight\r
-     */\r
-    synchronized public void onResourceFound(OcResource ocResource) {\r
-        /**\r
-         *  this may potentially be called by multiple threads at the same time\r
-         */\r
-        synchronized (this) {\r
-            String resourceUri;\r
-            String hostAddress;\r
-            resourceUri = ocResource.getUri();\r
-            hostAddress = ocResource.getHost();\r
-            logMessage(TAG + "Discovered Resource\nUri: " + resourceUri + " \n Host: " + hostAddress);\r
-            // get the resource types\r
-            if (resourceUri.contains("light")) {\r
-                curResource = ocResource;\r
-                doGetLightRepresentation();\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-     * get myLight values after observe\r
-     */\r
-    private void doObserveLightRepresentation() {\r
-        // eventhandler for observe()\r
-        OcResource.OnObserveListener onObserveListener = new OcResource.OnObserveListener() {\r
-            @Override\r
-            public void onObserveCompleted(List<OcHeaderOption> ocHeaderOptions,\r
-                                           OcRepresentation ocRepresentation, int seqNum) {\r
-                if (printOnce) {\r
-                    logMessage(TAG + "OBSERVE request was successful");\r
-                    printOnce = false;\r
-                }\r
-                try {\r
-                    boolean state = ocRepresentation.getValue(StringConstants.STATE);\r
-                    int power = ocRepresentation.getValue(StringConstants.POWER);\r
-                    String name = ocRepresentation.getValue(StringConstants.NAME);\r
-                    myLight.setState(state);\r
-                    myLight.setPower(power);\r
-                    myLight.setName(name);\r
-                } catch (OcException e) {\r
-                    Log.e(TAG, e.getMessage());\r
-                }\r
-                logMessage(TAG + "onObserve: Power: " + myLight.getPower());\r
-                if (seqNum > 20) {\r
-                    try {\r
-                        curResource.cancelObserve();\r
-                        logMessage(TAG + "Successfully cancelled observe");\r
-                   } catch (OcException e) {\r
-                        logMessage(TAG + "cancelObserve error. " + e.getMessage());\r
-                        Log.e(TAG, e.getMessage());\r
-                    }\r
-                }\r
-\r
-            }\r
-\r
-            @Override\r
-            public void onObserveFailed(Throwable throwable) {\r
-                if (throwable instanceof OcException) {\r
-                    OcException ocEx = (OcException) throwable;\r
-                    ErrorCode errCode = ocEx.getErrorCode();\r
-                    //do something based on errorCode\r
-                }\r
-                Log.e(TAG, throwable.toString());\r
-            }\r
-        };\r
-        try {\r
-            curResource.observe(ObserveType.OBSERVE, new HashMap<String, String>(), onObserveListener);\r
-        } catch (OcException e) {\r
-            logMessage(TAG + e.getMessage());\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-    }\r
-\r
-    /**\r
-     * get the current value of myLight after POST and call doObserveLightRepresentation\r
-     *\r
-     * @param ocRepresentation needed to invoke post()\r
-     */\r
-    private void doOnPost2(OcRepresentation ocRepresentation) {\r
-        // eventhandler for post()\r
-        OcResource.OnPostListener onPostListener2 = new OcResource.OnPostListener() {\r
-            @Override\r
-            public void onPostCompleted(List<OcHeaderOption> ocHeaderOptions, OcRepresentation rep) {\r
-                logMessage(TAG + "POST request was successful");\r
-                String createdUri = rep.getUri();\r
-                if (createdUri.equals(StringConstants.RESOURCE_URI1)) {\r
-                    logMessage(TAG + "Uri of the created resource: " + createdUri);\r
-                } else {\r
-                    try {\r
-                        boolean state = rep.getValue(StringConstants.STATE);\r
-                        int power = rep.getValue(StringConstants.POWER);\r
-                        String name = rep.getValue(StringConstants.NAME);\r
-                        myLight.setState(state);\r
-                        myLight.setPower(power);\r
-                        myLight.setName(name);\r
-                    } catch (OcException e) {\r
-                        Log.e(TAG, e.getMessage());\r
-                    }\r
-                    logMessage(TAG + "onPost\nState: " + myLight.getState() + "\nPower: " +\r
-                            myLight.getPower() + "\nName: " + myLight.getName());\r
-                }\r
-                doObserveLightRepresentation();\r
-            }\r
-\r
-            @Override\r
-            public void onPostFailed(Throwable throwable) {\r
-                if (throwable instanceof OcException) {\r
-                    OcException ocEx = (OcException) throwable;\r
-                    ErrorCode errCode = ocEx.getErrorCode();\r
-                    //do something based on errorCode\r
-                }\r
-                Log.e(TAG, throwable.toString());\r
-            }\r
-        };\r
-        try {\r
-            curResource.post(ocRepresentation, new HashMap<String, String>(), onPostListener2);\r
-        } catch (OcException e) {\r
-            logMessage(TAG + e.getMessage());\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-    }\r
-\r
-    /**\r
-     * create a new resource and update its value.\r
-     */\r
-    private void doPostLightRepresentation() {\r
-        // eventhandler for post()\r
-        OcResource.OnPostListener onPostListener = new OcResource.OnPostListener() {\r
-            @Override\r
-            public void onPostCompleted(List<OcHeaderOption> ocHeaderOptions,\r
-                                        OcRepresentation ocRepresentation) {\r
-                String createdUri = "";\r
-                try {\r
-                    createdUri = ocRepresentation.getValue(StringConstants.CREATED_URI);\r
-                } catch (OcException e) {\r
-                    Log.e(TAG, e.getMessage());\r
-                }\r
-                if (createdUri.equals(StringConstants.RESOURCE_URI1)) {\r
-                    logMessage(TAG + "Uri of the created resource: " + createdUri);\r
-                } else {\r
-                    boolean state = false;\r
-                    try {\r
-                        state = ocRepresentation.getValue(StringConstants.STATE);\r
-                        int power = ocRepresentation.getValue(StringConstants.POWER);\r
-                        String name = ocRepresentation.getValue(StringConstants.NAME);\r
-                        myLight.setState(state);\r
-                        myLight.setPower(power);\r
-                        myLight.setName(name);\r
-                    } catch (OcException e) {\r
-                        Log.e(TAG, e.getMessage());\r
-                    }\r
-                }\r
-                OcRepresentation rep = new OcRepresentation();\r
-                myLight.setState(true);\r
-                myLight.setPower(55);\r
-                try {\r
-                    rep.setValue(StringConstants.POWER, myLight.getPower());\r
-                    rep.setValue(StringConstants.STATE, myLight.getState());\r
-                } catch (OcException e) {\r
-                    Log.e(TAG, e.getMessage());\r
-                }\r
-                doOnPost2(rep);\r
-            }\r
-\r
-            @Override\r
-            public void onPostFailed(Throwable throwable) {\r
-                if (throwable instanceof OcException) {\r
-                    OcException ocEx = (OcException) throwable;\r
-                    ErrorCode errCode = ocEx.getErrorCode();\r
-                    //do something based on errorCode\r
-                }\r
-                Log.e(TAG, throwable.toString());\r
-            }\r
-        };\r
-\r
-        OcRepresentation rep = new OcRepresentation();\r
-        myLight.setState(false);\r
-        myLight.setPower(105);\r
-        try {\r
-            rep.setValue(StringConstants.STATE, myLight.getState());\r
-            rep.setValue(StringConstants.POWER, myLight.getPower());\r
-        } catch (OcException e) {\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-        try {\r
-            curResource.post(rep, new HashMap<String, String>(), onPostListener);\r
-        } catch (OcException e) {\r
-            logMessage(TAG + e.getMessage());\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-    }\r
-\r
-    /**\r
-     * modify the current value of myLight and call doPostLightRepresentation\r
-     */\r
-    private void doPutLightRepresentation() {\r
-        // eventhandler for put()\r
-        OcResource.OnPutListener onPutListener = new OcResource.OnPutListener() {\r
-            @Override\r
-            public void onPutCompleted(List<OcHeaderOption> ocHeaderOptions,\r
-                                       OcRepresentation ocRepresentation) {\r
-                logMessage(TAG + "PUT resource was successful");\r
-                try {\r
-                    boolean state = ocRepresentation.getValue(StringConstants.STATE);\r
-                    int power = ocRepresentation.getValue(StringConstants.POWER);\r
-                    String name = ocRepresentation.getValue(StringConstants.NAME);\r
-                    myLight.setState(state);\r
-                    myLight.setPower(power);\r
-                    myLight.setName(name);\r
-                } catch (OcException e) {\r
-                    Log.e(TAG, e.getMessage());\r
-                }\r
-\r
-                logMessage(TAG + "onPutCompleted:\nState:" + myLight.getState() + "\nPower: " +\r
-                        myLight.getPower() + "\nName: " + myLight.getName());\r
-                doPostLightRepresentation();\r
-            }\r
-\r
-            @Override\r
-            public void onPutFailed(Throwable throwable) {\r
-\r
-                if (throwable instanceof OcException) {\r
-                    OcException ocEx = (OcException) throwable;\r
-                    ErrorCode errCode = ocEx.getErrorCode();\r
-                    //do something based on errorCode\r
-                }\r
-                Log.e(TAG, throwable.toString());\r
-            }\r
-        };\r
-\r
-        OcRepresentation rep = new OcRepresentation();\r
-        Log.d(TAG, "myLight settings: power = 15");\r
-        myLight.setState(true);\r
-        myLight.setPower(15);\r
-        try {\r
-            rep.setValue(StringConstants.STATE, myLight.getState());\r
-            rep.setValue(StringConstants.POWER, myLight.getPower());\r
-            rep.setValue(StringConstants.NAME, myLight.getName());\r
-        } catch (OcException e) {\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-        try {\r
-            Log.d(TAG, "before calling put");\r
-            curResource.put(rep, new HashMap<String, String>(), onPutListener);\r
-        } catch (OcException e) {\r
-            logMessage(TAG + e.getMessage());\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-        Log.d(TAG, "end of put call");\r
-    }\r
-\r
-    /**\r
-     * get the existing value of myLight and call doPutLightRepresentation() to modify the current values\r
-     */\r
-    private void doGetLightRepresentation() {\r
-        // eventhandler for get()\r
-        OcResource.OnGetListener onGetListener = new OcResource.OnGetListener() {\r
-            @Override\r
-            public void onGetCompleted(List<OcHeaderOption> headerOptionList,\r
-                                       OcRepresentation ocRepresentation) {\r
-                logMessage(TAG + "GET resource was successful " + StringConstants.STATE);\r
-                try {\r
-                    boolean state = ocRepresentation.getValue(StringConstants.STATE);\r
-                    int power = ocRepresentation.getValue(StringConstants.POWER);\r
-                    String name = ocRepresentation.getValue(StringConstants.NAME);\r
-                    myLight.setState(state);\r
-                    myLight.setPower(power);\r
-                    myLight.setName(name);\r
-                } catch (OcException e) {\r
-                    Log.e(TAG, e.getMessage());\r
-                }\r
-                logMessage(TAG + "onGetCompleted\nState: " + myLight.getState() + "\nPower: " +\r
-                        myLight.getPower() + "\nName: " + myLight.getName());\r
-                doPutLightRepresentation();\r
-            }\r
-\r
-            @Override\r
-            public void onGetFailed(Throwable throwable) {\r
-                if (throwable instanceof OcException) {\r
-                    OcException ocEx = (OcException) throwable;\r
-                    ErrorCode errCode = ocEx.getErrorCode();\r
-                    //do something based on errorCode\r
-                }\r
-                Log.e(TAG, throwable.toString());\r
-            }\r
-        };\r
-\r
-        try {\r
-            curResource.get(new HashMap<String, String>(), onGetListener);\r
-        } catch (OcException e) {\r
-            logMessage(TAG + e.getMessage());\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-    }\r
-\r
-    /**\r
-     * to display on SimpleClient screen\r
-     */\r
-    public class MessageReceiver extends BroadcastReceiver {\r
-        @Override\r
-        public void onReceive(Context context, Intent intent) {\r
-            final String message = intent.getStringExtra(StringConstants.MESSAGE);\r
-            logMessage(message);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    protected void onCreate(Bundle savedInstanceState) {\r
-        super.onCreate(savedInstanceState);\r
-        setContentView(R.layout.activity_main);\r
-        mEventsTextView = new TextView(this);\r
-        mEventsTextView.setMovementMethod(new ScrollingMovementMethod());\r
-        LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);\r
-        layout.addView(mEventsTextView, new LinearLayout.LayoutParams(\r
-                LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f)\r
-        );\r
-        myLight = new Light();\r
-        filePath = getFilesDir().getPath() + "/"; //  data/data/<package>/files/\r
-        //copy json when application runs first time\r
-        SharedPreferences wmbPreference = PreferenceManager.getDefaultSharedPreferences(this);\r
-        boolean isFirstRun = wmbPreference.getBoolean("FIRSTRUN", true);\r
-        if (isFirstRun) {\r
-            copyJsonFromAsset();\r
-            SharedPreferences.Editor editor = wmbPreference.edit();\r
-            editor.putBoolean("FIRSTRUN", false);\r
-            editor.commit();\r
-        }\r
-\r
-\r
-        initOICStack();\r
-    }\r
-/**\r
-     * Copy svr db json file from assets folder to app data files dir\r
-     */\r
-    private void copyJsonFromAsset() {\r
-        AssetManager assetManager = getAssets();\r
-        InputStream in = null;\r
-        OutputStream out = null;\r
-        try {\r
-            in = assetManager.open(StringConstants.OIC_CLIENT_JSON_DB_FILE);\r
-            File file = new File(filePath);\r
-            //check files directory exists\r
-            if (!(file.exists() && file.isDirectory())) {\r
-                file.mkdirs();\r
-            }\r
-            out = new FileOutputStream(filePath + StringConstants.OIC_CLIENT_JSON_DB_FILE);\r
-            copyFile(in, out);\r
-        } catch (NullPointerException e) {\r
-            logMessage(TAG + "Null pointer exception " + e.getMessage());\r
-            Log.e(TAG, e.getMessage());\r
-        } catch (FileNotFoundException e) {\r
-            logMessage(TAG + "Json svr db file not found " + e.getMessage());\r
-            Log.e(TAG, e.getMessage());\r
-        } catch (IOException e) {\r
-            logMessage(TAG + StringConstants.OIC_CLIENT_JSON_DB_FILE+ " file copy failed");\r
-            Log.e(TAG, e.getMessage());\r
-        } finally {\r
-            if (in != null) {\r
-                try {\r
-                    in.close();\r
-                } catch (IOException e) {\r
-                    Log.e(TAG, e.getMessage());\r
-                }\r
-            }\r
-            if (out != null) {\r
-                try {\r
-                    out.close();\r
-                } catch (IOException e) {\r
-                    Log.e(TAG, e.getMessage());\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    private void copyFile(InputStream in, OutputStream out) throws IOException {\r
-        byte[] buffer = new byte[BUFFER_SIZE];\r
-        int read;\r
-        while ((read = in.read(buffer)) != -1) {\r
-            out.write(buffer, 0, read);\r
-        }\r
-    }\r
-    @Override\r
-    public void logMessage(String text) {\r
-        logMsg(text);\r
-    }\r
-\r
-    public void logMsg(final String text) {\r
-        runOnUiThread(new Runnable() {\r
-            public void run() {\r
-                Message msg = new Message();\r
-                msg.obj = text;\r
-                mEventsTextView.append("\n");\r
-                mEventsTextView.append(text);\r
-            }\r
-        });\r
-        Log.i(TAG, text);\r
-        //to print on SimpleServer screen\r
-        Intent intent = new Intent("org.iotivity.base.examples.simpleclient");\r
-        intent.putExtra(StringConstants.MESSAGE, text);\r
-        sendBroadcast(intent);\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base.examples.simpleclient;
+
+import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.res.AssetManager;
+import android.os.Bundle;
+import android.os.Message;
+import android.preference.PreferenceManager;
+import android.text.method.ScrollingMovementMethod;
+import android.util.Log;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import org.iotivity.base.ErrorCode;
+import org.iotivity.base.ModeType;
+import org.iotivity.base.ObserveType;
+import org.iotivity.base.OcConnectivityType;
+import org.iotivity.base.OcException;
+import org.iotivity.base.OcHeaderOption;
+import org.iotivity.base.OcPlatform;
+import org.iotivity.base.OcRepresentation;
+import org.iotivity.base.OcResource;
+import org.iotivity.base.PlatformConfig;
+import org.iotivity.base.QualityOfService;
+import org.iotivity.base.ServiceType;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.List;
+
+import base.iotivity.org.examples.message.IMessageLogger;
+
+/**
+ * SimpleClient
+ * <p/>
+ * SimpleClient is a sample client app which should be started after the simpleServer is started.
+ * It finds resources advertised by the server and calls different operations on it (GET, PUT,
+ * POST and OBSERVE).
+ * This implements IMessageLogger to display messages on the screen
+ */
+public class SimpleClient extends Activity implements OcPlatform.OnResourceFoundListener,
+        IMessageLogger {
+    private static final String TAG = "SimpleClient: ";
+
+    private static final int BUFFER_SIZE = 1024;
+    private String filePath = "";
+    private Light myLight;
+    private OcResource curResource;
+
+    //for display
+    private TextView mEventsTextView;
+    private static boolean printOnce = true;
+
+    /**
+     * configure OIC platform and call findResource
+     */
+    private void initOICStack() {
+        //create platform config
+        PlatformConfig cfg = new PlatformConfig(
+                this,
+                ServiceType.IN_PROC,
+                ModeType.CLIENT_SERVER,
+                "0.0.0.0", // bind to all available interfaces
+                0,
+                QualityOfService.LOW, filePath + StringConstants.OIC_CLIENT_JSON_DB_FILE);
+        OcPlatform.Configure(cfg);
+        try {
+            /**
+             * find all resources
+             */
+            OcPlatform.findResource("", OcPlatform.WELL_KNOWN_QUERY + "?rt=" + "core.light",
+                    OcConnectivityType.CT_DEFAULT, this);
+        } catch (OcException e) {
+            logMessage(TAG + "findResource error: " + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        }
+    }
+
+    @Override
+    /**
+     *  callback when a resource is found. This method calls doGetLightRepresentation to get the
+     *  current values of myLight
+     */
+    synchronized public void onResourceFound(OcResource ocResource) {
+        /**
+         *  this may potentially be called by multiple threads at the same time
+         */
+        synchronized (this) {
+            String resourceUri;
+            String hostAddress;
+            resourceUri = ocResource.getUri();
+            hostAddress = ocResource.getHost();
+            logMessage(TAG + "Discovered Resource\nUri: " + resourceUri + " \n Host: " + hostAddress);
+            // get the resource types
+            if (resourceUri.contains("light")) {
+                curResource = ocResource;
+                doGetLightRepresentation();
+            }
+        }
+    }
+
+    /**
+     * get myLight values after observe
+     */
+    private void doObserveLightRepresentation() {
+        // eventhandler for observe()
+        OcResource.OnObserveListener onObserveListener = new OcResource.OnObserveListener() {
+            @Override
+            public void onObserveCompleted(List<OcHeaderOption> ocHeaderOptions,
+                                           OcRepresentation ocRepresentation, int seqNum) {
+                if (printOnce) {
+                    logMessage(TAG + "OBSERVE request was successful");
+                    printOnce = false;
+                }
+                try {
+                    boolean state = ocRepresentation.getValue(StringConstants.STATE);
+                    int power = ocRepresentation.getValue(StringConstants.POWER);
+                    String name = ocRepresentation.getValue(StringConstants.NAME);
+                    myLight.setState(state);
+                    myLight.setPower(power);
+                    myLight.setName(name);
+                } catch (OcException e) {
+                    Log.e(TAG, e.getMessage());
+                }
+                logMessage(TAG + "onObserve: Power: " + myLight.getPower());
+                if (seqNum > 20) {
+                    try {
+                        curResource.cancelObserve();
+                        logMessage(TAG + "Successfully cancelled observe");
+                   } catch (OcException e) {
+                        logMessage(TAG + "cancelObserve error. " + e.getMessage());
+                        Log.e(TAG, e.getMessage());
+                    }
+                }
+
+            }
+
+            @Override
+            public void onObserveFailed(Throwable throwable) {
+                if (throwable instanceof OcException) {
+                    OcException ocEx = (OcException) throwable;
+                    ErrorCode errCode = ocEx.getErrorCode();
+                    //do something based on errorCode
+                }
+                Log.e(TAG, throwable.toString());
+            }
+        };
+        try {
+            curResource.observe(ObserveType.OBSERVE, new HashMap<String, String>(), onObserveListener);
+        } catch (OcException e) {
+            logMessage(TAG + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        }
+    }
+
+    /**
+     * get the current value of myLight after POST and call doObserveLightRepresentation
+     *
+     * @param ocRepresentation needed to invoke post()
+     */
+    private void doOnPost2(OcRepresentation ocRepresentation) {
+        // eventhandler for post()
+        OcResource.OnPostListener onPostListener2 = new OcResource.OnPostListener() {
+            @Override
+            public void onPostCompleted(List<OcHeaderOption> ocHeaderOptions, OcRepresentation rep) {
+                logMessage(TAG + "POST request was successful");
+                String createdUri = rep.getUri();
+                if (createdUri.equals(StringConstants.RESOURCE_URI1)) {
+                    logMessage(TAG + "Uri of the created resource: " + createdUri);
+                } else {
+                    try {
+                        boolean state = rep.getValue(StringConstants.STATE);
+                        int power = rep.getValue(StringConstants.POWER);
+                        String name = rep.getValue(StringConstants.NAME);
+                        myLight.setState(state);
+                        myLight.setPower(power);
+                        myLight.setName(name);
+                    } catch (OcException e) {
+                        Log.e(TAG, e.getMessage());
+                    }
+                    logMessage(TAG + "onPost\nState: " + myLight.getState() + "\nPower: " +
+                            myLight.getPower() + "\nName: " + myLight.getName());
+                }
+                doObserveLightRepresentation();
+            }
+
+            @Override
+            public void onPostFailed(Throwable throwable) {
+                if (throwable instanceof OcException) {
+                    OcException ocEx = (OcException) throwable;
+                    ErrorCode errCode = ocEx.getErrorCode();
+                    //do something based on errorCode
+                }
+                Log.e(TAG, throwable.toString());
+            }
+        };
+        try {
+            curResource.post(ocRepresentation, new HashMap<String, String>(), onPostListener2);
+        } catch (OcException e) {
+            logMessage(TAG + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        }
+    }
+
+    /**
+     * create a new resource and update its value.
+     */
+    private void doPostLightRepresentation() {
+        // eventhandler for post()
+        OcResource.OnPostListener onPostListener = new OcResource.OnPostListener() {
+            @Override
+            public void onPostCompleted(List<OcHeaderOption> ocHeaderOptions,
+                                        OcRepresentation ocRepresentation) {
+                String createdUri = "";
+                try {
+                    createdUri = ocRepresentation.getValue(StringConstants.CREATED_URI);
+                } catch (OcException e) {
+                    Log.e(TAG, e.getMessage());
+                }
+                if (createdUri.equals(StringConstants.RESOURCE_URI1)) {
+                    logMessage(TAG + "Uri of the created resource: " + createdUri);
+                } else {
+                    boolean state = false;
+                    try {
+                        state = ocRepresentation.getValue(StringConstants.STATE);
+                        int power = ocRepresentation.getValue(StringConstants.POWER);
+                        String name = ocRepresentation.getValue(StringConstants.NAME);
+                        myLight.setState(state);
+                        myLight.setPower(power);
+                        myLight.setName(name);
+                    } catch (OcException e) {
+                        Log.e(TAG, e.getMessage());
+                    }
+                }
+                OcRepresentation rep = new OcRepresentation();
+                myLight.setState(true);
+                myLight.setPower(55);
+                try {
+                    rep.setValue(StringConstants.POWER, myLight.getPower());
+                    rep.setValue(StringConstants.STATE, myLight.getState());
+                } catch (OcException e) {
+                    Log.e(TAG, e.getMessage());
+                }
+                doOnPost2(rep);
+            }
+
+            @Override
+            public void onPostFailed(Throwable throwable) {
+                if (throwable instanceof OcException) {
+                    OcException ocEx = (OcException) throwable;
+                    ErrorCode errCode = ocEx.getErrorCode();
+                    //do something based on errorCode
+                }
+                Log.e(TAG, throwable.toString());
+            }
+        };
+
+        OcRepresentation rep = new OcRepresentation();
+        myLight.setState(false);
+        myLight.setPower(105);
+        try {
+            rep.setValue(StringConstants.STATE, myLight.getState());
+            rep.setValue(StringConstants.POWER, myLight.getPower());
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+        }
+        try {
+            curResource.post(rep, new HashMap<String, String>(), onPostListener);
+        } catch (OcException e) {
+            logMessage(TAG + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        }
+    }
+
+    /**
+     * modify the current value of myLight and call doPostLightRepresentation
+     */
+    private void doPutLightRepresentation() {
+        // eventhandler for put()
+        OcResource.OnPutListener onPutListener = new OcResource.OnPutListener() {
+            @Override
+            public void onPutCompleted(List<OcHeaderOption> ocHeaderOptions,
+                                       OcRepresentation ocRepresentation) {
+                logMessage(TAG + "PUT resource was successful");
+                try {
+                    boolean state = ocRepresentation.getValue(StringConstants.STATE);
+                    int power = ocRepresentation.getValue(StringConstants.POWER);
+                    String name = ocRepresentation.getValue(StringConstants.NAME);
+                    myLight.setState(state);
+                    myLight.setPower(power);
+                    myLight.setName(name);
+                } catch (OcException e) {
+                    Log.e(TAG, e.getMessage());
+                }
+
+                logMessage(TAG + "onPutCompleted:\nState:" + myLight.getState() + "\nPower: " +
+                        myLight.getPower() + "\nName: " + myLight.getName());
+                doPostLightRepresentation();
+            }
+
+            @Override
+            public void onPutFailed(Throwable throwable) {
+
+                if (throwable instanceof OcException) {
+                    OcException ocEx = (OcException) throwable;
+                    ErrorCode errCode = ocEx.getErrorCode();
+                    //do something based on errorCode
+                }
+                Log.e(TAG, throwable.toString());
+            }
+        };
+
+        OcRepresentation rep = new OcRepresentation();
+        Log.d(TAG, "myLight settings: power = 15");
+        myLight.setState(true);
+        myLight.setPower(15);
+        try {
+            rep.setValue(StringConstants.STATE, myLight.getState());
+            rep.setValue(StringConstants.POWER, myLight.getPower());
+            rep.setValue(StringConstants.NAME, myLight.getName());
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+        }
+        try {
+            Log.d(TAG, "before calling put");
+            curResource.put(rep, new HashMap<String, String>(), onPutListener);
+        } catch (OcException e) {
+            logMessage(TAG + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        }
+        Log.d(TAG, "end of put call");
+    }
+
+    /**
+     * get the existing value of myLight and call doPutLightRepresentation() to modify the current values
+     */
+    private void doGetLightRepresentation() {
+        // eventhandler for get()
+        OcResource.OnGetListener onGetListener = new OcResource.OnGetListener() {
+            @Override
+            public void onGetCompleted(List<OcHeaderOption> headerOptionList,
+                                       OcRepresentation ocRepresentation) {
+                logMessage(TAG + "GET resource was successful " + StringConstants.STATE);
+                try {
+                    boolean state = ocRepresentation.getValue(StringConstants.STATE);
+                    int power = ocRepresentation.getValue(StringConstants.POWER);
+                    String name = ocRepresentation.getValue(StringConstants.NAME);
+                    myLight.setState(state);
+                    myLight.setPower(power);
+                    myLight.setName(name);
+                } catch (OcException e) {
+                    Log.e(TAG, e.getMessage());
+                }
+                logMessage(TAG + "onGetCompleted\nState: " + myLight.getState() + "\nPower: " +
+                        myLight.getPower() + "\nName: " + myLight.getName());
+                doPutLightRepresentation();
+            }
+
+            @Override
+            public void onGetFailed(Throwable throwable) {
+                if (throwable instanceof OcException) {
+                    OcException ocEx = (OcException) throwable;
+                    ErrorCode errCode = ocEx.getErrorCode();
+                    //do something based on errorCode
+                }
+                Log.e(TAG, throwable.toString());
+            }
+        };
+
+        try {
+            curResource.get(new HashMap<String, String>(), onGetListener);
+        } catch (OcException e) {
+            logMessage(TAG + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        }
+    }
+
+    /**
+     * to display on SimpleClient screen
+     */
+    public class MessageReceiver extends BroadcastReceiver {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            final String message = intent.getStringExtra(StringConstants.MESSAGE);
+            logMessage(message);
+        }
+    }
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_main);
+        mEventsTextView = new TextView(this);
+        mEventsTextView.setMovementMethod(new ScrollingMovementMethod());
+        LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);
+        layout.addView(mEventsTextView, new LinearLayout.LayoutParams(
+                LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f)
+        );
+        myLight = new Light();
+        filePath = getFilesDir().getPath() + "/"; //  data/data/<package>/files/
+        //copy json when application runs first time
+        SharedPreferences wmbPreference = PreferenceManager.getDefaultSharedPreferences(this);
+        boolean isFirstRun = wmbPreference.getBoolean("FIRSTRUN", true);
+        if (isFirstRun) {
+            copyJsonFromAsset();
+            SharedPreferences.Editor editor = wmbPreference.edit();
+            editor.putBoolean("FIRSTRUN", false);
+            editor.commit();
+        }
+
+
+        initOICStack();
+    }
+/**
+     * Copy svr db json file from assets folder to app data files dir
+     */
+    private void copyJsonFromAsset() {
+        AssetManager assetManager = getAssets();
+        InputStream in = null;
+        OutputStream out = null;
+        try {
+            in = assetManager.open(StringConstants.OIC_CLIENT_JSON_DB_FILE);
+            File file = new File(filePath);
+            //check files directory exists
+            if (!(file.exists() && file.isDirectory())) {
+                file.mkdirs();
+            }
+            out = new FileOutputStream(filePath + StringConstants.OIC_CLIENT_JSON_DB_FILE);
+            copyFile(in, out);
+        } catch (NullPointerException e) {
+            logMessage(TAG + "Null pointer exception " + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        } catch (FileNotFoundException e) {
+            logMessage(TAG + "Json svr db file not found " + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        } catch (IOException e) {
+            logMessage(TAG + StringConstants.OIC_CLIENT_JSON_DB_FILE+ " file copy failed");
+            Log.e(TAG, e.getMessage());
+        } finally {
+            if (in != null) {
+                try {
+                    in.close();
+                } catch (IOException e) {
+                    Log.e(TAG, e.getMessage());
+                }
+            }
+            if (out != null) {
+                try {
+                    out.close();
+                } catch (IOException e) {
+                    Log.e(TAG, e.getMessage());
+                }
+            }
+        }
+    }
+
+    private void copyFile(InputStream in, OutputStream out) throws IOException {
+        byte[] buffer = new byte[BUFFER_SIZE];
+        int read;
+        while ((read = in.read(buffer)) != -1) {
+            out.write(buffer, 0, read);
+        }
+    }
+    @Override
+    public void logMessage(String text) {
+        logMsg(text);
+    }
+
+    public void logMsg(final String text) {
+        runOnUiThread(new Runnable() {
+            public void run() {
+                Message msg = new Message();
+                msg.obj = text;
+                mEventsTextView.append("\n");
+                mEventsTextView.append(text);
+            }
+        });
+        Log.i(TAG, text);
+        //to print on SimpleServer screen
+        Intent intent = new Intent("org.iotivity.base.examples.simpleclient");
+        intent.putExtra(StringConstants.MESSAGE, text);
+        sendBroadcast(intent);
+    }
+}
index 54336f8..e02837e 100644 (file)
@@ -1,17 +1,17 @@
-package org.iotivity.base.examples.simpleclient;\r
-/**\r
- * StringConstant contains the simpleclient specific constant values.  To add another supported\r
- * Resource or Interface type to this app, begin by adding the new strings here, and then\r
- * find the places throughout the app where Resource-specific case switches occur, and add\r
- * the newly-supported type there.\r
- */\r
-public interface StringConstants {\r
-    public static final String RESOURCE_URI0 = "/a/light";\r
-    public static final String RESOURCE_URI1 = "/a/light2";\r
-    public static final String OIC_CLIENT_JSON_DB_FILE =  "oic_svr_db_client.json";\r
-    public static final String CREATED_URI = "createduri";\r
-    public static final String STATE = "state";\r
-    public static final String NAME = "name";\r
-    public static final String POWER = "power";\r
-    public static final String MESSAGE = "message";\r
-}\r
+package org.iotivity.base.examples.simpleclient;
+/**
+ * StringConstant contains the simpleclient specific constant values.  To add another supported
+ * Resource or Interface type to this app, begin by adding the new strings here, and then
+ * find the places throughout the app where Resource-specific case switches occur, and add
+ * the newly-supported type there.
+ */
+public interface StringConstants {
+    public static final String RESOURCE_URI0 = "/a/light";
+    public static final String RESOURCE_URI1 = "/a/light2";
+    public static final String OIC_CLIENT_JSON_DB_FILE =  "oic_svr_db_client.json";
+    public static final String CREATED_URI = "createduri";
+    public static final String STATE = "state";
+    public static final String NAME = "name";
+    public static final String POWER = "power";
+    public static final String MESSAGE = "message";
+}
old mode 100755 (executable)
new mode 100644 (file)
index 9aecf74..9797443
@@ -1,18 +1,18 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
-    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"\r
-    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"\r
-    android:paddingRight="@dimen/activity_horizontal_margin"\r
-    android:paddingTop="@dimen/activity_vertical_margin"\r
-    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"\r
-    android:label="@string/app_name">\r
-\r
-    <TextView android:text="@string/app_name" android:layout_width="wrap_content"\r
-        android:layout_height="wrap_content" />\r
-\r
-    <LinearLayout\r
-        android:layout_width="fill_parent"\r
-        android:layout_height="fill_parent"\r
-        android:orientation="vertical"\r
-        android:id="@+id/linearLayout" >\r
-    </LinearLayout>\r
-</RelativeLayout>\r
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
+    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
+    android:label="@string/app_name">
+
+    <TextView android:text="@string/app_name" android:layout_width="wrap_content"
+        android:layout_height="wrap_content" />
+
+    <LinearLayout
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent"
+        android:orientation="vertical"
+        android:id="@+id/linearLayout" >
+    </LinearLayout>
+</RelativeLayout>
old mode 100755 (executable)
new mode 100644 (file)
index a1045e9..b1cb908
@@ -1,6 +1,6 @@
-<menu xmlns:android="http://schemas.android.com/apk/res/android"\r
-    xmlns:app="http://schemas.android.com/apk/res-auto"\r
-    xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">\r
-    <item android:id="@+id/action_settings" android:title="@string/action_settings"\r
-        android:orderInCategory="100" app:showAsAction="never" />\r
-</menu>\r
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
+    <item android:id="@+id/action_settings" android:title="@string/action_settings"
+        android:orderInCategory="100" app:showAsAction="never" />
+</menu>
old mode 100755 (executable)
new mode 100644 (file)
index 62df187..63fc816
@@ -1,6 +1,6 @@
-<resources>\r
-    <!-- Example customization of dimensions originally defined in res/values/dimens.xml\r
-         (such as screen margins) for screens with more than 820dp of available width. This\r
-         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->\r
-    <dimen name="activity_horizontal_margin">64dp</dimen>\r
-</resources>\r
+<resources>
+    <!-- Example customization of dimensions originally defined in res/values/dimens.xml
+         (such as screen margins) for screens with more than 820dp of available width. This
+         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
+    <dimen name="activity_horizontal_margin">64dp</dimen>
+</resources>
old mode 100755 (executable)
new mode 100644 (file)
index 295b5a9..47c8224
@@ -1,5 +1,5 @@
-<resources>\r
-    <!-- Default screen margins, per the Android Design guidelines. -->\r
-    <dimen name="activity_horizontal_margin">16dp</dimen>\r
-    <dimen name="activity_vertical_margin">16dp</dimen>\r
-</resources>\r
+<resources>
+    <!-- Default screen margins, per the Android Design guidelines. -->
+    <dimen name="activity_horizontal_margin">16dp</dimen>
+    <dimen name="activity_vertical_margin">16dp</dimen>
+</resources>
old mode 100755 (executable)
new mode 100644 (file)
index 575b3e0..103ecb2
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<resources>\r
-\r
-    <string name="app_name">Starting Simple Client</string>\r
-    <string name="hello_world">Hello world!</string>\r
-    <string name="action_settings">Settings</string>\r
-\r
-</resources>\r
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="app_name">Starting Simple Client</string>
+    <string name="hello_world">Hello world!</string>
+    <string name="action_settings">Settings</string>
+
+</resources>
old mode 100755 (executable)
new mode 100644 (file)
index 084b42b..766ab99
@@ -1,8 +1,8 @@
-<resources>\r
-\r
-    <!-- Base application theme. -->\r
-    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">\r
-        <!-- Customize your theme here. -->\r
-    </style>\r
-\r
-</resources>\r
+<resources>
+
+    <!-- Base application theme. -->
+    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+        <!-- Customize your theme here. -->
+    </style>
+
+</resources>
old mode 100755 (executable)
new mode 100644 (file)
index 0026240..d1ba814
@@ -1,26 +1,26 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"\r
-    package="org.iotivity.base.examples.simpleserver"\r
-    xmlns:tools="http://schemas.android.com/tools">\r
-\r
-    <uses-sdk tools:overrideLibrary="org.iotivity.base"></uses-sdk>\r
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="org.iotivity.base.examples.simpleserver"
+    xmlns:tools="http://schemas.android.com/tools">
+
+    <uses-sdk tools:overrideLibrary="org.iotivity.base"></uses-sdk>
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
-\r
-    <application\r
-        android:allowBackup="true"\r
-        android:icon="@drawable/ic_launcher"\r
-        android:label="@string/app_name"\r
-        android:theme="@style/AppTheme" >\r
-        <activity\r
-            android:name=".SimpleServer"\r
-            android:label="@string/app_name" >\r
-            <intent-filter>\r
-                <action android:name="android.intent.action.MAIN" />\r
-\r
-                <category android:name="android.intent.category.LAUNCHER" />\r
-            </intent-filter>\r
-        </activity>\r
-    </application>\r
-\r
-</manifest>\r
+
+    <application
+        android:allowBackup="true"
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name"
+        android:theme="@style/AppTheme" >
+        <activity
+            android:name=".SimpleServer"
+            android:label="@string/app_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>
index 0993995..f27b23b 100644 (file)
@@ -1,86 +1,86 @@
-/*\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
-\r
-/*\r
- * // Starts a new thread for OBSERVE. It increments the value of mPower by 10 every 3 seconds\r
- */\r
-package org.iotivity.base.examples.simpleserver;\r
-\r
-import android.util.Log;\r
-\r
-import org.iotivity.base.EntityHandlerResult;\r
-import org.iotivity.base.OcException;\r
-import org.iotivity.base.OcPlatform;\r
-import org.iotivity.base.OcRepresentation;\r
-import org.iotivity.base.OcResourceResponse;\r
-\r
-import java.util.List;\r
-\r
-/**\r
- * LightRepThread\r
- *\r
- * Spawn a thread for OBSERVE. This increments the resource's power value by 10 every 3 seconds.\r
- * If there is an observationList, call notifyListOfObservers(). Otherwise, call notifyAllObservers()\r
- */\r
-public class LightRepThread extends Thread {\r
-    private static String TAG = "LightRepThread: ";\r
-\r
-    private LightResource mLightResource;\r
-    private List<Byte> mObservationList;\r
-    private static int count = 0;\r
-\r
-    LightRepThread(Object lr, List<Byte> observationList) {\r
-        mLightResource = (LightResource)lr;\r
-        mObservationList = observationList;\r
-    }\r
-\r
-    public void run() {\r
-        while(count < 20) {\r
-            try {\r
-                sleep(3000);\r
-            } catch (InterruptedException e) {\r
-                Log.e(TAG, e.getMessage());\r
-            }\r
-\r
-            // increment current power value by 10 every 3 seconds\r
-            mLightResource.setPower(mLightResource.getPower() + 10);\r
-            try {\r
-                // if observationList is not empty, call notifyListOfObservers\r
-                if (mObservationList.size() > 0) {\r
-                    OcResourceResponse ocResourceResponse = new OcResourceResponse();\r
-                    ocResourceResponse.setErrorCode(StringConstants.ERROR_CODE);\r
-                    ocResourceResponse.setResponseResult(EntityHandlerResult.OK);\r
-                    OcRepresentation r = mLightResource.get();\r
-                    ocResourceResponse.setResourceRepresentation\r
-                            (mLightResource.get(), OcPlatform.DEFAULT_INTERFACE);\r
-                    OcPlatform.notifyListOfObservers(mLightResource.getHandle(), mObservationList, ocResourceResponse);\r
-                } else {\r
-                    // notify all observers if mObservationList is empty\r
-                    OcPlatform.notifyAllObservers(mLightResource.getHandle());\r
-                }\r
-            } catch (OcException e) {\r
-                Log.e(TAG, e.getMessage());\r
-            }\r
-            ++count;\r
-        }\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+/*
+ * // Starts a new thread for OBSERVE. It increments the value of mPower by 10 every 3 seconds
+ */
+package org.iotivity.base.examples.simpleserver;
+
+import android.util.Log;
+
+import org.iotivity.base.EntityHandlerResult;
+import org.iotivity.base.OcException;
+import org.iotivity.base.OcPlatform;
+import org.iotivity.base.OcRepresentation;
+import org.iotivity.base.OcResourceResponse;
+
+import java.util.List;
+
+/**
+ * LightRepThread
+ *
+ * Spawn a thread for OBSERVE. This increments the resource's power value by 10 every 3 seconds.
+ * If there is an observationList, call notifyListOfObservers(). Otherwise, call notifyAllObservers()
+ */
+public class LightRepThread extends Thread {
+    private static String TAG = "LightRepThread: ";
+
+    private LightResource mLightResource;
+    private List<Byte> mObservationList;
+    private static int count = 0;
+
+    LightRepThread(Object lr, List<Byte> observationList) {
+        mLightResource = (LightResource)lr;
+        mObservationList = observationList;
+    }
+
+    public void run() {
+        while(count < 20) {
+            try {
+                sleep(3000);
+            } catch (InterruptedException e) {
+                Log.e(TAG, e.getMessage());
+            }
+
+            // increment current power value by 10 every 3 seconds
+            mLightResource.setPower(mLightResource.getPower() + 10);
+            try {
+                // if observationList is not empty, call notifyListOfObservers
+                if (mObservationList.size() > 0) {
+                    OcResourceResponse ocResourceResponse = new OcResourceResponse();
+                    ocResourceResponse.setErrorCode(StringConstants.ERROR_CODE);
+                    ocResourceResponse.setResponseResult(EntityHandlerResult.OK);
+                    OcRepresentation r = mLightResource.get();
+                    ocResourceResponse.setResourceRepresentation
+                            (mLightResource.get(), OcPlatform.DEFAULT_INTERFACE);
+                    OcPlatform.notifyListOfObservers(mLightResource.getHandle(), mObservationList, ocResourceResponse);
+                } else {
+                    // notify all observers if mObservationList is empty
+                    OcPlatform.notifyAllObservers(mLightResource.getHandle());
+                }
+            } catch (OcException e) {
+                Log.e(TAG, e.getMessage());
+            }
+            ++count;
+        }
+    }
+}
index a658663..78391c8 100644 (file)
-/*\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
-\r
-package org.iotivity.base.examples.simpleserver;\r
-\r
-import android.content.Context;\r
-import android.content.Intent;\r
-import android.util.Log;\r
-\r
-import org.iotivity.base.EntityHandlerResult;\r
-import org.iotivity.base.ObservationInfo;\r
-import org.iotivity.base.OcException;\r
-import org.iotivity.base.OcPlatform;\r
-import org.iotivity.base.OcRepresentation;\r
-import org.iotivity.base.OcResourceHandle;\r
-import org.iotivity.base.OcResourceRequest;\r
-import org.iotivity.base.OcResourceResponse;\r
-import org.iotivity.base.RequestHandlerFlag;\r
-import org.iotivity.base.RequestType;\r
-import org.iotivity.base.ResourceProperty;\r
-\r
-import java.util.EnumSet;\r
-import java.util.LinkedList;\r
-import java.util.List;\r
-\r
-import base.iotivity.org.examples.message.IMessageLogger;\r
-\r
-/**\r
- * LightResource\r
- *\r
- * class LightResource is the main class of the simpleServer. This creates resources and handles incoming requests from the client.\r
- */\r
-public class LightResource implements IMessageLogger {\r
-    private Context mContext;\r
-    private static String TAG = "SimpleServer: ";\r
-\r
-    private String mName;\r
-    private Boolean mState;\r
-    private Integer mPower;\r
-    private OcRepresentation mLightRep;\r
-    private OcResourceHandle mResourceHandle;\r
-    private List<Byte> mObservationIds;\r
-    private static boolean doOnce; // used in POST\r
-    LightRepThread lightRepThread;\r
-\r
-    // constructor\r
-    LightResource(Context context) {\r
-        mContext = context;\r
-        mName = "John's light";\r
-        mState = false;\r
-        mPower = 0;\r
-        mObservationIds = new LinkedList<>();\r
-        mLightRep = new OcRepresentation();\r
-        try {\r
-            mLightRep.setValue(StringConstants.STATE, mState);\r
-            mLightRep.setValue(StringConstants.POWER, mPower);\r
-            mLightRep.setValue(StringConstants.NAME, mName);\r
-        } catch (OcException e) {\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-        doOnce = true; // used in post\r
-        lightRepThread = null;\r
-    }\r
-\r
-    //accessor methods\r
-    protected int getPower() {\r
-        return mPower;\r
-    }\r
-    protected void setPower(int power) {\r
-        mPower = power;\r
-    }\r
-    protected OcResourceHandle getHandle() {\r
-        return mResourceHandle;\r
-    }\r
-\r
-    /**\r
-     *  creates a resource. this method internally calls registerResource\r
-     * @return returns the OcResourceHandle after creating and registering the resource\r
-     */\r
-    protected OcResourceHandle createResource0() {\r
-        // entityhandler for registerResource\r
-        OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() {\r
-            @Override\r
-            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {\r
-                // this is where the main logic of simpleserver is handled as different requests (GET, PUT, POST, OBSERVE, DELETE) are handled\r
-                return entityHandler(ocResourceRequest);\r
-            }\r
-        };\r
-\r
-        try {\r
-            mResourceHandle = OcPlatform.registerResource(StringConstants.RESOURCE_URI0, StringConstants.RESOURCE_TYPENAME,\r
-                StringConstants.RESOURCE_INTERFACE, eh,\r
-                EnumSet.of(ResourceProperty.DISCOVERABLE, ResourceProperty.OBSERVABLE));\r
-        } catch (OcException e) {\r
-            logMessage(TAG + "RegisterResource error. " + e.getMessage());\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-        logMessage(TAG + "Successfully registered resource");\r
-        return mResourceHandle;\r
-    }\r
-\r
-    /**\r
-     *  create another resource. this method internally calls registerResource\r
-     */\r
-    private void createResource1() {\r
-        // entityhandler for registerResource\r
-        OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() {\r
-            @Override\r
-            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {\r
-                // this is where the main logic of simpleserver is handled as different requests (GET, PUT, POST, OBSERVE, DELETE) are handled\r
-            return entityHandler(ocResourceRequest);\r
-            }\r
-        };\r
-\r
-        try {\r
-            OcPlatform.registerResource(StringConstants.RESOURCE_URI1, StringConstants.RESOURCE_TYPENAME,\r
-                StringConstants.RESOURCE_INTERFACE, eh,\r
-                EnumSet.of(ResourceProperty.DISCOVERABLE, ResourceProperty.OBSERVABLE));\r
-        } catch (OcException e) {\r
-            logMessage(TAG + "RegisterResource1 error: " + e.getMessage());\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-        logMessage(TAG + "Successfully registered resource1");\r
-    }\r
-\r
-    /**\r
-     * post representation . Post can act like put or can create a new resource.\r
-     * Gets value from the representation and updates the internal state\r
-     * @param rep current OcRepresentation of the object\r
-     * @return updated OcRepresentation\r
-     */\r
-    private OcRepresentation post(OcRepresentation rep) {\r
-        //create a resource the first time\r
-        if (true == doOnce) {\r
-            createResource1();\r
-            OcRepresentation representation = rep;\r
-            try {\r
-                representation.setValue(StringConstants.CREATED_URI, StringConstants.RESOURCE_URI1);\r
-            } catch (OcException e) {\r
-                Log.e(TAG, e.getMessage());\r
-            }\r
-            doOnce = false;\r
-            return representation;\r
-        }\r
-        // from second time onwards, put\r
-        put(rep);\r
-        return get();\r
-    }\r
-\r
-    /**\r
-     * puts representation . Gets value from the representation and updates the internal state\r
-     * @param rep current OcRepresentation of the object\r
-     */\r
-    private void put(OcRepresentation rep) {\r
-        try {\r
-            mState = rep.getValue(StringConstants.STATE);\r
-            mPower = rep.getValue(StringConstants.POWER);\r
-        } catch (OcException e) {\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-        logMessage(TAG + "Put State: " +  mState + " Name: " + mName + " Power: " + mPower);\r
-    }\r
-\r
-    /**\r
-     *  gets the updated representation. Updates the representation with internal state before sending out\r
-     * @return OcRepresentation after updating the values of the lightRepresentation\r
-     */\r
-    protected OcRepresentation get() {\r
-        try {\r
-            mLightRep.setValue(StringConstants.STATE, mState);\r
-            mLightRep.setValue(StringConstants.POWER, mPower);\r
-            mLightRep.setValue(StringConstants.NAME, mName);\r
-        } catch (OcException e) {\r
-            Log.e(TAG, e.getMessage());\r
-        }\r
-        return mLightRep;\r
-    }\r
-\r
-    /**\r
-     * this is the main method which handles different incoming requests appropriately.\r
-     * Init is not supported currently.\r
-     * @param request OcResourceRequest from the client\r
-     * @return EntityHandlerResult depending on whether the request was handled successfully or not\r
-     */\r
-    private EntityHandlerResult entityHandler(OcResourceRequest request) {\r
-        EntityHandlerResult result = EntityHandlerResult.ERROR;\r
-        if (null != request) {\r
-            RequestType requestType = request.getRequestType();\r
-            EnumSet<RequestHandlerFlag> requestFlag = request.getRequestHandlerFlagSet();\r
-\r
-            if (requestFlag.contains(RequestHandlerFlag.INIT)) {\r
-                logMessage(TAG + "Init");\r
-            }\r
-            if (requestFlag.contains(RequestHandlerFlag.REQUEST)) {\r
-                try {\r
-                    logMessage(TAG + "Request");\r
-                    OcResourceResponse ocResourceResponse = new OcResourceResponse();\r
-                    ocResourceResponse.setRequestHandle(request.getRequestHandle());\r
-                    ocResourceResponse.setResourceHandle(request.getResourceHandle());\r
-\r
-                    switch (requestType) {\r
-                        // handle GET request\r
-                        case GET:\r
-                            logMessage("GET");\r
-                            ocResourceResponse.setResponseResult(EntityHandlerResult.OK);\r
-                            ocResourceResponse.setErrorCode(StringConstants.ERROR_CODE);\r
-                            ocResourceResponse.setResourceRepresentation(get());\r
-                            OcPlatform.sendResponse(ocResourceResponse);\r
-                            break;\r
-                        // handle PUT request\r
-                        case PUT:\r
-                            OcRepresentation rep = request.getResourceRepresentation();\r
-                            put(rep);\r
-                            ocResourceResponse.setErrorCode(StringConstants.ERROR_CODE);\r
-                            ocResourceResponse.setResponseResult(EntityHandlerResult.OK);\r
-                            ocResourceResponse.setResourceRepresentation(get());\r
-                            OcPlatform.sendResponse(ocResourceResponse);\r
-                            break;\r
-                        // handle POST request\r
-                        case POST:\r
-                            rep = request.getResourceRepresentation();\r
-                            OcRepresentation rep_post = post(rep);\r
-                            ocResourceResponse.setResourceRepresentation(rep_post);\r
-                            ocResourceResponse.setErrorCode(StringConstants.ERROR_CODE);\r
-                            if (rep_post.hasAttribute(StringConstants.CREATED_URI)) {\r
-                                String createdUri = rep_post.getValue(StringConstants.CREATED_URI);\r
-                                if (createdUri.equals(StringConstants.RESOURCE_URI1)) {\r
-                                    ocResourceResponse.setNewResourceUri(createdUri);\r
-                                    ocResourceResponse.setResponseResult\r
-                                            (EntityHandlerResult.RESOURCE_CREATED);\r
-                                } else {\r
-                                    ocResourceResponse.setResponseResult(EntityHandlerResult.OK);\r
-                                }\r
-                            }\r
-                            OcPlatform.sendResponse(ocResourceResponse);\r
-                            break;\r
-                        // handle DELETE request\r
-                        case DELETE:\r
-                            logMessage(TAG + "DELETE");\r
-                            OcPlatform.unregisterResource(getHandle());\r
-                            OcPlatform.unregisterResource(getHandle());\r
-                            break;\r
-\r
-                    }\r
-\r
-                    result = EntityHandlerResult.OK;\r
-                } catch(OcException e) {\r
-                    logMessage(TAG + "Error in Request " + e.getMessage());\r
-                    Log.e(TAG, e.getMessage());\r
-                }\r
-            }\r
-            // handle OBSERVER request\r
-            if (requestFlag.contains(RequestHandlerFlag.OBSERVER)) {\r
-                logMessage(TAG + "OBSERVER");\r
-                ObservationInfo observationInfo = request.getObservationInfo();\r
-\r
-                switch (observationInfo.getObserveAction()) {\r
-                    case REGISTER:\r
-                        synchronized (mObservationIds) {\r
-                            mObservationIds.add(observationInfo.getOcObservationId());\r
-                        }\r
-                        break;\r
-                    case UNREGISTER:\r
-                        synchronized (mObservationIds) {\r
-                            mObservationIds.remove(observationInfo.getOcObservationId());\r
-                        }\r
-                        break;\r
-                }\r
-                if (null == lightRepThread) {\r
-                    lightRepThread = new LightRepThread(this, mObservationIds);\r
-                    lightRepThread.run();\r
-                }\r
-                result = EntityHandlerResult.OK;\r
-            }\r
-        }\r
-        return result;\r
-    }\r
-\r
-    @Override\r
-    public void logMessage(String msg) {\r
-        logMsg(msg);\r
-    }\r
-\r
-    public void logMsg(final String text) {\r
-        Intent intent = new Intent("org.iotivity.base.examples.simpleserver");\r
-        intent.putExtra(StringConstants.MESSAGE, text);\r
-        mContext.sendBroadcast(intent);\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base.examples.simpleserver;
+
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+import org.iotivity.base.EntityHandlerResult;
+import org.iotivity.base.ObservationInfo;
+import org.iotivity.base.OcException;
+import org.iotivity.base.OcPlatform;
+import org.iotivity.base.OcRepresentation;
+import org.iotivity.base.OcResourceHandle;
+import org.iotivity.base.OcResourceRequest;
+import org.iotivity.base.OcResourceResponse;
+import org.iotivity.base.RequestHandlerFlag;
+import org.iotivity.base.RequestType;
+import org.iotivity.base.ResourceProperty;
+
+import java.util.EnumSet;
+import java.util.LinkedList;
+import java.util.List;
+
+import base.iotivity.org.examples.message.IMessageLogger;
+
+/**
+ * LightResource
+ *
+ * class LightResource is the main class of the simpleServer. This creates resources and handles incoming requests from the client.
+ */
+public class LightResource implements IMessageLogger {
+    private Context mContext;
+    private static String TAG = "SimpleServer: ";
+
+    private String mName;
+    private Boolean mState;
+    private Integer mPower;
+    private OcRepresentation mLightRep;
+    private OcResourceHandle mResourceHandle;
+    private List<Byte> mObservationIds;
+    private static boolean doOnce; // used in POST
+    LightRepThread lightRepThread;
+
+    // constructor
+    LightResource(Context context) {
+        mContext = context;
+        mName = "John's light";
+        mState = false;
+        mPower = 0;
+        mObservationIds = new LinkedList<>();
+        mLightRep = new OcRepresentation();
+        try {
+            mLightRep.setValue(StringConstants.STATE, mState);
+            mLightRep.setValue(StringConstants.POWER, mPower);
+            mLightRep.setValue(StringConstants.NAME, mName);
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+        }
+        doOnce = true; // used in post
+        lightRepThread = null;
+    }
+
+    //accessor methods
+    protected int getPower() {
+        return mPower;
+    }
+    protected void setPower(int power) {
+        mPower = power;
+    }
+    protected OcResourceHandle getHandle() {
+        return mResourceHandle;
+    }
+
+    /**
+     *  creates a resource. this method internally calls registerResource
+     * @return returns the OcResourceHandle after creating and registering the resource
+     */
+    protected OcResourceHandle createResource0() {
+        // entityhandler for registerResource
+        OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() {
+            @Override
+            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {
+                // this is where the main logic of simpleserver is handled as different requests (GET, PUT, POST, OBSERVE, DELETE) are handled
+                return entityHandler(ocResourceRequest);
+            }
+        };
+
+        try {
+            mResourceHandle = OcPlatform.registerResource(StringConstants.RESOURCE_URI0, StringConstants.RESOURCE_TYPENAME,
+                StringConstants.RESOURCE_INTERFACE, eh,
+                EnumSet.of(ResourceProperty.DISCOVERABLE, ResourceProperty.OBSERVABLE));
+        } catch (OcException e) {
+            logMessage(TAG + "RegisterResource error. " + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        }
+        logMessage(TAG + "Successfully registered resource");
+        return mResourceHandle;
+    }
+
+    /**
+     *  create another resource. this method internally calls registerResource
+     */
+    private void createResource1() {
+        // entityhandler for registerResource
+        OcPlatform.EntityHandler eh = new OcPlatform.EntityHandler() {
+            @Override
+            public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest) {
+                // this is where the main logic of simpleserver is handled as different requests (GET, PUT, POST, OBSERVE, DELETE) are handled
+            return entityHandler(ocResourceRequest);
+            }
+        };
+
+        try {
+            OcPlatform.registerResource(StringConstants.RESOURCE_URI1, StringConstants.RESOURCE_TYPENAME,
+                StringConstants.RESOURCE_INTERFACE, eh,
+                EnumSet.of(ResourceProperty.DISCOVERABLE, ResourceProperty.OBSERVABLE));
+        } catch (OcException e) {
+            logMessage(TAG + "RegisterResource1 error: " + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        }
+        logMessage(TAG + "Successfully registered resource1");
+    }
+
+    /**
+     * post representation . Post can act like put or can create a new resource.
+     * Gets value from the representation and updates the internal state
+     * @param rep current OcRepresentation of the object
+     * @return updated OcRepresentation
+     */
+    private OcRepresentation post(OcRepresentation rep) {
+        //create a resource the first time
+        if (true == doOnce) {
+            createResource1();
+            OcRepresentation representation = rep;
+            try {
+                representation.setValue(StringConstants.CREATED_URI, StringConstants.RESOURCE_URI1);
+            } catch (OcException e) {
+                Log.e(TAG, e.getMessage());
+            }
+            doOnce = false;
+            return representation;
+        }
+        // from second time onwards, put
+        put(rep);
+        return get();
+    }
+
+    /**
+     * puts representation . Gets value from the representation and updates the internal state
+     * @param rep current OcRepresentation of the object
+     */
+    private void put(OcRepresentation rep) {
+        try {
+            mState = rep.getValue(StringConstants.STATE);
+            mPower = rep.getValue(StringConstants.POWER);
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+        }
+        logMessage(TAG + "Put State: " +  mState + " Name: " + mName + " Power: " + mPower);
+    }
+
+    /**
+     *  gets the updated representation. Updates the representation with internal state before sending out
+     * @return OcRepresentation after updating the values of the lightRepresentation
+     */
+    protected OcRepresentation get() {
+        try {
+            mLightRep.setValue(StringConstants.STATE, mState);
+            mLightRep.setValue(StringConstants.POWER, mPower);
+            mLightRep.setValue(StringConstants.NAME, mName);
+        } catch (OcException e) {
+            Log.e(TAG, e.getMessage());
+        }
+        return mLightRep;
+    }
+
+    /**
+     * this is the main method which handles different incoming requests appropriately.
+     * Init is not supported currently.
+     * @param request OcResourceRequest from the client
+     * @return EntityHandlerResult depending on whether the request was handled successfully or not
+     */
+    private EntityHandlerResult entityHandler(OcResourceRequest request) {
+        EntityHandlerResult result = EntityHandlerResult.ERROR;
+        if (null != request) {
+            RequestType requestType = request.getRequestType();
+            EnumSet<RequestHandlerFlag> requestFlag = request.getRequestHandlerFlagSet();
+
+            if (requestFlag.contains(RequestHandlerFlag.INIT)) {
+                logMessage(TAG + "Init");
+            }
+            if (requestFlag.contains(RequestHandlerFlag.REQUEST)) {
+                try {
+                    logMessage(TAG + "Request");
+                    OcResourceResponse ocResourceResponse = new OcResourceResponse();
+                    ocResourceResponse.setRequestHandle(request.getRequestHandle());
+                    ocResourceResponse.setResourceHandle(request.getResourceHandle());
+
+                    switch (requestType) {
+                        // handle GET request
+                        case GET:
+                            logMessage("GET");
+                            ocResourceResponse.setResponseResult(EntityHandlerResult.OK);
+                            ocResourceResponse.setErrorCode(StringConstants.ERROR_CODE);
+                            ocResourceResponse.setResourceRepresentation(get());
+                            OcPlatform.sendResponse(ocResourceResponse);
+                            break;
+                        // handle PUT request
+                        case PUT:
+                            OcRepresentation rep = request.getResourceRepresentation();
+                            put(rep);
+                            ocResourceResponse.setErrorCode(StringConstants.ERROR_CODE);
+                            ocResourceResponse.setResponseResult(EntityHandlerResult.OK);
+                            ocResourceResponse.setResourceRepresentation(get());
+                            OcPlatform.sendResponse(ocResourceResponse);
+                            break;
+                        // handle POST request
+                        case POST:
+                            rep = request.getResourceRepresentation();
+                            OcRepresentation rep_post = post(rep);
+                            ocResourceResponse.setResourceRepresentation(rep_post);
+                            ocResourceResponse.setErrorCode(StringConstants.ERROR_CODE);
+                            if (rep_post.hasAttribute(StringConstants.CREATED_URI)) {
+                                String createdUri = rep_post.getValue(StringConstants.CREATED_URI);
+                                if (createdUri.equals(StringConstants.RESOURCE_URI1)) {
+                                    ocResourceResponse.setNewResourceUri(createdUri);
+                                    ocResourceResponse.setResponseResult
+                                            (EntityHandlerResult.RESOURCE_CREATED);
+                                } else {
+                                    ocResourceResponse.setResponseResult(EntityHandlerResult.OK);
+                                }
+                            }
+                            OcPlatform.sendResponse(ocResourceResponse);
+                            break;
+                        // handle DELETE request
+                        case DELETE:
+                            logMessage(TAG + "DELETE");
+                            OcPlatform.unregisterResource(getHandle());
+                            OcPlatform.unregisterResource(getHandle());
+                            break;
+
+                    }
+
+                    result = EntityHandlerResult.OK;
+                } catch(OcException e) {
+                    logMessage(TAG + "Error in Request " + e.getMessage());
+                    Log.e(TAG, e.getMessage());
+                }
+            }
+            // handle OBSERVER request
+            if (requestFlag.contains(RequestHandlerFlag.OBSERVER)) {
+                logMessage(TAG + "OBSERVER");
+                ObservationInfo observationInfo = request.getObservationInfo();
+
+                switch (observationInfo.getObserveAction()) {
+                    case REGISTER:
+                        synchronized (mObservationIds) {
+                            mObservationIds.add(observationInfo.getOcObservationId());
+                        }
+                        break;
+                    case UNREGISTER:
+                        synchronized (mObservationIds) {
+                            mObservationIds.remove(observationInfo.getOcObservationId());
+                        }
+                        break;
+                }
+                if (null == lightRepThread) {
+                    lightRepThread = new LightRepThread(this, mObservationIds);
+                    lightRepThread.run();
+                }
+                result = EntityHandlerResult.OK;
+            }
+        }
+        return result;
+    }
+
+    @Override
+    public void logMessage(String msg) {
+        logMsg(msg);
+    }
+
+    public void logMsg(final String text) {
+        Intent intent = new Intent("org.iotivity.base.examples.simpleserver");
+        intent.putExtra(StringConstants.MESSAGE, text);
+        mContext.sendBroadcast(intent);
+    }
+}
index b48a9f5..f929ea0 100644 (file)
-/*\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
-\r
-package org.iotivity.base.examples.simpleserver;\r
-\r
-import android.app.Activity;\r
-import android.content.BroadcastReceiver;\r
-import android.content.Context;\r
-import android.content.Intent;\r
-import android.content.IntentFilter;\r
-import android.os.Bundle;\r
-import android.os.Message;\r
-import android.support.v4.content.LocalBroadcastManager;\r
-import android.text.method.ScrollingMovementMethod;\r
-import android.util.Log;\r
-import android.view.Menu;\r
-import android.view.MenuItem;\r
-import android.widget.LinearLayout;\r
-import android.widget.TextView;\r
-import android.content.SharedPreferences;\r
-import android.content.res.AssetManager;\r
-import android.preference.PreferenceManager;\r
-\r
-import org.iotivity.base.ModeType;\r
-import org.iotivity.base.OcPlatform;\r
-import org.iotivity.base.OcRepresentation;\r
-import org.iotivity.base.PlatformConfig;\r
-import org.iotivity.base.QualityOfService;\r
-import org.iotivity.base.ServiceType;\r
-\r
-import java.io.File;\r
-import java.io.FileNotFoundException;\r
-import java.io.FileOutputStream;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.io.OutputStream;\r
-\r
-import base.iotivity.org.examples.message.IMessageLogger;\r
-\r
-/**\r
- * SimpleServer\r
- *\r
- * SimpleServer instantiates a TextView and creates and configures OICPlatform.\r
- * It also creates a LightResource and waits for the incoming client requests to handle specific scenarios.\r
- * This implements IMessageLogger to display messages on the screen\r
- */\r
-\r
-public class SimpleServer extends Activity implements IMessageLogger {\r
-    private final static String TAG = "SimpleServer: ";\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.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+
+package org.iotivity.base.examples.simpleserver;
+
+import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Bundle;
+import android.os.Message;
+import android.support.v4.content.LocalBroadcastManager;
+import android.text.method.ScrollingMovementMethod;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import android.content.SharedPreferences;
+import android.content.res.AssetManager;
+import android.preference.PreferenceManager;
+
+import org.iotivity.base.ModeType;
+import org.iotivity.base.OcPlatform;
+import org.iotivity.base.OcRepresentation;
+import org.iotivity.base.PlatformConfig;
+import org.iotivity.base.QualityOfService;
+import org.iotivity.base.ServiceType;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import base.iotivity.org.examples.message.IMessageLogger;
+
+/**
+ * SimpleServer
+ *
+ * SimpleServer instantiates a TextView and creates and configures OICPlatform.
+ * It also creates a LightResource and waits for the incoming client requests to handle specific scenarios.
+ * This implements IMessageLogger to display messages on the screen
+ */
+
+public class SimpleServer extends Activity implements IMessageLogger {
+    private final static String TAG = "SimpleServer: ";
     private static final int BUFFER_SIZE = 1024;
-    private String filePath = "";\r
-    private TextView mEventsTextView;\r
-    private MessageReceiver mMessageReceiver = new MessageReceiver();\r
-\r
-    @Override\r
-    protected void onCreate(Bundle savedInstanceState) {\r
-        super.onCreate(savedInstanceState);\r
-        setContentView(R.layout.activity_main);\r
-        registerReceiver(mMessageReceiver, new IntentFilter("org.iotivity.base.examples.simpleserver"));\r
-\r
-        mEventsTextView = new TextView(this);\r
-        mEventsTextView.setMovementMethod(new ScrollingMovementMethod());\r
-        LinearLayout layout = (LinearLayout)findViewById(R.id.linearLayout);\r
-        layout.addView(mEventsTextView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f));\r
-\r
-        OcRepresentation rep = new OcRepresentation();\r
-        rep.setValueBool("test", false);\r
-        boolean result = rep.getValueBool("test");\r
-        filePath = getFilesDir().getPath() + "/";//  data/data/<package>/files/\r
-        //copy json when application runs first time\r
-        SharedPreferences wmbPreference = PreferenceManager.getDefaultSharedPreferences(this);\r
-        boolean isFirstRun = wmbPreference.getBoolean("FIRSTRUN", true);\r
-        if (isFirstRun) {\r
-            copyJsonFromAsset();\r
-            SharedPreferences.Editor editor = wmbPreference.edit();\r
-            editor.putBoolean("FIRSTRUN", false);\r
-            editor.commit();\r
+    private String filePath = "";
+    private TextView mEventsTextView;
+    private MessageReceiver mMessageReceiver = new MessageReceiver();
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_main);
+        registerReceiver(mMessageReceiver, new IntentFilter("org.iotivity.base.examples.simpleserver"));
+
+        mEventsTextView = new TextView(this);
+        mEventsTextView.setMovementMethod(new ScrollingMovementMethod());
+        LinearLayout layout = (LinearLayout)findViewById(R.id.linearLayout);
+        layout.addView(mEventsTextView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f));
+
+        OcRepresentation rep = new OcRepresentation();
+        rep.setValueBool("test", false);
+        boolean result = rep.getValueBool("test");
+        filePath = getFilesDir().getPath() + "/";//  data/data/<package>/files/
+        //copy json when application runs first time
+        SharedPreferences wmbPreference = PreferenceManager.getDefaultSharedPreferences(this);
+        boolean isFirstRun = wmbPreference.getBoolean("FIRSTRUN", true);
+        if (isFirstRun) {
+            copyJsonFromAsset();
+            SharedPreferences.Editor editor = wmbPreference.edit();
+            editor.putBoolean("FIRSTRUN", false);
+            editor.commit();
         }
-\r
-        initOICStack();\r
-    }\r
-
-    /**\r
-     * Copy svr db json file from assets folder to app data files dir\r
-     */\r
-    private void copyJsonFromAsset() {\r
-        AssetManager assetManager = getAssets();\r
-\r
-        InputStream in = null;\r
-        OutputStream out = null;\r
-        try {\r
-\r
-            in = assetManager.open(StringConstants.OIC_SERVER_JSON_DB_FILE);\r
-            File file = new File(filePath);\r
-            //check files directory exists\r
-            if (!(file.exists() && file.isDirectory())) {\r
-                file.mkdirs();\r
-            }\r
-            out = new FileOutputStream(filePath + StringConstants.OIC_SERVER_JSON_DB_FILE);\r
-            copyFile(in, out);\r
-        } catch (NullPointerException e) {\r
-            logMessage(TAG + "Null pointer exception " + e.getMessage());\r
-            Log.e(TAG, e.getMessage());\r
-        } catch (FileNotFoundException e) {\r
-            logMessage(TAG + "Json svr db file not found " + e.getMessage());\r
-            Log.e(TAG, e.getMessage());\r
-        } catch (IOException e) {\r
-            logMessage(TAG + StringConstants.OIC_SERVER_JSON_DB_FILE + " file copy failed");\r
-            Log.e(TAG, e.getMessage());\r
-        } finally {\r
-            if (in != null) {\r
-                try {\r
-                    in.close();\r
-                } catch (IOException e) {\r
-                    Log.e(TAG, e.getMessage());\r
-                }\r
-            }\r
-            if (out != null) {\r
-                try {\r
-                    out.close();\r
-                } catch (IOException e) {\r
-                    Log.e(TAG, e.getMessage());\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    private void copyFile(InputStream in, OutputStream out) throws IOException {\r
-        byte[] buffer = new byte[BUFFER_SIZE];\r
-        int read;\r
-        while ((read = in.read(buffer)) != -1) {\r
-            out.write(buffer, 0, read);\r
-        }\r
-    }\r
-    /**\r
-     * configure OIC platform and call findResource\r
-     */\r
-    private void initOICStack() {\r
-        //create platform config\r
-        PlatformConfig cfg = new PlatformConfig(\r
-                this,\r
-                ServiceType.IN_PROC,\r
-                ModeType.SERVER,\r
-                "0.0.0.0", // bind to all available interfaces\r
-                0,\r
-                QualityOfService.LOW,\r
-                filePath + StringConstants.OIC_SERVER_JSON_DB_FILE);\r
-        OcPlatform.Configure(cfg);\r
-        // Create instance of lightResource\r
-        LightResource myLight = new LightResource(this);\r
-        // create and register a resource\r
-        myLight.createResource0();\r
-    }\r
-
-    public class MessageReceiver extends BroadcastReceiver {\r
-        @Override\r
-        public void onReceive(Context context, Intent intent) {\r
-            final String message = intent.getStringExtra(StringConstants.MESSAGE);\r
-            logMessage(message);\r
-        }\r
-    }\r
-\r
-    public void logMessage(final String text) {\r
-        runOnUiThread(new Runnable() {\r
-            public void run() {\r
-                final Message msg = new Message();\r
-                msg.obj = text;\r
-                mEventsTextView.append("\n");\r
-                mEventsTextView.append(text);\r
-            }\r
-        });\r
-        Log.i(TAG, text);\r
-    }\r
-\r
-    @Override\r
-    public boolean onCreateOptionsMenu(Menu menu) {\r
-        getMenuInflater().inflate(R.menu.menu_main, menu);\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public boolean onOptionsItemSelected(MenuItem item) {\r
-        int id = item.getItemId();\r
-        if (id == R.id.action_settings) {\r
-            return true;\r
-        }\r
-        return super.onOptionsItemSelected(item);\r
-    }\r
-\r
-    @Override\r
-    public void onDestroy() {\r
-        super.onDestroy();\r
-        onStop();\r
-    }\r
-\r
-    @Override\r
-    protected void onStop() {\r
-        LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);\r
-        super.onStop();\r
-    }\r
+
+        initOICStack();
+    }
+
+    /**
+     * Copy svr db json file from assets folder to app data files dir
+     */
+    private void copyJsonFromAsset() {
+        AssetManager assetManager = getAssets();
+
+        InputStream in = null;
+        OutputStream out = null;
+        try {
+
+            in = assetManager.open(StringConstants.OIC_SERVER_JSON_DB_FILE);
+            File file = new File(filePath);
+            //check files directory exists
+            if (!(file.exists() && file.isDirectory())) {
+                file.mkdirs();
+            }
+            out = new FileOutputStream(filePath + StringConstants.OIC_SERVER_JSON_DB_FILE);
+            copyFile(in, out);
+        } catch (NullPointerException e) {
+            logMessage(TAG + "Null pointer exception " + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        } catch (FileNotFoundException e) {
+            logMessage(TAG + "Json svr db file not found " + e.getMessage());
+            Log.e(TAG, e.getMessage());
+        } catch (IOException e) {
+            logMessage(TAG + StringConstants.OIC_SERVER_JSON_DB_FILE + " file copy failed");
+            Log.e(TAG, e.getMessage());
+        } finally {
+            if (in != null) {
+                try {
+                    in.close();
+                } catch (IOException e) {
+                    Log.e(TAG, e.getMessage());
+                }
+            }
+            if (out != null) {
+                try {
+                    out.close();
+                } catch (IOException e) {
+                    Log.e(TAG, e.getMessage());
+                }
+            }
+        }
+    }
+
+    private void copyFile(InputStream in, OutputStream out) throws IOException {
+        byte[] buffer = new byte[BUFFER_SIZE];
+        int read;
+        while ((read = in.read(buffer)) != -1) {
+            out.write(buffer, 0, read);
+        }
+    }
+    /**
+     * configure OIC platform and call findResource
+     */
+    private void initOICStack() {
+        //create platform config
+        PlatformConfig cfg = new PlatformConfig(
+                this,
+                ServiceType.IN_PROC,
+                ModeType.SERVER,
+                "0.0.0.0", // bind to all available interfaces
+                0,
+                QualityOfService.LOW,
+                filePath + StringConstants.OIC_SERVER_JSON_DB_FILE);
+        OcPlatform.Configure(cfg);
+        // Create instance of lightResource
+        LightResource myLight = new LightResource(this);
+        // create and register a resource
+        myLight.createResource0();
+    }
+
+    public class MessageReceiver extends BroadcastReceiver {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            final String message = intent.getStringExtra(StringConstants.MESSAGE);
+            logMessage(message);
+        }
+    }
+
+    public void logMessage(final String text) {
+        runOnUiThread(new Runnable() {
+            public void run() {
+                final Message msg = new Message();
+                msg.obj = text;
+                mEventsTextView.append("\n");
+                mEventsTextView.append(text);
+            }
+        });
+        Log.i(TAG, text);
+    }
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        getMenuInflater().inflate(R.menu.menu_main, menu);
+        return true;
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        int id = item.getItemId();
+        if (id == R.id.action_settings) {
+            return true;
+        }
+        return super.onOptionsItemSelected(item);
+    }
+
+    @Override
+    public void onDestroy() {
+        super.onDestroy();
+        onStop();
+    }
+
+    @Override
+    protected void onStop() {
+        LocalBroadcastManager.getInstance(this).unregisterReceiver(mMessageReceiver);
+        super.onStop();
+    }
 }
\ No newline at end of file
index 46b5c2d..80b0f0c 100644 (file)
@@ -1,22 +1,22 @@
-package org.iotivity.base.examples.simpleserver;\r
-\r
-import org.iotivity.base.OcPlatform;\r
-/**\r
- * StringConstants contains the simpleserver specific constant values.  To add another supported\r
- * Resource or Interface type to this app, begin by adding the new strings here, and then\r
- * find the places throughout the app where Resource-specific case switches occur, and add\r
- * the newly-supported type there.\r
- */\r
-public interface StringConstants {\r
-    public static final String RESOURCE_URI0 = "/a/light";\r
-    public static final String RESOURCE_URI1 = "/a/light2";\r
-    public static final String RESOURCE_TYPENAME = "core.light";\r
-    public static final String OIC_SERVER_JSON_DB_FILE =  "oic_svr_db_server.json";\r
-    public static final String RESOURCE_INTERFACE = OcPlatform.DEFAULT_INTERFACE; //resource interface\r
-    public static final String CREATED_URI = "createduri";\r
-    public static final String STATE = "state";\r
-    public static final String NAME = "name";\r
-    public static final String POWER = "power";\r
-    public static final String MESSAGE = "message";\r
-    public static final int ERROR_CODE = 200;\r
-}\r
+package org.iotivity.base.examples.simpleserver;
+
+import org.iotivity.base.OcPlatform;
+/**
+ * StringConstants contains the simpleserver specific constant values.  To add another supported
+ * Resource or Interface type to this app, begin by adding the new strings here, and then
+ * find the places throughout the app where Resource-specific case switches occur, and add
+ * the newly-supported type there.
+ */
+public interface StringConstants {
+    public static final String RESOURCE_URI0 = "/a/light";
+    public static final String RESOURCE_URI1 = "/a/light2";
+    public static final String RESOURCE_TYPENAME = "core.light";
+    public static final String OIC_SERVER_JSON_DB_FILE =  "oic_svr_db_server.json";
+    public static final String RESOURCE_INTERFACE = OcPlatform.DEFAULT_INTERFACE; //resource interface
+    public static final String CREATED_URI = "createduri";
+    public static final String STATE = "state";
+    public static final String NAME = "name";
+    public static final String POWER = "power";
+    public static final String MESSAGE = "message";
+    public static final int ERROR_CODE = 200;
+}
old mode 100755 (executable)
new mode 100644 (file)
index ebe6ef7..b075b0b
@@ -1,31 +1,31 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
-    xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent"\r
-    android:layout_height="fill_parent" android:paddingLeft="@dimen/activity_horizontal_margin"\r
-    android:paddingRight="@dimen/activity_horizontal_margin"\r
-    android:paddingTop="@dimen/activity_vertical_margin"\r
-    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"\r
-    android:label="@string/app_name">\r
-\r
-    <ScrollView\r
-        android:layout_width="match_parent"\r
-        android:layout_height="match_parent"\r
-        android:id="@+id/scroll">\r
-\r
-        <TextView android:text="@string/simpleServer" android:layout_width="match_parent"\r
-            android:layout_height="match_parent"\r
-            android:id="@+id/textView"\r
-            android:scrollbars="vertical"\r
-            android:maxLines="10"/>\r
-\r
-    </ScrollView>\r
-\r
-    <LinearLayout\r
-        android:layout_width="match_parent"\r
-        android:layout_height="match_parent"\r
-        android:orientation="vertical"\r
-        android:id="@+id/linearLayout" >\r
-    </LinearLayout>\r
-\r
-\r
-</RelativeLayout>\r
-\r
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent"
+    android:layout_height="fill_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"
+    android:label="@string/app_name">
+
+    <ScrollView
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:id="@+id/scroll">
+
+        <TextView android:text="@string/simpleServer" android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:id="@+id/textView"
+            android:scrollbars="vertical"
+            android:maxLines="10"/>
+
+    </ScrollView>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical"
+        android:id="@+id/linearLayout" >
+    </LinearLayout>
+
+
+</RelativeLayout>
+
old mode 100755 (executable)
new mode 100644 (file)
index a1045e9..b1cb908
@@ -1,6 +1,6 @@
-<menu xmlns:android="http://schemas.android.com/apk/res/android"\r
-    xmlns:app="http://schemas.android.com/apk/res-auto"\r
-    xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">\r
-    <item android:id="@+id/action_settings" android:title="@string/action_settings"\r
-        android:orderInCategory="100" app:showAsAction="never" />\r
-</menu>\r
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
+    <item android:id="@+id/action_settings" android:title="@string/action_settings"
+        android:orderInCategory="100" app:showAsAction="never" />
+</menu>
old mode 100755 (executable)
new mode 100644 (file)
index 62df187..63fc816
@@ -1,6 +1,6 @@
-<resources>\r
-    <!-- Example customization of dimensions originally defined in res/values/dimens.xml\r
-         (such as screen margins) for screens with more than 820dp of available width. This\r
-         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->\r
-    <dimen name="activity_horizontal_margin">64dp</dimen>\r
-</resources>\r
+<resources>
+    <!-- Example customization of dimensions originally defined in res/values/dimens.xml
+         (such as screen margins) for screens with more than 820dp of available width. This
+         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
+    <dimen name="activity_horizontal_margin">64dp</dimen>
+</resources>
old mode 100755 (executable)
new mode 100644 (file)
index 295b5a9..47c8224
@@ -1,5 +1,5 @@
-<resources>\r
-    <!-- Default screen margins, per the Android Design guidelines. -->\r
-    <dimen name="activity_horizontal_margin">16dp</dimen>\r
-    <dimen name="activity_vertical_margin">16dp</dimen>\r
-</resources>\r
+<resources>
+    <!-- Default screen margins, per the Android Design guidelines. -->
+    <dimen name="activity_horizontal_margin">16dp</dimen>
+    <dimen name="activity_vertical_margin">16dp</dimen>
+</resources>
old mode 100755 (executable)
new mode 100644 (file)
index 4414f1d..2b03aa0
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="utf-8"?>\r
-<resources>\r
-\r
-    <string name="app_name">SimpleServer</string>\r
-    <string name="simpleServer">Starting Simple Server...</string>\r
-    <string name="action_settings">Settings</string>\r
-\r
-</resources>\r
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="app_name">SimpleServer</string>
+    <string name="simpleServer">Starting Simple Server...</string>
+    <string name="action_settings">Settings</string>
+
+</resources>
old mode 100755 (executable)
new mode 100644 (file)
index 084b42b..766ab99
@@ -1,8 +1,8 @@
-<resources>\r
-\r
-    <!-- Base application theme. -->\r
-    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">\r
-        <!-- Customize your theme here. -->\r
-    </style>\r
-\r
-</resources>\r
+<resources>
+
+    <!-- Base application theme. -->
+    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+        <!-- Customize your theme here. -->
+    </style>
+
+</resources>
index 518fb2a..c853da0 100644 (file)
@@ -20,7 +20,7 @@ editing capabilities, like the additions of various filters.
 
 Running OICMiddle with no arguments on a console shows the various capabilities
 it offers.  The most important are:
- -client.   Act as an OIC client. 
+ -client.   Act as an OIC client.
  -console.  Accept command lines from console input to drive the OIC client.
  -server.   Advertise resources found by the OIC client as OIC resources.
 
index ce6b173..8a6939b 100644 (file)
@@ -1,4 +1,4 @@
-#Set the two variables below for the client build. 
+#Set the two variables below for the client build.
 CLIENTARCH=x86
 BUILDTYPE=release
 ##
@@ -23,7 +23,7 @@ observer.o: observer.cpp
 server.o: server.cpp
 ifeq ($(SDKTARGETSYSROOT),)
        echo "Error: Yocto cross-toolchain environment not initialized"
-       exit 1 
+       exit 1
 endif
        $(CXX) -std=c++0x -c -o $@ $< $(YOCTOCXXFLAGS)
 
index ede704f..879fe2c 100644 (file)
@@ -165,7 +165,7 @@ if target_os == 'arduino':
 
                        os.system("find . -type f -exec dos2unix {} \;")
                        os.system("patch -p1 < " + src_dir + "/resource/csdk/connectivity/lib/arduino/arduino_due_ble.patch")
-               
+
                        # Remove downloaded file
                        os.remove(nordiclib_zip_file)
                else:
index 4dfa7ea..6ecdcd1 100644 (file)
@@ -69,7 +69,7 @@ elif target_os == 'linux':
                if not os.path.exists(gtest_dir + "/lib"):
                        # Run configure on gtest
                        print 'Configuring google unit test'
-                       if env.get('CROSS_COMPILE'): 
+                       if env.get('CROSS_COMPILE'):
                                env.Configure(gtest_dir, './configure --host=' + env['CROSS_COMPILE'])
                        else:
                                env.Configure(gtest_dir, './configure')
index a7b6093..4f8fe55 100644 (file)
@@ -1,4 +1,4 @@
-CONTENTS 
+CONTENTS
 
 This library contains functions and structures that can help
 constructing a single-threaded UDP server with DTLS support in
@@ -9,13 +9,13 @@ C99. The following components are available:
 
 * tests
   The subdirectory tests contains test programs that show how each
-  component is used. 
+  component is used.
 
 BUILDING
 
 When using the code from the git repository at sourceforge, invoke
 'autoreconf' to re-create the configure script. To build for Contiki,
-place tinydtls into Contiki's apps directory and call 
+place tinydtls into Contiki's apps directory and call
   ./configure --with-contiki.
 
 After configuration, invoke make to build the library and associated
index ead7ad3..4c6b4e1 100644 (file)
@@ -78,7 +78,7 @@ libtinydtls = env.StaticLibrary('libtinydtls', env.get('TINYDTLS_SRC'), OBJPREFI
 #
 # Note:
 # Currently there is a bug in debug.h/debug.c which fails compilation
-# of tinydtls samples in release mode. This bug is being tracked in 
+# of tinydtls samples in release mode. This bug is being tracked in
 # IOT-395
 ######################################################################
 if not env.get('RELEASE'):
old mode 100644 (file)
new mode 100755 (executable)
index fc98dce..819b828 100644 (file)
@@ -16,7 +16,7 @@ Edit connectivity/SConscript to build the APK
 uncomment the below line to build the sample :
 env.SConscript('./samples/' + target_os + '/casample/SConscript')
 
-Note : If this is enabled before building the SO files, Build will fail. 
+Note : If this is enabled before building the SO files, Build will fail.
 Ensure to disable the script whenever not required
 
 Installing the APK :
index 8e56590..726faee 100644 (file)
@@ -38,7 +38,7 @@ INC_DIRS        += -I$(DTLS_INC)
 SRC = $(wildcard *.c)
 OBJECTS = $(patsubst %.c, %.o, $(SRC))
 
-#Currently compiling libcoap objects. If it's provided by external party. 
+#Currently compiling libcoap objects. If it's provided by external party.
 #Then don't compile, Instead directly extract objects and create liboicinterface.a
 all: $(OBJECTS)
        $(MAKE) -C $(LIBCOAP) clean
index 5faa3dc..395be41 100644 (file)
@@ -2,7 +2,7 @@ libcoap: A C implementation of IETF Core Application protocol
 
 Copyright (C) 2010--2013 by Olaf Bergmann <bergmann@tzi.org>
 
-ABOUT LIBCOAP 
+ABOUT LIBCOAP
 
 libcoap is a C implementation of a lightweight application-protocol
 for devices that are constrained their resources such as computing
@@ -15,7 +15,7 @@ PACKAGE CONTENTS
 This directory contains a protocol parser and basic networking
 functions for platform with support for malloc() and BSD-style
 sockets. The examples directory contains a client and a server to
-demonstrate the use of this library. 
+demonstrate the use of this library.
 
 LICENSE INFORMATION
 
index 8c6ec26..08cdb86 100644 (file)
@@ -3,10 +3,10 @@
  * Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org>
  *
  * This file is part of the CoAP library libcoap. Please see
- * README for terms of use. 
+ * README for terms of use.
  */
 
-/** 
+/**
  * @file async.c
  * @brief state management for asynchronous messages
  */
index 0d7623b..3ec274f 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright (C) 2010--2012 Olaf Bergmann <bergmann@tzi.org>
  *
  * This file is part of the CoAP library libcoap. Please see
- * README for terms of use. 
+ * README for terms of use.
  */
 
 #ifndef _COAP_H_
index ba68c0e..116d7c1 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright (C) 2012--2013 Olaf Bergmann <bergmann@tzi.org>
  *
  * This file is part of the CoAP library libcoap. Please see
- * README for terms of use. 
+ * README for terms of use.
  */
 
 #include <string.h>
@@ -51,7 +51,7 @@ typedef struct
 
 coap_payload_t *test_resources = NULL;
 
-/** 
+/**
  * This structure is used to store URIs for dynamically allocated
  * resources, usually by POST or PUT.
  */
@@ -358,7 +358,7 @@ void hnd_put_test(coap_context_t *ctx, struct coap_resource_t *resource, coap_ad
         /* set default value */
         payload->media_type = COAP_MEDIATYPE_TEXT_PLAIN;
     }
-    /* FIXME: need to change attribute ct of resource. 
+    /* FIXME: need to change attribute ct of resource.
      To do so, we need dynamic management of the attribute value
      */
 
@@ -576,7 +576,7 @@ void init_resources(coap_context_t *ctx)
         coap_add_payload(r->key, test_payload, NULL);
     }
 
-    /* TD_COAP_BLOCK_01 
+    /* TD_COAP_BLOCK_01
      * TD_COAP_BLOCK_02 */
     test_payload = make_large("etsi_iot_01_largedata.txt");
     if (!test_payload)
index 02bc6ec..af5f022 100644 (file)
@@ -867,7 +867,7 @@ coap_tid_t coap_retransmit(coap_context_t *context, coap_queue_t *node)
     return COAP_INVALID_TID;
 }
 
-/** 
+/**
  * Checks if @p opt fits into the message that ends with @p maxpos.
  * This function returns @c 1 on success, or @c 0 if the option @p opt
  * would exceed @p maxpos.
index 725bbc4..6e71da8 100644 (file)
@@ -336,7 +336,7 @@ static inline unsigned short coap_new_message_id(coap_context_t *context)
     /**
      * Calculates a unique transaction id from given arguments @p peer and
      * @p pdu. The id is returned in @p id.
-     * 
+     *
      * @param peer The remote party who sent @p pdu.
      * @param pdu  The message that initiated the transaction.
      * @param id   Set to the new id.
@@ -427,7 +427,7 @@ static inline unsigned short coap_new_message_id(coap_context_t *context)
      * @code
      coap_opt_filter_t f = COAP_OPT_NONE;
      coap_opt_iterator_t opt_iter;
-     
+
      if (coap_option_check_critical(ctx, pdu, f) == 0) {
      coap_option_iterator_init(pdu, &opt_iter, f);
 
index 13a97f0..77c964c 100644 (file)
@@ -240,7 +240,7 @@ coap_opt_t *coap_check_option(coap_pdu_t *pdu, unsigned char type, coap_opt_iter
  * indicates by how many bytes @p opt must be advanced to encode the
  * option value.
  *
- * @param opt    The option buffer space where @p delta and @p length are 
+ * @param opt    The option buffer space where @p delta and @p length are
  *               written
  * @param maxlen The maximum length of @p opt
  * @param delta The actual delta value to encode.
index ae3d37a..9382615 100644 (file)
@@ -207,14 +207,14 @@ typedef unsigned int coap_print_status_t;
  *         the lower 28 bits will indicate the number of characters that
  *         have actually been output into @p buffer. The flag
  *         COAP_PRINT_STATUS_TRUNC indicates that the output has been
- *         truncated. 
+ *         truncated.
  */
 coap_print_status_t coap_print_link(const coap_resource_t *resource, unsigned char *buf,
         size_t *len, size_t *offset);
 
 /**
  * Registers the specified @p handler as message handler for the request type
- * @p method 
+ * @p method
  *
  * @param resource The resource for which the handler shall be registered.
  * @param method   The CoAP request method to handle.
@@ -245,7 +245,7 @@ coap_resource_t *coap_get_resource_from_key(coap_context_t *context, coap_key_t
 /**
  * Calculates the hash key for the resource requested by the
  * Uri-Options of @p request.  This function calls coap_hash() for
- * every path segment. 
+ * every path segment.
  *
  * @param request The requesting pdu.
  * @param key     The resulting hash is stored in @p key
@@ -253,7 +253,7 @@ coap_resource_t *coap_get_resource_from_key(coap_context_t *context, coap_key_t
 void coap_hash_request_uri(const coap_pdu_t *request, coap_key_t key);
 
 /**
- * @addtogroup observe 
+ * @addtogroup observe
  */
 
 /**
index 27c12ad..c964e8e 100644 (file)
@@ -741,7 +741,7 @@ void t_iterate_option10(void)
 }
 
 /************************************************************************
- ** initialization 
+ ** initialization
  ************************************************************************/
 
 CU_pSuite t_init_option_tests(void)
index c3a3449..375310a 100644 (file)
@@ -1,53 +1,53 @@
-##\r
-# Building sample application\r
-##\r
-\r
-Import('env')\r
-\r
-app_env = env.Clone()\r
-\r
-ca_os = app_env.get('TARGET_OS')\r
-ca_transport = app_env.get('TARGET_TRANSPORT')\r
-secured = app_env.get('SECURED')\r
-\r
-root_dir = './../../'\r
-main_dir  = Dir('.').srcnode().abspath\r
-jni_dir = main_dir + '/sample_serivce/android/jni'\r
-env.PrependUnique(CPPPATH = ['jni_dir'])\r
-app_env.PrependUnique(CPPDEFINES = ['__ANDROID__'])\r
-\r
-#####################################################################\r
-# Source files and Target(s)\r
-######################################################################\r
-\r
-print"Reading ca script %s"%ca_transport\r
-\r
-app_env.AppendUnique(CPPPATH = [root_dir + '/api/'])\r
-\r
-print "Reading sample application build script"\r
-\r
-build_dir = app_env.get('BUILD_DIR')\r
-secured = app_env.get('SECURED')\r
-\r
-print "Sample secured flag is %s" % secured\r
-\r
-sample_dir = 'casample/sampleService/src/main/jni/'\r
-sample_src = [sample_dir + 'ResourceModel.c',]\r
-\r
-print " sample src %s" % sample_src\r
-\r
-app_env.AppendUnique(LIBPATH = [app_env.get('BUILD_DIR'), '.',])\r
-app_env.AppendUnique(CPPPATH = ['lib/android'])\r
-app_env.PrependUnique(LIBS = ['connectivity_abstraction'])\r
+##
+# Building sample application
+##
+
+Import('env')
+
+app_env = env.Clone()
+
+ca_os = app_env.get('TARGET_OS')
+ca_transport = app_env.get('TARGET_TRANSPORT')
+secured = app_env.get('SECURED')
+
+root_dir = './../../'
+main_dir  = Dir('.').srcnode().abspath
+jni_dir = main_dir + '/sample_serivce/android/jni'
+env.PrependUnique(CPPPATH = ['jni_dir'])
+app_env.PrependUnique(CPPDEFINES = ['__ANDROID__'])
+
+#####################################################################
+# Source files and Target(s)
+######################################################################
+
+print"Reading ca script %s"%ca_transport
+
+app_env.AppendUnique(CPPPATH = [root_dir + '/api/'])
+
+print "Reading sample application build script"
+
+build_dir = app_env.get('BUILD_DIR')
+secured = app_env.get('SECURED')
+
+print "Sample secured flag is %s" % secured
+
+sample_dir = 'casample/sampleService/src/main/jni/'
+sample_src = [sample_dir + 'ResourceModel.c',]
+
+print " sample src %s" % sample_src
+
+app_env.AppendUnique(LIBPATH = [app_env.get('BUILD_DIR'), '.',])
+app_env.AppendUnique(CPPPATH = ['lib/android'])
+app_env.PrependUnique(LIBS = ['connectivity_abstraction'])
 app_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
-\r
-\r
-if secured == '1':\r
-       app_env.AppendUnique(CPPPATH = [root_dir + 'external/inc/'])\r
-       app_env.PrependUnique(CPPDEFINES = ['__WITH_DTLS__'])\r
-\r
-libRMInterface = app_env.SharedLibrary('RMInterface', sample_src, OBJPREFIX='libRMInterface_')\r
-app_env.InstallTarget(libRMInterface, 'RMInterface')\r
-app_env.UserInstallTargetLib(libRMInterface, 'RMInterface')\r
-\r
-\r
+
+
+if secured == '1':
+       app_env.AppendUnique(CPPPATH = [root_dir + 'external/inc/'])
+       app_env.PrependUnique(CPPDEFINES = ['__WITH_DTLS__'])
+
+libRMInterface = app_env.SharedLibrary('RMInterface', sample_src, OBJPREFIX='libRMInterface_')
+app_env.InstallTarget(libRMInterface, 'RMInterface')
+app_env.UserInstallTargetLib(libRMInterface, 'RMInterface')
+
+
index 8efa77c..8cdf053 100644 (file)
@@ -37,7 +37,7 @@ else:
                print "CA Transport is BT"
        else:
                env.AppendUnique(CPPDEFINES = ['NO_EDR_ADAPTER'])
-               
+
        if 'BLE' in transport:
                env.AppendUnique(CPPDEFINES = ['LE_ADAPTER','BLE_ADAPTER_TEST'])
                print "CA Transport is BLE"
@@ -49,7 +49,7 @@ else:
                print "CA Transport is IP"
        else:
                env.AppendUnique(CPPDEFINES = ['NO_IP_ADAPTER'])
-               
+
 
 ca_sample_src = [sample_dir + '/casample.c']
 
old mode 100755 (executable)
new mode 100644 (file)
index 2f4b5d5..da57dc1 100644 (file)
@@ -78,7 +78,7 @@ u_arraylist_t *CAIPGetInterfaceInformation(int desiredIndex)
         OIC_LOG_V(ERROR, TAG, "Failed to get ifaddrs: %s", strerror(errno));
         u_arraylist_destroy(iflist);
         return NULL;
-    } 
+    }
     OIC_LOG_V(DEBUG, TAG, "Got ifaddrs:: %s", ipAddr);
 
     struct in_addr inaddr;
index dbd2edf..2c5cf38 100644 (file)
@@ -1,49 +1,49 @@
-/******************************************************************\r
- *\r
- * Copyright 2014 Samsung Electronics All Rights Reserved.\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 <jni.h>\r
-/* Header for class org_iotivity_ca_CaIpInterface */\r
-\r
-#ifndef _Included_org_iotivity_ca_CaIpInterface\r
-#define _Included_org_iotivity_ca_CaIpInterface\r
-#ifdef __cplusplus\r
-extern "C"\r
-{\r
-#endif\r
-/*\r
- * Class:     org_iotivity_ca_caIpInterface\r
- * Method:    CaIpStateEnabled\r
- * Signature: ()V\r
- */\r
-JNIEXPORT void JNICALL\r
-Java_org_iotivity_ca_CaIpInterface_caIpStateEnabled(JNIEnv *, jclass);\r
-\r
-/*\r
- * Class:     org_iotivity_ca_caIpInterface\r
- * Method:    CaIpStateDisabled\r
- * Signature: ()V\r
- */\r
-JNIEXPORT void JNICALL\r
-Java_org_iotivity_ca_CaIpInterface_caIpStateDisabled(JNIEnv *, jclass);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-#endif\r
+/******************************************************************
+ *
+ * Copyright 2014 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * 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 <jni.h>
+/* Header for class org_iotivity_ca_CaIpInterface */
+
+#ifndef _Included_org_iotivity_ca_CaIpInterface
+#define _Included_org_iotivity_ca_CaIpInterface
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/*
+ * Class:     org_iotivity_ca_caIpInterface
+ * Method:    CaIpStateEnabled
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaIpInterface_caIpStateEnabled(JNIEnv *, jclass);
+
+/*
+ * Class:     org_iotivity_ca_caIpInterface
+ * Method:    CaIpStateDisabled
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaIpInterface_caIpStateDisabled(JNIEnv *, jclass);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
index 1e024fe..a4b5364 100644 (file)
@@ -4,18 +4,18 @@ Build notes
 // NOTICE - Transition to SCONS
 //-------------------------------------------------
 
-The IoTivity build system is transitioning to SCONS. Although the 
-makefiles are still available (until v1.0) and some developers are 
-still using them, they are currently no longer supported. To learn more 
-about building using SCONS see Readme.scons.txt in the repository root 
+The IoTivity build system is transitioning to SCONS. Although the
+makefiles are still available (until v1.0) and some developers are
+still using them, they are currently no longer supported. To learn more
+about building using SCONS see Readme.scons.txt in the repository root
 directory. The build steps used in continuous integration can be found
 in auto_build.sh which is also in the the repository root directory.
 
 //-------------------------------------------------
 // Linux
 //-------------------------------------------------
-To enable logging, ensure that 
-       -D TB_LOG 
+To enable logging, ensure that
+       -D TB_LOG
 is set in the compiler flags
 
 //-------------------------------------------------
@@ -28,7 +28,7 @@ LOCAL_CFLAGS := -DTB_LOG
 //-------------------------------------------------
 // Arduino
 //-------------------------------------------------
-To enable the logger for Arduino, TB_LOG should be defined in 
+To enable the logger for Arduino, TB_LOG should be defined in
 Properties|C/C++ Build|Settings|Tool Settings|AVR Compiler|Symbols
 and
 Properties|C/C++ Build|Settings|Tool Settings|AVR C++ Compiler|Symbols
index 4648a96..63152bf 100644 (file)
@@ -2,10 +2,10 @@
 // NOTICE - Transition to SCONS
 //---------------------------------------------------------------------
 
-The IoTivity build system is transitioning to SCONS. Although the 
-makefiles are still available (until v1.0) and some developers are 
-still using them, they are currently no longer supported. To learn more 
-about building using SCONS see Readme.scons.txt in the repository root 
+The IoTivity build system is transitioning to SCONS. Although the
+makefiles are still available (until v1.0) and some developers are
+still using them, they are currently no longer supported. To learn more
+about building using SCONS see Readme.scons.txt in the repository root
 directory. The build steps used in continuous integration can be found
 in auto_build.sh which is also in the the repository root directory.
 
index a1e8083..a7d94f5 100644 (file)
@@ -8,35 +8,35 @@
 05-30 12:56:28.136: D/Android(8314): this is a DEBUG message
 05-30 12:56:28.136: D/Android(8314): on multiple
 05-30 12:56:28.136: D/Android(8314): lines
-05-30 12:56:28.136: D/Android(8314): 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
-05-30 12:56:28.136: D/Android(8314): 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 
-05-30 12:56:28.136: D/Android(8314): 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 
-05-30 12:56:28.136: D/Android(8314): 30 31 
-05-30 12:56:28.136: D/Android(8314): 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
-05-30 12:56:28.136: D/Android(8314): 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 
-05-30 12:56:28.136: D/Android(8314): 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 
-05-30 12:56:28.136: D/Android(8314): 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 
-05-30 12:56:28.136: D/Android(8314): 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 
-05-30 12:56:28.136: D/Android(8314): 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 
-05-30 12:56:28.136: D/Android(8314): 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 
-05-30 12:56:28.136: D/Android(8314): 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 
-05-30 12:56:28.136: D/Android(8314): 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
-05-30 12:56:28.136: D/Android(8314): 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 
-05-30 12:56:28.136: D/Android(8314): 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 
-05-30 12:56:28.136: D/Android(8314): 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 
-05-30 12:56:28.136: D/Android(8314): 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 
-05-30 12:56:28.136: D/Android(8314): 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 
-05-30 12:56:28.136: D/Android(8314): 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 
-05-30 12:56:28.136: D/Android(8314): 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 
-05-30 12:56:28.136: D/Android(8314): 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
-05-30 12:56:28.136: D/Android(8314): 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 
-05-30 12:56:28.136: D/Android(8314): 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 
-05-30 12:56:28.136: D/Android(8314): 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 
-05-30 12:56:28.136: D/Android(8314): 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 
-05-30 12:56:28.136: D/Android(8314): 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 
-05-30 12:56:28.136: D/Android(8314): 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 
-05-30 12:56:28.136: D/Android(8314): 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 
-05-30 12:56:28.136: D/Android(8314): 80 
+05-30 12:56:28.136: D/Android(8314): 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+05-30 12:56:28.136: D/Android(8314): 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+05-30 12:56:28.136: D/Android(8314): 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+05-30 12:56:28.136: D/Android(8314): 30 31
+05-30 12:56:28.136: D/Android(8314): 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+05-30 12:56:28.136: D/Android(8314): 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+05-30 12:56:28.136: D/Android(8314): 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+05-30 12:56:28.136: D/Android(8314): 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+05-30 12:56:28.136: D/Android(8314): 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+05-30 12:56:28.136: D/Android(8314): 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
+05-30 12:56:28.136: D/Android(8314): 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+05-30 12:56:28.136: D/Android(8314): 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
+05-30 12:56:28.136: D/Android(8314): 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+05-30 12:56:28.136: D/Android(8314): 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+05-30 12:56:28.136: D/Android(8314): 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+05-30 12:56:28.136: D/Android(8314): 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+05-30 12:56:28.136: D/Android(8314): 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+05-30 12:56:28.136: D/Android(8314): 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
+05-30 12:56:28.136: D/Android(8314): 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+05-30 12:56:28.136: D/Android(8314): 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E
+05-30 12:56:28.136: D/Android(8314): 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+05-30 12:56:28.136: D/Android(8314): 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+05-30 12:56:28.136: D/Android(8314): 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+05-30 12:56:28.136: D/Android(8314): 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+05-30 12:56:28.136: D/Android(8314): 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+05-30 12:56:28.136: D/Android(8314): 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
+05-30 12:56:28.136: D/Android(8314): 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+05-30 12:56:28.136: D/Android(8314): 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
+05-30 12:56:28.136: D/Android(8314): 80
 05-30 12:56:28.136: D/Android(8314): this is a char: A
 05-30 12:56:28.136: D/Android(8314): this is an integer: 123
 05-30 12:56:28.136: D/Android(8314): this is a string: hello
index 8ffa9f3..f724654 100644 (file)
@@ -8,7 +8,7 @@ log outputs.
 
 arduinologgertestoutput.txt contains the output captured after running ArduinoLoggerTest.cpp
 
-Note: to enable the logger for Arduino, TB_LOG should be defined in 
+Note: to enable the logger for Arduino, TB_LOG should be defined in
 Properties|C/C++ Build|Settings|Tool Settings|AVR Compiler|Symbols
 and
 Properties|C/C++ Build|Settings|Tool Settings|AVR C++ Compiler|Symbols
index 1f91ee9..eb05280 100644 (file)
@@ -7,32 +7,32 @@ FATAL: Arduino: this is a FATAL message
 DEBUG: Arduino: this is a DEBUG message
 on multiple
 lines
-DEBUG: Arduino: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
-DEBUG: Arduino: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 
-DEBUG: Arduino: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 
-DEBUG: Arduino: 30 31 
-DEBUG: Arduino: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
-DEBUG: Arduino: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 
-DEBUG: Arduino: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 
-DEBUG: Arduino: 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 
-DEBUG: Arduino: 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 
-DEBUG: Arduino: 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 
-DEBUG: Arduino: 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 
-DEBUG: Arduino: 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 
-DEBUG: Arduino: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
-DEBUG: Arduino: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 
-DEBUG: Arduino: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 
-DEBUG: Arduino: 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 
-DEBUG: Arduino: 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 
-DEBUG: Arduino: 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 
-DEBUG: Arduino: 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 
-DEBUG: Arduino: 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 
-DEBUG: Arduino: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
-DEBUG: Arduino: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 
-DEBUG: Arduino: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 
-DEBUG: Arduino: 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 
-DEBUG: Arduino: 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 
-DEBUG: Arduino: 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 
-DEBUG: Arduino: 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 
-DEBUG: Arduino: 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 
-DEBUG: Arduino: 80 
+DEBUG: Arduino: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+DEBUG: Arduino: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+DEBUG: Arduino: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+DEBUG: Arduino: 30 31
+DEBUG: Arduino: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+DEBUG: Arduino: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+DEBUG: Arduino: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+DEBUG: Arduino: 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+DEBUG: Arduino: 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+DEBUG: Arduino: 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
+DEBUG: Arduino: 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+DEBUG: Arduino: 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
+DEBUG: Arduino: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+DEBUG: Arduino: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+DEBUG: Arduino: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+DEBUG: Arduino: 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+DEBUG: Arduino: 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+DEBUG: Arduino: 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
+DEBUG: Arduino: 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+DEBUG: Arduino: 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E
+DEBUG: Arduino: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+DEBUG: Arduino: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+DEBUG: Arduino: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+DEBUG: Arduino: 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+DEBUG: Arduino: 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+DEBUG: Arduino: 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
+DEBUG: Arduino: 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+DEBUG: Arduino: 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
+DEBUG: Arduino: 80
index 743c5e0..6850531 100644 (file)
@@ -1,29 +1,29 @@
-DEBUG: LogBuffer: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
-DEBUG: LogBuffer: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 
-DEBUG: LogBuffer: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 
-DEBUG: LogBuffer: 30 31 
-DEBUG: LogBuffer: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
-DEBUG: LogBuffer: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 
-DEBUG: LogBuffer: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 
-DEBUG: LogBuffer: 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 
-DEBUG: LogBuffer: 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 
-DEBUG: LogBuffer: 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 
-DEBUG: LogBuffer: 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 
-DEBUG: LogBuffer: 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 
-DEBUG: LogBuffer: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
-DEBUG: LogBuffer: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 
-DEBUG: LogBuffer: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 
-DEBUG: LogBuffer: 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 
-DEBUG: LogBuffer: 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 
-DEBUG: LogBuffer: 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 
-DEBUG: LogBuffer: 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 
-DEBUG: LogBuffer: 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 
-DEBUG: LogBuffer: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 
-DEBUG: LogBuffer: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 
-DEBUG: LogBuffer: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 
-DEBUG: LogBuffer: 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 
-DEBUG: LogBuffer: 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 
-DEBUG: LogBuffer: 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 
-DEBUG: LogBuffer: 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 
-DEBUG: LogBuffer: 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 
-DEBUG: LogBuffer: 80 
+DEBUG: LogBuffer: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+DEBUG: LogBuffer: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+DEBUG: LogBuffer: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+DEBUG: LogBuffer: 30 31
+DEBUG: LogBuffer: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+DEBUG: LogBuffer: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+DEBUG: LogBuffer: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+DEBUG: LogBuffer: 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+DEBUG: LogBuffer: 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+DEBUG: LogBuffer: 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
+DEBUG: LogBuffer: 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+DEBUG: LogBuffer: 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
+DEBUG: LogBuffer: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+DEBUG: LogBuffer: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+DEBUG: LogBuffer: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+DEBUG: LogBuffer: 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+DEBUG: LogBuffer: 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+DEBUG: LogBuffer: 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
+DEBUG: LogBuffer: 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+DEBUG: LogBuffer: 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E
+DEBUG: LogBuffer: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
+DEBUG: LogBuffer: 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
+DEBUG: LogBuffer: 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
+DEBUG: LogBuffer: 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
+DEBUG: LogBuffer: 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
+DEBUG: LogBuffer: 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
+DEBUG: LogBuffer: 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
+DEBUG: LogBuffer: 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
+DEBUG: LogBuffer: 80
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 78f204e..88ed6d3 100644 (file)
@@ -2,10 +2,10 @@
   NOTICE - Transition to SCONS
 -------------------------------------------------------------------------------
 
-The IoTivity build system is transitioning to SCONS. Although the 
-makefiles are still available (until v1.0) and some developers are 
-still using them, they are currently no longer supported. To learn more 
-about building using SCONS see Readme.scons.txt in the repository root 
+The IoTivity build system is transitioning to SCONS. Although the
+makefiles are still available (until v1.0) and some developers are
+still using them, they are currently no longer supported. To learn more
+about building using SCONS see Readme.scons.txt in the repository root
 directory. The build steps used in continuous integration can be found
 in auto_build.sh which is also in the the repository root directory.
 
index dc0e35b..89a41bf 100644 (file)
@@ -2,10 +2,10 @@
   NOTICE - Transition to SCONS
 -------------------------------------------------------------------------------
 
-The IoTivity build system is transitioning to SCONS. Although the 
-makefiles are still available (until v1.0) and some developers are 
-still using them, they are currently no longer supported. To learn more 
-about building using SCONS see Readme.scons.txt in the repository root 
+The IoTivity build system is transitioning to SCONS. Although the
+makefiles are still available (until v1.0) and some developers are
+still using them, they are currently no longer supported. To learn more
+about building using SCONS see Readme.scons.txt in the repository root
 directory. The build steps used in continuous integration can be found
 in auto_build.sh which is also in the the repository root directory.
 
index da8344f..df53605 100644 (file)
@@ -50,7 +50,7 @@ else:
                print "CA Transport is BT"
        else:
                env.AppendUnique(CPPDEFINES = ['NO_EDR_ADAPTER'])
-               
+
        if 'BLE' in transport:
                env.AppendUnique(CPPDEFINES = ['LE_ADAPTER','BLE_ADAPTER_TEST'])
                print "CA Transport is BLE"
old mode 100755 (executable)
new mode 100644 (file)
index 66aa0c0..c6d2bb8 100644 (file)
@@ -2,10 +2,10 @@
 //  NOTICE - Transition to SCONS
 //---------------------------------------------------------------------
 
-The IoTivity build system is transitioning to SCONS. Although the 
-makefiles are still available (until v1.0) and some developers are 
-still using them, they are currently no longer supported. To learn more 
-about building using SCONS see Readme.scons.txt in the repository root 
+The IoTivity build system is transitioning to SCONS. Although the
+makefiles are still available (until v1.0) and some developers are
+still using them, they are currently no longer supported. To learn more
+about building using SCONS see Readme.scons.txt in the repository root
 directory. The build steps used in continuous integration can be found
 in auto_build.sh which is also in the the repository root directory.
 
index 9260836..6e58afc 100644 (file)
@@ -80,11 +80,11 @@ extern "C" void asyncDoResourcesCallback(OCStackResult result, OCRepresentationH
 //  Tests
 //-----------------------------------------------------------------------------
 void test0() {
-    EXPECT_EQ(OC_STACK_OK, OCInit(0, 5683, OC_SERVER));  
+    EXPECT_EQ(OC_STACK_OK, OCInit(0, 5683, OC_SERVER));
 }
 
 void test1() {
-  EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 0, OC_SERVER));  
+  EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 0, OC_SERVER));
 }
 
 void test2() {
index a4954d7..69cf8b5 100644 (file)
@@ -135,7 +135,7 @@ extern "C" void asyncDoResourcesCallback(OCStackResult result, OCRepresentationH
 
 void test0() {
     OC_LOG(INFO, TAG, PCF("test0"));
-    EXPECT_EQ(OC_STACK_OK, OCInit(0, 5683, OC_SERVER)); 
+    EXPECT_EQ(OC_STACK_OK, OCInit(0, 5683, OC_SERVER));
 }
 
 void test1() {
index 3f51a4f..b950a79 100644 (file)
@@ -2,10 +2,10 @@
 //  NOTICE - Transition to SCONS
 //---------------------------------------------------------------------
 
-The IoTivity build system is transitioning to SCONS. Although the 
-makefiles are still available (until v1.0) and some developers are 
-still using them, they are currently no longer supported. To learn more 
-about building using SCONS see Readme.scons.txt in the repository root 
+The IoTivity build system is transitioning to SCONS. Although the
+makefiles are still available (until v1.0) and some developers are
+still using them, they are currently no longer supported. To learn more
+about building using SCONS see Readme.scons.txt in the repository root
 directory. The build steps used in continuous integration can be found
 in auto_build.sh which is also in the the repository root directory.
 
@@ -19,7 +19,7 @@ On Arduino, the logger outputs to the serial port using Serial.print.
 Run a serial terminal program such as CuteCom at 115200,8,N,1 to view the
 log outputs.
 
-Note: to enable the logger for Arduino, TB_LOG should be defined in 
+Note: to enable the logger for Arduino, TB_LOG should be defined in
 Properties|C/C++ Build|Settings|Tool Settings|AVR Compiler|Symbols
 and
 Properties|C/C++ Build|Settings|Tool Settings|AVR C++ Compiler|Symbols
old mode 100755 (executable)
new mode 100644 (file)
index 23cccc2..eff3a9a 100644 (file)
@@ -58,7 +58,7 @@ namespace OC
                         m_devAddr.flags =
                               (OCTransportFlags)(OC_FLAG_SECURE | m_devAddr.flags);
                     }
+
                     if (res->port != 0)
                     {
                          m_devAddr.port = res->port;
index 25a4cd3..aa8683e 100644 (file)
@@ -2,10 +2,10 @@
   NOTICE - Transition to SCONS
 -------------------------------------------------------------------------------
 
-The IoTivity build system is transitioning to SCONS. Although the 
-makefiles are still available (until v1.0) and some developers are 
-still using them, they are currently no longer supported. To learn more 
-about building using SCONS see Readme.scons.txt in the repository root 
+The IoTivity build system is transitioning to SCONS. Although the
+makefiles are still available (until v1.0) and some developers are
+still using them, they are currently no longer supported. To learn more
+about building using SCONS see Readme.scons.txt in the repository root
 directory. The build steps used in continuous integration can be found
 in auto_build.sh which is also in the the repository root directory.
 
index de7a8fd..72fbe85 100644 (file)
@@ -1,98 +1,98 @@
-Release notes\r
-Release date: Aug 5th, 2014. \r
-OS: Ubuntu 12.0.4 and above\r
-Requires boost version 1.55 to build. \r
-NOTE: Boost is not distributed but should be installed in the Ubuntu machine. \r
-\r
-What\92s new?\r
-Class OCPlatform (Header file: OCPlatform.h)\r
-registerResource API (signature update)\r
-\95This API provides the ability to register the resource with its name, type and list of properties\r
-\95Signature of this API has changed. The API takes reference to resource handle which will be filled upon successful registration. Other parameters include resource URI, resource Type, resource interface, entity handler address and resource property (whether discoverable, observable etc.). \r
-\95NOTE: This applies to server side functionality. \r
-\95NOTE: This API might get modified to accommodate for resource collection in future.\r
-\r
-notifyObservers API\r
-\95This new API provides the ability to notify core that resource\92s attributes have changed. When entity handler is ready to indicate core that a resource has changed, notifyObservers API needs to be invoked.\r
-\95This API takes resource handle as the only parameter. \r
-\95NOTE: This applies to server side functionality. \r
-\95NOTE: This API might get modified to accommodate for resource collection in future.\r
-\r
-Class OCResource (Header file: OCResource.h)\r
-\r
-get API\r
-\95This new API provides the ability to get the attributes of a resource. This API takes a callback as parameter. Callback will be invoked with Attribute map which will provide representation of the resource. Callback will also include error code for GET operation. \r
-\95NOTE: This applies to client side functionality. \r
-\95NOTE: This API might get modified to accommodate for resource collection in future.\r
-\r
-put API\r
-\95This new API provides the ability to set the attributes of a resource via PUT. \r
-\95This API takes Attribute map, query parameter map and a callback as parameters. Callback will be invoked with Attribute map which will provide current representation of the resource. Callback will also include error code for PUT operation. \r
-\95NOTE: This applies to client side functionality. \r
-\95NOTE: This API might get modified to accommodate for resource collection in future.\r
-\r
-Observe API\r
-\95This new API provides the ability for the client to set observation on a resource\r
-\95This API provides callback as a parameter. Callback will be invoked with attribute map and with an error code for this operation. \r
-\95NOTE: This applies to client side functionality. \r
-\r
-cancelObserve API\r
-\95This new API provides the ability for the client to cancel observation on a resource\r
-\95This API provides callback as a parameter. Callback will be invoked with error code for this operation. \r
-\95NOTE: This applies to client side functionality. \r
-Class OCResourceRequest (Header file: OCResourceRequest.h)\r
-NOTE: This applies to server side functionality. \r
-\r
-getRequestType API\r
-\95This new API provides the ability to retrieve the type of request. This could be GET, PUT (and in future POST and DELETE).\r
-\r
-getQueryParams API\r
-\95This new API provides the ability to retrieve the query parameters from the URL request. \r
-\r
-getRequestHandlerFlag API\r
-\95This new API provides the ability to retrieve the request handler flag on the URL request. This could be either INIT, REQUEST or OBSERVE flag. \r
-\r
-getResourceRepresentation API\r
-\95This new API provides the ability to retrieve attribute representation of the resource. \r
-\r
-Class OCResourceResponse (Header file: OCResourceResponse.h)\r
-NOTE: This applies to server side functionality. \r
-\r
-setErrorCode API\r
-\95This new API provides the ability to set the error code\r
-\r
-setResourceRepresentation API\r
-\95This new API provides the ability to set the attribute representation of a resource.  \r
-\r
-Other Notes:\r
-1.     Security model is still open. \r
-2.     APIs have OCStackResult as return type. This is will indicate success or failure for the API operation. \r
-3.     Resource collection/hierarchy APIs are not checked into the code base. They will be given as separate header files.  \r
-4.     Query parameters are not used in this deliverable.\r
-5.     Only single client observer has been tested.\r
-6.     Maximum length of URI supported is 64 bytes\r
-7.     Maximum length of response (for GET, PUT) from server is 128 bytes.\r
-\r
-\r
-How to build:\r
-1.     Root folder oic-resource consists of \91OIC\92 folder.  Inside OIC folder there is a Makefile. \r
-2.     Before building, make sure to have contents from oic-utilities repo at the folder level where oic-resource is.  \r
-3.     Use \91make\92 to build the entire OIC code. This would build the C++ SDK, stack and samples. \r
-\r
-Samples:\r
-1.     We have a sample for hosting a resource on a server and a sample for client which will be able to discover resources. \r
-2.     Server sample location: OIC/examples/simpleserver.cpp\r
-3.     Client sample location: OIC/examples/simpleclient.cpp\r
-4.     In simpleserver.cpp, inside main, \r
-\r
-PlatformConfig cfg;\r
-cfg.ipAddress = "134.134.161.33";\r
-\r
-Modify the above IP address to the IP address of the machine where this server is running. \r
-\r
-Similarly, in simpleclient.cpp, inside main, modify the IP address to the IP address of the machine where the client is running. \r
-\r
-The server and client can run in same machine or in different machines.\r
-\r
-5. To run simpleServer do \91./simpleServer\92 and to run simpleClient do \91./simpleClient\92.\r
-\r
+Release notes
+Release date: Aug 5th, 2014.
+OS: Ubuntu 12.0.4 and above
+Requires boost version 1.55 to build.
+NOTE: Boost is not distributed but should be installed in the Ubuntu machine.
+
+What\92s new?
+Class OCPlatform (Header file: OCPlatform.h)
+registerResource API (signature update)
+\95This API provides the ability to register the resource with its name, type and list of properties
+\95Signature of this API has changed. The API takes reference to resource handle which will be filled upon successful registration. Other parameters include resource URI, resource Type, resource interface, entity handler address and resource property (whether discoverable, observable etc.).
+\95NOTE: This applies to server side functionality.
+\95NOTE: This API might get modified to accommodate for resource collection in future.
+
+notifyObservers API
+\95This new API provides the ability to notify core that resource\92s attributes have changed. When entity handler is ready to indicate core that a resource has changed, notifyObservers API needs to be invoked.
+\95This API takes resource handle as the only parameter.
+\95NOTE: This applies to server side functionality.
+\95NOTE: This API might get modified to accommodate for resource collection in future.
+
+Class OCResource (Header file: OCResource.h)
+
+get API
+\95This new API provides the ability to get the attributes of a resource. This API takes a callback as parameter. Callback will be invoked with Attribute map which will provide representation of the resource. Callback will also include error code for GET operation.
+\95NOTE: This applies to client side functionality.
+\95NOTE: This API might get modified to accommodate for resource collection in future.
+
+put API
+\95This new API provides the ability to set the attributes of a resource via PUT.
+\95This API takes Attribute map, query parameter map and a callback as parameters. Callback will be invoked with Attribute map which will provide current representation of the resource. Callback will also include error code for PUT operation.
+\95NOTE: This applies to client side functionality.
+\95NOTE: This API might get modified to accommodate for resource collection in future.
+
+Observe API
+\95This new API provides the ability for the client to set observation on a resource
+\95This API provides callback as a parameter. Callback will be invoked with attribute map and with an error code for this operation.
+\95NOTE: This applies to client side functionality.
+
+cancelObserve API
+\95This new API provides the ability for the client to cancel observation on a resource
+\95This API provides callback as a parameter. Callback will be invoked with error code for this operation.
+\95NOTE: This applies to client side functionality.
+Class OCResourceRequest (Header file: OCResourceRequest.h)
+NOTE: This applies to server side functionality.
+
+getRequestType API
+\95This new API provides the ability to retrieve the type of request. This could be GET, PUT (and in future POST and DELETE).
+
+getQueryParams API
+\95This new API provides the ability to retrieve the query parameters from the URL request.
+
+getRequestHandlerFlag API
+\95This new API provides the ability to retrieve the request handler flag on the URL request. This could be either INIT, REQUEST or OBSERVE flag.
+
+getResourceRepresentation API
+\95This new API provides the ability to retrieve attribute representation of the resource.
+
+Class OCResourceResponse (Header file: OCResourceResponse.h)
+NOTE: This applies to server side functionality.
+
+setErrorCode API
+\95This new API provides the ability to set the error code
+
+setResourceRepresentation API
+\95This new API provides the ability to set the attribute representation of a resource.
+
+Other Notes:
+1.     Security model is still open.
+2.     APIs have OCStackResult as return type. This is will indicate success or failure for the API operation.
+3.     Resource collection/hierarchy APIs are not checked into the code base. They will be given as separate header files.
+4.     Query parameters are not used in this deliverable.
+5.     Only single client observer has been tested.
+6.     Maximum length of URI supported is 64 bytes
+7.     Maximum length of response (for GET, PUT) from server is 128 bytes.
+
+
+How to build:
+1.     Root folder oic-resource consists of \91OIC\92 folder.  Inside OIC folder there is a Makefile.
+2.     Before building, make sure to have contents from oic-utilities repo at the folder level where oic-resource is.
+3.     Use \91make\92 to build the entire OIC code. This would build the C++ SDK, stack and samples.
+
+Samples:
+1.     We have a sample for hosting a resource on a server and a sample for client which will be able to discover resources.
+2.     Server sample location: OIC/examples/simpleserver.cpp
+3.     Client sample location: OIC/examples/simpleclient.cpp
+4.     In simpleserver.cpp, inside main,
+
+PlatformConfig cfg;
+cfg.ipAddress = "134.134.161.33";
+
+Modify the above IP address to the IP address of the machine where this server is running.
+
+Similarly, in simpleclient.cpp, inside main, modify the IP address to the IP address of the machine where the client is running.
+
+The server and client can run in same machine or in different machines.
+
+5. To run simpleServer do \91./simpleServer\92 and to run simpleClient do \91./simpleClient\92.
+
index 74d059e..67bdee2 100644 (file)
@@ -14,25 +14,25 @@ What is new?
 --------------------------------------------
 Class OCPlatform (Header file: OCPlatform.h)
 --------------------------------------------
-This release includes support for using OCPlatform instance in multiple threads. 
+This release includes support for using OCPlatform instance in multiple threads.
 OCPlatform functions are now supported to be called from multiple threads.
-Applications need not create OCPlatform object explicitly. 
+Applications need not create OCPlatform object explicitly.
 
 
 ***************
 Configure API
 ***************
-Applications can set the PlatformConfig and then invoke new API "Configure" in OCPlatform.h. 
+Applications can set the PlatformConfig and then invoke new API "Configure" in OCPlatform.h.
 NOTE: This API is optional. First time an OCPlatform API is called, stack creates the singleton
 instance internally. After which, setting the configuration will have no effect.
 
-NOTE: OCPlatform functions can be called without OCPlatform instance. 
-Sample: 
+NOTE: OCPlatform functions can be called without OCPlatform instance.
+Sample:
 
-OCStackResult result = OCPlatform::registerResource(... ); 
+OCStackResult result = OCPlatform::registerResource(... );
 
 NOTE: For clarity, registerResource parameters are not shown above.
-NOTE: Iotivity stack internally creates a singleton instance. 
+NOTE: Iotivity stack internally creates a singleton instance.
 NOTE: C++ sample applications are updated accordingly. Please refer oic-resource/examples
 
 ------------
@@ -50,11 +50,11 @@ OIC base supports Arduino WiFi shield.
 This support has been tested with Arduino Mega 2560 and with Arduino 1.0.5 WiFi library.
 Please refer to oic-resource/csdk/README file for building OIC base with WiFi support.
 
-Minor bug fixes done. 
+Minor bug fixes done.
 
 Simple attribute sample update:
 This release has updates to roomserver and roomclient applications to demonstrate simple
-attribute support in collections. 
+attribute support in collections.
 
 C++ unit test infrastructure:
 This release includes infrastructure for C++ unit tests (oic-resource/unittests)
index 6ab1dc0..3990fdb 100644 (file)
@@ -1,13 +1,13 @@
 Release notes
 ****************************************************************************
-Release date: Sept 2nd, 2014. 
+Release date: Sept 2nd, 2014.
 OS: Ubuntu 12.0.4 and above
-Requires boost version 1.55 to build. 
-Code buildable in gcc 4.6.3 and above. 
-NOTE: Boost is not distributed but should be installed in the Ubuntu machine. 
+Requires boost version 1.55 to build.
+Code buildable in gcc 4.6.3 and above.
+NOTE: Boost is not distributed but should be installed in the Ubuntu machine.
 *****************************************************************************
 
-What\92s new? 
+What\92s new?
 
 --------------------------------------------
 Class OCPlatform (Header file: OCPlatform.h)
@@ -17,9 +17,9 @@ Class OCPlatform (Header file: OCPlatform.h)
 startPresence API
 *****************
 
-This API allows the server to notify its presence via multicast. 
+This API allows the server to notify its presence via multicast.
 
-NOTE: This applies to server side functionality only. 
+NOTE: This applies to server side functionality only.
 
 *******************
 stopPresence API
@@ -27,14 +27,14 @@ stopPresence API
 
 This API allows the server to stop presence notification.
 
-NOTE: This applies to server side functionality. 
+NOTE: This applies to server side functionality.
 
 
 ******************
 subscribePresence API
 ******************
 
-This API allows a client to subscribe to a device's presence notifications. Notifications include new addition of resource on the device, deletion of a resource on the device, change in properties of a resource. 
+This API allows a client to subscribe to a device's presence notifications. Notifications include new addition of resource on the device, deletion of a resource on the device, change in properties of a resource.
 
 NOTE: This applies to client side functionality only.
 NOTE: In this release, when client uses subscribePresence API, it gets notified only for new addition of resource on the device (server).
@@ -43,7 +43,7 @@ NOTE: In this release, when client uses subscribePresence API, it gets notified
 unsubscribePresence API
 *******************
 
-This API allows a client to unsubscribe from a device's presence events.  
+This API allows a client to unsubscribe from a device's presence events.
 
 NOTE: This applies to client side functionality only.
 
@@ -55,26 +55,26 @@ NOTE: This applies to client side functionality only.
 OCStartPresence API
 *****************
 
-This API will start sending out presence notifications to clients via multicast. 
+This API will start sending out presence notifications to clients via multicast.
 
-NOTE: This applies to server side functionality only. 
+NOTE: This applies to server side functionality only.
 
 *******************
 OCStopPresence API
 *******************
 
-This API will stop sending out presence notifications to clients via multicast. 
+This API will stop sending out presence notifications to clients via multicast.
 
-NOTE: This applies to server side functionality. 
+NOTE: This applies to server side functionality.
 
 ------------
 Other Notes:
 ------------
 
-Security model is still open. 
-APIs have OCStackResult as return type. This is will indicate success or failure for the API operation. 
+Security model is still open.
+APIs have OCStackResult as return type. This is will indicate success or failure for the API operation.
 
-Implementation for presence code is in both C (base) and C++ (SDK). In C (base) stack, presence code is defined with 'WITH_PRESENCE' preprocessor macro. 
+Implementation for presence code is in both C (base) and C++ (SDK). In C (base) stack, presence code is defined with 'WITH_PRESENCE' preprocessor macro.
 
 Maximum length of URI supported is 64 bytes (sent from the client)
 Maximum length of query supported is 64 bytes (sent from the client)
@@ -85,27 +85,27 @@ Maximum length of request and response from server for non-Ardunio is is 1024 by
 How to build:
 -------------
 
-REFER https://oic-review.01.org/gerrit for more details on getting oic-resource repo. 
-If the code is not cloned: 
-Clone the oic-resource repo using this command: git clone oic:oic-resource 
-Clone the oic-utilities repo using this command: git clone oic:oic-utilities 
+REFER https://oic-review.01.org/gerrit for more details on getting oic-resource repo.
+If the code is not cloned:
+Clone the oic-resource repo using this command: git clone oic:oic-resource
+Clone the oic-utilities repo using this command: git clone oic:oic-utilities
 
-NOTE: If the repo is already cloned, use 'git pull' inside oic-resource folder to get the latest code. 
+NOTE: If the repo is already cloned, use 'git pull' inside oic-resource folder to get the latest code.
 
-In repo oic-core, root folder ccf-opensource consists of \91OIC\92 folder.  Inside OIC folder there is a Makefile. 
+In repo oic-core, root folder ccf-opensource consists of \91OIC\92 folder.  Inside OIC folder there is a Makefile.
 
-Before building, make sure to have contents from oic-utilities repo at the folder level where oic-resource is. 
+Before building, make sure to have contents from oic-utilities repo at the folder level where oic-resource is.
 
-Inside oic-resource directory, use \91make\92 to build the entire OIC code. This would build the C++ SDK, core(i.e base) and samples. 
+Inside oic-resource directory, use \91make\92 to build the entire OIC code. This would build the C++ SDK, core(i.e base) and samples.
 
-Use \91make BUILD=debug\92 to build the entire OIC code in debug mode. This would build the C++ SDK, core(i.e base) and samples. All the executables for debug build 
+Use \91make BUILD=debug\92 to build the entire OIC code in debug mode. This would build the C++ SDK, core(i.e base) and samples. All the executables for debug build
 are in 'debug/samples'.
 
 --------
 Samples:
 --------
 
-After building the code in oic-resource, executables are in directory named 'release/samples'.  
+After building the code in oic-resource, executables are in directory named 'release/samples'.
 A sample for hosting a resource on a server and a sample for client for discovering resources are provided in the following paths:
 
 Server sample location: oic-resource/examples/simpleserver.cpp
index 8d53151..e89e274 100644 (file)
@@ -18,10 +18,10 @@ setDefaultDeviceEntityHandler API
 *****************
 
 This new API allows the server side app developer to provide a default device entity handler.
-If server receives a request in which the resource URI does not match any of the existing 
-resource URIs, base will invoke this default entity handler. It is app developer's responsibility 
+If server receives a request in which the resource URI does not match any of the existing
+resource URIs, base will invoke this default entity handler. It is app developer's responsibility
 to handle the implementation of default device entity handler accordingly.
-If the default device entity handler is not configured and the URI in the request does not match 
+If the default device entity handler is not configured and the URI in the request does not match
 any of the existing resource URIs, server will return OC_STACK_NO_RESOURCE.
 
 
@@ -35,7 +35,7 @@ Class OCResource (Header file: OCResource.h)
 post API
 *****************
 
-This new API allows the client to perform POST operation on a resource. 
+This new API allows the client to perform POST operation on a resource.
 
 NOTE: This applies to client side functionality.
 
@@ -44,7 +44,7 @@ Class OCRepresentation (Header file: OCApi.h)
 --------------------------------------------
 
 OCRepresentation has modifications which provides
-- Ability to get/set OCRepresenation (JSON object) in the OCRepresentation. 
+- Ability to get/set OCRepresenation (JSON object) in the OCRepresentation.
 - Ability to get/set vector of strings, booleans, double, integers, null.
 - Has additional functions
 
@@ -82,10 +82,10 @@ OCSetDefaultDeviceEntityHandler API
 *****************
 
 This new API allows the server side app developer to provide a default device entity handler.
-If server receives a request in which the resource URI does not match any of the existing 
-resource URIs, base will invoke this default entity handler. It is app developer's responsibility 
+If server receives a request in which the resource URI does not match any of the existing
+resource URIs, base will invoke this default entity handler. It is app developer's responsibility
 to handle the implementation of default device entity handler accordingly.
-If the default device entity handler is not configured and the URI in the request does not match 
+If the default device entity handler is not configured and the URI in the request does not match
 any of the existing resource URIs, server will return OC_STACK_NO_RESOURCE.
 
 NOTE: This applies to server side functionality only.
@@ -112,8 +112,8 @@ Minor bugs fixed
 
 Known issues:
 1. POST operation does not create new resources
-2. Header options from client to server and vice-versa is not available. 
-3. Setting CON/NON-CON option is possible only during initialization configuration. 
+2. Header options from client to server and vice-versa is not available.
+3. Setting CON/NON-CON option is possible only during initialization configuration.
 -------------
 How to build:
 -------------
index 59fa0f8..fb1d23e 100755 (executable)
@@ -44,7 +44,7 @@ FRAMEWORK_INSTALL_NAME=$FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/$FRAMEWORK_
 
 lipolite()
 {
-   PREV="$PWD" 
+   PREV="$PWD"
    cd "$1"
    ar -x "$2"
    cd "$PREV"
@@ -61,8 +61,8 @@ for ARCH in $ARCHS
 do
     echo "extracting $ARCH"
        mkdir $OUTDIR/objs/$ARCH
-       lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBCOAP.a" 
-       lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$SDKLIB.a" 
+       lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBCOAP.a"
+       lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$SDKLIB.a"
        ar -r $OUTDIR/objs/$ARCH.a $OUTDIR/objs/$ARCH/*.o
 done
 
@@ -79,7 +79,7 @@ $LIPO \
     || abort "Lipo $1 failed"
 
 echo rm -rf objs
-find $OUTDIR/objs -name "*.o" | xargs rm 
+find $OUTDIR/objs -name "*.o" | xargs rm
 
 echo "Framework: Copying includes..."
 cp -r  resource/csdk/stack/include/*.h  $FRAMEWORK_BUNDLE/Headers
index fc5554f..9fa2e0a 100755 (executable)
@@ -44,7 +44,7 @@ FRAMEWORK_INSTALL_NAME=$FRAMEWORK_BUNDLE/Versions/$FRAMEWORK_VERSION/$FRAMEWORK_
 
 lipolite()
 {
-   PREV="$PWD" 
+   PREV="$PWD"
    cd "$1"
    ar -x "$2"
    cd "$PREV"
@@ -61,8 +61,8 @@ for ARCH in $ARCHS
 do
     echo "extracting $ARCH"
        mkdir $OUTDIR/objs/$ARCH
-       lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBCOAP.a" 
-       lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$SDKLIB.a" 
+       lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$LIBCOAP.a"
+       lipolite $OUTDIR/objs/$ARCH "$OUTDIR/$ARCH/$BUILD/$SDKLIB.a"
        ar -r $OUTDIR/objs/$ARCH.a $OUTDIR/objs/$ARCH/*.o
 done
 
@@ -81,7 +81,7 @@ cp $OUTDIR/objs/x86_64.a "$FRAMEWORK_INSTALL_NAME"
 #    || abort "Lipo $1 failed"
 
 echo rm -rf objs
-find $OUTDIR/objs -name "*.o" | xargs rm 
+find $OUTDIR/objs -name "*.o" | xargs rm
 
 echo "Framework: Copying includes..."
 cp -r  resource/csdk/stack/include/*.h  $FRAMEWORK_BUNDLE/Headers
index d1f722b..54cac6b 100644 (file)
@@ -1,89 +1,89 @@
-# -*- coding: utf-8 -*-\r
-\r
-# *********************************************************************\r
-#\r
-# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.\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
-# This SCONS builder executes the boost bootstrap function which\r
-# is needed to create their build utility called 'b2'\r
-\r
-import os, subprocess\r
-import SCons.Builder, SCons.Node, SCons.Errors\r
-\r
-# creates the downloading output message\r
-# @param s original message\r
-# @param target target name\r
-# @param source source name\r
-# @param env environment object\r
-def __message( s, target, source, env ) :\r
-    print 'bootstrapping using [%s] ...' % (source[0])\r
-\r
-\r
-# Create the builder action which executes the bootstrap script\r
-#\r
-# @param target target file on the local drive\r
-# @param source URL for download\r
-# @param env environment object\r
-def __action( target, source, env ) :\r
-    cmd = None\r
-\r
-    # Windows...\r
-    if env['PLATFORM'] in ['win32'] :\r
-        if env.WhereIs('cmd') :\r
-            # TODO: Add Windows Support\r
-            cmd = None\r
-\r
-    # read the tools on *nix systems and sets the default parameters\r
-    elif env['PLATFORM'] in ['darwin', 'linux', 'posix'] :\r
-        if env.WhereIs('sh') :\r
-            cmd = './bootstrap.sh'\r
-\r
-    if not cmd :\r
-        raise SCons.Errors.StopError('Bootstrapping shell on this platform [%s] unkown' % (env['PLATFORM']))\r
-\r
-    # We need to be in the target's directory\r
-    cwd = os.path.dirname(os.path.realpath(target[0].path))\r
-\r
-    # build it now (we need the shell, because some programs need it)\r
-    devnull = open(os.devnull, 'wb')\r
-    handle  = subprocess.Popen( cmd, shell=True, cwd=cwd, stdout=devnull )\r
-\r
-    if handle.wait() <> 0 :\r
-        raise SCons.Errors.BuildError( 'Bootstrapping script [%s] on the source [%s]' % (cmd, source[0])  )\r
-\r
-# Define the emitter of the builder\r
-#\r
-# @param target target file on the local drive\r
-# @param source\r
-# @param env environment object\r
-def __emitter( target, source, env ) :\r
-    return target, source\r
-\r
-# Generate function which adds the builder to the environment,\r
-#\r
-# @param env environment object\r
-def generate( env ) :\r
-    env['BUILDERS']['BoostBootstrap'] = SCons.Builder.Builder( action = __action,  emitter = __emitter,  target_factory = SCons.Node.FS.File,  source_factory = SCons.Node.FS.File,  single_source = True,  PRINT_CMD_LINE_FUNC = __message )\r
-\r
-# Exist function of the builder\r
-# @param env environment object\r
-# @return true\r
-def exists( env ) :\r
-    return 1\r
-\r
+# -*- coding: utf-8 -*-
+
+# *********************************************************************
+#
+# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
+#
+# *********************************************************************
+#
+# 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.
+#
+# *********************************************************************
+
+# This SCONS builder executes the boost bootstrap function which
+# is needed to create their build utility called 'b2'
+
+import os, subprocess
+import SCons.Builder, SCons.Node, SCons.Errors
+
+# creates the downloading output message
+# @param s original message
+# @param target target name
+# @param source source name
+# @param env environment object
+def __message( s, target, source, env ) :
+    print 'bootstrapping using [%s] ...' % (source[0])
+
+
+# Create the builder action which executes the bootstrap script
+#
+# @param target target file on the local drive
+# @param source URL for download
+# @param env environment object
+def __action( target, source, env ) :
+    cmd = None
+
+    # Windows...
+    if env['PLATFORM'] in ['win32'] :
+        if env.WhereIs('cmd') :
+            # TODO: Add Windows Support
+            cmd = None
+
+    # read the tools on *nix systems and sets the default parameters
+    elif env['PLATFORM'] in ['darwin', 'linux', 'posix'] :
+        if env.WhereIs('sh') :
+            cmd = './bootstrap.sh'
+
+    if not cmd :
+        raise SCons.Errors.StopError('Bootstrapping shell on this platform [%s] unkown' % (env['PLATFORM']))
+
+    # We need to be in the target's directory
+    cwd = os.path.dirname(os.path.realpath(target[0].path))
+
+    # build it now (we need the shell, because some programs need it)
+    devnull = open(os.devnull, 'wb')
+    handle  = subprocess.Popen( cmd, shell=True, cwd=cwd, stdout=devnull )
+
+    if handle.wait() <> 0 :
+        raise SCons.Errors.BuildError( 'Bootstrapping script [%s] on the source [%s]' % (cmd, source[0])  )
+
+# Define the emitter of the builder
+#
+# @param target target file on the local drive
+# @param source
+# @param env environment object
+def __emitter( target, source, env ) :
+    return target, source
+
+# Generate function which adds the builder to the environment,
+#
+# @param env environment object
+def generate( env ) :
+    env['BUILDERS']['BoostBootstrap'] = SCons.Builder.Builder( action = __action,  emitter = __emitter,  target_factory = SCons.Node.FS.File,  source_factory = SCons.Node.FS.File,  single_source = True,  PRINT_CMD_LINE_FUNC = __message )
+
+# Exist function of the builder
+# @param env environment object
+# @return true
+def exists( env ) :
+    return 1
+
index 2d43d33..b0d53e0 100644 (file)
-# -*- coding: utf-8 -*-\r
-\r
-# *********************************************************************\r
-#\r
-# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.\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
-# This builder executes the boost builder ('b2') for the toolchain\r
-# defined currently in the SCONS environment. This builder was created\r
-# to create cross-compiled version of boost. In particular, it has\r
-# created to create boost binaries for Android's various architectures.\r
-\r
-import os, subprocess\r
-import SCons.Builder, SCons.Node, SCons.Errors\r
-\r
-# Creates the building message\r
-#\r
-# @param s original message\r
-# @param target target name\r
-# @param source source name\r
-# @param env environment object\r
-def __message( s, target, source, env ) :\r
-    print "building boost from [%s] for ..." % (source[0])\r
-\r
-\r
-# Create the builder action which constructs a user-config.jam based\r
-# on the current toolchain and executes the boost build system ('b2')\r
-#\r
-# @param target target file on the local drive\r
-# @param source URL for download\r
-# @@param env environment object\r
-def __action( target, source, env ) :\r
-    cmd = None\r
-\r
-    # Windows...\r
-    if env["PLATFORM"] in ["win32"] :\r
-        if env.WhereIs("cmd") :\r
-            # TODO: Add Windows Support\r
-            cmd = None\r
-\r
-    # read the tools on *nix systems and sets the default parameters\r
-    elif env["PLATFORM"] in ["darwin", "linux", "posix"] :\r
-        if env.WhereIs("sh") :\r
-            cmd = ['./b2']\r
-\r
-    if not cmd :\r
-        raise SCons.Errors.StopError("Boost build system not supported on this platform [%s]" % (env["PLATFORM"]))\r
-\r
-    # We need to be in the target's directory\r
-    cwd = os.path.dirname(os.path.realpath(source[0].path))\r
-\r
-    # Gather all of the path, bin and flags\r
-    version     = env.get('VERSION','')\r
-    target_os   = env['TARGET_OS']\r
-    target_arch = env['TARGET_ARCH']\r
-    tool_path   = os.path.dirname(env['CXX'])\r
-    cxx_bin     = os.path.basename(env['CXX'])\r
-    ar_bin      = os.path.basename(env['AR'])\r
-    ranlib_bin  = os.path.basename(env['RANLIB'])\r
-    ccflags     = list(env['CFLAGS'])\r
-    cxxflags    = list(env['CXXFLAGS'])\r
-\r
-    try:\r
-        cxxflags.remove('-fno-rtti')\r
-    except ValueError:\r
-        pass\r
-    try:\r
-        cxxflags.remove('-fno-exceptions')\r
-    except ValueError:\r
-        pass\r
-\r
-    # Write a user-config for this variant\r
-    user_config_name = cwd+os.sep+'tools'+os.sep+'build'+os.sep+'src'+os.sep+'user-config.jam'\r
-    user_config_file = open(user_config_name, 'w')\r
-    user_config_file.write('import os ;\n')\r
-    user_config_file.write('using gcc :')\r
-    user_config_file.write(' '+version+' :')\r
-    #user_config_file.write(' :')\r
-    #user_config_file.write(' '+os.path.basename(toolchain['CXX']['BIN'])+' :\n')\r
-    user_config_file.write(' '+cxx_bin+' :\n')\r
-    user_config_file.write('    <archiver>'+ar_bin+'\n')\r
-    user_config_file.write('    <ranlib>'+ranlib_bin+'\n')\r
-    for value in env['CPPDEFINES'] :\r
-        if len(value) > 1 :\r
-            user_config_file.write('    <compileflags>-D'+value[0]+'='+value[1]+'\n')\r
-        else :\r
-            user_config_file.write('    <compileflags>-D'+value[0]+'\n')\r
-    for value in env['CPPPATH'] :\r
-        user_config_file.write('    <compileflags>-I'+value+'\n')\r
-    for flag in ccflags :\r
-        user_config_file.write('    <compileflags>'+flag+'\n')\r
-    for flag in cxxflags :\r
-        user_config_file.write('    <cxxflags>'+flag+'\n')\r
-    user_config_file.write('    ;\n')\r
-    user_config_file.close();\r
-\r
-    # Ensure that the toolchain is in the PATH\r
-    penv = os.environ.copy()\r
-    penv["PATH"] = tool_path+":" + penv["PATH"]\r
-\r
-    build_path = 'build' + os.sep + target_os + os.sep + target_arch\r
-\r
-    cmd.append('-q')\r
-    cmd.append('target-os=linux')\r
-    cmd.append('link=static')\r
-    cmd.append('threading=multi')\r
-    cmd.append('--layout=system')\r
-    cmd.append('--build-type=minimal')\r
-    cmd.append('--prefix='+env['PREFIX'])\r
-    cmd.append('--build-dir='+build_path)\r
-    for module in env.get('MODULES',[]) :\r
-        cmd.append('--with-'+module)\r
-    cmd.append('headers')\r
-    cmd.append('install')\r
-\r
-    # build it now (we need the shell, because some programs need it)\r
-    devnull = open(os.devnull, "wb")\r
-    handle  = subprocess.Popen( cmd, env=penv, cwd=cwd ) #, stdout=devnull )\r
-\r
-    if handle.wait() <> 0 :\r
-        raise SCons.Errors.BuildError( "Building boost [%s] on the source [%s]" % (cmd, source[0])  )\r
-\r
-# Define the emitter of the builder\r
-#\r
-# @param target target file on the local drive\r
-# @param source\r
-# @param env environment object\r
-def __emitter( target, source, env ) :\r
-    return target, source\r
-\r
-# Generate function which adds the builder to the environment\r
-#\r
-# @param env environment object\r
-def generate( env ) :\r
-    env["BUILDERS"]["BoostBuild"] = SCons.Builder.Builder( action = __action,  emitter = __emitter,  target_factory = SCons.Node.FS.Entry,  source_factory = SCons.Node.FS.File,  single_source = True,  PRINT_CMD_LINE_FUNC = __message )\r
-\r
-# Exist function of the builder\r
-# @param env environment object\r
-# @return true\r
-def exists( env ) :\r
-    return 1\r
+# -*- coding: utf-8 -*-
+
+# *********************************************************************
+#
+# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
+#
+# *********************************************************************
+#
+# 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.
+#
+# *********************************************************************
+
+# This builder executes the boost builder ('b2') for the toolchain
+# defined currently in the SCONS environment. This builder was created
+# to create cross-compiled version of boost. In particular, it has
+# created to create boost binaries for Android's various architectures.
+
+import os, subprocess
+import SCons.Builder, SCons.Node, SCons.Errors
+
+# Creates the building message
+#
+# @param s original message
+# @param target target name
+# @param source source name
+# @param env environment object
+def __message( s, target, source, env ) :
+    print "building boost from [%s] for ..." % (source[0])
+
+
+# Create the builder action which constructs a user-config.jam based
+# on the current toolchain and executes the boost build system ('b2')
+#
+# @param target target file on the local drive
+# @param source URL for download
+# @@param env environment object
+def __action( target, source, env ) :
+    cmd = None
+
+    # Windows...
+    if env["PLATFORM"] in ["win32"] :
+        if env.WhereIs("cmd") :
+            # TODO: Add Windows Support
+            cmd = None
+
+    # read the tools on *nix systems and sets the default parameters
+    elif env["PLATFORM"] in ["darwin", "linux", "posix"] :
+        if env.WhereIs("sh") :
+            cmd = ['./b2']
+
+    if not cmd :
+        raise SCons.Errors.StopError("Boost build system not supported on this platform [%s]" % (env["PLATFORM"]))
+
+    # We need to be in the target's directory
+    cwd = os.path.dirname(os.path.realpath(source[0].path))
+
+    # Gather all of the path, bin and flags
+    version     = env.get('VERSION','')
+    target_os   = env['TARGET_OS']
+    target_arch = env['TARGET_ARCH']
+    tool_path   = os.path.dirname(env['CXX'])
+    cxx_bin     = os.path.basename(env['CXX'])
+    ar_bin      = os.path.basename(env['AR'])
+    ranlib_bin  = os.path.basename(env['RANLIB'])
+    ccflags     = list(env['CFLAGS'])
+    cxxflags    = list(env['CXXFLAGS'])
+
+    try:
+        cxxflags.remove('-fno-rtti')
+    except ValueError:
+        pass
+    try:
+        cxxflags.remove('-fno-exceptions')
+    except ValueError:
+        pass
+
+    # Write a user-config for this variant
+    user_config_name = cwd+os.sep+'tools'+os.sep+'build'+os.sep+'src'+os.sep+'user-config.jam'
+    user_config_file = open(user_config_name, 'w')
+    user_config_file.write('import os ;\n')
+    user_config_file.write('using gcc :')
+    user_config_file.write(' '+version+' :')
+    #user_config_file.write(' :')
+    #user_config_file.write(' '+os.path.basename(toolchain['CXX']['BIN'])+' :\n')
+    user_config_file.write(' '+cxx_bin+' :\n')
+    user_config_file.write('    <archiver>'+ar_bin+'\n')
+    user_config_file.write('    <ranlib>'+ranlib_bin+'\n')
+    for value in env['CPPDEFINES'] :
+        if len(value) > 1 :
+            user_config_file.write('    <compileflags>-D'+value[0]+'='+value[1]+'\n')
+        else :
+            user_config_file.write('    <compileflags>-D'+value[0]+'\n')
+    for value in env['CPPPATH'] :
+        user_config_file.write('    <compileflags>-I'+value+'\n')
+    for flag in ccflags :
+        user_config_file.write('    <compileflags>'+flag+'\n')
+    for flag in cxxflags :
+        user_config_file.write('    <cxxflags>'+flag+'\n')
+    user_config_file.write('    ;\n')
+    user_config_file.close();
+
+    # Ensure that the toolchain is in the PATH
+    penv = os.environ.copy()
+    penv["PATH"] = tool_path+":" + penv["PATH"]
+
+    build_path = 'build' + os.sep + target_os + os.sep + target_arch
+
+    cmd.append('-q')
+    cmd.append('target-os=linux')
+    cmd.append('link=static')
+    cmd.append('threading=multi')
+    cmd.append('--layout=system')
+    cmd.append('--build-type=minimal')
+    cmd.append('--prefix='+env['PREFIX'])
+    cmd.append('--build-dir='+build_path)
+    for module in env.get('MODULES',[]) :
+        cmd.append('--with-'+module)
+    cmd.append('headers')
+    cmd.append('install')
+
+    # build it now (we need the shell, because some programs need it)
+    devnull = open(os.devnull, "wb")
+    handle  = subprocess.Popen( cmd, env=penv, cwd=cwd ) #, stdout=devnull )
+
+    if handle.wait() <> 0 :
+        raise SCons.Errors.BuildError( "Building boost [%s] on the source [%s]" % (cmd, source[0])  )
+
+# Define the emitter of the builder
+#
+# @param target target file on the local drive
+# @param source
+# @param env environment object
+def __emitter( target, source, env ) :
+    return target, source
+
+# Generate function which adds the builder to the environment
+#
+# @param env environment object
+def generate( env ) :
+    env["BUILDERS"]["BoostBuild"] = SCons.Builder.Builder( action = __action,  emitter = __emitter,  target_factory = SCons.Node.FS.Entry,  source_factory = SCons.Node.FS.File,  single_source = True,  PRINT_CMD_LINE_FUNC = __message )
+
+# Exist function of the builder
+# @param env environment object
+# @return true
+def exists( env ) :
+    return 1
index 88c184a..94db96b 100644 (file)
@@ -1,88 +1,88 @@
-# -*- coding: utf-8 -*-\r
-\r
-# *********************************************************************\r
-#\r
-# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.\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
-# This builder executes configure\r
-\r
-import os, subprocess\r
-import SCons.Builder, SCons.Node, SCons.Errors\r
-\r
-# Create the output message\r
-#\r
-# @param s original message\r
-# @param target target name\r
-# @param source source name\r
-# @param env environment object\r
-def __message( s, target, source, env ) :\r
-    print "Configuring using [%s] ..." % (source[0])\r
-\r
-# Create the action\r
-#\r
-# @param target target file on the local drive\r
-# @param source URL for download\r
-# @@param env environment object\r
-def __action( target, source, env ) :\r
-    cmd = None\r
-\r
-    # Windows...\r
-    if env["PLATFORM"] in ["win32"] :\r
-        if env.WhereIs("cmd") :\r
-            # TODO: Add Windows Support\r
-            cmd = None\r
-\r
-    # read the tools on *nix systems and sets the default parameters\r
-    elif env["PLATFORM"] in ["darwin", "linux", "posix"] :\r
-        if env.WhereIs("sh") :\r
-            cmd = "./configure"\r
-\r
-    if not cmd :\r
-        raise SCons.Errors.StopError("Configure shell on this platform [%s] unkown" % (env["PLATFORM"]))\r
-\r
-    # We need to be in the target's directory\r
-    cwd = os.path.dirname(os.path.realpath(target[0].path))\r
-\r
-    # build it now (we need the shell, because some programs need it)\r
-    devnull = open(os.devnull, "wb")\r
-    handle  = subprocess.Popen( cmd, shell=True, cwd=cwd, stdout=devnull )\r
-\r
-    if handle.wait() <> 0 :\r
-        raise SCons.Errors.BuildError( "Configuring script [%s] on the source [%s]" % (cmd, source[0])  )\r
-\r
-# Define the builder's emitter\r
-#\r
-# @param target target file on the local drive\r
-# @param source \r
-# @param env environment object\r
-def __emitter( target, source, env ) :\r
-    return target, source\r
-\r
-# Generate function which adds the builder to the environment,\r
-#\r
-# @param env environment object\r
-def generate( env ) :\r
-    env["BUILDERS"]["Configure"] = SCons.Builder.Builder( action = __action,  emitter = __emitter,  target_factory = SCons.Node.FS.File,  source_factory = SCons.Node.FS.File,  single_source = True,  PRINT_CMD_LINE_FUNC = __message )\r
-\r
-# Exist function for the builder\r
-#\r
-# @param env environment object\r
-# @return true\r
-def exists( env ) :\r
-    return 1\r
+# -*- coding: utf-8 -*-
+
+# *********************************************************************
+#
+# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
+#
+# *********************************************************************
+#
+# 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.
+#
+# *********************************************************************
+
+# This builder executes configure
+
+import os, subprocess
+import SCons.Builder, SCons.Node, SCons.Errors
+
+# Create the output message
+#
+# @param s original message
+# @param target target name
+# @param source source name
+# @param env environment object
+def __message( s, target, source, env ) :
+    print "Configuring using [%s] ..." % (source[0])
+
+# Create the action
+#
+# @param target target file on the local drive
+# @param source URL for download
+# @@param env environment object
+def __action( target, source, env ) :
+    cmd = None
+
+    # Windows...
+    if env["PLATFORM"] in ["win32"] :
+        if env.WhereIs("cmd") :
+            # TODO: Add Windows Support
+            cmd = None
+
+    # read the tools on *nix systems and sets the default parameters
+    elif env["PLATFORM"] in ["darwin", "linux", "posix"] :
+        if env.WhereIs("sh") :
+            cmd = "./configure"
+
+    if not cmd :
+        raise SCons.Errors.StopError("Configure shell on this platform [%s] unkown" % (env["PLATFORM"]))
+
+    # We need to be in the target's directory
+    cwd = os.path.dirname(os.path.realpath(target[0].path))
+
+    # build it now (we need the shell, because some programs need it)
+    devnull = open(os.devnull, "wb")
+    handle  = subprocess.Popen( cmd, shell=True, cwd=cwd, stdout=devnull )
+
+    if handle.wait() <> 0 :
+        raise SCons.Errors.BuildError( "Configuring script [%s] on the source [%s]" % (cmd, source[0])  )
+
+# Define the builder's emitter
+#
+# @param target target file on the local drive
+# @param source 
+# @param env environment object
+def __emitter( target, source, env ) :
+    return target, source
+
+# Generate function which adds the builder to the environment,
+#
+# @param env environment object
+def generate( env ) :
+    env["BUILDERS"]["Configure"] = SCons.Builder.Builder( action = __action,  emitter = __emitter,  target_factory = SCons.Node.FS.File,  source_factory = SCons.Node.FS.File,  single_source = True,  PRINT_CMD_LINE_FUNC = __message )
+
+# Exist function for the builder
+#
+# @param env environment object
+# @return true
+def exists( env ) :
+    return 1
index 724ad4d..6d88723 100644 (file)
-# -*- coding: utf-8 -*-\r
-\r
-############################################################################\r
-# GPL License                                                              #\r
-#                                                                          #\r
-# This file is a SCons (http://www.scons.org/) builder                     #\r
-# Copyright (c) 2012-14, Philipp Kraus, <philipp.kraus@flashpixx.de>       #\r
-# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.     #\r
-# This program is free software: you can redistribute it and/or modify     #\r
-# it under the terms of the GNU General Public License as                  #\r
-# published by the Free Software Foundation, either version 3 of the       #\r
-# License, or (at your option) any later version.                          #\r
-#                                                                          #\r
-# This program is distributed in the hope that it will be useful,          #\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of           #\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #\r
-# GNU General Public License for more details.                             #\r
-#                                                                          #\r
-# You should have received a copy of the GNU General Public License        #\r
-# along with this program. If not, see <http://www.gnu.org/licenses/>.     #\r
-############################################################################\r
-\r
-# the URLDownload-Builder can download any data from an URL into a target\r
-# file. The target name is used are the file name of the downloaded file.\r
-\r
-# This builder originated from work by Philipp Kraus and flashpixx project\r
-# (see https://github.com/flashpixx). It has been modified to leverage\r
-# the HTTP ETag header to be used as the csig. This allows the download\r
-# builder to determine if the file should be downloaded again when the\r
-# ETag header is supported\r
-\r
-import os, time\r
-import urllib2, urlparse\r
-import SCons.Builder, SCons.Node, SCons.Errors\r
-\r
-# Define a source node to represent the remote file. The construction of the\r
-# node will query the hosting site to get the ETag, size and last-modified\r
-# date.  This node also defines the method by which we will determine if\r
-# the file should be downloaded again.\r
-#\r
-# This node derives from the Python.Value node\r
-#\r
-class URLNode(SCons.Node.Python.Value) :\r
-    def make_ready(self) :\r
-        try :\r
-            stream = urllib2.urlopen( str(self.value) )\r
-            info = stream.info()\r
-\r
-            self.url_etag = None\r
-            self.url_last_modified = None\r
-            self.url_content_length = None\r
-\r
-            if 'ETag' in info :\r
-                self.url_etag = info['ETag']\r
-            if 'Last-Modified' in info :\r
-                self.url_last_modified = time.mktime(time.strptime(info['Last-Modified'], '%a, %d %b %Y %H:%M:%S GMT'))\r
-            if 'Content-Length' in info :\r
-                self.url_content_legth = info['Content-Length']\r
-        except Exception, e :\r
-            raise SCons.Errors.StopError( '%s [%s]' % (e, self.value) )\r
-\r
-    def visited(self) :\r
-        ninfo = self.get_ninfo()\r
-\r
-        if self.url_etag :\r
-            ninfo.csig = self.url_etag\r
-        if self.url_last_modified :\r
-            ninfo.timestamp = self.url_last_modified\r
-        if self.url_content_length :\r
-            ninfo.size = self.url_content_length\r
-        SCons.Node.Node.visited(self);\r
-\r
-    def changed_since_last_build(self, target, prev_ni):\r
-        if prev_ni :\r
-            if self.url_etag :\r
-                if prev_ni.csig == self.url_etag :\r
-                    # print 'Matched on ETag:'+prev_ni.csig\r
-                    return False\r
-\r
-            if not self.url_last_modified :\r
-                # print 'Last modified date is not available'\r
-                return True\r
-            if not self.url_content_length :\r
-                # print 'Content length is not available'\r
-                return True\r
-            if prev_ni.timestamp != self.url_last_modified :\r
-                # print 'Modified since last build'\r
-                return True\r
-            if prev_ni.size != self.url_content_length :\r
-                # print 'Content length has changed'\r
-                return True\r
-\r
-            return False\r
-\r
-        # print 'Not previous built'\r
-        return True\r
-\r
-# Creates the output message\r
-# @param s original message\r
-# @param target target name\r
-# @param source source name\r
-# @param env environment object\r
-def __message( s, target, source, env ) :\r
-    print 'downloading [%s] from [%s] ...' % (target[0], source[0])\r
-\r
-# Creates the action ie. the download function.\r
-# This reads the data from the URL and writes it down to the file\r
-# @param target target file on the local drive\r
-# @param source URL for download\r
-# @@param env environment object\r
-def __action( target, source, env ) :\r
-    try :\r
-        source_name = str(source[0])\r
-        target_name = str(target[0])\r
-        stream = urllib2.urlopen(source_name)\r
-        file = open( target_name, 'wb' )\r
-        file.write(stream.read())\r
-        file.close()\r
-\r
-        # Change the access/modified time to match\r
-        # the date on the downloaded file, if available\r
-        ninfo = source[0].get_ninfo()\r
-        if hasattr(ninfo, 'timestamp') :\r
-            mtime = ninfo.timestamp\r
-            if mtime :\r
-                os.utime(target_name, (mtime, mtime))\r
-    except Exception, e :\r
-        raise SCons.Errors.StopError( '%s [%s]' % (e, source[0]) )\r
-\r
-\r
-# Defines the emitter of the builder\r
-# @param target target file on the local drive\r
-# @param source URL for download\r
-# @param env environment object\r
-def __emitter( target, source, env ) :\r
-    return target, source\r
-\r
-# generate function, that adds the builder to the environment,\r
-# @param env environment object\r
-def generate( env ) :\r
-    env['BUILDERS']['URLDownload'] = SCons.Builder.Builder( action = __action,  emitter = __emitter,  target_factory = SCons.Node.FS.File,  source_factory = URLNode,  single_source = True,  PRINT_CMD_LINE_FUNC = __message )\r
-\r
-# existing function of the builder\r
-# @param env environment object\r
-# @return true\r
-def exists(env) :\r
-    return 1\r
+# -*- coding: utf-8 -*-
+
+############################################################################
+# GPL License                                                              #
+#                                                                          #
+# This file is a SCons (http://www.scons.org/) builder                     #
+# Copyright (c) 2012-14, Philipp Kraus, <philipp.kraus@flashpixx.de>       #
+# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.     #
+# This program is free software: you can redistribute it and/or modify     #
+# it under the terms of the GNU General Public License as                  #
+# published by the Free Software Foundation, either version 3 of the       #
+# License, or (at your option) any later version.                          #
+#                                                                          #
+# This program is distributed in the hope that it will be useful,          #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of           #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
+# GNU General Public License for more details.                             #
+#                                                                          #
+# You should have received a copy of the GNU General Public License        #
+# along with this program. If not, see <http://www.gnu.org/licenses/>.     #
+############################################################################
+
+# the URLDownload-Builder can download any data from an URL into a target
+# file. The target name is used are the file name of the downloaded file.
+
+# This builder originated from work by Philipp Kraus and flashpixx project
+# (see https://github.com/flashpixx). It has been modified to leverage
+# the HTTP ETag header to be used as the csig. This allows the download
+# builder to determine if the file should be downloaded again when the
+# ETag header is supported
+
+import os, time
+import urllib2, urlparse
+import SCons.Builder, SCons.Node, SCons.Errors
+
+# Define a source node to represent the remote file. The construction of the
+# node will query the hosting site to get the ETag, size and last-modified
+# date.  This node also defines the method by which we will determine if
+# the file should be downloaded again.
+#
+# This node derives from the Python.Value node
+#
+class URLNode(SCons.Node.Python.Value) :
+    def make_ready(self) :
+        try :
+            stream = urllib2.urlopen( str(self.value) )
+            info = stream.info()
+
+            self.url_etag = None
+            self.url_last_modified = None
+            self.url_content_length = None
+
+            if 'ETag' in info :
+                self.url_etag = info['ETag']
+            if 'Last-Modified' in info :
+                self.url_last_modified = time.mktime(time.strptime(info['Last-Modified'], '%a, %d %b %Y %H:%M:%S GMT'))
+            if 'Content-Length' in info :
+                self.url_content_legth = info['Content-Length']
+        except Exception, e :
+            raise SCons.Errors.StopError( '%s [%s]' % (e, self.value) )
+
+    def visited(self) :
+        ninfo = self.get_ninfo()
+
+        if self.url_etag :
+            ninfo.csig = self.url_etag
+        if self.url_last_modified :
+            ninfo.timestamp = self.url_last_modified
+        if self.url_content_length :
+            ninfo.size = self.url_content_length
+        SCons.Node.Node.visited(self);
+
+    def changed_since_last_build(self, target, prev_ni):
+        if prev_ni :
+            if self.url_etag :
+                if prev_ni.csig == self.url_etag :
+                    # print 'Matched on ETag:'+prev_ni.csig
+                    return False
+
+            if not self.url_last_modified :
+                # print 'Last modified date is not available'
+                return True
+            if not self.url_content_length :
+                # print 'Content length is not available'
+                return True
+            if prev_ni.timestamp != self.url_last_modified :
+                # print 'Modified since last build'
+                return True
+            if prev_ni.size != self.url_content_length :
+                # print 'Content length has changed'
+                return True
+
+            return False
+
+        # print 'Not previous built'
+        return True
+
+# Creates the output message
+# @param s original message
+# @param target target name
+# @param source source name
+# @param env environment object
+def __message( s, target, source, env ) :
+    print 'downloading [%s] from [%s] ...' % (target[0], source[0])
+
+# Creates the action ie. the download function.
+# This reads the data from the URL and writes it down to the file
+# @param target target file on the local drive
+# @param source URL for download
+# @@param env environment object
+def __action( target, source, env ) :
+    try :
+        source_name = str(source[0])
+        target_name = str(target[0])
+        stream = urllib2.urlopen(source_name)
+        file = open( target_name, 'wb' )
+        file.write(stream.read())
+        file.close()
+
+        # Change the access/modified time to match
+        # the date on the downloaded file, if available
+        ninfo = source[0].get_ninfo()
+        if hasattr(ninfo, 'timestamp') :
+            mtime = ninfo.timestamp
+            if mtime :
+                os.utime(target_name, (mtime, mtime))
+    except Exception, e :
+        raise SCons.Errors.StopError( '%s [%s]' % (e, source[0]) )
+
+
+# Defines the emitter of the builder
+# @param target target file on the local drive
+# @param source URL for download
+# @param env environment object
+def __emitter( target, source, env ) :
+    return target, source
+
+# generate function, that adds the builder to the environment,
+# @param env environment object
+def generate( env ) :
+    env['BUILDERS']['URLDownload'] = SCons.Builder.Builder( action = __action,  emitter = __emitter,  target_factory = SCons.Node.FS.File,  source_factory = URLNode,  single_source = True,  PRINT_CMD_LINE_FUNC = __message )
+
+# existing function of the builder
+# @param env environment object
+# @return true
+def exists(env) :
+    return 1
index 409f980..557e2a1 100644 (file)
-# -*- coding: utf-8 -*-\r
-\r
-############################################################################\r
-# GPL License                                                              #\r
-#                                                                          #\r
-# This file is a SCons (http://www.scons.org/) builder                     #\r
-# Copyright (c) 2012-14, Philipp Kraus, <philipp.kraus@flashpixx.de>       #\r
-# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.     #\r
-# This program is free software: you can redistribute it and/or modify     #\r
-# it under the terms of the GNU General Public License as                  #\r
-# published by the Free Software Foundation, either version 3 of the       #\r
-# License, or (at your option) any later version.                          #\r
-#                                                                          #\r
-# This program is distributed in the hope that it will be useful,          #\r
-# but WITHOUT ANY WARRANTY; without even the implied warranty of           #\r
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #\r
-# GNU General Public License for more details.                             #\r
-#                                                                          #\r
-# You should have received a copy of the GNU General Public License        #\r
-# along with this program. If not, see <http://www.gnu.org/licenses/>.     #\r
-############################################################################\r
-\r
-# This builder originated from work by Philipp Kraus and flashpixx project\r
-# (see https://github.com/flashpixx). Based on the Unpack.py, it only\r
-# contains changes to allow a complete unpacking of the archive.\r
-# It is assumed that the target represents a file in the archive after it\r
-# is unpacked.\r
-\r
-# The Unpack Builder can be used for unpacking archives (eg Zip, TGZ, BZ, ... ).\r
-# The emitter of the Builder reads the archive data and creates a returning\r
-# file list the builder extract the archive. The environment variable\r
-# stores a dictionary "UNPACK" for set different extractions (subdict "EXTRACTOR"):\r
-# {\r
-#   PRIORITY         => a value for setting the extractor order (lower numbers = extractor is used earlier)\r
-#   SUFFIX           => defines a list with file suffixes, which should be handled with this extractor\r
-#   EXTRACTSUFFIX    => suffix of the extract command\r
-#   EXTRACTFLAGS     => a string parameter for the RUN command for extracting the data\r
-#   EXTRACTCMD       => full extract command of the builder\r
-#   RUN              => the main program which will be started (if the parameter is empty, the extractor will be ignored)\r
-#   LISTCMD          => the listing command for the emitter\r
-#   LISTFLAGS        => the string options for the RUN command for showing a list of files\r
-#   LISTSUFFIX       => suffix of the list command\r
-#   LISTEXTRACTOR    => a optional Python function, that is called on each output line of the\r
-#                       LISTCMD for extracting file & dir names, the function need two parameters (first line number,\r
-#                       second line content) and must return a string with the file / dir path (other value types\r
-#                       will be ignored)\r
-# }\r
-# Other options in the UNPACK dictionary are:\r
-#   STOPONEMPTYFILE  => bool variable for stoping if the file has empty size (default True)\r
-#   VIWEXTRACTOUTPUT => shows the output messages of the extraction command (default False)\r
-#   EXTRACTDIR       => path in that the data will be extracted (default #)\r
-#\r
-# The file which is handled by the first suffix match of the extractor, the extractor list can be append for other files.\r
-# The order of the extractor dictionary creates the listing & extractor command eg file extension .tar.gz should be\r
-# before .gz, because the tar.gz is extract in one shoot.\r
-#\r
-# Under *nix system these tools are supported: tar, bzip2, gzip, unzip\r
-# Under Windows only 7-Zip (http://www.7-zip.org/) is supported\r
-\r
-\r
-import subprocess, os\r
-import SCons.Errors, SCons.Warnings, SCons.Util\r
-\r
-# enables Scons warning for this builder\r
-class UnpackWarning(SCons.Warnings.Warning) :\r
-    pass\r
-\r
-SCons.Warnings.enableWarningClass(UnpackWarning)\r
-\r
-# extractor function for Tar output\r
-# @param env environment object\r
-# @param count number of returning lines\r
-# @param no number of the output line\r
-# @param i line content\r
-def __fileextractor_nix_tar( env, count, no, i ) :\r
-    return i.split()[-1]\r
-\r
-# extractor function for GZip output,\r
-# ignore the first line\r
-# @param env environment object\r
-# @param count number of returning lines\r
-# @param no number of the output line\r
-# @param i line content\r
-def __fileextractor_nix_gzip( env, count, no, i ) :\r
-    if no == 0 :\r
-        return None\r
-    return i.split()[-1]\r
-\r
-# extractor function for Unzip output,\r
-# ignore the first & last two lines\r
-# @param env environment object\r
-# @param count number of returning lines\r
-# @param no number of the output line\r
-# @param i line content\r
-def __fileextractor_nix_unzip( env, count, no, i ) :\r
-    if no < 3 or no >= count - 2 :\r
-        return None\r
-    return i.split()[-1]\r
-\r
-# extractor function for 7-Zip\r
-# @param env environment object\r
-# @param count number of returning lines\r
-# @param no number of the output line\r
-# @param i line content\r
-def __fileextractor_win_7zip( env, count, no, i ) :\r
-    item = i.split()\r
-    if no > 8 and no < count - 2 :\r
-        return item[-1]\r
-    return None\r
-\r
-\r
-\r
-# returns the extractor item for handling the source file\r
-# @param source input source file\r
-# @param env environment object\r
-# @return extractor entry or None on non existing\r
-def __getExtractor( source, env ) :\r
-    # we check each unpacker and get the correct list command first, run the command and\r
-    # replace the target filelist with the list values, we sorte the extractors by their priority\r
-    for unpackername, extractor in sorted(env["UNPACK"]["EXTRACTOR"].iteritems(), key = lambda (k,v) : (v["PRIORITY"],k)):\r
-\r
-        if not SCons.Util.is_String(extractor["RUN"]) :\r
-            raise SCons.Errors.StopError("list command of the unpack builder for [%s] archives is not a string" % (unpackername))\r
-        if not len(extractor["RUN"]) :\r
-            raise SCons.Errors.StopError("run command of the unpack builder for [%s] archives is not set - can not extract files" % (unpackername))\r
-\r
-\r
-        if not SCons.Util.is_String(extractor["LISTFLAGS"]) :\r
-            raise SCons.Errors.StopError("list flags of the unpack builder for [%s] archives is not a string" % (unpackername))\r
-        if not SCons.Util.is_String(extractor["LISTCMD"]) :\r
-            raise SCons.Errors.StopError("list command of the unpack builder for [%s] archives is not a string" % (unpackername))\r
-\r
-        if not SCons.Util.is_String(extractor["EXTRACTFLAGS"]) :\r
-            raise SCons.Errors.StopError("extract flags of the unpack builder for [%s] archives is not a string" % (unpackername))\r
-        if not SCons.Util.is_String(extractor["EXTRACTCMD"]) :\r
-            raise SCons.Errors.StopError("extract command of the unpack builder for [%s] archives is not a string" % (unpackername))\r
-\r
-\r
-        # check the source file suffix and if the first is found, run the list command\r
-        if not SCons.Util.is_List(extractor["SUFFIX"]) :\r
-            raise SCons.Errors.StopError("suffix list of the unpack builder for [%s] archives is not a list" % (unpackername))\r
-\r
-        for suffix in extractor["SUFFIX"] :\r
-            if str(source[0]).lower()[-len(suffix):] == suffix.lower() :\r
-                return extractor\r
-\r
-    return None\r
-\r
-\r
-# creates the extracter output message\r
-# @param s original message\r
-# @param target target name\r
-# @param source source name\r
-# @param env environment object\r
-def __message( s, target, source, env ) :\r
-    print "extract [%s] ..." % (source[0])\r
-\r
-\r
-# action function for extracting of the data\r
-# @param target target packed file\r
-# @param source extracted files\r
-# @param env environment object\r
-def __action( target, source, env ) :\r
-    extractor = __getExtractor(source, env)\r
-    if not extractor :\r
-        raise SCons.Errors.StopError( "can not find any extractor value for the source file [%s]" % (source[0]) )\r
-\r
-    extractor_cmd = extractor["EXTRACTCMD"]\r
-\r
-    # if the extract command is empty, we create an error\r
-    if len(extractor_cmd) == 0 :\r
-        raise SCons.Errors.StopError( "the extractor command for the source file [%s] is empty" % (source[0]) )\r
-\r
-    # build it now (we need the shell, because some programs need it)\r
-    handle = None\r
-\r
-    source_path = os.path.realpath(source[0].path)\r
-    target_path = os.path.realpath(target[0].path)\r
-\r
-    cmd = env.subst(extractor_cmd, source=source_path, target=target)\r
-    cwd = os.path.dirname(source_path)\r
-\r
-    if env["UNPACK"]["VIWEXTRACTOUTPUT"] :\r
-        handle  = subprocess.Popen( cmd, shell=True )\r
-    else :\r
-        devnull = open(os.devnull, "wb")\r
-        handle  = subprocess.Popen( cmd, shell=True, stdout=devnull, cwd=cwd)\r
-\r
-    if handle.wait() <> 0 :\r
-        raise SCons.Errors.BuildError( "error running extractor [%s] on the source [%s]" % (cmd, source[0]) )\r
-\r
-    fhandle = open(target_path, 'a')\r
-    try:\r
-        os.utime(target_path, None)\r
-    finally:\r
-        fhandle.close()\r
-\r
-\r
-# emitter function for getting the files\r
-# within the archive\r
-# @param target target packed file\r
-# @param source extracted files\r
-# @param env environment object\r
-def __emitter( target, source, env ) :\r
-    return target, source\r
-\r
-\r
-# generate function, that adds the builder to the environment\r
-# @param env environment object\r
-def generate( env ) :\r
-    # setup environment variable\r
-    toolset = {\r
-        "STOPONEMPTYFILE"  : True,\r
-        "VIWEXTRACTOUTPUT" : False,\r
-        "EXTRACTDIR"       : os.curdir,\r
-        "EXTRACTOR" : {\r
-            "TARGZ" : {\r
-                "PRIORITY"       : 0,\r
-                "SUFFIX"         : [".tar.gz", ".tgz", ".tar.gzip"],\r
-                "EXTRACTSUFFIX"  : "",\r
-                "EXTRACTFLAGS"   : "",\r
-                "EXTRACTCMD"     : "${UNPACK['EXTRACTOR']['TARGZ']['RUN']} ${UNPACK['EXTRACTOR']['TARGZ']['EXTRACTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['TARGZ']['EXTRACTSUFFIX']}",\r
-                "RUN"            : "",\r
-                "LISTCMD"        : "${UNPACK['EXTRACTOR']['TARGZ']['RUN']} ${UNPACK['EXTRACTOR']['TARGZ']['LISTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['TARGZ']['LISTSUFFIX']}",\r
-                "LISTSUFFIX"     : "",\r
-                "LISTFLAGS"      : "",\r
-                "LISTEXTRACTOR"  : None\r
-            },\r
-\r
-            "TARBZ" : {\r
-                "PRIORITY"       : 0,\r
-                "SUFFIX"         : [".tar.bz", ".tbz", ".tar.bz2", ".tar.bzip2", ".tar.bzip"],\r
-                "EXTRACTSUFFIX"  : "",\r
-                "EXTRACTFLAGS"   : "",\r
-                "EXTRACTCMD"     : "${UNPACK['EXTRACTOR']['TARBZ']['RUN']} ${UNPACK['EXTRACTOR']['TARBZ']['EXTRACTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['TARBZ']['EXTRACTSUFFIX']}",\r
-                "RUN"            : "",\r
-                "LISTCMD"        : "${UNPACK['EXTRACTOR']['TARBZ']['RUN']} ${UNPACK['EXTRACTOR']['TARBZ']['LISTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['TARBZ']['LISTSUFFIX']}",\r
-                "LISTSUFFIX"     : "",\r
-                "LISTFLAGS"      : "",\r
-                "LISTEXTRACTOR"  : None\r
-            },\r
-\r
-            "BZIP" : {\r
-                "PRIORITY"       : 1,\r
-                "SUFFIX"         : [".bz", "bzip", ".bz2", ".bzip2"],\r
-                "EXTRACTSUFFIX"  : "",\r
-                "EXTRACTFLAGS"   : "",\r
-                "EXTRACTCMD"     : "${UNPACK['EXTRACTOR']['BZIP']['RUN']} ${UNPACK['EXTRACTOR']['BZIP']['EXTRACTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['BZIP']['EXTRACTSUFFIX']}",\r
-                "RUN"            : "",\r
-                "LISTCMD"        : "${UNPACK['EXTRACTOR']['BZIP']['RUN']} ${UNPACK['EXTRACTOR']['BZIP']['LISTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['BZIP']['LISTSUFFIX']}",\r
-                "LISTSUFFIX"     : "",\r
-                "LISTFLAGS"      : "",\r
-                "LISTEXTRACTOR"  : None\r
-            },\r
-\r
-            "GZIP" : {\r
-                "PRIORITY"       : 1,\r
-                "SUFFIX"         : [".gz", ".gzip"],\r
-                "EXTRACTSUFFIX"  : "",\r
-                "EXTRACTFLAGS"   : "",\r
-                "EXTRACTCMD"     : "${UNPACK['EXTRACTOR']['GZIP']['RUN']} ${UNPACK['EXTRACTOR']['GZIP']['EXTRACTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['GZIP']['EXTRACTSUFFIX']}",\r
-                "RUN"            : "",\r
-                "LISTCMD"        : "${UNPACK['EXTRACTOR']['GZIP']['RUN']} ${UNPACK['EXTRACTOR']['GZIP']['LISTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['GZIP']['LISTSUFFIX']}",\r
-                "LISTSUFFIX"     : "",\r
-                "LISTFLAGS"      : "",\r
-                "LISTEXTRACTOR"  : None\r
-            },\r
-\r
-            "TAR" : {\r
-                "PRIORITY"       : 1,\r
-                "SUFFIX"         : [".tar"],\r
-                "EXTRACTSUFFIX"  : "",\r
-                "EXTRACTFLAGS"   : "",\r
-                "EXTRACTCMD"     : "${UNPACK['EXTRACTOR']['TAR']['RUN']} ${UNPACK['EXTRACTOR']['TAR']['EXTRACTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['TAR']['EXTRACTSUFFIX']}",\r
-                "RUN"            : "",\r
-                "LISTCMD"        : "${UNPACK['EXTRACTOR']['TAR']['RUN']} ${UNPACK['EXTRACTOR']['TAR']['LISTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['TAR']['LISTSUFFIX']}",\r
-                "LISTSUFFIX"     : "",\r
-                "LISTFLAGS"      : "",\r
-                "LISTEXTRACTOR"  : None\r
-            },\r
-\r
-            "ZIP" : {\r
-                "PRIORITY"       : 1,\r
-                "SUFFIX"         : [".zip"],\r
-                "EXTRACTSUFFIX"  : "",\r
-                "EXTRACTFLAGS"   : "",\r
-                "EXTRACTCMD"     : "${UNPACK['EXTRACTOR']['ZIP']['RUN']} ${UNPACK['EXTRACTOR']['ZIP']['EXTRACTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['ZIP']['EXTRACTSUFFIX']}",\r
-                "RUN"            : "",\r
-                "LISTCMD"        : "${UNPACK['EXTRACTOR']['ZIP']['RUN']} ${UNPACK['EXTRACTOR']['ZIP']['LISTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['ZIP']['LISTSUFFIX']}",\r
-                "LISTSUFFIX"     : "",\r
-                "LISTFLAGS"      : "",\r
-                "LISTEXTRACTOR"  : None\r
-            }\r
-        }\r
-    }\r
-\r
-    # read tools for Windows system\r
-    if env["PLATFORM"] <> "darwin" and "win" in env["PLATFORM"] :\r
-\r
-        if env.WhereIs("7z") :\r
-            toolset["EXTRACTOR"]["TARGZ"]["RUN"]           = "7z"\r
-            toolset["EXTRACTOR"]["TARGZ"]["LISTEXTRACTOR"] = __fileextractor_win_7zip\r
-            toolset["EXTRACTOR"]["TARGZ"]["LISTFLAGS"]     = "x"\r
-            toolset["EXTRACTOR"]["TARGZ"]["LISTSUFFIX"]    = "-so -y | ${UNPACK['EXTRACTOR']['TARGZ']['RUN']} l -sii -ttar -y -so"\r
-            toolset["EXTRACTOR"]["TARGZ"]["EXTRACTFLAGS"]  = "x"\r
-            toolset["EXTRACTOR"]["TARGZ"]["EXTRACTSUFFIX"] = "-so -y | ${UNPACK['EXTRACTOR']['TARGZ']['RUN']} x -sii -ttar -y -oc:${UNPACK['EXTRACTDIR']}"\r
-\r
-            toolset["EXTRACTOR"]["TARBZ"]["RUN"]           = "7z"\r
-            toolset["EXTRACTOR"]["TARBZ"]["LISTEXTRACTOR"] = __fileextractor_win_7zip\r
-            toolset["EXTRACTOR"]["TARBZ"]["LISTFLAGS"]     = "x"\r
-            toolset["EXTRACTOR"]["TARBZ"]["LISTSUFFIX"]    = "-so -y | ${UNPACK['EXTRACTOR']['TARGZ']['RUN']} l -sii -ttar -y -so"\r
-            toolset["EXTRACTOR"]["TARBZ"]["EXTRACTFLAGS"]  = "x"\r
-            toolset["EXTRACTOR"]["TARBZ"]["EXTRACTSUFFIX"] = "-so -y | ${UNPACK['EXTRACTOR']['TARGZ']['RUN']} x -sii -ttar -y -oc:${UNPACK['EXTRACTDIR']}"\r
-\r
-            toolset["EXTRACTOR"]["BZIP"]["RUN"]            = "7z"\r
-            toolset["EXTRACTOR"]["BZIP"]["LISTEXTRACTOR"]  = __fileextractor_win_7zip\r
-            toolset["EXTRACTOR"]["BZIP"]["LISTFLAGS"]      = "l"\r
-            toolset["EXTRACTOR"]["BZIP"]["LISTSUFFIX"]     = "-y -so"\r
-            toolset["EXTRACTOR"]["BZIP"]["EXTRACTFLAGS"]   = "x"\r
-            toolset["EXTRACTOR"]["BZIP"]["EXTRACTSUFFIX"]  = "-y -oc:${UNPACK['EXTRACTDIR']}"\r
-\r
-            toolset["EXTRACTOR"]["GZIP"]["RUN"]            = "7z"\r
-            toolset["EXTRACTOR"]["GZIP"]["LISTEXTRACTOR"]  = __fileextractor_win_7zip\r
-            toolset["EXTRACTOR"]["GZIP"]["LISTFLAGS"]      = "l"\r
-            toolset["EXTRACTOR"]["GZIP"]["LISTSUFFIX"]     = "-y -so"\r
-            toolset["EXTRACTOR"]["GZIP"]["EXTRACTFLAGS"]   = "x"\r
-            toolset["EXTRACTOR"]["GZIP"]["EXTRACTSUFFIX"]  = "-y -oc:${UNPACK['EXTRACTDIR']}"\r
-\r
-            toolset["EXTRACTOR"]["ZIP"]["RUN"]             = "7z"\r
-            toolset["EXTRACTOR"]["ZIP"]["LISTEXTRACTOR"]   = __fileextractor_win_7zip\r
-            toolset["EXTRACTOR"]["ZIP"]["LISTFLAGS"]       = "l"\r
-            toolset["EXTRACTOR"]["ZIP"]["LISTSUFFIX"]      = "-y -so"\r
-            toolset["EXTRACTOR"]["ZIP"]["EXTRACTFLAGS"]    = "x"\r
-            toolset["EXTRACTOR"]["ZIP"]["EXTRACTSUFFIX"]   = "-y -oc:${UNPACK['EXTRACTDIR']}"\r
-\r
-            toolset["EXTRACTOR"]["TAR"]["RUN"]             = "7z"\r
-            toolset["EXTRACTOR"]["TAR"]["LISTEXTRACTOR"]   = __fileextractor_win_7zip\r
-            toolset["EXTRACTOR"]["TAR"]["LISTFLAGS"]       = "l"\r
-            toolset["EXTRACTOR"]["TAR"]["LISTSUFFIX"]      = "-y -ttar -so"\r
-            toolset["EXTRACTOR"]["TAR"]["EXTRACTFLAGS"]    = "x"\r
-            toolset["EXTRACTOR"]["TAR"]["EXTRACTSUFFIX"]   = "-y -ttar -oc:${UNPACK['EXTRACTDIR']}"\r
-\r
-        # here can add some other Windows tools, that can handle the archive files\r
-        # but I don't know which ones can handle all file types\r
-\r
-\r
-\r
-    # read the tools on *nix systems and sets the default parameters\r
-    elif env["PLATFORM"] in ["darwin", "linux", "posix"] :\r
-\r
-        if env.WhereIs("unzip") :\r
-            toolset["EXTRACTOR"]["ZIP"]["RUN"]             = "unzip"\r
-            toolset["EXTRACTOR"]["ZIP"]["LISTEXTRACTOR"]   = __fileextractor_nix_unzip\r
-            toolset["EXTRACTOR"]["ZIP"]["LISTFLAGS"]       = "-l"\r
-            toolset["EXTRACTOR"]["ZIP"]["EXTRACTFLAGS"]    = "-oqq"\r
-            toolset["EXTRACTOR"]["ZIP"]["EXTRACTSUFFIX"]   = "-d ${UNPACK['EXTRACTDIR']}"\r
-\r
-        if env.WhereIs("tar") :\r
-            toolset["EXTRACTOR"]["TAR"]["RUN"]             = "tar"\r
-            toolset["EXTRACTOR"]["TAR"]["LISTEXTRACTOR"]   = __fileextractor_nix_tar\r
-            toolset["EXTRACTOR"]["TAR"]["LISTFLAGS"]       = "tvf"\r
-            toolset["EXTRACTOR"]["TAR"]["EXTRACTFLAGS"]    = "xf"\r
-            toolset["EXTRACTOR"]["TAR"]["EXTRACTSUFFIX"]   = "-C ${UNPACK['EXTRACTDIR']}"\r
-\r
-            toolset["EXTRACTOR"]["TARGZ"]["RUN"]           = "tar"\r
-            toolset["EXTRACTOR"]["TARGZ"]["LISTEXTRACTOR"] = __fileextractor_nix_tar\r
-            toolset["EXTRACTOR"]["TARGZ"]["EXTRACTFLAGS"]  = "xfz"\r
-            toolset["EXTRACTOR"]["TARGZ"]["LISTFLAGS"]     = "tvfz"\r
-            toolset["EXTRACTOR"]["TARGZ"]["EXTRACTSUFFIX"] = "-C ${UNPACK['EXTRACTDIR']}"\r
-\r
-            toolset["EXTRACTOR"]["TARBZ"]["RUN"]           = "tar"\r
-            toolset["EXTRACTOR"]["TARBZ"]["LISTEXTRACTOR"] = __fileextractor_nix_tar\r
-            toolset["EXTRACTOR"]["TARBZ"]["EXTRACTFLAGS"]  = "xfj"\r
-            toolset["EXTRACTOR"]["TARBZ"]["LISTFLAGS"]     = "tvfj"\r
-            toolset["EXTRACTOR"]["TARBZ"]["EXTRACTSUFFIX"] = "-C ${UNPACK['EXTRACTDIR']}"\r
-\r
-        if env.WhereIs("bzip2") :\r
-            toolset["EXTRACTOR"]["BZIP"]["RUN"]            = "bzip2"\r
-            toolset["EXTRACTOR"]["BZIP"]["EXTRACTFLAGS"]   = "-df"\r
-\r
-        if env.WhereIs("gzip") :\r
-            toolset["EXTRACTOR"]["GZIP"]["RUN"]            = "gzip"\r
-            toolset["EXTRACTOR"]["GZIP"]["LISTEXTRACTOR"]  = __fileextractor_nix_gzip\r
-            toolset["EXTRACTOR"]["GZIP"]["LISTFLAGS"]      = "-l"\r
-            toolset["EXTRACTOR"]["GZIP"]["EXTRACTFLAGS"]   = "-df"\r
-\r
-    else :\r
-        raise SCons.Errors.StopError("Unpack tool detection on this platform [%s] unkown" % (env["PLATFORM"]))\r
-\r
-    # the target_factory must be a "Entry", because the target list can be files and dirs, so we can not specified the targetfactory explicite\r
-    env.Replace(UNPACK = toolset)\r
-    env["BUILDERS"]["UnpackAll"] = SCons.Builder.Builder( action = __action,  emitter = __emitter,  target_factory = SCons.Node.FS.Entry,  source_factory = SCons.Node.FS.File,  single_source = True,  PRINT_CMD_LINE_FUNC = __message )\r
-\r
-\r
-# existing function of the builder\r
-# @param env environment object\r
-# @return true\r
-def exists(env) :\r
-    return 1\r
+# -*- coding: utf-8 -*-
+
+############################################################################
+# GPL License                                                              #
+#                                                                          #
+# This file is a SCons (http://www.scons.org/) builder                     #
+# Copyright (c) 2012-14, Philipp Kraus, <philipp.kraus@flashpixx.de>       #
+# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.     #
+# This program is free software: you can redistribute it and/or modify     #
+# it under the terms of the GNU General Public License as                  #
+# published by the Free Software Foundation, either version 3 of the       #
+# License, or (at your option) any later version.                          #
+#                                                                          #
+# This program is distributed in the hope that it will be useful,          #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of           #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
+# GNU General Public License for more details.                             #
+#                                                                          #
+# You should have received a copy of the GNU General Public License        #
+# along with this program. If not, see <http://www.gnu.org/licenses/>.     #
+############################################################################
+
+# This builder originated from work by Philipp Kraus and flashpixx project
+# (see https://github.com/flashpixx). Based on the Unpack.py, it only
+# contains changes to allow a complete unpacking of the archive.
+# It is assumed that the target represents a file in the archive after it
+# is unpacked.
+
+# The Unpack Builder can be used for unpacking archives (eg Zip, TGZ, BZ, ... ).
+# The emitter of the Builder reads the archive data and creates a returning
+# file list the builder extract the archive. The environment variable
+# stores a dictionary "UNPACK" for set different extractions (subdict "EXTRACTOR"):
+# {
+#   PRIORITY         => a value for setting the extractor order (lower numbers = extractor is used earlier)
+#   SUFFIX           => defines a list with file suffixes, which should be handled with this extractor
+#   EXTRACTSUFFIX    => suffix of the extract command
+#   EXTRACTFLAGS     => a string parameter for the RUN command for extracting the data
+#   EXTRACTCMD       => full extract command of the builder
+#   RUN              => the main program which will be started (if the parameter is empty, the extractor will be ignored)
+#   LISTCMD          => the listing command for the emitter
+#   LISTFLAGS        => the string options for the RUN command for showing a list of files
+#   LISTSUFFIX       => suffix of the list command
+#   LISTEXTRACTOR    => a optional Python function, that is called on each output line of the
+#                       LISTCMD for extracting file & dir names, the function need two parameters (first line number,
+#                       second line content) and must return a string with the file / dir path (other value types
+#                       will be ignored)
+# }
+# Other options in the UNPACK dictionary are:
+#   STOPONEMPTYFILE  => bool variable for stoping if the file has empty size (default True)
+#   VIWEXTRACTOUTPUT => shows the output messages of the extraction command (default False)
+#   EXTRACTDIR       => path in that the data will be extracted (default #)
+#
+# The file which is handled by the first suffix match of the extractor, the extractor list can be append for other files.
+# The order of the extractor dictionary creates the listing & extractor command eg file extension .tar.gz should be
+# before .gz, because the tar.gz is extract in one shoot.
+#
+# Under *nix system these tools are supported: tar, bzip2, gzip, unzip
+# Under Windows only 7-Zip (http://www.7-zip.org/) is supported
+
+
+import subprocess, os
+import SCons.Errors, SCons.Warnings, SCons.Util
+
+# enables Scons warning for this builder
+class UnpackWarning(SCons.Warnings.Warning) :
+    pass
+
+SCons.Warnings.enableWarningClass(UnpackWarning)
+
+# extractor function for Tar output
+# @param env environment object
+# @param count number of returning lines
+# @param no number of the output line
+# @param i line content
+def __fileextractor_nix_tar( env, count, no, i ) :
+    return i.split()[-1]
+
+# extractor function for GZip output,
+# ignore the first line
+# @param env environment object
+# @param count number of returning lines
+# @param no number of the output line
+# @param i line content
+def __fileextractor_nix_gzip( env, count, no, i ) :
+    if no == 0 :
+        return None
+    return i.split()[-1]
+
+# extractor function for Unzip output,
+# ignore the first & last two lines
+# @param env environment object
+# @param count number of returning lines
+# @param no number of the output line
+# @param i line content
+def __fileextractor_nix_unzip( env, count, no, i ) :
+    if no < 3 or no >= count - 2 :
+        return None
+    return i.split()[-1]
+
+# extractor function for 7-Zip
+# @param env environment object
+# @param count number of returning lines
+# @param no number of the output line
+# @param i line content
+def __fileextractor_win_7zip( env, count, no, i ) :
+    item = i.split()
+    if no > 8 and no < count - 2 :
+        return item[-1]
+    return None
+
+
+
+# returns the extractor item for handling the source file
+# @param source input source file
+# @param env environment object
+# @return extractor entry or None on non existing
+def __getExtractor( source, env ) :
+    # we check each unpacker and get the correct list command first, run the command and
+    # replace the target filelist with the list values, we sorte the extractors by their priority
+    for unpackername, extractor in sorted(env["UNPACK"]["EXTRACTOR"].iteritems(), key = lambda (k,v) : (v["PRIORITY"],k)):
+
+        if not SCons.Util.is_String(extractor["RUN"]) :
+            raise SCons.Errors.StopError("list command of the unpack builder for [%s] archives is not a string" % (unpackername))
+        if not len(extractor["RUN"]) :
+            raise SCons.Errors.StopError("run command of the unpack builder for [%s] archives is not set - can not extract files" % (unpackername))
+
+
+        if not SCons.Util.is_String(extractor["LISTFLAGS"]) :
+            raise SCons.Errors.StopError("list flags of the unpack builder for [%s] archives is not a string" % (unpackername))
+        if not SCons.Util.is_String(extractor["LISTCMD"]) :
+            raise SCons.Errors.StopError("list command of the unpack builder for [%s] archives is not a string" % (unpackername))
+
+        if not SCons.Util.is_String(extractor["EXTRACTFLAGS"]) :
+            raise SCons.Errors.StopError("extract flags of the unpack builder for [%s] archives is not a string" % (unpackername))
+        if not SCons.Util.is_String(extractor["EXTRACTCMD"]) :
+            raise SCons.Errors.StopError("extract command of the unpack builder for [%s] archives is not a string" % (unpackername))
+
+
+        # check the source file suffix and if the first is found, run the list command
+        if not SCons.Util.is_List(extractor["SUFFIX"]) :
+            raise SCons.Errors.StopError("suffix list of the unpack builder for [%s] archives is not a list" % (unpackername))
+
+        for suffix in extractor["SUFFIX"] :
+            if str(source[0]).lower()[-len(suffix):] == suffix.lower() :
+                return extractor
+
+    return None
+
+
+# creates the extracter output message
+# @param s original message
+# @param target target name
+# @param source source name
+# @param env environment object
+def __message( s, target, source, env ) :
+    print "extract [%s] ..." % (source[0])
+
+
+# action function for extracting of the data
+# @param target target packed file
+# @param source extracted files
+# @param env environment object
+def __action( target, source, env ) :
+    extractor = __getExtractor(source, env)
+    if not extractor :
+        raise SCons.Errors.StopError( "can not find any extractor value for the source file [%s]" % (source[0]) )
+
+    extractor_cmd = extractor["EXTRACTCMD"]
+
+    # if the extract command is empty, we create an error
+    if len(extractor_cmd) == 0 :
+        raise SCons.Errors.StopError( "the extractor command for the source file [%s] is empty" % (source[0]) )
+
+    # build it now (we need the shell, because some programs need it)
+    handle = None
+
+    source_path = os.path.realpath(source[0].path)
+    target_path = os.path.realpath(target[0].path)
+
+    cmd = env.subst(extractor_cmd, source=source_path, target=target)
+    cwd = os.path.dirname(source_path)
+
+    if env["UNPACK"]["VIWEXTRACTOUTPUT"] :
+        handle  = subprocess.Popen( cmd, shell=True )
+    else :
+        devnull = open(os.devnull, "wb")
+        handle  = subprocess.Popen( cmd, shell=True, stdout=devnull, cwd=cwd)
+
+    if handle.wait() <> 0 :
+        raise SCons.Errors.BuildError( "error running extractor [%s] on the source [%s]" % (cmd, source[0]) )
+
+    fhandle = open(target_path, 'a')
+    try:
+        os.utime(target_path, None)
+    finally:
+        fhandle.close()
+
+
+# emitter function for getting the files
+# within the archive
+# @param target target packed file
+# @param source extracted files
+# @param env environment object
+def __emitter( target, source, env ) :
+    return target, source
+
+
+# generate function, that adds the builder to the environment
+# @param env environment object
+def generate( env ) :
+    # setup environment variable
+    toolset = {
+        "STOPONEMPTYFILE"  : True,
+        "VIWEXTRACTOUTPUT" : False,
+        "EXTRACTDIR"       : os.curdir,
+        "EXTRACTOR" : {
+            "TARGZ" : {
+                "PRIORITY"       : 0,
+                "SUFFIX"         : [".tar.gz", ".tgz", ".tar.gzip"],
+                "EXTRACTSUFFIX"  : "",
+                "EXTRACTFLAGS"   : "",
+                "EXTRACTCMD"     : "${UNPACK['EXTRACTOR']['TARGZ']['RUN']} ${UNPACK['EXTRACTOR']['TARGZ']['EXTRACTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['TARGZ']['EXTRACTSUFFIX']}",
+                "RUN"            : "",
+                "LISTCMD"        : "${UNPACK['EXTRACTOR']['TARGZ']['RUN']} ${UNPACK['EXTRACTOR']['TARGZ']['LISTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['TARGZ']['LISTSUFFIX']}",
+                "LISTSUFFIX"     : "",
+                "LISTFLAGS"      : "",
+                "LISTEXTRACTOR"  : None
+            },
+
+            "TARBZ" : {
+                "PRIORITY"       : 0,
+                "SUFFIX"         : [".tar.bz", ".tbz", ".tar.bz2", ".tar.bzip2", ".tar.bzip"],
+                "EXTRACTSUFFIX"  : "",
+                "EXTRACTFLAGS"   : "",
+                "EXTRACTCMD"     : "${UNPACK['EXTRACTOR']['TARBZ']['RUN']} ${UNPACK['EXTRACTOR']['TARBZ']['EXTRACTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['TARBZ']['EXTRACTSUFFIX']}",
+                "RUN"            : "",
+                "LISTCMD"        : "${UNPACK['EXTRACTOR']['TARBZ']['RUN']} ${UNPACK['EXTRACTOR']['TARBZ']['LISTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['TARBZ']['LISTSUFFIX']}",
+                "LISTSUFFIX"     : "",
+                "LISTFLAGS"      : "",
+                "LISTEXTRACTOR"  : None
+            },
+
+            "BZIP" : {
+                "PRIORITY"       : 1,
+                "SUFFIX"         : [".bz", "bzip", ".bz2", ".bzip2"],
+                "EXTRACTSUFFIX"  : "",
+                "EXTRACTFLAGS"   : "",
+                "EXTRACTCMD"     : "${UNPACK['EXTRACTOR']['BZIP']['RUN']} ${UNPACK['EXTRACTOR']['BZIP']['EXTRACTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['BZIP']['EXTRACTSUFFIX']}",
+                "RUN"            : "",
+                "LISTCMD"        : "${UNPACK['EXTRACTOR']['BZIP']['RUN']} ${UNPACK['EXTRACTOR']['BZIP']['LISTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['BZIP']['LISTSUFFIX']}",
+                "LISTSUFFIX"     : "",
+                "LISTFLAGS"      : "",
+                "LISTEXTRACTOR"  : None
+            },
+
+            "GZIP" : {
+                "PRIORITY"       : 1,
+                "SUFFIX"         : [".gz", ".gzip"],
+                "EXTRACTSUFFIX"  : "",
+                "EXTRACTFLAGS"   : "",
+                "EXTRACTCMD"     : "${UNPACK['EXTRACTOR']['GZIP']['RUN']} ${UNPACK['EXTRACTOR']['GZIP']['EXTRACTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['GZIP']['EXTRACTSUFFIX']}",
+                "RUN"            : "",
+                "LISTCMD"        : "${UNPACK['EXTRACTOR']['GZIP']['RUN']} ${UNPACK['EXTRACTOR']['GZIP']['LISTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['GZIP']['LISTSUFFIX']}",
+                "LISTSUFFIX"     : "",
+                "LISTFLAGS"      : "",
+                "LISTEXTRACTOR"  : None
+            },
+
+            "TAR" : {
+                "PRIORITY"       : 1,
+                "SUFFIX"         : [".tar"],
+                "EXTRACTSUFFIX"  : "",
+                "EXTRACTFLAGS"   : "",
+                "EXTRACTCMD"     : "${UNPACK['EXTRACTOR']['TAR']['RUN']} ${UNPACK['EXTRACTOR']['TAR']['EXTRACTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['TAR']['EXTRACTSUFFIX']}",
+                "RUN"            : "",
+                "LISTCMD"        : "${UNPACK['EXTRACTOR']['TAR']['RUN']} ${UNPACK['EXTRACTOR']['TAR']['LISTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['TAR']['LISTSUFFIX']}",
+                "LISTSUFFIX"     : "",
+                "LISTFLAGS"      : "",
+                "LISTEXTRACTOR"  : None
+            },
+
+            "ZIP" : {
+                "PRIORITY"       : 1,
+                "SUFFIX"         : [".zip"],
+                "EXTRACTSUFFIX"  : "",
+                "EXTRACTFLAGS"   : "",
+                "EXTRACTCMD"     : "${UNPACK['EXTRACTOR']['ZIP']['RUN']} ${UNPACK['EXTRACTOR']['ZIP']['EXTRACTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['ZIP']['EXTRACTSUFFIX']}",
+                "RUN"            : "",
+                "LISTCMD"        : "${UNPACK['EXTRACTOR']['ZIP']['RUN']} ${UNPACK['EXTRACTOR']['ZIP']['LISTFLAGS']} $SOURCE ${UNPACK['EXTRACTOR']['ZIP']['LISTSUFFIX']}",
+                "LISTSUFFIX"     : "",
+                "LISTFLAGS"      : "",
+                "LISTEXTRACTOR"  : None
+            }
+        }
+    }
+
+    # read tools for Windows system
+    if env["PLATFORM"] <> "darwin" and "win" in env["PLATFORM"] :
+
+        if env.WhereIs("7z") :
+            toolset["EXTRACTOR"]["TARGZ"]["RUN"]           = "7z"
+            toolset["EXTRACTOR"]["TARGZ"]["LISTEXTRACTOR"] = __fileextractor_win_7zip
+            toolset["EXTRACTOR"]["TARGZ"]["LISTFLAGS"]     = "x"
+            toolset["EXTRACTOR"]["TARGZ"]["LISTSUFFIX"]    = "-so -y | ${UNPACK['EXTRACTOR']['TARGZ']['RUN']} l -sii -ttar -y -so"
+            toolset["EXTRACTOR"]["TARGZ"]["EXTRACTFLAGS"]  = "x"
+            toolset["EXTRACTOR"]["TARGZ"]["EXTRACTSUFFIX"] = "-so -y | ${UNPACK['EXTRACTOR']['TARGZ']['RUN']} x -sii -ttar -y -oc:${UNPACK['EXTRACTDIR']}"
+
+            toolset["EXTRACTOR"]["TARBZ"]["RUN"]           = "7z"
+            toolset["EXTRACTOR"]["TARBZ"]["LISTEXTRACTOR"] = __fileextractor_win_7zip
+            toolset["EXTRACTOR"]["TARBZ"]["LISTFLAGS"]     = "x"
+            toolset["EXTRACTOR"]["TARBZ"]["LISTSUFFIX"]    = "-so -y | ${UNPACK['EXTRACTOR']['TARGZ']['RUN']} l -sii -ttar -y -so"
+            toolset["EXTRACTOR"]["TARBZ"]["EXTRACTFLAGS"]  = "x"
+            toolset["EXTRACTOR"]["TARBZ"]["EXTRACTSUFFIX"] = "-so -y | ${UNPACK['EXTRACTOR']['TARGZ']['RUN']} x -sii -ttar -y -oc:${UNPACK['EXTRACTDIR']}"
+
+            toolset["EXTRACTOR"]["BZIP"]["RUN"]            = "7z"
+            toolset["EXTRACTOR"]["BZIP"]["LISTEXTRACTOR"]  = __fileextractor_win_7zip
+            toolset["EXTRACTOR"]["BZIP"]["LISTFLAGS"]      = "l"
+            toolset["EXTRACTOR"]["BZIP"]["LISTSUFFIX"]     = "-y -so"
+            toolset["EXTRACTOR"]["BZIP"]["EXTRACTFLAGS"]   = "x"
+            toolset["EXTRACTOR"]["BZIP"]["EXTRACTSUFFIX"]  = "-y -oc:${UNPACK['EXTRACTDIR']}"
+
+            toolset["EXTRACTOR"]["GZIP"]["RUN"]            = "7z"
+            toolset["EXTRACTOR"]["GZIP"]["LISTEXTRACTOR"]  = __fileextractor_win_7zip
+            toolset["EXTRACTOR"]["GZIP"]["LISTFLAGS"]      = "l"
+            toolset["EXTRACTOR"]["GZIP"]["LISTSUFFIX"]     = "-y -so"
+            toolset["EXTRACTOR"]["GZIP"]["EXTRACTFLAGS"]   = "x"
+            toolset["EXTRACTOR"]["GZIP"]["EXTRACTSUFFIX"]  = "-y -oc:${UNPACK['EXTRACTDIR']}"
+
+            toolset["EXTRACTOR"]["ZIP"]["RUN"]             = "7z"
+            toolset["EXTRACTOR"]["ZIP"]["LISTEXTRACTOR"]   = __fileextractor_win_7zip
+            toolset["EXTRACTOR"]["ZIP"]["LISTFLAGS"]       = "l"
+            toolset["EXTRACTOR"]["ZIP"]["LISTSUFFIX"]      = "-y -so"
+            toolset["EXTRACTOR"]["ZIP"]["EXTRACTFLAGS"]    = "x"
+            toolset["EXTRACTOR"]["ZIP"]["EXTRACTSUFFIX"]   = "-y -oc:${UNPACK['EXTRACTDIR']}"
+
+            toolset["EXTRACTOR"]["TAR"]["RUN"]             = "7z"
+            toolset["EXTRACTOR"]["TAR"]["LISTEXTRACTOR"]   = __fileextractor_win_7zip
+            toolset["EXTRACTOR"]["TAR"]["LISTFLAGS"]       = "l"
+            toolset["EXTRACTOR"]["TAR"]["LISTSUFFIX"]      = "-y -ttar -so"
+            toolset["EXTRACTOR"]["TAR"]["EXTRACTFLAGS"]    = "x"
+            toolset["EXTRACTOR"]["TAR"]["EXTRACTSUFFIX"]   = "-y -ttar -oc:${UNPACK['EXTRACTDIR']}"
+
+        # here can add some other Windows tools, that can handle the archive files
+        # but I don't know which ones can handle all file types
+
+
+
+    # read the tools on *nix systems and sets the default parameters
+    elif env["PLATFORM"] in ["darwin", "linux", "posix"] :
+
+        if env.WhereIs("unzip") :
+            toolset["EXTRACTOR"]["ZIP"]["RUN"]             = "unzip"
+            toolset["EXTRACTOR"]["ZIP"]["LISTEXTRACTOR"]   = __fileextractor_nix_unzip
+            toolset["EXTRACTOR"]["ZIP"]["LISTFLAGS"]       = "-l"
+            toolset["EXTRACTOR"]["ZIP"]["EXTRACTFLAGS"]    = "-oqq"
+            toolset["EXTRACTOR"]["ZIP"]["EXTRACTSUFFIX"]   = "-d ${UNPACK['EXTRACTDIR']}"
+
+        if env.WhereIs("tar") :
+            toolset["EXTRACTOR"]["TAR"]["RUN"]             = "tar"
+            toolset["EXTRACTOR"]["TAR"]["LISTEXTRACTOR"]   = __fileextractor_nix_tar
+            toolset["EXTRACTOR"]["TAR"]["LISTFLAGS"]       = "tvf"
+            toolset["EXTRACTOR"]["TAR"]["EXTRACTFLAGS"]    = "xf"
+            toolset["EXTRACTOR"]["TAR"]["EXTRACTSUFFIX"]   = "-C ${UNPACK['EXTRACTDIR']}"
+
+            toolset["EXTRACTOR"]["TARGZ"]["RUN"]           = "tar"
+            toolset["EXTRACTOR"]["TARGZ"]["LISTEXTRACTOR"] = __fileextractor_nix_tar
+            toolset["EXTRACTOR"]["TARGZ"]["EXTRACTFLAGS"]  = "xfz"
+            toolset["EXTRACTOR"]["TARGZ"]["LISTFLAGS"]     = "tvfz"
+            toolset["EXTRACTOR"]["TARGZ"]["EXTRACTSUFFIX"] = "-C ${UNPACK['EXTRACTDIR']}"
+
+            toolset["EXTRACTOR"]["TARBZ"]["RUN"]           = "tar"
+            toolset["EXTRACTOR"]["TARBZ"]["LISTEXTRACTOR"] = __fileextractor_nix_tar
+            toolset["EXTRACTOR"]["TARBZ"]["EXTRACTFLAGS"]  = "xfj"
+            toolset["EXTRACTOR"]["TARBZ"]["LISTFLAGS"]     = "tvfj"
+            toolset["EXTRACTOR"]["TARBZ"]["EXTRACTSUFFIX"] = "-C ${UNPACK['EXTRACTDIR']}"
+
+        if env.WhereIs("bzip2") :
+            toolset["EXTRACTOR"]["BZIP"]["RUN"]            = "bzip2"
+            toolset["EXTRACTOR"]["BZIP"]["EXTRACTFLAGS"]   = "-df"
+
+        if env.WhereIs("gzip") :
+            toolset["EXTRACTOR"]["GZIP"]["RUN"]            = "gzip"
+            toolset["EXTRACTOR"]["GZIP"]["LISTEXTRACTOR"]  = __fileextractor_nix_gzip
+            toolset["EXTRACTOR"]["GZIP"]["LISTFLAGS"]      = "-l"
+            toolset["EXTRACTOR"]["GZIP"]["EXTRACTFLAGS"]   = "-df"
+
+    else :
+        raise SCons.Errors.StopError("Unpack tool detection on this platform [%s] unkown" % (env["PLATFORM"]))
+
+    # the target_factory must be a "Entry", because the target list can be files and dirs, so we can not specified the targetfactory explicite
+    env.Replace(UNPACK = toolset)
+    env["BUILDERS"]["UnpackAll"] = SCons.Builder.Builder( action = __action,  emitter = __emitter,  target_factory = SCons.Node.FS.Entry,  source_factory = SCons.Node.FS.File,  single_source = True,  PRINT_CMD_LINE_FUNC = __message )
+
+
+# existing function of the builder
+# @param env environment object
+# @return true
+def exists(env) :
+    return 1
index d03a71f..b4a6098 100755 (executable)
@@ -55,9 +55,9 @@ for file in `find  "$indir"  -type f  -name "*$fileext" ` ; do
        else
                infile=$file
        fi
+
        # test end of string for no file extension
-       if [ ! "${infile:(-$extLength)}" = $fileext ] ; then    
+       if [ ! "${infile:(-$extLength)}" = $fileext ] ; then
                fileHasSpaces=true
                continue
        fi
@@ -80,7 +80,7 @@ for file in `find  "$indir"  -type f  -name "*$fileext" ` ; do
 
        #  copy or move the files
        $copyfiles  -f  "$infile"  "$outpath"
-       if [ $? -ne 0 ] ; then  
+       if [ $? -ne 0 ] ; then
                read -sn1 -p "press any key to continue!"
                echo
        fi
index 4de319f..cb28569 100644 (file)
@@ -10,7 +10,7 @@ in the current directory.  You can then connect to the VM with
 
     % vagrant ssh
 
-On the newly provisioned VM, the IoTivity repo will be checked out in 
+On the newly provisioned VM, the IoTivity repo will be checked out in
 the `iotivity` directory in the vagrant user's home directory and
 configured to use the Arduino SDKs which are automatically downloaded
 and installed in the home directory and patched when the VM is provisioned.
@@ -26,7 +26,7 @@ Using Vagrant to build a VM might be useful for:
 
 The bootstrap.sh and iotivity-setup.sh files can be used independent of
 Vagrant to configure a existing Ubuntu environment.  How to do so is left
-as an exercise for the reader.  (Hint: try `sudo bootstrap.sh && 
+as an exercise for the reader.  (Hint: try `sudo bootstrap.sh &&
 iotivity-setup.sh`.)
 
 For more information about Vagrant, please see https://docs.vagrantup.com/v2/
index 13602cc..7fd1760 100644 (file)
@@ -1,5 +1,5 @@
 apt-get update
-apt-get install -y git build-essential ia32-libs scons make g++ unzip 
+apt-get install -y git build-essential ia32-libs scons make g++ unzip
 apt-get install -y libboost-dev libboost-program-options-dev libcurl4-nss-dev
 
 # for Android development