replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / service / notification / android / notification-service / src / main / java / org / iotivity / service / ns / provider / Consumer.java
old mode 100644 (file)
new mode 100755 (executable)
index 37e2417..64210c4
 //
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 package org.iotivity.service.ns.provider;
+
 import org.iotivity.service.ns.common.*;
 import java.util.Vector;
+
 /**
-  * @class   Consumer
 * @brief   This class provides implementation of Notification Consumer object.
-  */
-public class Consumer
-{
+ *
* This class provides implementation of Notification Consumer object.
+ *
+ */
+public class Consumer {
 
-    public String mConsumerId = null;
+    private String mConsumerId = null;
 
-    public Consumer(final String consumerId)
-    {
+    /**
+     * Constructor of Consumer
+     */
+    public Consumer(final String consumerId) {
         mConsumerId = consumerId;
     }
-    public String getConsumerId( )
-    {
+
+    /**
+     * API for getting consumerId
+     *
+     * @return ConsumerId as string
+     */
+    public String getConsumerId() {
         return mConsumerId;
     }
-    public int AcceptSubscription(Consumer consumer, boolean accepted) throws NSException
-    {
-        if (consumer != null)
-            return nativeAcceptSubscription(consumer, accepted);
-        return -1;
+
+    /**
+     * API for accepting Subscription request. This function is valid only when
+     * subControllability is set true.
+     *
+     * @param accepted
+     *            boolean variable representing Subscription response as
+     *            TRUE/FALSE.
+     *
+     * @throws NSException failure accepting subscription request
+     */
+    public void acceptSubscription(boolean accepted) throws NSException {
+        nativeAcceptSubscription(mConsumerId, accepted);
     }
 
-    public int SelectTopic(String topicName) throws NSException
-    {
-        return nativeSelectTopic(mConsumerId, topicName);
+    /**
+     * Select a topic for a consumer
+     *
+     * @param topicName
+     *            Topic name to select
+     *
+     * @throws NSException failure selecting a topic
+     */
+    public void setTopic(String topicName) throws NSException {
+        nativeSetConsumerTopic(mConsumerId, topicName);
     }
-    public int UnselectTopic(String topicName) throws NSException
-    {
-        return nativeUnselectTopic(mConsumerId, topicName);
+
+    /**
+     * Unselect a topic for a consumer
+     *
+     * @param topicName
+     *            Topic name to Unselect
+     *
+     * @throws NSException failure unselecting topic
+     */
+    public void unsetTopic(String topicName) throws NSException {
+        nativeUnsetConsumerTopic(mConsumerId, topicName);
     }
 
-    public TopicsList GetConsumerTopics() throws NSException
-    {
-        return nativeGetConsumerTopics(mConsumerId);
+    /**
+     * Request topic list with selection state for the consumer
+     *
+     * @return Topic list
+     */
+    public TopicsList getConsumerTopicList() throws NSException {
+        return nativeGetConsumerTopicList(mConsumerId);
     }
 
-    public native int  nativeAcceptSubscription(Consumer consumer, boolean accepted);
-    public native int  nativeSelectTopic(String consumerId, String topicName);
-    public native int  nativeUnselectTopic(String consumerId, String topicName);
-    public native TopicsList  nativeGetConsumerTopics(String consumerId);
-}
\ No newline at end of file
+    private native void nativeAcceptSubscription(String consumerId,
+            boolean accepted) throws NSException;
+
+    private native void nativeSetConsumerTopic(String consumerId,
+            String topicName) throws NSException;
+
+    private native void nativeUnsetConsumerTopic(String consumerId,
+            String topicName) throws NSException;
+
+    private native TopicsList nativeGetConsumerTopicList(String consumerId)
+            throws NSException;
+}