You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Jacques Le Roux <ja...@les7arts.com> on 2010/01/27 20:41:54 UTC

Re: svn commit: r903766 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java

Thanks Adam,

I had intuitively a repulsion about this fixed value, but did not take the time to really think about it (mostly because there was 
already one in the class). It's clear now.

Jacques

> Author: doogie
> Date: Wed Jan 27 17:55:13 2010
> New Revision: 903766
>
> URL: http://svn.apache.org/viewvc?rev=903766&view=rev
> Log:
> Fix handling of default values in getPropertyNumber.
>
> Modified:
>    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java
>
> Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java
> URL: 
> http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java?rev=903766&r1=903765&r2=903766&view=diff
> ==============================================================================
> --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java (original)
> +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java Wed Jan 27 17:55:13 2010
> @@ -119,22 +119,20 @@
>     }
>
>     public static double getPropertyNumber(String resource, String name, double defaultValue) {
> -        double value = getPropertyNumber(resource, name);
> +        String str = getPropertyValue(resource, name);
> +        if (str == null) {
> +            return defaultValue;
> +        }
>
> -        if (value == 0.00000)
> +        try {
> +            return Double.parseDouble(str);
> +        } catch (NumberFormatException nfe) {
>             return defaultValue;
> -        else
> -            return value;
> +        }
>     }
>
>     public static double getPropertyNumber(String resource, String name) {
> -        String str = getPropertyValue(resource, name);
> -        double strValue = 0.00000;
> -
> -        try {
> -            strValue = Double.parseDouble(str);
> -        } catch (NumberFormatException nfe) {}
> -        return strValue;
> +        return getPropertyNumber(resource, name, 0.00000);
>     }
>
>     /** Returns the value of the specified property name from the specified resource/properties file
>
>