Merge "Partial Implementation of US1574:"
[platform/upstream/iotivity.git] / csdk / android / OCClient / src / com / oc / ub / sample / LightControl.java
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 package com.oc.ub.sample;
22
23 import com.oc.OCObserver;
24 import com.oc.annotations.OCInterface;
25 import com.oc.annotations.OCProperty;
26
27 /**
28  * APPLICATION NOTE: This interface is exposed to via the framework because of the @OCInterface
29  * annotation. Without the annotation, this interface would be ignored by the framework.
30  * 
31  * APPLICATION NOTE: This interface needs to be accessible on the client and the server as the
32  * contract for operation.
33  * 
34  */
35 @OCInterface
36 public interface LightControl {
37   /**
38    * APPLICATION NOTE: This is a synchronous request. It will throw immediately if the stack is down
39    * or the network is otherwise not available. It may throw is the remote side does not responds or
40    * returns an error.
41    * 
42    * @param powered - The new power state of this implemented interface.
43    */
44   @OCProperty(name = "powered")
45   void setPowered(boolean powered);
46
47   /**
48    * APPLICATION NOTE: This is a synchronous request. It will throw immediately if the stack is down
49    * or the network is otherwise not available. It may throw is the remote side does not responds or
50    * returns an error.
51    * 
52    * @return Returns power state of this implemented interface.
53    */
54   @OCProperty(name = "powered")
55   boolean isPowered();
56
57   /**
58    * APPLICATION NOTE: It is the objects responsibility to throw an exception (TBD) if it cannot
59    * handle an additional observers which will in turn return an error to the requestor.
60    * 
61    * @param observer the observer that will be notified when a change to the power property has
62    *        occurred.
63    */
64   @OCProperty(name = "powered")
65   void addPoweredObserver(OCObserver<Boolean> observer);
66
67   /**
68    * APPLICATION NOTE: Even properties (or methods) that are not annotated are exposed, by default,
69    * via the framework. Getter and setter methods are assumed to be properties unless annotated
70    * otherwise.
71    * 
72    * @param level - Sets the power level of this implemented interface.
73    */
74   void setLevel(int level);
75
76   int getLevel();
77
78   /**
79    * APPLICATION NOTE: This is an example of a method. The annotation is not required except to
80    * override the defaults.
81    */
82   void flash();
83 }