/hg/gfx-test: * src/org/gfxtest/common/Configuration.java:

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Fri Apr 6 04:01:22 PDT 2012


changeset 0594d3a7c745 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=0594d3a7c745
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Fri Apr 06 13:03:55 2012 +0200

	* src/org/gfxtest/common/Configuration.java:
		* src/org/gfxtest/common/ConfigurationException.java:
		* src/org/gfxtest/common/InvalidParameterValueException.java:
		Code and JavaDoc improvements.


diffstat:

 ChangeLog                                                  |   7 ++
 src/org/gfxtest/common/Configuration.java                  |  39 +++++++++++--
 src/org/gfxtest/common/ConfigurationException.java         |  22 +++++++-
 src/org/gfxtest/common/InvalidParameterValueException.java |  15 ++++-
 4 files changed, 71 insertions(+), 12 deletions(-)

diffs (227 lines):

diff -r b26c11e47283 -r 0594d3a7c745 ChangeLog
--- a/ChangeLog	Wed Apr 04 11:57:23 2012 +0200
+++ b/ChangeLog	Fri Apr 06 13:03:55 2012 +0200
@@ -1,3 +1,10 @@
+2012-04-05  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/gfxtest/common/Configuration.java:
+	* src/org/gfxtest/common/ConfigurationException.java:
+	* src/org/gfxtest/common/InvalidParameterValueException.java:
+	Code and JavaDoc improvements.
+
 2012-04-04  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/gfxtest/testsuites/ClippingCircleByRoundRectangleShape.java:
diff -r b26c11e47283 -r 0594d3a7c745 src/org/gfxtest/common/Configuration.java
--- a/src/org/gfxtest/common/Configuration.java	Wed Apr 04 11:57:23 2012 +0200
+++ b/src/org/gfxtest/common/Configuration.java	Fri Apr 06 13:03:55 2012 +0200
@@ -1,7 +1,7 @@
 /*
   Java gfx-test framework
 
-   Copyright (C) 2010, 2011  Red Hat
+   Copyright (C) 2010, 2011, 2012  Red Hat
 
 This file is part of IcedTea.
 
@@ -50,7 +50,7 @@
 
 /**
  * This class is used to store actual configuration of graphics test framework.
- * Configuration can be changed via command line switches.
+ * Configuration can be changed via various command line switches.
  * 
  * @author Pavel Tisnovsky
  */
@@ -62,7 +62,7 @@
     protected Log log;
 
     /**
-     * Constructor called with array containing command line arguments.
+     * Constructor called with an array containing command line arguments.
      * 
      * @param args
      *            command line arguments
@@ -80,26 +80,42 @@
         printParameters();
     }
 
+    /**
+     * Implementation of this abstract method should reads and process all
+     * command line parameters.
+     * 
+     * @param args
+     *            command line arguments
+     */
     protected abstract void readCommandLineParameters(String[] args) throws ConfigurationException;
