[IoTivity Simulator] Handling resource interfaces.
[platform/upstream/iotivity.git] / service / simulator / java / sdk / src / org / oic / simulator / AttributeValueValidation.java
index 30ace70..54bc4e1 100644 (file)
@@ -1,19 +1,59 @@
+/*
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.oic.simulator;
 
+/**
+ * This class holds a set of methods for validating the attribute values of
+ * different types using the given value properties {@link AttributeProperty}.
+ */
 public class AttributeValueValidation implements
         AttributeValueVisitor.VisitingMethods<Boolean> {
     private AttributeProperty mProperty = null;
 
+    /**
+     * Constructs {@link AttributeValueValidation} with the given attribute
+     * value property.
+     *
+     * @param property
+     *            Attribute value property.
+     */
     public AttributeValueValidation(AttributeProperty property) {
         mProperty = property;
     }
 
+    /**
+     * API to validate the given attribute value. The given value is said to be
+     * valid if it matches with the values given in the value property.
+     *
+     * @param value
+     *            {@link AttributeValue} to be validated.
+     * @return True if the given value is valid, otherwise false.
+     */
     public boolean validate(AttributeValue value) {
         AttributeValueVisitor visitor = new AttributeValueVisitor(value, this);
         Boolean result = (Boolean) visitor.visit();
         return result.booleanValue();
     }
 
+    /**
+     * API to validate an Integer value.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(Integer value) {
         if (mProperty == null)
@@ -24,6 +64,11 @@ public class AttributeValueValidation implements
         return false;
     }
 
+    /**
+     * API to validate a Double value.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(Double value) {
         if (mProperty == null)
@@ -34,6 +79,11 @@ public class AttributeValueValidation implements
         return false;
     }
 
+    /**
+     * API to validate a Boolean value.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(Boolean value) {
         if (mProperty == null)
@@ -44,6 +94,11 @@ public class AttributeValueValidation implements
         return false;
     }
 
+    /**
+     * API to validate a String value.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(String value) {
         if (mProperty == null)
@@ -54,11 +109,21 @@ public class AttributeValueValidation implements
         return false;
     }
 
+    /**
+     * API to validate a {@link SimulatorResourceModel} value.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(SimulatorResourceModel value) {
         return false;
     }
 
+    /**
+     * API to validate an array of integer values.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(Integer[] values) {
         if (mProperty == null)
@@ -79,6 +144,11 @@ public class AttributeValueValidation implements
         return true;
     }
 
+    /**
+     * API to validate an array of double values.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(Double[] values) {
         if (mProperty == null)
@@ -99,6 +169,11 @@ public class AttributeValueValidation implements
         return true;
     }
 
+    /**
+     * API to validate an array of boolean values.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(Boolean[] values) {
         if (mProperty == null)
@@ -119,6 +194,11 @@ public class AttributeValueValidation implements
         return true;
     }
 
+    /**
+     * API to validate an array of string values.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(String[] values) {
         if (mProperty == null)
@@ -139,11 +219,21 @@ public class AttributeValueValidation implements
         return true;
     }
 
+    /**
+     * API to validate an array of {@link SimulatorResourceModel} values.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(SimulatorResourceModel[] value) {
         return false;
     }
 
+    /**
+     * API to validate a 2D array of integer values.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(Integer[][] values) {
         if (mProperty == null)
@@ -164,6 +254,11 @@ public class AttributeValueValidation implements
         return true;
     }
 
+    /**
+     * API to validate a 2D array of double values.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(Double[][] values) {
         if (mProperty == null)
@@ -184,6 +279,11 @@ public class AttributeValueValidation implements
         return true;
     }
 
+    /**
+     * API to validate a 2D array of boolean values.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(Boolean[][] values) {
         if (mProperty == null)
@@ -204,6 +304,11 @@ public class AttributeValueValidation implements
         return true;
     }
 
+    /**
+     * API to validate a 2D array of string values.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(String[][] values) {
         if (mProperty == null)
@@ -224,11 +329,21 @@ public class AttributeValueValidation implements
         return true;
     }
 
+    /**
+     * API to validate a 2D array of {@link SimulatorResourceModel} values.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(SimulatorResourceModel[][] value) {
         return false;
     }
 
+    /**
+     * API to validate a 3D array of integer values.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(Integer[][][] values) {
         if (mProperty == null)
@@ -249,6 +364,11 @@ public class AttributeValueValidation implements
         return true;
     }
 
+    /**
+     * API to validate a 3D array of double values.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(Double[][][] values) {
         if (mProperty == null)
@@ -269,6 +389,11 @@ public class AttributeValueValidation implements
         return true;
     }
 
+    /**
+     * API to validate a 3D array of boolean values.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(Boolean[][][] values) {
         if (mProperty == null)
@@ -289,6 +414,11 @@ public class AttributeValueValidation implements
         return true;
     }
 
+    /**
+     * API to validate a 3D array of string values.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(String[][][] values) {
         if (mProperty == null)
@@ -309,6 +439,11 @@ public class AttributeValueValidation implements
         return true;
     }
 
+    /**
+     * API to validate a 3D array of {@link SimulatorResourceModel} values.
+     *
+     * @return True if the given value is valid, otherwise false.
+     */
     @Override
     public Boolean visitingValue(SimulatorResourceModel[][][] value) {
         return false;