* limitations under the License.
*/
-/**
- * This file contains a class which has a set of native methods for
- * getting the information associated with a particular attribute.
- */
package org.oic.simulator;
/**
- * This class represents an attribute of a resource. It has a set of native
- * methods for getting the attribute's information.
+ * This class represents the resource attribute which contains attribute value
+ * and its property.
*/
public class SimulatorResourceAttribute {
- /**
- * Handle to the native object of the simulator resource attribute.
- */
- private long nativeHandle;
-
- public SimulatorResourceAttribute() {
- }
+ private String mName = null;
+ private AttributeValue mValue = null;
+ private AttributeProperty mProperty = null;
/**
- * Constructor for SimulatorResourceAttribute.
+ * Constructs {@link SimulatorResourceAttribute} with the given attribute
+ * name, value and its property.
*
- * @param nativeHandle
- * Handle to the native SimulatorResourceAttribute object.
+ * @param name
+ * Name of the attribute.
+ * @param value
+ * Value of the attribute.
+ * @param property
+ * Property of attribute value.
*/
- private SimulatorResourceAttribute(long handle) {
- nativeHandle = handle;
+ public SimulatorResourceAttribute(String name, AttributeValue value,
+ AttributeProperty property) {
+ mName = new String(name);
+ mValue = value;
+ mProperty = property;
}
/**
- * This constructor is used to create a new attribute.
+ * Constructs {@link SimulatorResourceAttribute} with the given attribute
+ * name and value.
*
- * @param attrName
- * Name of the attribute
+ * @param name
+ * Name of the attribute.
+ * @param value
+ * Value of the attribute.
*/
- public SimulatorResourceAttribute(String attrName) {
- create(attrName);
- }
-
- @Override
- protected void finalize() throws Throwable {
- dispose();
+ public SimulatorResourceAttribute(String name, AttributeValue value) {
+ mName = new String(name);
+ mValue = value;
+ mProperty = null;
}
/**
- * This generic API is used to get the value of an attribute whose type is
- * given by the caller of the method.
- *
- * @param <T>
- * This specifies the type in which the value has to be returned.
+ * API to get name of attribute.
*
- * @return The attribute's value in a specified type.
+ * @return Attribute's name.
*/
- public <T> T getAttributeValue() {
- Object obj = getValue();
- @SuppressWarnings("unchecked")
- T t = (T) obj;
- return t;
+ public String name() {
+ return mName;
}
/**
- * Native method to create a new attribute with the given name.
- *
- * @param attrName
- * Name of the attribute.
- */
- public native void create(String attrName);
-
- /**
- * Native method for getting the attribute's name.
+ * API to get value of attribute.
*
- * @return Attribute's name
+ * @return Attribute's value {@link AttributeValue}.
*/
- public native String getName();
-
- /**
- * Native method for getting the attribute's value.
- *
- * @return Attribute's value represented as {@link Object}.
- */
- public native Object getValue();
+ public AttributeValue value() {
+ return mValue;
+ }
/**
- * Native method for getting the number of values in the allowed values
- * list.
+ * API to get property of attribute's value.
*
- * @return Count of allowed values
+ * @return Attribute's value property {@link AttributeProperty
+ * }.
*/
- public native int allowedValuesSize();
+ public AttributeProperty property() {
+ return mProperty;
+ }
/**
- * Native method for returning the string representation of the attribute's
- * value.
+ * API to set the value of attribute.
*
- * @return Attribute's value as {@link String}.
+ * @param value
+ * Value of the attribute.
*/
- public native String valueToString();
+ public void setValue(AttributeValue value) {
+ this.mValue = value;
+ }
/**
- * Native method for returning the string representation of the attribute's
- * allowed values.
+ * API to set the property of attribute.
*
- * @return Attribute's allowed values as {@link String}.
+ * @param property
+ * Property of the attribute.
*/
- public native String allowedValuesToString();
-
- /**
- * Native function to release the memory allocated to the native object for
- * SimulatorResourceAttribute.
- */
- private native void dispose();
-
-}
\ No newline at end of file
+ public void setProperty(AttributeProperty property) {
+ this.mProperty = property;
+ }
+}