2 * Copyright 2015 Samsung Electronics All Rights Reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.oic.simulator.server;
19 import org.oic.simulator.AttributeValue;
20 import org.oic.simulator.InvalidArgsException;
21 import org.oic.simulator.SimulatorException;
22 import org.oic.simulator.SimulatorResourceAttribute;
25 * This class represents a single type resource(Non-collection resource). It
26 * provides APIs specific to single resource for manipulating the resource model
27 * by adding/removing the attributes, and updating the attribute values manually
30 public final class SimulatorSingleResource extends SimulatorResource {
32 private SimulatorSingleResource(long nativeHandle) {
33 mNativeHandle = nativeHandle;
37 * API to get attribute of resource.
40 * Name of the attribute
42 * @return An object of {@link SimulatorResourceAttribute}, or null if
43 * resource does not have attribute of this name.
45 * @throws InvalidArgsException
46 * This exception will be thrown if the attribute name is
48 * @throws SimulatorException
49 * This exception will be thrown either if the resource model is
50 * not found or for some general errors.
52 public native SimulatorResourceAttribute getAttribute(String attrName)
53 throws InvalidArgsException, SimulatorException;
56 * API to add an attribute to resource's representation model.
59 * Attribute to be added to resource's representation model.
61 * @throws InvalidArgsException
62 * This exception will be thrown on invalid input.
63 * @throws SimulatorException
64 * This exception will be thrown for other errors.
66 public native void addAttribute(SimulatorResourceAttribute attribute)
67 throws InvalidArgsException, SimulatorException;
70 * API to update the value of an attribute.
73 * Name of the attribute.
75 * New value of the attribute.
77 * @throws InvalidArgsException
78 * This exception will be thrown on invalid input.
79 * @throws SimulatorException
80 * This exception will be thrown for other errors.
82 public native void updateAttribute(String attrName, AttributeValue value)
83 throws InvalidArgsException, SimulatorException;
86 * API to remove an attribute from the simulated resource.
89 * Name of the attribute to be deleted.
91 * @throws InvalidArgsException
92 * This exception will be thrown on invalid input.
93 * @throws SimulatorException
94 * This exception will be thrown for other errors.
96 public native void removeAttribute(String attrName)
97 throws InvalidArgsException, SimulatorException;
100 * API to start the resource level automation. This automation involves
101 * automatically updating all the possible values for all the attributes
105 * {@link AutoUpdateType} indicating whether the automation is
106 * one-time or recursive.
108 * Interval time in milliseconds.
110 * Listener to be notified when automation ends.
112 * @return Automation ID using which the automation can be stopped.
114 * @throws InvalidArgsException
115 * This exception will be thrown on invalid input.
116 * @throws SimulatorException
117 * This exception will be thrown for other errors.
119 public native int startResourceUpdation(AutoUpdateType type, int interval,
120 AutoUpdateListener listener) throws InvalidArgsException,
124 * API to start the attribute level automation. This automation involves
125 * automatically updating all the possible values for a given attribute
129 * Name of the attribute to be automated.
131 * {@link AutoUpdateType} indicating whether the automation is
132 * one-time or recursive.
134 * Interval time in milliseconds.
136 * Listener to be notified when automation ends.
138 * @return Automation ID using which the automation can be stopped.
140 * @throws InvalidArgsException
141 * This exception will be thrown on invalid input.
142 * @throws SimulatorException
143 * This exception will be thrown for other errors.
145 public native int startAttributeUpdation(String attrName,
146 AutoUpdateType type, int interval, AutoUpdateListener listener)
147 throws InvalidArgsException, SimulatorException;
150 * API to stop the automation based on automation id.
153 * Using which a specific automation can be stopped.
155 * @throws SimulatorException
156 * This exception will be thrown for general errors.
158 public native void stopUpdation(int id) throws SimulatorException;