package privacyfriendlyshoppinglist.secuso.org.privacyfriendlyshoppinglist.framework.utils;

import java.text.DecimalFormat;
import java.text.ParseException;

/**
 * Description:
 * Author: Grebiel Jose Ifill Brito
 * Created: 12.06.16 creation date
 */
public abstract class StringUtils
{

    private static final String EMPTY = "";

    public static boolean isEmpty(String string)
    {
        return string == null || string.isEmpty();
    }

    public static String getDoubleAsString(double number, String format)
    {
        String numberAsString;
        try
        {
            DecimalFormat df = new DecimalFormat(format);
            numberAsString = df.format(number);
        }
        catch ( Exception e )
        {
            numberAsString = EMPTY;
        }
        return numberAsString;
    }

    public static Double getStringAsDouble(String numberAsString, String format)
    {
        DecimalFormat df = new DecimalFormat(format);
        try
        {
            Number parse = df.parse(numberAsString);
            return parse.doubleValue();

        }
        catch ( ParseException e )
        {
            return 0.0;
        }
    }

    public static Double getStringAsDouble(String productPrice, String priceFormat2, String priceFormat1, String priceFormat0)
    {
        Double stringAsDouble;
        try
        {

            stringAsDouble = StringUtils.getStringAsDouble(productPrice, priceFormat2);
        }
        catch ( Exception e1 )
        {
            try
            {
                stringAsDouble = StringUtils.getStringAsDouble(productPrice, priceFormat1);
            }
            catch ( Exception e2 )
            {
                try
                {
                    stringAsDouble = StringUtils.getStringAsDouble(productPrice, priceFormat0);
                }
                catch ( Exception e3 )
                {
                    stringAsDouble = 0.0;
                }
            }
        }

        return stringAsDouble;
    }
}

@@ -1070,17 +1070,16 @@
 alue();%0A
-%0A
         
@@ -1072,32 +1072,246 @@
 ue();%0A        %7D%0A
+%0A        catch ( ParseException e )%0A        %7B%0A            try%0A            %7B%0A                Number parse = df.parse(numberAsString.replace(%22.%22, %22,%22));%0A                return parse.doubleValue();%0A            %7D%0A%0A    
         catch ( 
@@ -1318,32 +1318,33 @@
 ParseException e
+1
  )%0A        %7B%0A   
@@ -1330,34 +1330,42 @@
 on e1 )%0A        
-%7B%0A
+    %7B%0A    
             retu
@@ -1368,24 +1368,38 @@
 return 0.0;%0A
+            %7D%0A
         %7D%0A  

Fix Price Input