1 //******************************************************************
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20 package org.iotivity.service.ns.provider;
22 import org.iotivity.service.ns.common.*;
23 import java.util.Vector;
27 * This class provides implementation of Notification Consumer object.
30 public class Consumer {
32 private String mConsumerId = null;
35 * Constructor of Consumer
37 public Consumer(final String consumerId) {
38 mConsumerId = consumerId;
42 * API for getting consumerId
44 * @return ConsumerId as string
46 public String getConsumerId() {
51 * API for accepting Subscription request. This function is valid only when
52 * subControllability is set true.
55 * boolean variable representing Subscription response as
58 * @throws NSException failure accepting subscription request
60 public void acceptSubscription(boolean accepted) throws NSException {
61 nativeAcceptSubscription(mConsumerId, accepted);
65 * Select a topic for a consumer
68 * Topic name to select
70 * @throws NSException failure selecting a topic
72 public void setTopic(String topicName) throws NSException {
73 nativeSetConsumerTopic(mConsumerId, topicName);
77 * Unselect a topic for a consumer
80 * Topic name to Unselect
82 * @throws NSException failure unselecting topic
84 public void unsetTopic(String topicName) throws NSException {
85 nativeUnsetConsumerTopic(mConsumerId, topicName);
89 * Request topic list with selection state for the consumer
93 public TopicsList getConsumerTopicList() throws NSException {
94 return nativeGetConsumerTopicList(mConsumerId);
97 private native void nativeAcceptSubscription(String consumerId,
98 boolean accepted) throws NSException;
100 private native void nativeSetConsumerTopic(String consumerId,
101 String topicName) throws NSException;
103 private native void nativeUnsetConsumerTopic(String consumerId,
104 String topicName) throws NSException;
106 private native TopicsList nativeGetConsumerTopicList(String consumerId)