Updating Simulator Java API project with the following changes.
[platform/upstream/iotivity.git] / service / simulator / java / sdk / src / org / oic / simulator / clientcontroller / SimulatorRemoteResource.java
index 583c273..078e999 100644 (file)
  */
 
 /**
- * This file contains a class which has a set of native methods for 
- * communicating with a remote resource.  
+ * This file contains a class which has a set of native methods for
+ * communicating with a remote resource.
  */
 package org.oic.simulator.clientcontroller;
 
-import java.util.List;
+import java.util.LinkedList;
 import java.util.Map;
 
-import org.oic.simulator.serviceprovider.SimulatorResourceModel;
+import org.oic.simulator.SimulatorResourceModel;
 
 /**
  * SimulatorRemoteResource represents a Resource running in the remote Simulator
@@ -33,41 +33,76 @@ import org.oic.simulator.serviceprovider.SimulatorResourceModel;
 public class SimulatorRemoteResource {
 
     private SimulatorRemoteResource(long nativeHandle) {
-        this.mNativeHandle = nativeHandle;
+        this.nativeHandle = nativeHandle;
     }
 
     /**
      * Method to get the URI for this resource
-     *
+     * 
      * @return resource URI
      */
-    public native String getUri();
+    public String getUri() {
+        return mUri;
+    }
+
+    /**
+     * Method to get the observe capability of this resource
+     * 
+     * @return true if the resource is observable, otherwise false.
+     */
+    public boolean getIsObservable() {
+        return mIsObservable;
+    }
+
+    /**
+     * Method to get the connectivity type for this resource
+     * 
+     * @return Connectivity type.
+     */
+    public String getConnectivityType() {
+        return mConnType;
+    }
 
     /**
      * Method to get the list of resource types
-     *
+     * 
      * @return List of resource types
      */
-    public native List<String> getResourceTypes();
+    public LinkedList<String> getResourceTypes() {
+        return mResTypes;
+    }
 
     /**
      * Method to get the list of resource interfaces
-     *
+     * 
      * @return List of resource interface
      */
-    public native List<String> getResourceInterfaces();
+    public LinkedList<String> getResourceInterfaces() {
+        return mResInterfaces;
+    }
 
     /**
      * Method to get a string representation of the resource's server ID. This
      * is unique per-server independent on how it was discovered.
-     *
+     * 
      * @return server ID
      */
