Proper allignment of braces and Modified comments from doxygen format to javadoc.
Patch 4: Applied formatter from iotivity/tools/styles
Patch 5: Resolve conflict due to merge of
https://gerrit.iotivity.org/gerrit/#/c/15497/
Change-Id: I406fb56aad290f06cb0094c09041b13142aed350
Signed-off-by: nikhil.a <nikhil.a7@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/15457
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
import android.util.Log;
/**
+ *
* This class provides implementation of Notification MediaContents object.
+ *
*/
-public class MediaContents
-{
- private static final String LOG_TAG = "NotificationService_MediaContents";
+public class MediaContents {
- public String mIconImage = null;
+ private static final String LOG_TAG = "NotificationService_MediaContents";
- public MediaContents(String iconImage)
- {
- Log.i (LOG_TAG, "MediaContents()");
+ public String mIconImage = null;
+
+ public MediaContents(String iconImage) {
+ Log.i(LOG_TAG, "MediaContents()");
mIconImage = iconImage;
}
- public String getIconImage()
- {
+ public String getIconImage() {
return mIconImage;
}
- public void setIconImage(String iconImage)
- {
+ public void setIconImage(String iconImage) {
mIconImage = iconImage;
}
}
import org.iotivity.base.OcRepresentation;
/**
- * This class provides implementation of Notification Message object.
+ *
+ * This class provides implementation of Notification Message object.
+ *
*/
-public class Message
-{
+public class Message {
+
private static final String LOG_TAG = "NotificationService_Message";
- public enum MessageType
- {
+ /**
+ * This enum is used to represent different types of notification messages
+ */
+ public enum MessageType {
ALERT(1),
NOTICE(2),
EVENT(3),
INFO(4),
WARNING(5);
+
private int type;
- private MessageType(int type)
- {
+ private MessageType(int type) {
this.type = type;
}
- public int getMessageType()
- {
+ public int getMessageType() {
return this.type;
}
};
- public long mMessageId = 0;
- public String mProviderId = null;
- public String mSourceName = null;
- public MessageType mType = MessageType.ALERT;
- public String mTime = null;
- public long mTTL = 0;
- public String mTitle = null;
- public String mContentText = null;
- public MediaContents mMediaContents = null;
- public String mTopic = null;
- public OcRepresentation mExtraInfo = null;
+ public long mMessageId = 0;
+ public String mProviderId = null;
+
+ public String mSourceName = null;
+ public MessageType mType = MessageType.ALERT;
+ public String mTime = null;
+ public long mTTL = 0;
+ public String mTitle = null;
+ public String mContentText = null;
+ public MediaContents mMediaContents = null;
+ public String mTopic = null;
+ public OcRepresentation mExtraInfo = null;
- private long mNativeHandle = 0;
+ private long mNativeHandle = 0;
- public Message(String title, String contentText, String sourceName)
- {
- Log.i (LOG_TAG, "Message()");
+ public Message(String title, String contentText, String sourceName) {
+ Log.i(LOG_TAG, "Message()");
mTitle = title;
mContentText = contentText;
mSourceName = sourceName;
}
- public long getMessageId()
- {
+ public long getMessageId() {
return mMessageId;
}
- public String getProviderId()
- {
+ public String getProviderId() {
return mProviderId;
}
- public String getSourceName ()
- {
+ public String getSourceName() {
return mSourceName;
}
- public MessageType getType()
- {
+ public MessageType getType() {
return mType;
}
- public String getTime()
- {
+ public String getTime() {
return mTime;
}
- public long getTTL()
- {
+ public long getTTL() {
return mTTL;
}
- public String getTitle()
- {
+ public String getTitle() {
return mTitle;
}
- public String getContentText()
- {
+ public String getContentText() {
return mContentText;
}
- public MediaContents getMediaContents()
- {
+ public MediaContents getMediaContents() {
return mMediaContents;
}
- public String getTopic()
- {
+ public String getTopic() {
return mTopic;
}
- public OcRepresentation getExtraInfo()
- {
+ public OcRepresentation getExtraInfo() {
return mExtraInfo;
}
- public void setSourceName (String sourceName)
- {
+ public void setSourceName(String sourceName) {
mSourceName = sourceName;
}
- public void setType(MessageType type)
- {
+ public void setType(MessageType type) {
mType = type;
}
- public void setTime(String time)
- {
+ public void setTime(String time) {
mTime = time;
}
- public void setTTL(long ttl)
- {
+ public void setTTL(long ttl) {
mTTL = ttl;
}
- public void setTitle(String title)
- {
+ public void setTitle(String title) {
mTitle = title;
}
- public void setContentText(String contextText)
- {
+ public void setContentText(String contextText) {
mContentText = contextText;
}
- public void setMediaContents(MediaContents mediaContents)
- {
+ public void setMediaContents(MediaContents mediaContents) {
mMediaContents = mediaContents;
}
- public void setTopic(String topic)
- {
+ public void setTopic(String topic) {
mTopic = topic;
}
- public void setExtraInfo(OcRepresentation extraInfo)
- {
+ public void setExtraInfo(OcRepresentation extraInfo) {
mExtraInfo = extraInfo;
}
}
package org.iotivity.service.ns.common;
-public enum NSErrorCode
-{
+/**
+ *
+ * This enum provides details of error code messages thrown in NSException.
+ *
+ */
+public enum NSErrorCode {
OK("OK", ""),
ERROR("ERROR", ""),
SUCCESS("SUCCESS", ""),
DENY("DENY", ""),
JNI_EXCEPTION("JNI_EXCEPTION", "Generic Java binder error"),
JNI_NO_NATIVE_OBJECT("JNI_NO_NATIVE_OBJECT", ""),
- JNI_INVALID_VALUE("JNI_INVALID_VALUE", ""),;
+ JNI_INVALID_VALUE("JNI_INVALID_VALUE", "");
private String error;
private String description;
- private NSErrorCode(String error, String description)
-{
- this.error = error;
- this.description = description;
-}
+ private NSErrorCode(String error, String description) {
+ this.error = error;
+ this.description = description;
+ }
-public String getError()
-{
- return error;
-}
+ public String getError() {
+ return error;
+ }
-public String getDescription()
-{
- return description;
-}
+ public String getDescription() {
+ return description;
+ }
-public static NSErrorCode get(String errorCode)
-{
- for (NSErrorCode eCode : NSErrorCode.values())
- {
- if (eCode.getError().equals(errorCode))
- {
- return eCode;
+ public static NSErrorCode get(String errorCode) {
+ for (NSErrorCode eCode : NSErrorCode.values()) {
+ if (eCode.getError().equals(errorCode)) {
+ return eCode;
+ }
}
+ throw new IllegalArgumentException("Unexpected NSErrorCode value");
}
- throw new IllegalArgumentException("Unexpected NSErrorCode value");
-}
-@Override
-public String toString()
-{
- return error + (description.isEmpty() ? "" : " : " + description);
-}
+ @Override
+ public String toString() {
+ return error + (description.isEmpty() ? "" : " : " + description);
+ }
}
\ No newline at end of file
package org.iotivity.service.ns.common;
-public class NSException extends Exception
-{
+/**
+ *
+ * This class provides implementation of exceptions thrown by API's.
+ *
+ */
+public class NSException extends Exception {
+
private NSErrorCode errorCode;
- public NSException(NSErrorCode errorCode, String errMessage)
- {
+ public NSException(NSErrorCode errorCode, String errMessage) {
super(errMessage + " " + errorCode.toString());
this.errorCode = errorCode;
}
- private NSException(String error, String errMessage)
- {
+ private NSException(String error, String errMessage) {
super(errMessage + " " + error);
this.errorCode = NSErrorCode.get(error);
}
- public NSErrorCode getErrorCode()
- {
+ public NSErrorCode getErrorCode() {
return errorCode;
}
- private static void addStackTrace(Throwable throwable,
- String file,
- String functionName,
- int line)
- {
+ 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);
+ newStack[0] = new StackTraceElement("<native>", functionName, file,
+ line);
throwable.setStackTrace(newStack);
}
- private void setNativeExceptionLocation(String file, String functionName, int line)
- {
+ private void setNativeExceptionLocation(String file, String functionName,
+ int line) {
NSException.addStackTrace(this, file, functionName, line);
}
}
\ No newline at end of file
import android.util.Log;
/**
- * Implementation of Notification SyncInfo object.
+ *
+ * This class provides implementation of Notification SyncInfo object.
+ *
*/
-public class SyncInfo
-{
+public class SyncInfo {
+
private static final String LOG_TAG = "NotificationService_SyncInfo";
- public enum SyncType
- {
+ /**
+ * This enum is used to inform about read status of notification message
+ */
+ public enum SyncType {
UNREAD(0),
READ(1),
DELETED(2);
+
private int type;
- private SyncType(int type)
- {
- this.type = type;
- }
+ private SyncType(int type) {
+ this.type = type;
+ }
- public int getSyncType()
- {
- return this.type;
- }
+ public int getSyncType() {
+ return this.type;
+ }
};
- public long mMessageId = 0;
- public String mProviderId = null;
- public SyncType mState = SyncType.UNREAD;
- public SyncInfo(long messageId, String providerId, SyncType state)
- {
- Log.i (LOG_TAG, "SyncInfo()");
+ public long mMessageId = 0;
+ public String mProviderId = null;
+ public SyncType mState = SyncType.UNREAD;
+
+ public SyncInfo(long messageId, String providerId, SyncType state) {
+ Log.i(LOG_TAG, "SyncInfo()");
mMessageId = messageId;
mProviderId = providerId;
mState = state;
}
- public long getMessageId()
- {
+ public long getMessageId() {
return mMessageId;
}
- public String getProviderId()
- {
+ public String getProviderId() {
return mProviderId;
}
- public SyncType getState()
- {
+ public SyncType getState() {
return mState;
}
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
package org.iotivity.service.ns.common;
+
import android.util.Log;
+
/**
- * Provides implementation of Notification Topic object.
+ *
+ * This class provides implementation of Notification Topic object.
+ *
*/
-public class Topic
-{
+public class Topic {
+
private static final String LOG_TAG = "NotificationService_Topic";
- public enum TopicState
- {
- UNSUBSCRIBED (0),
- SUBSCRIBED (1);
+ /**
+ * This enum is used to represent subscribtion status for this Topic
+ * resource
+ */
+ public enum TopicState {
+ UNSUBSCRIBED(0),
+ SUBSCRIBED(1);
+
private int type;
- private TopicState(int type)
- {
+ private TopicState(int type) {
this.type = type;
}
- public int getTopicState()
- {
+ public int getTopicState() {
return this.type;
}
};
- public String mTopicName = null;
- public TopicState mState = TopicState.UNSUBSCRIBED;
- public Topic(String topicName, TopicState state)
- {
- Log.i (LOG_TAG, "Topic()");
+ public String mTopicName = null;
+ public TopicState mState = TopicState.UNSUBSCRIBED;
+
+ public Topic(String topicName, TopicState state) {
+ Log.i(LOG_TAG, "Topic()");
mTopicName = topicName;
mState = state;
}
- public String getTopicName()
- {
+ public String getTopicName() {
return mTopicName;
}
- public void setTopicName(String topicName)
- {
+ public void setTopicName(String topicName) {
mTopicName = topicName;
}
- public TopicState getState()
- {
+ public TopicState getState() {
return mState;
}
- public void setState(TopicState state)
- {
+ public void setState(TopicState state) {
mState = state;
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
package org.iotivity.service.ns.common;
+
import android.util.Log;
import java.util.Vector;
import java.util.Iterator;
+
/**
- * provides implementation of Topics List
+ *
+ * This class provides implementation of Topics List.
+ *
*/
-public class TopicsList
-{
- private static final String LOG_TAG = "NotificationService_TopicList";
+public class TopicsList {
- public Vector<Topic> mTopicsList = new Vector<Topic>();
+ private static final String LOG_TAG = "NotificationService_TopicList";
- public void addTopic(String topicname, Topic.TopicState state)
- {
- mTopicsList.add(new Topic(topicname,state));
+ public Vector<Topic> mTopicsList = new Vector<Topic>();
+
+ public void addTopic(String topicname, Topic.TopicState state) {
+ mTopicsList.add(new Topic(topicname, state));
}
- public void removeTopic(String topicName)
- {
- Iterator <Topic> it = getTopicsList().iterator();
- while(it.hasNext())
- {
+ public void removeTopic(String topicName) {
+ Iterator<Topic> it = getTopicsList().iterator();
+ while (it.hasNext()) {
Topic element = it.next();
- if(element.getTopicName().equals(topicName))
- {
+ if (element.getTopicName().equals(topicName)) {
mTopicsList.remove(element);
}
}
}
- public Vector<Topic> getTopicsList()
- {
+ public Vector<Topic> getTopicsList() {
return mTopicsList;
}
}
-
import java.util.Vector;
/**
- * This class provides a set of Java APIs for Notification Consumer.
- */
-public class ConsumerService
-{
+ *
+ * This class provides a set of Java APIs for Notification ConsumerService.
+ *
+ */
+public class ConsumerService {
+
private static final String LOG_TAG = "ConsumerService";
- static
- {
+ static {
System.loadLibrary("gnustl_shared");
System.loadLibrary("oc_logger");
System.loadLibrary("connectivity_abstraction");
}
private static ConsumerService instance;
- static
- {
+ static {
instance = new ConsumerService();
}
/**
- * API for getting instance of ConsumerService
- * @return ConsumerService singleton instance created
- */
- public static ConsumerService getInstance()
- {
+ * API for getting instance of ConsumerService
+ *
+ * @return ConsumerService singleton instance created
+ */
+ public static ConsumerService getInstance() {
return instance;
}
- /**
- * Start ConsumerService
- * @param onProviderDiscoveredListener - OnProviderDiscoveredListener Callback Interface
+ /**
+ * This API will Start ConsumerService
+ *
+ * @param onProviderDiscoveredListener
+ * OnProviderDiscoveredListener Callback Interface
+ *
+ * @throws NSException
+ * if the parameter passed is null
*/
- public void start(
- OnProviderDiscoveredListener onProviderDiscoveredListener
- ) throws NSException
- {
+ public void start(OnProviderDiscoveredListener onProviderDiscoveredListener)
+ throws NSException {
nativeStart(onProviderDiscoveredListener);
}
/**
- * Stop ConsumerService
- */
- public void stop() throws NSException
- {
+ * This API will Stop ConsumerService
+ */
+ public void stop() throws NSException {
nativeStop();
}
/**
- * Request to publish resource to cloud server
- * @param serverAddress combined with IP address and port number using delimiter [in]
- */
- public void enableRemoteService(String serverAddress) throws NSException
- {
+ * Request to publish resource to cloud server
+ *
+ * @param serverAddress
+ * serverAddress combined with IP address and port number using
+ * delimiter
+ */
+ public void enableRemoteService(String serverAddress) throws NSException {
nativeEnableRemoteService(serverAddress);
}
/**
- * Request to subscribe to MQ server
- * @param servAdd - servAdd combined with IP address and port number and MQ broker uri using delimiter :
- * @param topicName - the interest Topic name for subscription
- * @return result code
- */
- public int subscribeMQService(String servAdd, String topicName) throws NSException
- {
+ * Request to subscribe to MQ server
+ *
+ * @param servAdd
+ * servAdd combined with IP address and port number and MQ broker
+ * uri using delimiter
+ * @param topicName
+ * the interest Topic name for subscription
+ *
+ * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
+ */
+ public int subscribeMQService(String servAdd, String topicName)
+ throws NSException {
return nativeSubscribeMQService(servAdd, topicName);
}
/**
- * Request discovery manually
- */
- public void rescanProvider() throws NSException
- {
+ * This API is called to request discovery manually
+ */
+ public void rescanProvider() throws NSException {
nativeRescanProvider();
}
/**
- * Interface to implement callback function to receive provider on discovery
- */
- public interface OnProviderDiscoveredListener
- {
+ * Interface to implement callback function to receive provider on discovery
+ */
+ public interface OnProviderDiscoveredListener {
+
/**
- * Callback function to receive provider on discovery
- * @param provider - Provider object
- */
+ * Callback function to receive provider on discovery
+ *
+ * @param provider
+ * Provider object
+ */
public void onProviderDiscovered(Provider provider);
}
- private native void nativeStart (
- OnProviderDiscoveredListener onProviderDiscoveredListener
- ) throws NSException;
+ private native void nativeStart(
+ OnProviderDiscoveredListener onProviderDiscoveredListener)
+ throws NSException;
private native void nativeStop() throws NSException;
- private native void nativeEnableRemoteService(String serverAddress) throws NSException;
- private native int nativeSubscribeMQService(String servAdd, String topicName) throws NSException;
- private native void nativeRescanProvider() throws NSException;
+
+ private native void nativeEnableRemoteService(String serverAddress)
+ throws NSException;
+
+ private native int nativeSubscribeMQService(String servAdd,
+ String topicName) throws NSException;
+
+ private native void nativeRescanProvider() throws NSException;
}
import java.util.Vector;
/**
- * This class provides implementation of Notification Provider object.
- */
-public class Provider
-{
+ *
+ * This class provides implementation of Notification Provider object.
+ *
+ */
+public class Provider {
+
private static final String LOG_TAG = "ConsumerService_Provider";
/**
- * ProviderState of Notification resource
- */
- public enum ProviderState
- {
+ * Enum for defining different state of provider object
+ */
+ public enum ProviderState {
ALLOW(1),
DENY(2),
TOPIC(3),
STOPPED(12);
+
private int state;
- private ProviderState(int state)
- {
+ private ProviderState(int state) {
this.state = state;
}
- public int getProviderState()
- {
+ public int getProviderState() {
return this.state;
}
};
- public String mProviderId = null;
- private long mNativeHandle = 0;
+ public String mProviderId = null;
+ private long mNativeHandle = 0;
/**
- * Constructor of Provider.
- * @param providerId - providerId of Provider.
- */
- public Provider(String providerId)
- {
- Log.i (LOG_TAG, "Provider()");
+ * Constructor of Provider.
+ *
+ * @param providerId
+ * unique Id of Provider
+ */
+ public Provider(String providerId) {
+ Log.i(LOG_TAG, "Provider()");
mProviderId = providerId;
}
/**
- * API for getting providerId.
- * @return ConsumerId as string.
- */
- public String getProviderId()
- {
- return mProviderId ;
+ * API for getting providerId
+ *
+ * @return ConsumerId as string
+ */
+ public String getProviderId() {
+ return mProviderId;
}
/**
- * API for getting for getting Topic List.
- * @return TopicsList.
- */
- public TopicsList getTopicList() throws NSException
- {
+ * API for getting for getting Topic List
+ *
+ * @return TopicsList
+ */
+ public TopicsList getTopicList() throws NSException {
return nativeGetTopicList();
}
/**
- * API for getting for getting ProviderState.
- * @return ProviderState.
- */
- public ProviderState getProviderState() throws NSException
- {
+ * API for getting for getting ProviderState
+ *
+ * @return ProviderState
+ */
+ public ProviderState getProviderState() throws NSException {
return nativeGetProviderState();
}
/**
- * API for for requesting subscription of Notification service.
- */
- public void subscribe() throws NSException
- {
+ * API for for requesting subscription of Notification service
+ */
+ public void subscribe() throws NSException {
nativeSubscribe();
}
/**
- * API for for requesting subscription status from Provider of Notification service.
- */
- public boolean isSubscribed () throws NSException
- {
+ * API for for requesting subscription status from Provider of Notification
+ * service
+ */
+ public boolean isSubscribed() throws NSException {
return nativeIsSubscribed();
}
/**
- * This method is for Sending SyncInfo of Notification service.
- * @param messageId - id of message.
- * @param syncType - SyncType of Notification service.
- */
- public void sendSyncInfo(long messageId, SyncInfo.SyncType syncType) throws NSException
- {
+ * This method is for Sending SyncInfo of Notification service.
+ *
+ * @param messageId
+ * unique Id of message
+ * @param syncType
+ * SyncType of Notification service
+ */
+ public void sendSyncInfo(long messageId, SyncInfo.SyncType syncType)
+ throws NSException {
nativeSendSyncInfo(messageId, syncType.ordinal());
}
/**
- * This method is for registering for listeners of Notification .
- * @param onProviderStateListener - OnProviderStateListener callback Interface.
- * @param onMessageReceivedListner - OnMessageReceivedListner callback Interface.
- * @param onSyncInfoReceivedListner - OnSyncInfoReceivedListner callback Interface.
- */
+ * This method is for registering for listeners of Notification .
+ *
+ * @param onProviderStateListener
+ * OnProviderStateListener callback Interface
+ * @param onMessageReceivedListner
+ * OnMessageReceivedListner callback Interface
+ * @param onSyncInfoReceivedListner
+ * OnSyncInfoReceivedListner callback Interface
+ */
public void setListener(OnProviderStateListener onProviderStateListener,
- OnMessageReceivedListner onMessageReceivedListner,
- OnSyncInfoReceivedListner onSyncInfoReceivedListner) throws NSException
- {
- nativeSetListener(onProviderStateListener, onMessageReceivedListner, onSyncInfoReceivedListner);
+ OnMessageReceivedListner onMessageReceivedListner,
+ OnSyncInfoReceivedListner onSyncInfoReceivedListner)
+ throws NSException {
+ nativeSetListener(onProviderStateListener, onMessageReceivedListner,
+ onSyncInfoReceivedListner);
}
/**
- * Update Topic list that is wanted to be subscribed from provider
- * @param topicsList - TopicsList of interested Topics.
- * @return :: result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
- */
- public int updateTopicList(TopicsList topicsList) throws NSException
- {
+ * Update Topic list that is wanted to be subscribed from provider
+ *
+ * @param topicsList
+ * TopicsList of interested Topics
+ *
+ * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
+ */
+ public int updateTopicList(TopicsList topicsList) throws NSException {
return nativeUpdateTopicList(topicsList);
}
/**
- * Interface to implement callback function to receive provider state information
- */
- public interface OnProviderStateListener
- {
+ * Interface to implement callback function to receive provider state
+ * information
+ */
+ public interface OnProviderStateListener {
+
/**
- * Callback function to receive provider state information
- * @param state - ProviderState
- */
+ * Callback function to receive provider state information
+ *
+ * @param state
+ * ProviderState
+ */
public void onProviderStateReceived(ProviderState state);
}
/**
- * Interface to implement callback function to receive Notification Message
- */
- public interface OnMessageReceivedListner
- {
+ * Interface to implement callback function to receive Notification Message
+ */
+ public interface OnMessageReceivedListner {
+
/**
- * Callback function to receive Notification Message
- * @param message - Notification Message
- */
+ * Callback function to receive Notification Message.
+ *
+ * @param message
+ * Notification Message
+ */
public void onMessageReceived(Message message);
}
/**
- * Interface to implement callback function to receive message read synchronization
- */
- public interface OnSyncInfoReceivedListner
- {
+ * Interface to implement callback function to receive message read
+ * synchronization
+ */
+ public interface OnSyncInfoReceivedListner {
+
/**
- * Callback function to receive message read synchronization
- * @param sync - SyncInfo
- */
+ * Callback function to receive message read synchronization
+ *
+ * @param sync
+ * SyncInfo
+ */
public void onSyncInfoReceived(SyncInfo sync);
}
private native void nativeSubscribe() throws NSException;
- private native void nativeSendSyncInfo(long messageId, int syncType) throws NSException;
- private native void nativeSetListener(OnProviderStateListener onProviderStateListener,
- OnMessageReceivedListner onMessageReceivedListner,
- OnSyncInfoReceivedListner onSyncInfoReceivedListner) throws NSException;
- public native TopicsList nativeGetTopicList() throws NSException;
- private native int nativeUpdateTopicList(TopicsList topicsList) throws NSException;
+
+ private native void nativeSendSyncInfo(long messageId, int syncType)
+ throws NSException;
+
+ private native void nativeSetListener(
+ OnProviderStateListener onProviderStateListener,
+ OnMessageReceivedListner onMessageReceivedListner,
+ OnSyncInfoReceivedListner onSyncInfoReceivedListner)
+ throws NSException;
+
+ public native TopicsList nativeGetTopicList() throws NSException;
+
+ private native int nativeUpdateTopicList(TopicsList topicsList)
+ throws NSException;
+
private native ProviderState nativeGetProviderState() throws NSException;
- public native boolean nativeIsSubscribed() throws NSException;
+
+ public native boolean nativeIsSubscribed() throws NSException;
}
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
package org.iotivity.service.ns.provider;
+
import org.iotivity.service.ns.common.*;
import java.util.Vector;
+
/**
- * Provides implementation of Notification Consumer object.
- */
-public class Consumer
-{
+ *
+ * This class provides implementation of Notification Consumer object.
+ *
+ */
+public class Consumer {
public String mConsumerId = null;
/**
- * Constructor of Consumer.
- */
- public Consumer(final String consumerId)
- {
+ * Constructor of Consumer
+ */
+ public Consumer(final String consumerId) {
mConsumerId = consumerId;
}
/**
- * API for getting consumerId
- * @return ConsumerId as string
- */
- public String getConsumerId( )
- {
+ * API for getting consumerId
+ *
+ * @return ConsumerId as string
+ */
+ public String getConsumerId() {
return mConsumerId;
}
/**
- * 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.
- * @return :: result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
- */
- public int acceptSubscription(boolean accepted) throws NSException
- {
+ * 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.
+ *
+ * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
+ */
+ public int acceptSubscription(boolean accepted) throws NSException {
return nativeAcceptSubscription(mConsumerId, accepted);
}
/**
- * Select a topic for a consumer
- * @param topicName - Topic name to select
- * @return :: result code
- */
- public int setTopic(String topicName) throws NSException
- {
+ * Select a topic for a consumer
+ *
+ * @param topicName
+ * Topic name to select
+ *
+ * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
+ */
+ public int setTopic(String topicName) throws NSException {
return nativeSetConsumerTopic(mConsumerId, topicName);
}
/**
- * Unselect a topic for a consumer
- * @param topicName - Topic name to Unselect
- * @return :: result code
- */
- public int unsetTopic(String topicName) throws NSException
- {
+ * Unselect a topic for a consumer
+ *
+ * @param topicName
+ * Topic name to Unselect
+ *
+ * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
+ */
+ public int unsetTopic(String topicName) throws NSException {
return nativeUnsetConsumerTopic(mConsumerId, topicName);
}
/**
- * Request topic list with selection state for the consumer
- * @return :: Topic list
- */
- public TopicsList getConsumerTopicList() throws NSException
- {
+ * Request topic list with selection state for the consumer
+ *
+ * @return Topic list
+ */
+ public TopicsList getConsumerTopicList() throws NSException {
return nativeGetConsumerTopicList(mConsumerId);
}
- public native int nativeAcceptSubscription(String consumerId, boolean accepted) throws NSException;
- public native int nativeSetConsumerTopic(String consumerId, String topicName) throws NSException;
- public native int nativeUnsetConsumerTopic(String consumerId, String topicName) throws NSException;
- public native TopicsList nativeGetConsumerTopicList(String consumerId) throws NSException;
-}
+ public native int nativeAcceptSubscription(String consumerId,
+ boolean accepted) throws NSException;
+
+ public native int nativeSetConsumerTopic(String consumerId,
+ String topicName) throws NSException;
+
+ public native int nativeUnsetConsumerTopic(String consumerId,
+ String topicName) throws NSException;
+
+ public native TopicsList nativeGetConsumerTopicList(String consumerId)
+ throws NSException;
+}
\ No newline at end of file
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
package org.iotivity.service.ns.provider;
+
import org.iotivity.service.ns.common.*;
import java.util.Vector;
+
/**
- * Provides a set of Java APIs for Notification ProviderService.
+ *
+ * This class provides a set of Java APIs for Notification ProviderService.
+ *
*/
-public class ProviderService
-{
+public class ProviderService {
- static
- {
+ static {
System.loadLibrary("gnustl_shared");
System.loadLibrary("oc_logger");
System.loadLibrary("connectivity_abstraction");
private static ProviderService instance;
- static
- {
+ static {
instance = new ProviderService();
}
/**
- * API for getting instance of ProviderService
- * @return ProviderService singleton instance created
- */
- public static ProviderService getInstance()
- {
+ * API for getting instance of ProviderService
+ *
+ * @return ProviderService singleton instance created
+ */
+ public static ProviderService getInstance() {
return instance;
}
/**
- * Start ProviderService
- * @param subscribedListener - OnConsumerSubscribedListener Callback
- * @param messageSynchronized - OnMessageSynchronizedListener Callback
- * @param subControllability - Set the policy for notification servcie which checks whether
- * provider is capable of denying the subscription of notification message from consumer and
- * getting controllabliity to set consumer topic list.
- * If true, provider is able to control subscription request and consumer topic list.
- * Otherwise(policy is false), consumer can do the same.
- * @param userInfo - User defined information such as device friendly name
- * @param resourceSecurity - Set on/off for secure resource channel setting
- * @return :: result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
- */
- public int start(OnConsumerSubscribedListener subscribedListener,
- OnMessageSynchronizedListener messageSynchronized,
- boolean subControllability, String userInfo,
- boolean resourceSecurity) throws NSException
- {
+ * Start ProviderService
+ *
+ * @param subscribedListener
+ * OnConsumerSubscribedListener Callback
+ * @param messageSynchronized
+ * OnMessageSynchronizedListener Callback
+ * @param subControllability
+ * Set the policy for notification servcie which checks whether
+ * provider is capable of denying the subscription of
+ * notification message from consumer and getting controllabliity
+ * to set consumer topic list. If true, provider is able to
+ * control subscription request and consumer topic list.
+ * Otherwise(policy is false), consumer can do the same.
+ * @param userInfo
+ * User defined information such as device friendly name
+ * @param resourceSecurity
+ * Set on/off for secure resource channel setting
+ *
+ * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
+ *
+ * @throws NSException
+ * if any callback parameter passed is null
+ */
+ public int start(OnConsumerSubscribedListener subscribedListener,
+ OnMessageSynchronizedListener messageSynchronized,
+ boolean subControllability, String userInfo,
+ boolean resourceSecurity) throws NSException {
return nativeStart(subscribedListener, messageSynchronized,
- subControllability, userInfo, resourceSecurity);
+ subControllability, userInfo, resourceSecurity);
}
/**
- * Stop ProviderService
- * @return :: result code
- */
- public int stop() throws NSException
- {
+ * Stop ProviderService
+ *
+ * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
+ */
+ public int stop() throws NSException {
return nativeStop();
}
/**
- * Send notification message to all subscribers
- * @param message - Notification message including id, title, contentText
- * @return :: result code
- */
- public int sendMessage(Message message) throws NSException
- {
+ * Send notification message to all subscribers
+ *
+ * @param message
+ * Notification message including id, title, contentText
+ *
+ * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
+ */
+ public int sendMessage(Message message) throws NSException {
return nativeSendMessage(message);
}
/**
- * Send read-check to provider in order to synchronize notification status with other consumers
- * @param messageId - ID of Notification message to synchronize the status
- * @param syncType - SyncType of the SyncInfo message
- */
- public void sendSyncInfo ( long messageId , SyncInfo.SyncType syncType) throws NSException
- {
+ * Send read-check to provider in order to synchronize notification status
+ * with other consumers
+ *
+ * @param messageId
+ * unique Id of Notification message to synchronize the status
+ * @param syncType
+ * SyncType of the SyncInfo message
+ */
+ public void sendSyncInfo(long messageId, SyncInfo.SyncType syncType)
+ throws NSException {
nativeSendSyncInfo(messageId, syncType.ordinal());
}
/**
- * Initialize Message class, Mandatory fields which are messge id and provider(device) id are filled with.
- * @return Message
- */
- public Message createMessage () throws NSException
- {
+ * Initialize Message class, Mandatory fields which are messge id and
+ * provider(device) id are filled with
+ *
+ * @return Message
+ */
+ public Message createMessage() throws NSException {
return nativeCreateMessage();
}
/**
- * Request to publish resource to cloud server
- * @param servAdd combined with IP address and port number using delimiter [in]
- * @return result code
- */
- public int enableRemoteService(String servAdd) throws NSException
- {
+ * Request to publish resource to cloud server
+ *
+ * @param servAdd
+ * servAdd combined with IP address and port number using
+ * delimiter
+ *
+ * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
+ */
+ public int enableRemoteService(String servAdd) throws NSException {
return nativeEnableRemoteService(servAdd);
}
/**
- * Request to cancel remote service using cloud server
- * @param servAdd combined with IP address and port number using delimiter :
- * @return result code
- */
- public int disableRemoteService(String servAdd) throws NSException
- {
+ * Request to cancel remote service using cloud server
+ *
+ * @param servAdd
+ * servAdd combined with IP address and port number using
+ * delimiter
+ *
+ * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
+ */
+ public int disableRemoteService(String servAdd) throws NSException {
return nativeDisableRemoteService(servAdd);
}
/**
- * Request to subscribe to MQ server
- * @param servAdd - servAdd combined with IP address and port number and MQ broker uri using delimiter :
- * @param topicName - the interest Topic name for subscription
- * @return result code
- */
- public int subscribeMQService(String servAdd, String topicName) throws NSException
- {
+ * Request to subscribe to MQ server
+ *
+ * @param servAdd
+ * servAdd combined with IP address and port number and MQ broker
+ * uri using delimiter
+ * @param topicName
+ * the interest Topic name for subscription
+ *
+ * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
+ */
+ public int subscribeMQService(String servAdd, String topicName)
+ throws NSException {
return nativeSubscribeMQService(servAdd, topicName);
}
/**
- * Add topic to topic list
- * @param topicName - Topic name to add
- * @return :: result code
- */
- public int registerTopic(String topicName) throws NSException
- {
+ * Add topic to topic list
+ *
+ * @param topicName
+ * Topic name to add
+ *
+ * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
+ */
+ public int registerTopic(String topicName) throws NSException {
return nativeRegisterTopic(topicName);
}
/**
- * Delete topic from topic list
- * @param topicName - Topic name to add
- * @return :: result code
- */
- public int unregisterTopic(String topicName) throws NSException
- {
+ * Delete topic from topic list
+ *
+ * @param topicName
+ * Topic name to add
+ *
+ * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
+ */
+ public int unregisterTopic(String topicName) throws NSException {
return nativeUnregisterTopic(topicName);
}
/**
- * Request topics list already registered by provider user
- * @return :: Topic list
- */
- public TopicsList getRegisteredTopicList() throws NSException
- {
+ * Request topics list already registered by provider user
+ *
+ *
+ * @return result code 100 = OK , 200 = ERROR , 300 = SUCCESS , 400 = FAIL
+ */
+ public TopicsList getRegisteredTopicList() throws NSException {
return nativeGetRegisteredTopicList();
}
/**
- * Interface to implement callback function to receive subscription request of consumer
- */
- public interface OnConsumerSubscribedListener
- {
+ * Interface to implement callback function to receive subscription request
+ * of consumer
+ */
+ public interface OnConsumerSubscribedListener {
/**
- * Callback function to receive subscription request of consumer
- * @param consumer - Consumer who subscribes the notification message resource
- */
+ * Callback function to receive subscription request of consumer
+ *
+ * @param consumer
+ * Consumer who subscribes the notification message resource
+ */
public void onConsumerSubscribed(Consumer consumer);
}
/**
- * Interface to implement callback function to receive the status of the message synchronization
- */
- public interface OnMessageSynchronizedListener
- {
+ * Interface to implement callback function to receive the status of the
+ * message synchronization
+ */
+ public interface OnMessageSynchronizedListener {
/**
- * Callback function to receive the status of the message synchronization
- * @param syncInfo - Synchronization information of the notification message
- */
+ * Callback function to receive the status of the message
+ * synchronization
+ *
+ * @param syncInfo
+ * Synchronization information of the notification message
+ */
public void onMessageSynchronized(SyncInfo syncInfo);
}
- public native int nativeStart(OnConsumerSubscribedListener subscribedListener,
- OnMessageSynchronizedListener messageSynchronized,
- boolean subControllability, String userInfo,
- boolean resourceSecurity) throws NSException;
- public native int nativeStop() throws NSException;
- public native int nativeSendMessage(Message message) throws NSException;
- public native void nativeSendSyncInfo( long messageId , int type) throws NSException;
+ public native int nativeStart(
+ OnConsumerSubscribedListener subscribedListener,
+ OnMessageSynchronizedListener messageSynchronized,
+ boolean subControllability, String userInfo,
+ boolean resourceSecurity) throws NSException;
+
+ public native int nativeStop() throws NSException;
+
+ public native int nativeSendMessage(Message message) throws NSException;
+
+ public native void nativeSendSyncInfo(long messageId, int type)
+ throws NSException;
+
public native Message nativeCreateMessage() throws NSException;
- public native int nativeEnableRemoteService(String servAdd) throws NSException;
- public native int nativeDisableRemoteService(String servAdd) throws NSException;
- public native int nativeSubscribeMQService(String servAdd, String topicName) throws NSException;
- public native int nativeRegisterTopic(String topicName) throws NSException;
- public native int nativeUnregisterTopic(String topicName) throws NSException;
- public native TopicsList nativeGetRegisteredTopicList() throws NSException;
+
+ public native int nativeEnableRemoteService(String servAdd)
+ throws NSException;
+
+ public native int nativeDisableRemoteService(String servAdd)
+ throws NSException;
+
+ public native int nativeSubscribeMQService(String servAdd, String topicName)
+ throws NSException;
+
+ public native int nativeRegisterTopic(String topicName) throws NSException;
+
+ public native int nativeUnregisterTopic(String topicName)
+ throws NSException;
+
+ public native TopicsList nativeGetRegisteredTopicList() throws NSException;
}