c04b07e04516f9bff81ba9052a585da12a002e0a
[contrib/iotivity.git] / service / simulator / java / eclipse-plugin / ServiceProviderPlugin / src / oic / simulator / serviceprovider / resource / LocalResourceAttribute.java
1 /*
2  * Copyright 2015 Samsung Electronics All Rights Reserved.
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package oic.simulator.serviceprovider.resource;
18
19 import java.util.List;
20
21 import org.oic.simulator.ResourceAttribute;
22 import org.oic.simulator.ResourceAttribute.Range;
23 import org.oic.simulator.ResourceAttribute.Type;
24 import org.oic.simulator.serviceprovider.AutomationType;
25
26 /**
27  * This class represents an attribute in the simulated resource.
28  */
29 public class LocalResourceAttribute {
30
31     // Native object reference
32     private ResourceAttribute resourceAttribute;
33
34     private Object            attributeValue;
35     private List<String>      attValues;
36
37     private int               automationId;
38
39     private boolean           automationInProgress;
40
41     private int               automationUpdateInterval;
42
43     private AutomationType    automationType;
44
45     public ResourceAttribute getResourceAttribute() {
46         return resourceAttribute;
47     }
48
49     public void setResourceAttribute(ResourceAttribute resourceAttribute) {
50         this.resourceAttribute = resourceAttribute;
51     }
52
53     public String getAttributeName() {
54         return resourceAttribute.getName();
55     }
56
57     public Object getAttributeValue() {
58         return attributeValue;
59     }
60
61     public void setAttributeValue(Object attributeValue) {
62         this.attributeValue = attributeValue;
63     }
64
65     public Object[] getAllowedValues() {
66         return resourceAttribute.getAllowedValues();
67     }
68
69     public Object getMinValue() {
70         return resourceAttribute.getRange().getMin();
71     }
72
73     public Object getMaxValue() {
74         return resourceAttribute.getRange().getMax();
75     }
76
77     public boolean isAutomationInProgress() {
78         return automationInProgress;
79     }
80
81     public void setAutomationInProgress(boolean automationInProgress) {
82         this.automationInProgress = automationInProgress;
83     }
84
85     public int getAutomationUpdateInterval() {
86         return automationUpdateInterval;
87     }
88
89     public void setAutomationUpdateInterval(int automationUpdateInterval) {
90         this.automationUpdateInterval = automationUpdateInterval;
91     }
92
93     public AutomationType getAutomationType() {
94         return automationType;
95     }
96
97     public void setAutomationType(AutomationType automationType) {
98         this.automationType = automationType;
99     }
100
101     public int getAutomationId() {
102         return automationId;
103     }
104
105     public void setAutomationId(int automationId) {
106         this.automationId = automationId;
107     }
108
109     public Type getAttValType() {
110         return resourceAttribute.getType();
111     }
112
113     public Type getAttValBaseType() {
114         return resourceAttribute.getBaseType();
115     }
116
117     public List<String> getAttValues() {
118         return attValues;
119     }
120
121     public void setAttValues(List<String> attValues) {
122         this.attValues = attValues;
123     }
124
125     public void printAttributeDetails() {
126         System.out.println("Attribute Name:" + resourceAttribute.getName());
127         System.out.println("Attribute Value:" + resourceAttribute.getValue());
128         System.out.println("Attribute Base Type:"
129                 + resourceAttribute.getBaseType());
130         System.out.println("Attribute Type:" + resourceAttribute.getType());
131         System.out.print("Allowed Values:");
132         Object[] values = getAllowedValues();
133         for (Object obj : values) {
134             System.out.print(obj);
135         }
136         Range range = resourceAttribute.getRange();
137         if (null != range) {
138             System.out.println("Range:" + range.getMin() + " to "
139                     + range.getMax());
140         }
141     }
142 }