diff gnv-artifacts/src/main/java/de/intevation/gnv/state/MeasurementState.java @ 796:a5526908f92f

Added javadoc in state package. gnv-artifacts/trunk@878 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 01 Apr 2010 09:15:36 +0000
parents e764cab8c885
children feae2f9d6c6f
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/MeasurementState.java	Wed Mar 31 13:48:07 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/MeasurementState.java	Thu Apr 01 09:15:36 2010 +0000
@@ -34,6 +34,12 @@
 import org.w3c.dom.Node;
 
 /**
+ * This state handles input of measurements relating to a parameter. The user
+ * interface description created by this class represents a matrix - each
+ * parameter in a single row, each measurement in a column. An invalid
+ * measurement column for a specific parameter is marked as disabled and should
+ * not be selected.
+ * 
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
 public class MeasurementState
@@ -41,11 +47,24 @@
 {
     private static Logger logger = Logger.getLogger(MeasurementState.class);
 
+    /**
+     *
+     */
     public static final String SQL_KEY_PARAMETERID = "PARAMETERID";
 
+    /**
+     *
+     */
     public static final String SEPARATOR = ";";
 
 
+    /**
+     * This class is used to generate the Matrix in <code>MinMaxDateState</code>.
+     * Parameter and Measurements are stored in separate lists and can be
+     * requested via different methods.
+     *
+     * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+     */
     private class ParameterMatrix {
         private final Logger logger =
             Logger.getLogger(ParameterMatrix.class);
@@ -55,6 +74,12 @@
         private List parameters;
         private boolean[][] values;
 
+        /**
+         * Constructs a new matrix.
+         *
+         * @param data A collection containing the measurements.
+         * @param parameter An array of parameters.
+         */
         public ParameterMatrix(Collection data, String[] parameter) {
             measurements  = new ArrayList(data.size());
             mDescriptions = new ArrayList(data.size());
@@ -69,6 +94,11 @@
             initMeasurements(data);
         }
 
+        /**
+         * Initialize the measurements used in this matrix.
+         * 
+         * @param data The measurements.
+         */
         private void initMeasurements(Collection data) {
             Iterator iter = data.iterator();
             while (iter.hasNext()) {
@@ -103,12 +133,22 @@
             }
         }
 
+        /**
+         * Initialize the parameters used in this matrix.
+         * 
+         * @param parameter Parameters.
+         */
         private void initParameters(String[] parameter) {
             for (String param: parameter) {
                 parameters.add(param);
             }
         }
 
+        /**
+         * Returns the number of measurements.
+         * 
+         * @return the number of measurements.
+         */
         public int measurementSize() {
             if (measurements != null)
                 return measurements.size();
@@ -116,6 +156,11 @@
             return 0;
         }
 
+        /**
+         * Returns the number of parameters.
+         * 
+         * @return number of parameters.
+         */
         public int parameterSize() {
             if (parameters != null)
                 return parameters.size();
@@ -123,6 +168,12 @@
             return 0;
         }
 
+        /**
+         * Returns the measurement at idx.
+         * 
+         * @param idx Index.
+         * @return the measurement.
+         */
         public String getMeasurement(int idx) {
             if (idx >= 0 && idx < measurements.size())
                 return (String) measurements.get(idx);
@@ -131,6 +182,12 @@
             return "";
         }
 
+        /**
+         * Returns the parameter at idx.
+         * 
+         * @param idx Index
+         * @return the parameter.
+         */
         public String getParameter(int idx) {
             if (idx >= 0 && idx < parameters.size()) {
                 return (String) parameters.get(idx);
@@ -140,6 +197,12 @@
             return "";
         }
 
+        /**
+         * Returns a description text for a specific measurement.
+         *
+         * @param idx Index of a measurement.
+         * @return measurement's description.
+         */
         public String getMDescription(int idx) {
             if (mDescriptions != null) {
                 return (String) mDescriptions.get(idx);
@@ -148,6 +211,14 @@
             return null;
         }
 
+        /**
+         * This method returns true, if a measurement is valid for a specific
+         * parameter - otherwise false.
+         * 
+         * @param i Index of a measurement column.
+         * @param j Index of a parameter row.
+         * @return true, if valid, else false.
+         */
         public boolean isValid(int i, int j) {
             if (i < 0 || i > measurements.size()
             ||  j < 0 || j > parameters.size())
@@ -161,6 +232,9 @@
     } // End of ParameterMatrix
 
 
+    /**
+     *
+     */
     public MeasurementState() {
         super();
     }
@@ -200,6 +274,18 @@
     }
 
 
+    /**
+     * This method create the user interface description for measurement and
+     * parameters as matrix. A row for each parameter, a column for each
+     * measurement.
+     * 
+     * @param artCreator
+     * @param creator
+     * @param document
+     * @param dynamicNode
+     * @param callMeta
+     * @param o
+     */
     @Override
     protected void appendToDynamicNode(
         XMLUtils.ElementCreator artCreator,
@@ -266,6 +352,17 @@
     }
 
 
+    /**
+     * This feed takes some input data storing measurement ids and parameter ids
+     * and put them into ExtendedInputData objects to save the relation between
+     * a measurement and the parameter it belongs to.
+     * 
+     * @param context
+     * @param input
+     * @param uuid
+     * @return
+     * @throws StateException
+     */
     @Override
     public Document feed(
         CallContext           context,
@@ -334,6 +431,15 @@
     }
 
 
+    /**
+     * Extract parameter ids and measurement ids from DefaultInputData objects
+     * and return an array. In the first position of this array, the measurement
+     * ids are placed, in the second position the parameter ids - all separated
+     * by a character.
+     *
+     * @param tmp String containing measurement ids and parameter ids.
+     * @return An array with separated measurements and parameters.
+     */
     protected String[] extractValuesAndParams(String tmp) {
         String[] array = tmp.split(DefaultInputData.VALUE_SEPARATOR);
 
@@ -363,4 +469,4 @@
         return extracted;
     }
 }
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
\ No newline at end of file

http://dive4elements.wald.intevation.org