-    public native String getServerId();
+    public String getServerId() {
+        return mSid;
+    }
+
+    /**
+     * Method to get a unique Id of the resource.
+     * 
+     * @return Unique ID.
+     */
+    public String getUid() {
+        return mUid;
+    }
 
     /**
      * Method to set observation on the resource
-     *
+     * 
      * @param observeType
      *            allows the client to specify how it wants to observe
      * @param queryParamsMap
@@ -75,7 +110,7 @@ public class SimulatorRemoteResource {
      * @param onObserveListener
      *            event handler The handler method will be invoked with a map of
      *            attribute name and values.
-     *
+     * 
      */
     public native void observe(SimulatorObserveType observeType,
             Map<String, String> queryParamsMap,
@@ -83,13 +118,12 @@ public class SimulatorRemoteResource {
 
     /**
      * Method to cancel the observation on the resource
-     *
      */
     public native void cancelObserve();
 
     /**
      * Method to get the attributes of a resource.
-     *
+     * 
      * @param queryParamsMap
      *            map which can have the query parameter name and value
      * @param onGetListener
@@ -97,14 +131,14 @@ public class SimulatorRemoteResource {
      *            and values. The event handler will also have the result from
      *            this Get operation This will have error codes
      */
-    public native void get(Map<String, String> queryParamsMap,
-            IGetListener onGetListener);
+    public void get(Map<String, String> queryParamsMap,
+            IGetListener onGetListener) {
+        this.get(null, queryParamsMap, onGetListener);
+    }
 
     /**
      * Method to get the attributes of a resource.
-     *
-     * @param resourceType
-     *            resourceType of the resource to operate on
+     * 
      * @param resourceInterface
      *            interface type of the resource to operate on
      * @param queryParamsMap
@@ -114,18 +148,12 @@ public class SimulatorRemoteResource {
      *            and values. The event handler will also have the result from
      *            this Get operation This will have error codes
      */
-    public void get(String resourceType, String resourceInterface,
-            Map<String, String> queryParamsMap, IGetListener onGetListener) {
-        this.get2(resourceType, resourceInterface, queryParamsMap,
-                onGetListener);
-    }
-
-    private native void get2(String resourceType, String resourceInterface,
+    public native void get(String resourceInterface,
             Map<String, String> queryParamsMap, IGetListener onGetListener);
 
     /**
      * Method to set the representation of a resource (via PUT)
-     *
+     * 
      * @param representation
      *            representation of the resource
      * @param queryParamsMap
@@ -134,14 +162,14 @@ public class SimulatorRemoteResource {
      *            event handler The event handler will be invoked with a map of
      *            attribute name and values.
      */
-    public native void put(SimulatorResourceModel representation,
-            Map<String, String> queryParamsMap, IPutListener onPutListener);
+    public void put(SimulatorResourceModel representation,
+            Map<String, String> queryParamsMap, IPutListener onPutListener) {
+        this.put(null, representation, queryParamsMap, onPutListener);
+    }
 
     /**
      * Method to set the representation of a resource (via PUT)
-     *
-     * @param resourceType
-     *            resource type of the resource to operate on
+     * 
      * @param resourceInterface
      *            interface type of the resource to operate on
      * @param representation
@@ -152,20 +180,13 @@ public class SimulatorRemoteResource {
      *            event handler The event handler will be invoked with a map of
      *            attribute name and values.
      */
-    public void put(String resourceType, String resourceInterface,
-            SimulatorResourceModel representation,
-            Map<String, String> queryParamsMap, IPutListener onPutListener) {
-        this.put2(resourceType, resourceInterface, representation,
-                queryParamsMap, onPutListener);
-    }
-
-    private native void put2(String resourceType, String resourceInterface,
+    private native int put(String resourceInterface,
             SimulatorResourceModel representation,
             Map<String, String> queryParamsMap, IPutListener onPutListener);
 
     /**
      * Method to POST on a resource
-     *
+     * 
      * @param representation
      *            representation of the resource
      * @param queryParamsMap
@@ -174,14 +195,14 @@ public class SimulatorRemoteResource {
      *            event handler The event handler will be invoked with a map of
      *            attribute name and values.
      */
-    public native void post(SimulatorResourceModel representation,
-            Map<String, String> queryParamsMap, IPostListener onPostListener);
+    public void post(SimulatorResourceModel representation,
+            Map<String, String> queryParamsMap, IPostListener onPostListener) {
+        this.post(null, representation, queryParamsMap, onPostListener);
+    }
 
     /**
      * Method to POST on a resource
-     *
-     * @param resourceType
-     *            resource type of the resource to operate on
+     * 
      * @param resourceInterface
      *            interface type of the resource to operate on
      * @param representation
@@ -192,17 +213,43 @@ public class SimulatorRemoteResource {
      *            event handler The event handler will be invoked with a map of
      *            attribute name and values.
      */
-    public void post(String resourceType, String resourceInterface,
-            SimulatorResourceModel representation,
-            Map<String, String> queryParamsMap, IPostListener onPostListener) {
-        this.post2(resourceType, resourceInterface, representation,
-                queryParamsMap, onPostListener);
-    }
-
-    private native void post2(String resourceType, String resourceInterface,
+    private native int post(String resourceInterface,
             SimulatorResourceModel representation,
             Map<String, String> queryParamsMap, IPostListener onPostListener);
 
+    /**
+     * Method to set the RAML file path from application
+     * 
+     * @param ramlPath
+     *            RAML configuration file path
+     */
+    public native void configureRAMLPath(String ramlPath);
+
+    /**
+     * Method to start verification of a resource using automation
+     * 
+     * @param requestType
+     *            request type to verify
+     * 
+     * @param onVerifyListener
+     *            event handler The event handler will be invoked with the
+     *            automation ID.
+     * 
+     * @return Automation ID.
+     * 
+     */
+    public native int startVerification(int requestType,
+            IVerificationListener onVerifyListener);
+
+    /**
+     * Method to stop verification of a resource previously started.
+     * 
+     * @param id
+     *            Automation ID.
+     * 
+     */
+    public native void stopVerification(int id);
+
     @Override
     protected void finalize() throws Throwable {
         super.finalize();
@@ -212,5 +259,12 @@ public class SimulatorRemoteResource {
 
     private native void dispose();
 
-    private long mNativeHandle;
+    private long               nativeHandle;
+    private String             mUri;
+    private String             mConnType;
+    private String             mSid;
+    private String             mUid;
+    private boolean            mIsObservable;
+    private LinkedList<String> mResTypes;
+    private LinkedList<String> mResInterfaces;
 }