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 vaule 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 propety type.
34 UNKNOWN, RANGE, VALUESET
38 * Constructs {@AttributeProperty} of type
39 * {@AttributeProperty.Type.Range} with min
43 * Minimun value the attribute can have.
45 * Maximum value the attribute can have.
47 public AttributeProperty(double min, double max) {
54 * Constructs {@AttributeProperty} of type
55 * {@AttributeProperty.Type.VALUESET} with
59 * Array of int type values.
61 public AttributeProperty(int[] values) {
62 mType = Type.VALUESET;
63 mValueSet = new AttributeValue[values.length];
64 for (int i = 0; i < values.length; i++)
65 mValueSet[i] = new AttributeValue(values[i]);
69 * Constructs {@AttributeProperty} of type
70 * {@AttributeProperty.Type.VALUESET} with
74 * Array of double type values.
76 public AttributeProperty(double[] values) {
77 mType = Type.VALUESET;
78 mValueSet = new AttributeValue[values.length];
79 for (int i = 0; i < values.length; i++)
80 mValueSet[i] = new AttributeValue(values[i]);
84 * Constructs {@AttributeProperty} of type
85 * {@AttributeProperty.Type.VALUESET} with
89 * Array of boolean type values.
91 public AttributeProperty(boolean[] values) {
92 mType = Type.VALUESET;
93 mValueSet = new AttributeValue[values.length];
94 for (int i = 0; i < values.length; i++)
95 mValueSet[i] = new AttributeValue(values[i]);
99 * Constructs {@AttributeProperty} of type
100 * {@AttributeProperty.Type.VALUESET} with
106 public AttributeProperty(String[] values) {
107 mType = Type.VALUESET;
108 mValueSet = new AttributeValue[values.length];
109 for (int i = 0; i < values.length; i++)
110 mValueSet[i] = new AttributeValue(values[i]);
114 * API to get type of property.
116 * @return {@AttributeProperty.Type}.
123 * API to get minimum value which was set as property.
125 public double min() {
130 * API to get maximum value which was set as property.
132 public double max() {
137 * API to get array of values which was set as property.
139 * @return array of {@AttributeValue}.
141 public AttributeValue[] valueSet() {
146 * API to set child attribute propety.
148 * @param childProperty
149 * Child element property this property used if the Attribute
150 * value is of array type.
152 public void setChildProperty(AttributeProperty childProperty) {
153 mChildProperty = childProperty;
157 * API to get child attribute propety.
159 * @return Child element property.
161 public AttributeProperty getChildProperty() {
162 return mChildProperty;
165 private AttributeProperty(AttributeValue[] values) {
166 mType = Type.VALUESET;