+
+    /**
+     * Implementation of this abstract method should prints all test suite
+     * parameters.
+     */
     protected abstract void printParameters();
 
     /**
-     * Method for get value of parameter which has integer value.
+     * Method for get value of parameter which has an integer type.
      * 
      * @param options
-     *            map containing all parameters
+     *            map containing all configuration parameters
      * @param parameterName
      *            parameter name
      * @return integer value of selected parameter
      * @throws ConfigurationException
+     *             thrown if parameter is not found or has wrong value
      */
     protected int getIntegerParameter(Map<String, String> options, String parameterName) throws ConfigurationException
     {
+        // check if parameter map contains parameter with given name
         if (!options.containsKey(parameterName))
         {
             throw new ParameterNotFoundException(parameterName);
         }
+        // get a value of a parameter
         String parameterValue = options.get(parameterName);
+        // and parse it as integer
         try
         {
             return Integer.parseInt(parameterValue);
@@ -111,18 +127,20 @@
     }
 
     /**
-     * Method for get value of parameter which has string value.
+     * Method for get value of parameter which has a string type.
      * 
      * @param options
-     *            map containing all parameters
+     *            map containing all configuration parameters
      * @param parameterName
      *            parameter name
      * @return string value of selected parameter
      * @throws ConfigurationException
+     *             thrown if parameter is not found or has wrong value
      */
     protected String getStringParameter(Map<String, String> options, String parameterName)
                     throws ConfigurationException
     {
+        // check if parameter map contains parameter with given name
         if (!options.containsKey(parameterName))
         {
             throw new ParameterNotFoundException(parameterName);
@@ -134,20 +152,25 @@
      * Resolve all configuration options, ie. parse it and push it to a map.
      * 
      * @param args
-     *            command line parameters
+     *            command line arguments
      * @return map containing all parameters
      */
     @SuppressWarnings("nls")
     protected Map<String, String> resolveAllOptions(String[] args)
     {
         Map<String, String> options = new HashMap<String, String>();
+        // loop over all command line arguments
         for (String arg : args)
         {
+            // quick and dirty parsing of command line parameters
+            // param is split at '=' symbol
             String[] splittedArg = arg.split("=");
             if (splittedArg.length >= 1 && splittedArg[0].length() >= 2)
             {
                 this.log.log("found option " + arg);
+                // get parameter name
                 String optionName = splittedArg[0].substring(1);
+                // get parameter value
                 String optionValue = splittedArg.length == 2 ? splittedArg[1] : "true";
                 options.put(optionName, optionValue);
             }
diff -r b26c11e47283 -r 0594d3a7c745 src/org/gfxtest/common/ConfigurationException.java
--- a/src/org/gfxtest/common/ConfigurationException.java	Wed Apr 04 11:57:23 2012 +0200
+++ b/src/org/gfxtest/common/ConfigurationException.java	Fri Apr 06 13:03:55 2012 +0200
@@ -1,7 +1,7 @@
 /*
   Java gfx-test framework
 
-   Copyright (C) 2010, 2011  Red Hat
+   Copyright (C) 2010, 2011, 2012  Red Hat
 
 This file is part of IcedTea.
 
@@ -40,19 +40,37 @@
 
 package org.gfxtest.common;
 
+
+
 /**
+ * This exception is thrown in case of any configuration problem.
  * 
  * @author Pavel Tisnovsky
  */
 public abstract class ConfigurationException extends Exception
 {
     /**
-     * Generated serial version ID
+     * Generated serial version ID.
      */
     private static final long serialVersionUID = -2168810923554713703L;
 
+    /**
+     * Disable implicit constructor.
+     */
+    @SuppressWarnings("unused")
+    private ConfigurationException()
+    {
+        // empty
+    }
+
+    /**
+     * Constructor for this type of exception.
+     *
+     * @param message the detail message
+     */
     public ConfigurationException(String message)
     {
+        // simply pass detail message
         super(message);
     }
 }
diff -r b26c11e47283 -r 0594d3a7c745 src/org/gfxtest/common/InvalidParameterValueException.java
--- a/src/org/gfxtest/common/InvalidParameterValueException.java	Wed Apr 04 11:57:23 2012 +0200
+++ b/src/org/gfxtest/common/InvalidParameterValueException.java	Fri Apr 06 13:03:55 2012 +0200
@@ -41,20 +41,31 @@
 package org.gfxtest.common;
 
 
+
 /**
+ * This exception is thrown when any configuration parameter (specified on
+ * command line) has wrong value.
  * 
  * @author Pavel Tisnovsky
  */
 public class InvalidParameterValueException extends ConfigurationException
 {
     /**
-     * Genereated serial version ID.
+     * Generated serial version ID.
      */
     private static final long serialVersionUID = 3027080845460577282L;
 
+    /**
+     * Constructor for this type of exception.
+     * 
+     * @param parameterName
+     *            name of parameter which has wrong value
+     * @param value
+     *            (wrong) value of parameter specified on command line
+     */
     public InvalidParameterValueException(String parameterName, String value)
     {
+        // create and pass detail message
         super("invalid value of parameter " + parameterName + ": " + value); //$NON-NLS-1$ //$NON-NLS-2$
     }
-
 }



More information about the distro-pkg-dev mailing list