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;
20 * This class represents an attribute of a resource. It has a set of native
21 * methods for getting the attribute's information.
23 public class ResourceAttribute {
25 * Type of attribute value.
28 UNKNOWN, INT, DOUBLE, BOOL, STRING;
30 private static Type[] m_cvalues = Type.values();
32 @SuppressWarnings("unused")
33 private static Type getType(int x) {
39 * Class contains range property in min and max value.
50 private Range(int min, int max) {
59 @SuppressWarnings("unused")
60 private void setRange(int min, int max) {
61 m_range = new Range(min, max);
65 * This generic API is used to get the value of an attribute whose type is
66 * given by the caller of the method.
69 * This specifies the type in which the value has to be returned.
71 * @return The attribute's value in a specified type.
73 public <T> T getValue() {
74 @SuppressWarnings("unchecked")
80 * Method for getting the attribute's name.
82 * @return Attribute's name
84 public String getName() {
89 * Method for getting the attribute's value type.
91 * @return Attribute's value type as {@link Type}
93 public Type getType() {
98 * Method for getting the attribute's value base type. For example If the
99 * attribute value object is of type Vector of {@link Integer} then its type
100 * is Vector and base type is INT.
102 * @return Attribute's value type as {@link Type}
104 public Type getBaseType() {
109 * Method for getting the attribute's range property. Range will be valid
110 * only for Integer type.
112 * @return Attribute's value range as {@link Range}.
114 public Range getRange() {
119 * Method for getting the attribute's allowed values property. Allowed
120 * values property will be valid only for Integer, Double, String types.
123 * Attribute's allowed values whose type is given by the caller
126 * @return Attribute's value range as {@link Range}.
128 public <T> T getAllowedValues() {
129 @SuppressWarnings("unchecked")
130 T t = (T) m_AllowedValues;
134 private String m_name = null;
135 private Object m_value = null;
136 private Type m_type = Type.STRING;
137 private Range m_range = null;
138 private Object m_AllowedValues = null;