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 ResourceAttribute {
29 * Type of attribute value.
32 INT, DOUBLE, BOOL, STRING;
34 private static Type[] m_cvalues = Type.values();
36 @SuppressWarnings("unused")
37 private static Type getType(int x) {
43 * Class contains range property in min and max value.
54 private Range(int min, int max) {
63 @SuppressWarnings("unused")
64 private void setRange(int min, int max) {
65 m_range = new Range(min, max);
69 * This generic API is used to get the value of an attribute whose type is
70 * given by the caller of the method.
73 * This specifies the type in which the value has to be returned.
75 * @return The attribute's value in a specified type.
77 public <T> T getValue() {
78 @SuppressWarnings("unchecked")
84 * Method for getting the attribute's name.
86 * @return Attribute's name
88 public String getName() {
93 * Method for getting the attribute's value type.
95 * @return Attribute's value type as {@link Type}
97 public Type getType() {
102 * Method for getting the attribute's value base type. For example If the
103 * attribute value object is of type Vector of {@link Integer} then its type
104 * is Vector and base type is INT.
106 * @return Attribute's value type as {@link Type}
108 public Type getBaseType() {
113 * Method for getting the attribute's range property. Range will be valid
114 * only for Integer type.
116 * @return Attribute's value range as {@link Range}.
118 public Range getRange() {
123 * Method for getting the attribute's allowed values property. Allowed
124 * values property will be valid only for Integer, Double, String types.
127 * Attribute's allowed values whose type is given by the caller
130 * @return Attribute's value range as {@link Range}.
132 public <T> T getAllowedValues() {
133 @SuppressWarnings("unchecked")
134 T t = (T) m_AllowedValues;
138 private String m_name = null;
139 private Object m_value = null;
140 private Type m_type = Type.STRING;
141 private Range m_range = null;
142 private Object m_AllowedValues = null;