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
19 * getting the information associated with a particular attribute.
21 package org.oic.simulator;
24 * This class represents an attribute of a resource. It has a set of native
25 * methods for getting the attribute's information.
27 public class SimulatorResourceAttribute {
30 * Handle to the native object of the simulator resource attribute.
32 private long nativeHandle;
34 public SimulatorResourceAttribute() {
38 * Constructor for SimulatorResourceAttribute.
41 * Handle to the native SimulatorResourceAttribute object.
43 private SimulatorResourceAttribute(long handle) {
44 nativeHandle = handle;
48 * This constructor is used to create a new attribute.
51 * Name of the attribute
53 public SimulatorResourceAttribute(String attrName) {
58 protected void finalize() throws Throwable {
63 * This generic API is used to get the value of an attribute whose type is
64 * given by the caller of the method.
67 * This specifies the type in which the value has to be returned.
69 * @return The attribute's value in a specified type.
71 public <T> T getAttributeValue() {
72 Object obj = getValue();
73 @SuppressWarnings("unchecked")
79 * Native method to create a new attribute with the given name.
82 * Name of the attribute.
84 public native void create(String attrName);
87 * Native method for getting the attribute's name.
89 * @return Attribute's name
91 public native String getName();
94 * Native method for getting the attribute's value.
96 * @return Attribute's value represented as {@link Object}.
98 public native Object getValue();
101 * Native method for getting the number of values in the allowed values
104 * @return Count of allowed values
106 public native int allowedValuesSize();
109 * Native method for returning the string representation of the attribute's
112 * @return Attribute's value as {@link String}.
114 public native String valueToString();
117 * Native method for returning the string representation of the attribute's
120 * @return Attribute's allowed values as {@link String}.
122 public native String allowedValuesToString();
125 * Native function to release the memory allocated to the native object for
126 * SimulatorResourceAttribute.
128 private native void dispose();