Refine comments for android apis of resource-encapsulation.
authorcoderhyme <jhyo.kim@samsung.com>
Mon, 28 Sep 2015 08:21:41 +0000 (01:21 -0700)
committerMadan Lanka <lanka.madan@samsung.com>
Mon, 28 Sep 2015 09:24:05 +0000 (09:24 +0000)
Incorrect tags are fixed.
Links for types and methods in comments are added for convenience.

Change-Id: I8f4bbc31dfb4ead6b4b5fd0f80046002f8e80589
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3189
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
15 files changed:
service/resource-encapsulation/android/SConscript
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsResourceAttributes.java
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/RcsValue.java
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/client/RcsAddress.java
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/client/RcsDiscoveryManager.java
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/client/RcsRemoteResourceObject.java
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsGetResponse.java
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsLockedAttributes.java
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsResourceObject.java
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsResponse.java
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsSetResponse.java
service/resource-encapsulation/android/service/src/main/java/org/iotivity/service/server/RcsUnlockedException.java
service/resource-encapsulation/android/service/src/main/jni/JniRcsResourceAttributes.cpp
service/resource-encapsulation/include/RCSResourceAttributes.h
service/resource-encapsulation/include/RCSResourceObject.h

index 23a3951..689eec9 100644 (file)
@@ -45,8 +45,7 @@ if not os.path.exists(android_home + '/platforms/android-21') or not os.path.exi
 
 def ensure_libs(target, source, env):
     return target, [source, env.get('BUILD_DIR') + 'librcs_server.so', 
-                    env.get('BUILD_DIR') + 'librcs_client.so',
-                    env.get('BUILD_DIR') + 'librcs_container.so']
+                    env.get('BUILD_DIR') + 'librcs_client.so']
 
 jdk_env = Environment(ENV=os.environ)
 jdk_env['BUILDERS']['Gradle'] = Builder(action = env.get('ANDROID_GRADLE') + 
index 41849a9..8151102 100644 (file)
@@ -26,9 +26,11 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
+import org.iotivity.service.server.RcsLockedAttributes;
+
 /**
  *
- * RCSResourceAttributes represents the attributes for a resource.
+ * This class represents the attributes for a resource.
  *
  * @see RcsValue
  */
@@ -55,6 +57,13 @@ public final class RcsResourceAttributes extends RcsObject {
     public RcsResourceAttributes() {
     }
 
+    public RcsResourceAttributes(RcsLockedAttributes lockedAttrs)
+            throws RcsException {
+        for (final String key : lockedAttrs.keySet()) {
+            mCache.put(key, lockedAttrs.get(key));
+        }
+    }
+
     /**
      * Returns a unmodifiable Set view of the keys contained in this attributes.
      *
@@ -99,13 +108,15 @@ public final class RcsResourceAttributes extends RcsObject {
      * If the object previously contained a mapping for the key, the old value
      * is replaced by the specified value.
      *
-     *
      * @param key
      *            key with which the specified value is to be associated
      *
      * @param value
      *            value to be associated with the specified key
      *
+     * @throws NullPointerException
+     *             if key or value is null
+     *
      */
     public void put(String key, RcsValue value) {
         if (key == null) throw new NullPointerException("key is null");
@@ -115,7 +126,25 @@ public final class RcsResourceAttributes extends RcsObject {
         if (hasHandle()) nativeRemove(key);
     }
 
+    /**
+     * Sets the specified value with the specified key.
+     * If the object previously contained a mapping for the key, the old value
+     * is replaced by the specified value.
+     *
+     * @param key
+     *            key with which the specified value is to be associated
+     *
+     * @param value
+     *            value to be associated with the specified key
+     *
+     * @throws NullPointerException
+     *             if key or value is null
+     * @throws IllegalArgumentException
+     *             if object is not supported type by {@link RcsValue}
+     */
     public void put(String key, Object object) {
+        if (key == null) throw new NullPointerException("key is null");
+
         put(key, new RcsValue(object));
     }
 
@@ -171,6 +200,9 @@ public final class RcsResourceAttributes extends RcsObject {
      *            key whose presence is to be tested
      *
      * @return true if this contains a mapping for the specified key.
+     *
+     * @throws NullPointerException
+     *             if key is null
      */
     public boolean contains(String key) {
         if (key == null) throw new NullPointerException("key is null");
index 7e916fe..e1fd331 100644 (file)
@@ -29,7 +29,7 @@ import java.util.Map;
  *
  * Type helps identify type information of Value.
  *
- * @see RCSResourceAttributes
+ * @see RcsResourceAttributes
  * @see Type
  */
 public final class RcsValue {
@@ -53,8 +53,8 @@ public final class RcsValue {
     /**
      * A Helper class to identify types of Value.
      *
-     * @see RCSResourceAttributes
-     * @see Value
+     * @see RcsResourceAttributes
+     * @see RcsValue
      * @see TypeId
      */
     public static class Type {
@@ -69,9 +69,9 @@ public final class RcsValue {
          *
          * @return Identifier of type
          *
-         * @see getBaseTypeId
+         * @see #getBaseTypeId(RcsValue.Type)
          */
-        public final TypeId getTypeId() {
+        public final TypeId getId() {
             return mTypeId;
         }
 
@@ -86,7 +86,7 @@ public final class RcsValue {
         /**
          * Returns the type identifier of a base type of sequence.
          *
-         * For non sequence types, it is equivalent to calling getId.
+         * For non sequence types, it is equivalent to calling {@link #getId()}.
          *
          * @return identifier of type
          *
@@ -110,11 +110,10 @@ public final class RcsValue {
 
         /**
          * Factory method to create Type instance from an object.
+         * Note that object must be a supported type by RcsValue.
          *
          * @return An instance that has TypeId for obj.
          *
-         * @note object must be a supported type by Value.
-         *
          * @throws NullPointerException
          *             if obj is null.
          * @throws IllegalArgumentException
@@ -130,12 +129,11 @@ public final class RcsValue {
         }
 
         /**
-         * Factory method to create Type instance from a clss.
+         * Factory method to create Type instance from a class.
+         * Note that class must be a supported type by RcsValue.
          *
          * @return An instance that has TypeId for class.
          *
-         * @note class must be a supported type by Value.
-         *
          * @throws NullPointerException
          *             if cls is null.
          * @throws IllegalArgumentException
@@ -257,7 +255,7 @@ public final class RcsValue {
     }
 
     /**
-     * Constructs a new value that holds null value.
+     * Constructs a new value that holds a boolean value.
      *
      * @param value
      *            a boolean
@@ -510,7 +508,7 @@ public final class RcsValue {
     }
 
     /**
-     * Returns the value it represents is null.
+     * Returns whether the value is null.
      *
      * @return true if the value is null.
      */
@@ -519,7 +517,7 @@ public final class RcsValue {
     }
 
     /**
-     * Returns the object represents null for RcsValue.
+     * Returns whether the object represents null for RcsValue.
      *
      * @param o
      *            an object to be tested
index 4864b81..af6faee 100644 (file)
 package org.iotivity.service.client;
 
 /**
- * This class provides a set of APIs for constructing RCSAddress object.
- *
- * <p>
- * RCSAddress object is the first parameter for Discover Resource APIs of
- * RCSDiscoveryManager Class.
- * <p>
- * {@link RcsDiscoveryManager}
+ * This is to specify a target address to discover.
+ * 
+ * @see RcsDiscoveryManager
  */
 public final class RcsAddress {
     private final String mAddress;
index 6e6e934..7e8c44f 100644 (file)
@@ -45,6 +45,12 @@ public final class RcsDiscoveryManager {
         System.loadLibrary("rcs_jni");
     }
 
+    /**
+     * This represents a task for discovery.
+     *
+     * The task must be canceled if no longer needed.
+     *
+     */
     public static class DiscoveryTask extends RcsObject {
         private DiscoveryTask() {
         }
@@ -92,6 +98,8 @@ public final class RcsDiscoveryManager {
      *
      * @param address
      *            the target address
+     * @param listener
+     *            the listener to be invoked when a resource is discovered
      *
      * @return a task object indicating this request.
      *
@@ -114,7 +122,9 @@ public final class RcsDiscoveryManager {
      *            the target address
      * @param uri
      *            the relative uri of resource to be searched
-     * 
+     * @param listener
+     *            the listener to be invoked when a resource is discovered
+     *
      * @return a task object indicating this request.
      *
      * @throws RcsPlatformException
@@ -135,6 +145,8 @@ public final class RcsDiscoveryManager {
      *            the target address
      * @param resourceType
      *            the resource type
+     * @param listener
+     *            the listener to be invoked when a resource is discovered
      *
      * @return a task object indicating this request.
      *
@@ -161,6 +173,8 @@ public final class RcsDiscoveryManager {
      *            the relative uri of resource to be searched
      * @param resourceType
      *            the resource type
+     * @param listener
+     *            the listener to be invoked when a resource is discovered
      *
      * @return a task object indicating this request.
      *
index 0577dab..df13696 100644 (file)
@@ -27,7 +27,6 @@ import org.iotivity.service.RcsObject;
 import org.iotivity.service.RcsPlatformException;
 import org.iotivity.service.RcsResourceAttributes;
 import org.iotivity.service.RcsValue;
-import org.iotivity.service.server.RcsResourceObject;
 
 /**
  *
@@ -86,21 +85,29 @@ public final class RcsRemoteResourceObject extends RcsObject {
     /**
      * This represents states of monitoring.
      *
-     * @see #startMonitoring()
+     * @see #startMonitoring(OnStateChangedListener)
      * @see #getState()
      * @see OnStateChangedListener
      *
      */
     public enum ResourceState {
+        /** Monitoring is not started. */
+        NONE,
+
+        /**
+         * Monitoring is started and checking state is in progress.
+         * This is the default state after startMonitoring.
+         */
+        REQUESTED,
+
+        /** The resource is alive. */
+        ALIVE,
 
-        NONE, /** < Monitoring is not started. */
-        REQUESTED, /**
-                    * < Monitoring is started and checking state is in progress.
-                    * This is the default state after startMonitoring.
-                    */
-        ALIVE, /** < The resource is alive. */
-        LOST_SIGNAL, /** < Failed to reach the resource. */
-        DESTROYED /** < The resource is deleted. */
+        /** Failed to reach the resource. */
+        LOST_SIGNAL,
+
+        /** The resource is deleted. */
+        DESTROYED
     }
 
     /**
@@ -110,14 +117,20 @@ public final class RcsRemoteResourceObject extends RcsObject {
      * @see #getCacheState()
      */
     public enum CacheState {
+        /** Caching is not started. */
+        NONE,
+
+        /**
+         * Caching is started, but the data is not ready yet. This is
+         * the default state after startCaching.
+         */
+        UNREADY,
 
-        NONE, /** < Caching is not started. */
-        UNREADY, /**
-                  * < Caching is started, but the data is not ready yet. This is
-                  * the default state after startCaching.
-                  */
-        READY, /** < The data is ready. */
-        LOST_SIGNAL /** < Failed to reach the resource. */
+        /** The data is ready. */
+        READY,
+
+        /** Failed to reach the resource. */
+        LOST_SIGNAL
     }
 
     /**
@@ -227,7 +240,7 @@ public final class RcsRemoteResourceObject extends RcsObject {
      * @throws RcsDestroyedObjectException
      *             if the object is already destroyed
      *
-     * @see RcsResourceObject.Builder#setObservable(boolean)
+     * @see org.iotivity.service.server.RcsResourceObject.Builder#setObservable(boolean)
      */
     public boolean isObservable() throws RcsException {
         assertAlive();
@@ -303,8 +316,9 @@ public final class RcsRemoteResourceObject extends RcsObject {
      * This will start data caching for the resource. Once caching started it
      * will look for the data updation on the resource and updates the cache
      * data accordingly.
-     *
-     * It is equivalent to calling startCaching(CacheUpdatedCallback) with null.
+     * <p>
+     * It is equivalent to calling {@link #startCaching(OnCacheUpdatedListener)}
+     * with null.
      *
      * @throws RcsDestroyedObjectException
      *             if the object is already destroyed
@@ -386,8 +400,9 @@ public final class RcsRemoteResourceObject extends RcsObject {
     /**
      * Returns whether cached data is available.
      *
-     * Cache will be available always once cache state had been READY even if
-     * current state is LOST_SIGNAL.
+     * Cache will be available always once cache state had been
+     * {@link CacheState#READY} even if current state is
+     * {@link CacheState#LOST_SIGNAL} until stopped.
      *
      * @return true if cache data is available.
      *
@@ -407,7 +422,8 @@ public final class RcsRemoteResourceObject extends RcsObject {
 
     /**
      * Returns the cached attributes.
-     * This works only when cache is available.
+     * <p>
+     * Note that this works only when cache is available.
      *
      * @return the cached attributes.
      *
@@ -431,9 +447,9 @@ public final class RcsRemoteResourceObject extends RcsObject {
 
     /**
      * Returns the cached value to which the specified key is mapped, or null if
-     * RcsResourceAttributes contains no mapping for the key.
-     *
-     * This works only when cache is available.
+     * no mapping for the key.
+     * <p>
+     * Note that this works only when cache is available.
      *
      * @param key
      *            the key whose associated value is to be returned
@@ -466,7 +482,7 @@ public final class RcsRemoteResourceObject extends RcsObject {
     }
 
     /**
-     * Sends a request for the resource attributes directly to the server.
+     * Sends a request for the resource attributes directly to the resource.
      *
      * @param listener
      *            the listener to receive the response
@@ -491,8 +507,8 @@ public final class RcsRemoteResourceObject extends RcsObject {
     }
 
     /**
-     * Sends a set request with resource attributes to the server.
-     *
+     * Sends a set request with resource attributes to the resource.
+     * <p>
      * The SetRequest behavior depends on the server, whether updating its
      * attributes or not.
      *
index 7809275..96dcd24 100644 (file)
@@ -23,8 +23,7 @@ package org.iotivity.service.server;
 import org.iotivity.service.RcsResourceAttributes;
 
 /**
- * This class provides methods to create the response for a received get
- * request.
+ * This class provides methods to create the response for a get request.
  *
  * @see RcsResourceObject
  * @see RcsSetResponse
@@ -32,9 +31,9 @@ import org.iotivity.service.RcsResourceAttributes;
 public class RcsGetResponse extends RcsResponse {
 
     /**
-     * Creates a default RcsResourceObject. The response will have
-     * RCSResponse.DEFAULT_ERROR_CODE for the errorCode. The attributes of
-     * RCSResourceObject will be set as the result attributes.
+     * Creates a default RCcsGetResponse. The response will have
+     * {@link #DEFAULT_ERROR_CODE} for the errorCode. The attributes of
+     * {@link RcsResourceObject} will be set as the result attributes.
      *
      */
     public static RcsGetResponse defaultAction() {
@@ -42,11 +41,12 @@ public class RcsGetResponse extends RcsResponse {
     }
 
     /**
-     * Creates a RcsResourceObject with error code passed. The
-     * attributes of the RCSResourceObject will be set as the result attributes.
+     * Creates a RcsGetResponse with error code passed. The
+     * attributes of the {@link RcsResourceObject} will be set as the result
+     * attributes.
      *
      * @param errorCode
-     *            The error code to set in response.
+     *            error code to be set in response
      *
      */
     public static RcsGetResponse create(int errorCode) {
@@ -55,12 +55,13 @@ public class RcsGetResponse extends RcsResponse {
     }
 
     /**
-     * Creates a RcsResourceObject with custom attributes. This sends the passed
+     * Creates a RcsGetResponse with custom attributes and
+     * {@link #DEFAULT_ERROR_CODE} for the errorCode. This sends the passed
      * attributes as the result attributes instead of the one the
-     * RCSResourceObject holds.
+     * {@link RcsResourceObject} holds.
      *
      * @param attributes
-     *            The attributes to send in response.
+     *            attributes to be sent as the result
      *
      */
     public static RcsGetResponse create(RcsResourceAttributes attributes) {
@@ -68,14 +69,14 @@ public class RcsGetResponse extends RcsResponse {
     }
 
     /**
-     * Creates a RcsResourceObject with error code passed. This sends
+     * Creates a RcsGetResponse with error code passed. This sends
      * the passed attributes as the result attributes instead of one the
-     * RCSResourceObject holds.
+     * {@link RcsResourceObject} holds.
      *
      * @param attributes
-     *            The attributes to send in response.
+     *            attributes to be sent as the result
      * @param errorCode
-     *            The error code for response.
+     *            error code for response
      *
      */
     public static RcsGetResponse create(RcsResourceAttributes attributes,
index 13381d2..67651ce 100644 (file)
@@ -92,6 +92,15 @@ public final class RcsLockedAttributes extends RcsObject {
         }
     }
 
+    /**
+     * Returns a unmodifiable Set view of the keys contained in this attributes.
+     *
+     * @return an unmodifiable set view of the keys in this attributes
+     *
+     * @throws RcsUnlockedException
+     *             if the {@link RcsResourceObject.AttributesLock} for this
+     *             object is unlocked
+     */
     public Set<String> keySet() throws RcsException {
         ensureLocked();
 
@@ -102,6 +111,22 @@ public final class RcsLockedAttributes extends RcsObject {
         return Collections.unmodifiableSet(keySet);
     }
 
+    /**
+     * Returns the value to which the specified key is mapped, or null if this
+     * contains no mapping for the key.
+     *
+     * @param key
+     *            the key whose associated value is to be returned
+     *
+     * @return the value to which the specified key is mapped, or null if this
+     *         contains no mapping for the key
+     *
+     * @throws NullPointerException
+     *             if key is null
+     * @throws RcsUnlockedException
+     *             if the {@link RcsResourceObject.AttributesLock} for this
+     *             object is unlocked
+     */
     public RcsValue get(String key) throws RcsException {
         ensureLocked();
 
@@ -113,7 +138,21 @@ public final class RcsLockedAttributes extends RcsObject {
         return mCache.get(key);
     }
 
-    public RcsLockedAttributes putAll(RcsResourceAttributes attributes) {
+    /**
+     * Copies all of the mappings from the specified to this
+     *
+     * @param attributes
+     *            attributes to be copied
+     *
+     * @throws RcsUnlockedException
+     *             if the {@link RcsResourceObject.AttributesLock} for this
+     *             object is unlocked
+     *
+     */
+    public RcsLockedAttributes putAll(RcsResourceAttributes attributes)
+            throws RcsException {
+        ensureLocked();
+
         final Set<String> keys = attributes.keySet();
 
         for (final String k : keys) {
@@ -123,13 +162,21 @@ public final class RcsLockedAttributes extends RcsObject {
     }
 
     /**
-     * set a attribute value.
+     * Sets the specified value with the specified key.
+     * If the object previously contained a mapping for the key, the old value
+     * is replaced by the specified value.
      *
      * @param key
-     *            - Key of the element to be added.
+     *            key with which the specified value is to be associated
      *
      * @param value
-     *            - value to be set.
+     *            value to be associated with the specified key
+     *
+     * @throws NullPointerException
+     *             if key or value is null
+     * @throws RcsUnlockedException
+     *             if the {@link RcsResourceObject.AttributesLock} for this
+     *             object is unlocked
      *
      */
     public RcsLockedAttributes put(String key, RcsValue value)
@@ -145,9 +192,36 @@ public final class RcsLockedAttributes extends RcsObject {
     }
 
     /**
+     * Sets the specified value with the specified key.
+     * If the object previously contained a mapping for the key, the old value
+     * is replaced by the specified value.
+     *
+     * @param key
+     *            key with which the specified value is to be associated
+     *
+     * @param value
+     *            value to be associated with the specified key
+     *
+     * @throws NullPointerException
+     *             if key or value is null
+     * @throws IllegalArgumentException
+     *             if object is not supported type by {@link RcsValue}
+     * @throws RcsUnlockedException
+     *             if the {@link RcsResourceObject.AttributesLock} for this
+     *             object is unlocked
+     */
+    public void put(String key, Object value) throws RcsException {
+        if (key == null) throw new NullPointerException("key is null");
+
+        put(key, new RcsValue(value));
+    }
+
+    /**
      * Returns whether attribute is empty.
      *
-     * @return boolean
+     * @throws RcsUnlockedException
+     *             if the {@link RcsResourceObject.AttributesLock} for this
+     *             object is unlocked
      */
     public boolean isEmpty() throws RcsException {
         ensureLocked();
@@ -156,8 +230,11 @@ public final class RcsLockedAttributes extends RcsObject {
     }
 
     /**
-     * Returns the number of elements.
+     * Returns the number of key-value mappings.
      *
+     * @throws RcsUnlockedException
+     *             if the {@link RcsResourceObject.AttributesLock} for this
+     *             object is unlocked
      */
     public int size() throws RcsException {
         ensureLocked();
@@ -166,12 +243,16 @@ public final class RcsLockedAttributes extends RcsObject {
     }
 
     /**
-     * Removes a single attribute
+     * Removes the mapping for a key from this attributes if it is present.
      *
      * @param key
-     *            Key to be removed.
+     *            key whose mapping is to be removed
+     *
+     * @return true if the key is present and the the value mapped is removed.
      *
-     * @return true if an attribute is removed, false otherwise.
+     * @throws RcsUnlockedException
+     *             if the {@link RcsResourceObject.AttributesLock} for this
+     *             object is unlocked
      */
     public boolean remove(String key) throws RcsException {
         ensureLocked();
@@ -185,18 +266,32 @@ public final class RcsLockedAttributes extends RcsObject {
         return cacheRemove || nativeRemove;
     }
 
-    public void clear() {
+    /**
+     * Removes all elements.
+     *
+     * @throws RcsUnlockedException
+     *             if the {@link RcsResourceObject.AttributesLock} for this
+     *             object is unlocked
+     */
+    public void clear() throws RcsException {
+        ensureLocked();
+
         nativeClear(mResourceObject);
     }
 
     /**
-     * Checks the container has an attribute with a Key equivalent to the
-     * provided key.
+     * Returns true if this contains a mapping for the specified key.
      *
      * @param key
-     *            Key to check.
+     *            key whose presence is to be tested
+     *
+     * @return true if this contains a mapping for the specified key.
      *
-     * @return true if an attribute with requests key exists, false otherwise.
+     * @throws NullPointerException
+     *             if key is null
+     * @throws RcsUnlockedException
+     *             if the {@link RcsResourceObject.AttributesLock} for this
+     *             object is unlocked
      */
     public boolean contains(String key) throws RcsException {
         ensureLocked();
index 383ce13..f890404 100644 (file)
@@ -43,23 +43,25 @@ import org.iotivity.service.RcsValue;
  * <p>
  * It also provides an auto notification mechanism that notifies to the
  * observers. Requests are handled automatically by defaultAction of
- * RCSGetResponse and RCSSetResponse. Developer can override them and send your
- * own response.
+ * {@link RcsGetResponse} and {@link RcsSetResponse}. You can override them and
+ * send your own response with {@link GetRequestHandler} and
+ * {@link SetRequestHandler}.
  * <p>
- * For simple resources, developer may want to know whenever attributes are
- * changed by a set request. In this case, add an AttributeUpdatedListener with
- * a key interested in instead of overriding SetRequestHandler.
+ * For simple resources, they are simply required to notify whenever attributes
+ * are changed by a set request. In this case, add an
+ * {@link OnAttributeUpdatedListener} with a key interested in instead of
+ * overriding {@link SetRequestHandler}.
  *
  * @see Builder
  */
 public final class RcsResourceObject extends RcsObject {
     /**
-     * This class provides APIs for resource creation, setting properties and
-     * attributes for the constructed resource. It provides the build() API
-     * which
-     * builds a resource and returns RCSResourceObject.
+     * This is a builder to create resource with properties and attributes.
+     *
+     * The resource will be observable and discoverable by default, to make them
+     * disable
+     * set these properties explicitly with setDiscoverable and setObservable.
      *
-     * {@link RcsResourceObject}
      */
     public static class Builder {
         private final String          mUri;
@@ -70,21 +72,20 @@ public final class RcsResourceObject extends RcsObject {
         private RcsResourceAttributes mAttributes;
 
         /**
-         * Constructor
+         * Constructs a Builder.
          *
          * @param uri
-         *            Resource URI value to be set
+         *            resource uri
          * @param resourceType
-         *            Resource type value to be set
+         *            resource type
          * @param resourceInterface
-         *            Interface value to be set
+         *            resource interface
          *
          * @throws NullPointerException
-         *             If any parameter is null.
+         *             if any parameter is null
          */
         public Builder(String uri, String resourceType,
                 String resourceInterface) {
-
             if (uri == null) {
                 throw new NullPointerException("uri is null.");
             }
@@ -101,10 +102,10 @@ public final class RcsResourceObject extends RcsObject {
         }
 
         /**
-         * Sets the discoverable(OC_DISCOVERABLE) property for the resource.
+         * Sets whether the resource is discoverable.
          *
          * @param isDiscoverable
-         *            Whether to be discovered or not
+         *            whether to be discoverable or not
          *
          */
         public Builder setDiscoverable(boolean isDiscoverable) {
@@ -116,7 +117,7 @@ public final class RcsResourceObject extends RcsObject {
          * Sets the observable(OC_OBSERVABLE) property of the resource.
          *
          * @param isObservable
-         *            Whether to be observed or not
+         *            whether to be observable or not
          *
          */
         public Builder setObservable(boolean isObservable) {
@@ -125,10 +126,7 @@ public final class RcsResourceObject extends RcsObject {
         }
 
         /**
-         * API for setting attributes of the resource.
-         *
-         * @param attributes
-         *            Attributes to set
+         * Sets attributes foe the resource.
          *
          */
         public Builder setAttributes(RcsResourceAttributes attributes) {
@@ -137,7 +135,7 @@ public final class RcsResourceObject extends RcsObject {
         }
 
         /**
-         * Creates a RCSResourceObject.
+         * Register a resource and returns a RCSResourceObject.
          *
          * @throws RcsPlatformException
          *             If registering a resource is failed.
@@ -161,8 +159,7 @@ public final class RcsResourceObject extends RcsObject {
      * {@code
      * AttributesLock lock = rcsResourceObject.getAttributesLock();
      *
-     * try
-     * {
+     * try {
      *     lock.lock();
      *
      *     ....
@@ -171,6 +168,7 @@ public final class RcsResourceObject extends RcsObject {
      * } finally {
      *     lock.unlock();
      * }
+     * }
      * </pre>
      */
     public static class AttributesLock {
@@ -185,8 +183,8 @@ public final class RcsResourceObject extends RcsObject {
         }
 
         private RcsResourceObject ensureResourceObject() throws RcsException {
-
             final RcsResourceObject object = mResourceObjectRef.get();
+
             if (object == null || object.isDestroyed()) {
                 throw new RcsDestroyedObjectException(
                         "The object is already destroyed!");
@@ -202,7 +200,7 @@ public final class RcsResourceObject extends RcsObject {
          * @return Locked attributes.
          *
          * @throws RcsException
-         *             If the RcsResourceObject is destroyed.
+         *             if the RcsResourceObject is destroyed
          */
         public RcsLockedAttributes lock() throws RcsException {
             return mCurrentAttributes = new RcsLockedAttributes(
@@ -225,7 +223,7 @@ public final class RcsResourceObject extends RcsObject {
          * Applies the modified attributes to the RcsResourceObject.
          *
          * @throws RcsIllegalStateException
-         *             If not in locked state.
+         *             if not in locked state
          */
         public void apply() throws RcsIllegalStateException {
             if (mCurrentAttributes == null) {
@@ -278,38 +276,58 @@ public final class RcsResourceObject extends RcsObject {
 
     /**
      * Represents the policy of AutoNotify function of RCSResourceObject class
-     * In accord with this policy, observers are notified of attributes that are
+     * In accord with this, observers are notified of attributes that are
      * changed or updated.
      *
      * <p>
      * Attributes are changed or updated according to execution of some
-     * functions or receipt of 'set-request'.
+     * functions which modify attributes or receipt of set requests.
+     *
+     * @see setAttribute
+     * @see removeAttribute
+     * @see getAttributesLock
      *
-     * {@link RcsResourceObject}
      */
     public enum AutoNotifyPolicy {
-        NEVER, /** < Never notify. */
-        ALWAYS, /** < Always notify. */
-        UPDATED;
-        /** < When attributes are changed, notify. */
+        /** Never */
+        NEVER,
+
+        /** Always */
+        ALWAYS,
+
+        /** When attributes are changed */
+        UPDATED
     }
 
+    /**
+     * Represents the policy of set-request handler.
+     * In accord with this, the RCSResourceObject decides whether a set-request
+     * is
+     * acceptable or not.
+     */
     public enum SetRequestHandlerPolicy {
+        /**
+         * Requests will be ignored if attributes of the request contain
+         * a new key or a value that has different type from the current
+         * value of the key.
+         */
+        NEVER,
 
-        NEVER, /**
-                * < Server ignore when server is received set-request of
-                * attributes of the new key.
-                */
-        ACCEPT;
         /**
-         * < Server creates attributes of the new key When server is received
-         * set-request of attributes of the new key.
+         * The attributes of the request will be applied unconditionally
+         * even if there are new name or type conflicts.
          */
+        ACCEPT
     }
 
     /**
      * Interface definition for a handler to be invoked when a get request is
      * received.
+     * <p>
+     * The handler will be called first when a get request is received, before
+     * the RCSResourceObject handles.
+     *
+     * @see setGetRequestHandler
      */
     public interface GetRequestHandler {
 
@@ -333,6 +351,13 @@ public final class RcsResourceObject extends RcsObject {
     /**
      * Interface definition for a handler to be invoked when a set request is
      * received.
+     * <p>
+     * The handler will be called first when a get request is received, before
+     * the RCSResourceObject handles. If the attributes are modified in the
+     * callback, the modified attributes will be set in the RCSResourceObject if
+     * the request is not ignored.
+     *
+     * @see setGetRequestHandler
      */
     public interface SetRequestHandler {
 
@@ -340,10 +365,10 @@ public final class RcsResourceObject extends RcsObject {
          * Called when received a set request from the client.
          *
          * @param request
-         *            Request information.
+         *            request information
          * @param attributes
-         *            The attributes of the request.
-         *            It will be applied to the RcsResourceObject.
+         *            the attributes of the request.
+         *            it will be applied to the RcsResourceObject
          *
          * @return A response indicating how to handle this request.
          *
@@ -364,9 +389,9 @@ public final class RcsResourceObject extends RcsObject {
          * Called when an attribute value is updated.
          *
          * @param oldValue
-         *            The attribute value before updated.
+         *            the attribute value before updated
          * @param newValue
-         *            The current resource attribute value.
+         *            the current resource attribute value
          */
         void onAttributeUpdated(RcsValue oldValue, RcsValue newValue);
     }
@@ -379,18 +404,17 @@ public final class RcsResourceObject extends RcsObject {
     }
 
     /**
-     * Sets a particular attribute value as a integer.
-     * The thread-safety for attributes is taken care internally.
+     * Sets a particular attribute value.
      *
      * @param key
-     *            name of attribute(used to map the attribute value).
+     *            key with which the specified value is to be associated
      * @param value
-     *            value to be mapped against the key.
+     *            value to be associated with the specified key
      *
-     * @throws RcsException
-     *             If the object is destroyed.
+     * @throws RcsDestroyedObjectException
+     *             if the object is destroyed
      * @throws NullPointerException
-     *             If key or value is null.
+     *             if key or value is null
      *
      */
     public void setAttribute(String key, RcsValue value) throws RcsException {
@@ -404,17 +428,17 @@ public final class RcsResourceObject extends RcsObject {
 
     /**
      * Returns a copied attribute value associated with the supplied key.
-     * The thread-safety for attributes is taken care internally.
      *
      * @param key
-     *            key of an attribute.
+     *            the key whose associated value is to be returned
      *
-     * @return An attributes value.
+     * @return the value to which the specified key is mapped, or null if no
+     *         attribute for the key
      *
-     * @throws RcsException
-     *             If the object is destroyed.
+     * @throws RcsDestroyedObjectException
+     *             if the object is destroyed
      * @throws NullPointerException
-     *             If key is null.
+     *             if key is null
      */
     public RcsValue getAttributeValue(String key) throws RcsException {
         assertAlive();
@@ -424,18 +448,17 @@ public final class RcsResourceObject extends RcsObject {
     }
 
     /**
-     * API for removing a particular attribute of the resource.
-     * The thread-safety for attributes is taken care internally.
+     * Removes the mapping for a key from the attributes if it is present.
      *
      * @param key
-     *            Name of the attribute.
+     *            key whose mapping is to be removed
      *
-     * @return If the key exist and matched attribute is deleted, return true.
+     * @return true if the key is present and the the value mapped is removed.
      *
-     * @throws RcsException
-     *             If the object is destroyed.
+     * @throws RcsDestroyedObjectException
+     *             if the object is destroyed
      * @throws NullPointerException
-     *             If key is null.
+     *             if key is null
      */
     public boolean removeAttribute(String key) throws RcsException {
         assertAlive();
@@ -445,19 +468,17 @@ public final class RcsResourceObject extends RcsObject {
     }
 
     /**
-     * API for checking whether a particular attribute is there for a resource
-     * or not.
-     * The thread-safety for attributes is taken care internally.
+     * Returns true if the attributes contains a mapping for the specified key.
      *
      * @param key
-     *            Name of the attribute.
+     *            key whose presence is to be tested
      *
-     * @return If the key exist, return true.
+     * @return true if the attributes contains a mapping for the specified key.
      *
-     * @throws RcsException
-     *             If the object is destroyed.
+     * @throws RcsDestroyedObjectException
+     *             if the object is destroyed
      * @throws NullPointerException
-     *             If key is null.
+     *             if key is null
      */
     public boolean containsAttribute(String key) throws RcsException {
         assertAlive();
@@ -468,10 +489,10 @@ public final class RcsResourceObject extends RcsObject {
 
     /**
      * Returns a copied attributes of the RCSResourceObject.
-     * To modify the attributes, use AttrbutesLock.
+     * To modify the attributes, use {@link AttributesLock}.
      *
-     * @throws RcsException
-     *             If the object is destroyed.
+     * @throws RcsDestroyedObjectException
+     *             if the object is destroyed
      *
      * @see getAttributesLock
      */
@@ -482,10 +503,10 @@ public final class RcsResourceObject extends RcsObject {
     }
 
     /**
-     * Returns the AttributesLock for this RcsResourceObject.
+     * Returns an AttributesLock for this RcsResourceObject.
      *
-     * @throws RcsException
-     *             If the object is destroyed.
+     * @throws RcsDestroyedObjectException
+     *             if the object is destroyed
      */
     public AttributesLock getAttributesLock() throws RcsException {
         assertAlive();
@@ -494,12 +515,10 @@ public final class RcsResourceObject extends RcsObject {
     }
 
     /**
-     * API for checking whether the particular resource is observable or not.
-     *
-     * @return true if this is observable. Otherwise false.
+     * Checks whether the resource is observable or not.
      *
-     * @throws RcsException
-     *             If the object is destroyed.
+     * @throws RcsDestroyedObjectException
+     *             if the object is destroyed
      */
     public boolean isObservable() throws RcsException {
         assertAlive();
@@ -508,12 +527,10 @@ public final class RcsResourceObject extends RcsObject {
     }
 
     /**
-     * API for checking whether the particular resource is discoverable or not.
+     * Checks whether the resource is discoverable or not.
      *
-     * @return true if this is discoverable. Otherwise false.
-     *
-     * @throws RcsException
-     *             If the object is destroyed.
+     * @throws RcsDestroyedObjectException
+     *             if the object is destroyed
      */
     public boolean isDiscoverable() throws RcsException {
         assertAlive();
@@ -522,13 +539,12 @@ public final class RcsResourceObject extends RcsObject {
     }
 
     /**
-     * API for setting the resource's get request handler by the
-     * developer/application. If developer set this handler then all get request
-     * will come to the application and developer can send the response to the
-     * client using APIs of RCSGetResponse class.
+     * Sets the get request handler. To remove handler, pass null.
+     *
+     * Default behavior is {@link RcsGetResponse#defaultAction()}.
      *
-     * @throws RcsException
-     *             If the object is destroyed.
+     * @throws RcsDestroyedObjectException
+     *             if the object is destroyed
      */
     public void setGetRequestHandler(GetRequestHandler handler)
             throws RcsException {
@@ -538,13 +554,12 @@ public final class RcsResourceObject extends RcsObject {
     }
 
     /**
-     * API for setting the resource's set request handler by the
-     * developer/application. If developer set this handler then all set request
-     * will come to the application and developer can send the response to the
-     * client using APIs of RCSSetResponse class.
+     * Sets the set request handler. To remove handler, pass null.
      *
-     * @throws RcsException
-     *             If the object is destroyed.
+     * Default behavior is {@link RcsSetResponse#defaultAction()}.
+     *
+     * @throws RcsDestroyedObjectException
+     *             if the object is destroyed
      *
      */
     public void setSetRequestHandler(SetRequestHandler handler)
@@ -555,16 +570,17 @@ public final class RcsResourceObject extends RcsObject {
     }
 
     /**
-     * API for setting the Listener for a particular attribute update.
+     * Adds a listener for a particular attribute updated.
      *
      * @param key
-     *            The interested attribute's key
+     *            the interested attribute's key
+     * @param listener
+     *            listener to be invoked
      *
      * @throws NullPointerException
-     *             If key or listener is null.
-     *
-     * @throws RcsException
-     *             If the object is destroyed.
+     *             if key or listener is null
+     * @throws RcsDestroyedObjectException
+     *             if the object is destroyed
      */
     public void addAttributeUpdatedListener(String key,
             OnAttributeUpdatedListener listener) throws RcsException {
@@ -581,18 +597,17 @@ public final class RcsResourceObject extends RcsObject {
     }
 
     /**
-     * API for removing the handler for a particular attribute update.
+     * Removes a listener for a particular attribute updated.
      *
      * @param key
-     *            The interested attribute's key
+     *            key the key associated with the listener to be removed
      *
-     * @return true if the requested attribute is removed successfully.
-     *         Otherwise false.
+     * @return true if the listener added with same key exists and is removed.
      *
-     * @throws RcsException
-     *             If the object is destroyed.
+     * @throws RcsDestroyedObjectException
+     *             if the object is destroyed
      * @throws NullPointerException
-     *             If key is null.
+     *             if key is null
      */
     public boolean removeAttributeUpdatedListener(String key)
             throws RcsException {
@@ -603,13 +618,12 @@ public final class RcsResourceObject extends RcsObject {
     }
 
     /**
-     * API for notifying all observers of the RCSResourceObject with the updated
-     * attributes value
+     * Notifies all observers of the current attributes.
      *
-     * @throws RcsException
-     *             If the object is destroyed.
+     * @throws RcsDestroyedObjectException
+     *             if the object is destroyed
      * @throws RcsPlatformException
-     *             If the operation failed.
+     *             if the operation failed
      */
     public void notifyObservers() throws RcsException {
         assertAlive();
@@ -618,13 +632,13 @@ public final class RcsResourceObject extends RcsObject {
     }
 
     /**
-     * API for setting Auto notify policy
+     * Sets auto notify policy
      *
      * @param policy
      *            policy to be set
      *
-     * @throws RcsException
-     *             If the object is destroyed.
+     * @throws RcsDestroyedObjectException
+     *             if the object is destroyed
      *
      */
     public void setAutoNotifyPolicy(AutoNotifyPolicy policy)
@@ -636,12 +650,10 @@ public final class RcsResourceObject extends RcsObject {
     }
 
     /**
-     * API for getting auto notify policy
+     * Returns the current policy
      *
-     * @return AntoNotify policy
-     *
-     * @throws RcsException
-     *             If the object is destroyed.
+     * @throws RcsDestroyedObjectException
+     *             if the object is destroyed
      *
      */
     public AutoNotifyPolicy getAutoNotifyPolicy() throws RcsException {
@@ -651,13 +663,13 @@ public final class RcsResourceObject extends RcsObject {
     }
 
     /**
-     * API for setting the policy for a setRequestHandler.
+     * Sets the policy for handling a set request.
      *
      * @param policy
      *            policy to be set
      *
-     * @throws RcsException
-     *             If the object is destroyed.
+     * @throws RcsDestroyedObjectException
+     *             if the object is destroyed
      *
      */
     public void setSetRequestHandlerPolicy(SetRequestHandlerPolicy policy)
@@ -669,13 +681,10 @@ public final class RcsResourceObject extends RcsObject {
     }
 
     /**
-     * API for getting the SetRequestHandler Policy.
-     *
-     * @return Property of setRequesthandler
-     *
-     * @throws RcsException
-     *             If the object is destroyed.
+     * Returns the current policy.
      *
+     * @throws RcsDestroyedObjectException
+     *             if the object is destroyed
      */
     public SetRequestHandlerPolicy getSetRequestHandlerPolicy()
             throws RcsException {
index 0311553..73e876f 100644 (file)
@@ -22,7 +22,7 @@ package org.iotivity.service.server;
 
 import org.iotivity.service.RcsResourceAttributes;
 
-public class RcsResponse {
+class RcsResponse {
     private native static int nativeGetDefaultErrorCode();
 
     public static final int DEFAULT_ERROR_CODE;
index 95fbd2e..266501d 100644 (file)
@@ -33,14 +33,12 @@ public final class RcsSetResponse extends RcsResponse {
     /**
      * Options for handling a set request.
      *
-     * This overrides RcsResourceObject#SetRequestHandlerPolicy.
-     *
-     * @see RcsResourceObject#SetRequestHandlerPolicy
+     * This overrides {@link RcsResourceObject.SetRequestHandlerPolicy}.
      *
      */
     public enum AcceptanceMethod {
         /**
-         * Follow RcsResourceObject#SetRequestHandlerPolicy.
+         * Follow {@link RcsResourceObject.SetRequestHandlerPolicy}.
          */
         DEFAULT,
 
@@ -59,9 +57,10 @@ public final class RcsSetResponse extends RcsResponse {
     private AcceptanceMethod mAcceptanceMethod = AcceptanceMethod.DEFAULT;
 
     /**
-     * Creates a default RCSSetResponse with DEFAULT acceptance method. The
-     * response will have RCSResponse.DEFAULT_ERROR_CODE for the errorCode. The
-     * attributes of RCSResourceObject will be set as the result attributes.
+     * Creates a default RcsSetResponse with {@link AcceptanceMethod#DEFAULT}.
+     * The response will have {@link #DEFAULT_ERROR_CODE} for the errorCode. The
+     * attributes of {@link RcsResourceObject} will be set as the result
+     * attributes.
      *
      */
     public static RcsSetResponse defaultAction() {
@@ -69,9 +68,10 @@ public final class RcsSetResponse extends RcsResponse {
     }
 
     /**
-     * Creates a default RCSSetResponse with ACCEPT acceptance method. The
-     * response will have RCSResponse.DEFAULT_ERROR_CODE for the errorCode. The
-     * attributes of RCSResourceObject will be set as the result attributes.
+     * Creates a default RcsSetResponse with {@link AcceptanceMethod#ACCEPT}
+     * The response will have {@link #DEFAULT_ERROR_CODE} for the errorCode. The
+     * attributes of {@link RcsResourceObject} will be set as the result
+     * attributes.
      *
      */
     public static RcsSetResponse accept() {
@@ -80,13 +80,13 @@ public final class RcsSetResponse extends RcsResponse {
     }
 
     /**
-     * Creates a RCSSetResponse with ACCEPT acceptance method and error code
-     * passed.
-     * The attributes of the RCSResourceObject will be set as the result
+     * Creates a RcsSetResponse with {@link AcceptanceMethod#ACCEPT} and error
+     * code passed.
+     * The attributes of the {@link RcsResourceObject} will be set as the result
      * attributes.
      *
      * @param errorCode
-     *            The error code to set in response.
+     *            error code to be set in response
      *
      */
     public static RcsSetResponse accept(int errorCode) {
@@ -95,9 +95,10 @@ public final class RcsSetResponse extends RcsResponse {
     }
 
     /**
-     * Creates a default RCSSetResponse with IGNORE acceptance method. The
-     * response will have RCSResponse.DEFAULT_ERROR_CODE for the errorCode. The
-     * attributes of RCSResourceObject will be set as the result attributes.
+     * Creates a default RcsSetResponse with {@link AcceptanceMethod#IGNORE}.
+     * The response will have {@link #DEFAULT_ERROR_CODE} for the errorCode. The
+     * attributes of {@link RcsResourceObject} will be set as the result
+     * attributes.
      *
      */
     public static RcsSetResponse ignore() {
@@ -106,12 +107,12 @@ public final class RcsSetResponse extends RcsResponse {
     }
 
     /**
-     * Creates a RCSSetResponse with IGNORE acceptance method and
-     * error code passed. The attributes of the RCSResourceObject will be set as
-     * the result attributes.
+     * Creates a RcsSetResponse with {@link AcceptanceMethod#IGNORE} and error
+     * code passed. The attributes of the {@link RcsResourceObject} will be set
+     * as the result attributes.
      *
      * @param errorCode
-     *            The error code to set in response.
+     *            error code to be set in response
      *
      */
     public static RcsSetResponse ignore(int errorCode) {
@@ -120,12 +121,12 @@ public final class RcsSetResponse extends RcsResponse {
     }
 
     /**
-     * Creates a RCSSetResponse with error code passed and has
-     * DEFAULT acceptance method. The attributes of the RCSResourceObject will
-     * be set as the result attributes.
+     * Creates a RcsSetResponse with error code passed and
+     * {@link AcceptanceMethod#DEFAULT}. The attributes of the
+     * {@link RcsResourceObject} will be set as the result attributes.
      *
      * @param errorCode
-     *            The error code to set in response.
+     *            error code to be set in response
      *
      */
     public static RcsSetResponse create(int errorCode) {
@@ -133,12 +134,12 @@ public final class RcsSetResponse extends RcsResponse {
     }
 
     /**
-     * Creates a RCSSetResponse with custom attributes and has DEFAULT
-     * acceptance method. This sends the passed attributes as the result
-     * attributes instead of one the RCSResourceObject holds.
+     * Creates a RcsSetResponse with custom attributes and
+     * {@link AcceptanceMethod#DEFAULT}. This sends the passed attributes as the
+     * result attributes instead of one the {@link RcsResourceObject} holds.
      *
      * @param attributes
-     *            The attributes to send in response.
+     *            attributes to be sent as the result
      *
      */
     public static RcsSetResponse create(RcsResourceAttributes attributes) {
@@ -146,6 +147,22 @@ public final class RcsSetResponse extends RcsResponse {
     }
 
     /**
+     * Creates a RcsSetResponse with error code passed and
+     * {@link AcceptanceMethod#DEFAULT}. This sends the passed attributes as the
+     * result attributes instead of one the {@link RcsResourceObject} holds.
+     *
+     * @param attributes
+     *            attributes to be sent as the result
+     * @param errorCode
+     *            error code for response
+     *
+     */
+    public static RcsSetResponse create(RcsResourceAttributes attributes,
+            int errorCode) {
+        return new RcsSetResponse(attributes, errorCode);
+    }
+
+    /**
      * Returns the acceptance method.
      *
      */
@@ -154,12 +171,12 @@ public final class RcsSetResponse extends RcsResponse {
     }
 
     /**
-     * Sets the acceptance method for the RCSSetResponse.
+     * Sets the acceptance method.
      *
      * @param method
-     *            AcceptanceMethod value to set
+     *            method to be set
      *
-     * @return The reference to this RCSSetResponse
+     * @return The reference to this RcsSetResponse
      *
      */
     public RcsSetResponse setAcceptanceMethod(AcceptanceMethod method) {
@@ -167,22 +184,6 @@ public final class RcsSetResponse extends RcsResponse {
         return this;
     }
 
-    /**
-     * Creates a RCSSetResponse with error code passed. This sends
-     * the passed attributes as the result attributes instead of one the
-     * RCSResourceObject holds.
-     *
-     * @param attributes
-     *            The attributes to send in response.
-     * @param errorCode
-     *            The error code for response.
-     *
-     */
-    public static RcsSetResponse create(RcsResourceAttributes attributes,
-            int errorCode) {
-        return new RcsSetResponse(attributes, errorCode);
-    }
-
     private RcsSetResponse() {
         super();
     }
index 143ac35..d23975e 100644 (file)
@@ -3,7 +3,7 @@ package org.iotivity.service.server;
 import org.iotivity.service.RcsException;
 
 /**
- * Thrown when trying to access a unlocked RcsLockedAttributes.
+ * Thrown when trying to access a unlocked {@link RcsLockedAttributes}.
  *
  */
 public class RcsUnlockedException extends RcsException {
index 405468d..4e02d77 100644 (file)
@@ -224,7 +224,7 @@ JNIEXPORT void JNICALL Java_org_iotivity_service_RcsResourceAttributes_nativeAdd
 JNIEXPORT jobject JNICALL Java_org_iotivity_service_RcsResourceAttributes_nativeExtract
 (JNIEnv* env, jobject obj, jstring keyObj)
 {
-    LOGD("extractAsJavaObject");
+    LOGD("extract");
     EXPECT_RET_DEF(keyObj, "Key is null.");
     EXPECT_RET_DEF(hasNativeHandle(env, obj), "no native handle.");
 
@@ -240,6 +240,7 @@ JNIEXPORT jobject JNICALL Java_org_iotivity_service_RcsResourceAttributes_native
     VERIFY_NO_EXC_RET_DEF(env);
 
     attrs.erase(key);
+    if (attrs.empty()) releaseNativeHandle(env, obj);
     return valueObj;
 }
 
index 7ebbc4d..d20985e 100644 (file)
@@ -523,7 +523,7 @@ namespace OIC
             bool erase(const std::string& key);
 
             /**
-             * Checks the container has an element with a Key equivalent to key.
+             * Checks this contains an element for the specified key.
              *
              * @param key Key to check.
              *
index b5e6a51..40044c6 100755 (executable)
@@ -113,7 +113,7 @@ namespace OIC
                     NEVER,     /**< Requests will be ignored if attributes of the request contain
                                     a new key or a value that has different type from the current
                                     value of the key. */
-                    ACCEPTANCE /**< The whole attributes of the request will be applied
+                    ACCEPTANCE /**< The attributes of the request will be applied unconditionally
                                     even if there are new name or type conflicts. */
                 };
 
@@ -143,7 +143,7 @@ namespace OIC
                         /**
                          * Sets whether the resource is discoverable.
                          *
-                         * @param discoverable whether to be discovered.
+                         * @param discoverable whether to be discoverable.
                          *
                          */
                         Builder& setDiscoverable(bool discoverable);
@@ -151,13 +151,13 @@ namespace OIC
                         /**
                          * Sets the observable property of the resource.
                          *
-                         * @param observable whether to be observed.
+                         * @param observable whether to be observable.
                          *
                          */
                         Builder& setObservable(bool observable);
 
                         /**
-                         * Sets attribute of the resource.
+                         * Sets attributes for the resource.
                          *
                          * @param attributes attributes to set
                          *
@@ -344,12 +344,12 @@ namespace OIC
                 const RCSResourceAttributes& getAttributes() const;
 
                 /**
-                 * Checks whether the particular resource is observable or not.
+                 * Checks whether the resource is observable or not.
                  */
                 virtual bool isObservable() const;
 
                 /**
-                 * Checks whether the particular resource is discoverable or not.
+                 * Checks whether the resource is discoverable or not.
                  */
                 virtual bool isDiscoverable() const;
 
@@ -357,7 +357,7 @@ namespace OIC
                  * Sets the get request handler.
                  * To remove handler, pass empty handler or nullptr.
                  *
-                 * Default behavior is RCSGetResponse::defaultAction()
+                 * Default behavior is RCSGetResponse::defaultAction().
                  *
                  * @param handler a get request handler
                  *
@@ -370,7 +370,7 @@ namespace OIC
                  * Sets the set request handler.
                  * To remove handler, pass empty handler or nullptr.
                  *
-                 * Default behavior is RCSGetResponse::defaultAction()
+                 * Default behavior is RCSSetResponse::defaultAction().
                  *
                  * @param handler a set request handler
                  *
@@ -380,7 +380,7 @@ namespace OIC
                 virtual void setSetRequestHandler(SetRequestHandler handler);
 
                 /**
-                 * Adds a listener for a particular attribute update.
+                 * Adds a listener for a particular attribute updated.
                  *
                  * @param key the interested attribute's key
                  * @param listener listener to be invoked
@@ -396,9 +396,11 @@ namespace OIC
                         AttributeUpdatedListener listener);
 
                 /**
-                 * Removes a listener for a particular attribute update.
+                 * Removes a listener for a particular attribute updated.
                  *
-                 * @param key the key to be removed
+                 * @param key the key associated with the listener to be removed
+                 *
+                 * @return True if the listener added with same key exists and is removed.
                  *
                  */
                 virtual bool removeAttributeUpdatedListener(const std::string& key);
@@ -488,7 +490,7 @@ namespace OIC
         };
 
         /**
-         * The class provides a convinent RAII-style mechanism for the attributes of a
+         * The class provides a convenient RAII-style mechanism for the attributes of a
          * RCSResourceObject. When a LockGuard is created, it attempts to lock the attributes of
          * the RCSResourceObject it is given. When control leaves the scope in which the LockGuard
          * object was created, the LockGuard is destructed and the attributes is unlocked.