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 the resource attribute's value property.
22 public class AttributeProperty {
24 private Type mType = Type.UNKNOWN;
25 private double mMin = -1;
26 private double mMax = -1;
27 private AttributeValue[] mValueSet = null;
28 private AttributeProperty mChildProperty = null;
31 * Enum to represent property type.
34 UNKNOWN, RANGE, VALUESET
38 * Constructs {@link AttributeProperty} of type
39 * {@link AttributeProperty.Type#RANGE} with min and max values.
42 * Minimum value the attribute can have.
44 * Maximum value the attribute can have.
46 public AttributeProperty(double min, double max) {
53 * Constructs {@link AttributeProperty} of type
54 * {@link AttributeProperty.Type#VALUESET} with array of integer.
57 * Array of int type values.
59 public AttributeProperty(int[] values) {
60 mType = Type.VALUESET;
61 mValueSet = new AttributeValue[values.length];
62 for (int i = 0; i < values.length; i++)
63 mValueSet[i] = new AttributeValue(values[i]);
67 * Constructs {@link AttributeProperty} of type
68 * {@link AttributeProperty.Type#VALUESET} with array of double.
71 * Array of double type values.
73 public AttributeProperty(double[] values) {
74 mType = Type.VALUESET;
75 mValueSet = new AttributeValue[values.length];
76 for (int i = 0; i < values.length; i++)
77 mValueSet[i] = new AttributeValue(values[i]);
81 * Constructs {@link AttributeProperty} of type
82 * {@link AttributeProperty.Type#VALUESET} with array of boolean.
85 * Array of boolean type values.
87 public AttributeProperty(boolean[] values) {
88 mType = Type.VALUESET;
89 mValueSet = new AttributeValue[values.length];
90 for (int i = 0; i < values.length; i++)
91 mValueSet[i] = new AttributeValue(values[i]);
95 * Constructs {@link AttributeProperty} of type
96 * {@link AttributeProperty.Type#VALUESET} with array of Strings.
99 * Array of string type values.
101 public AttributeProperty(String[] values) {
102 mType = Type.VALUESET;
103 mValueSet = new AttributeValue[values.length];
104 for (int i = 0; i < values.length; i++)
105 mValueSet[i] = new AttributeValue(values[i]);
109 * API to get type of property.
111 * @return {@link AttributeProperty.Type}.
118 * API to get minimum value which was set as property.
120 * @return Minimum value.
122 public double min() {
127 * API to get maximum value which was set as property.
129 * @return Maximum value.
131 public double max() {
136 * API to get array of values which was set as property.
138 * @return Array of {@link AttributeValue}.
140 public AttributeValue[] valueSet() {
145 * API to set child attribute property.
147 * @param childProperty
148 * Child element property used if the Attribute value is of array
151 public void setChildProperty(AttributeProperty childProperty) {
152 mChildProperty = childProperty;
156 * API to get child attribute property.
158 * @return Child element property.
160 public AttributeProperty getChildProperty() {
161 return mChildProperty;
164 private AttributeProperty(AttributeValue[] values) {
165 mType = Type.VALUESET;