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.
18 * This file contains a class which has a set of native methods for accessing
21 package org.oic.simulator;
23 import org.oic.simulator.ResourceAttribute;
27 * This class represents the resource model of a resource and it provides a set
28 * of native methods for accessing the resource model.
30 public class SimulatorResourceModel {
35 public SimulatorResourceModel() {
40 * Method for adding an attribute whose value is of type int.
43 * Name of the attribute
45 * Value of the attribute
47 public void addAttribute(String name, int value) {
48 addAttributeInt(name, value);
52 * Method for adding an attribute whose value is of type double.
55 * Name of the attribute
57 * Value of the attribute
59 public void addAttribute(String name, double value) {
60 addAttributeDouble(name, value);
64 * Method for adding an attribute whose value is of type boolean.
67 * Name of the attribute
69 * Value of the attribute
71 public void addAttribute(String name, boolean value) {
72 addAttributeBoolean(name, value);
76 * Method for adding an attribute whose value is of type string.
79 * Name of the attribute
81 * Value of the attribute
83 public void addAttribute(String name, String value) {
84 addAttributeString(name, value);
88 * Method for getting the number of attributes this model comprised of.
90 * @return Number of attributes.
92 public native int size();
95 * Method for getting all attributes.
97 * @return Map of attributes with attribute name as the key and its
98 * corresponding {@link ResourceAttribute} object as the value.
100 public native Map<String, ResourceAttribute> getAttributes();
103 * Method for getting a specific attribute by its name.
106 * Name of the attribute
108 * @return An object of {@link ResourceAttribute}.
110 public native ResourceAttribute getAttribute(String attrName);
112 private native void addAttributeInt(String name, int value);
114 private native void addAttributeDouble(String name, double value);
116 private native void addAttributeBoolean(String name, boolean value);
118 private native void addAttributeString(String name, String value);
120 private SimulatorResourceModel(long nativeHandle) {
121 this.nativeHandle = nativeHandle;
125 protected void finalize() throws Throwable {
129 private native void create();
131 private native void dispose();
133 private long nativeHandle;