// Decompiled by DJ v2.6.6.51 Copyright 2000 Atanas Neshkov  Date: 10/2/2001 11:01:02
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   com/macromedia/generator/utils/PropertyParser

package com.macromedia.generator.utils;

import com.macromedia.generator.api.Context;
import com.macromedia.generator.app.FlashEnvironment;
import java.util.*;

public class PropertyParser
{

    public PropertyParser(String s, FlashEnvironment flashenvironment, Context context, Properties properties)
    {
        _fld0160 = flashenvironment;
        _fld0144 = context;
        _fld0145 = properties;
        _fld028B = s.concat("Data");
        _fld028C = false;
    }

    public FlashEnvironment GetEnvironment()
    {
        return _fld0160;
    }

    public float GetFloatParam(String s, float f)
    {
        float f1 = f;
        String s1 = GetStringParam(s);
        if(!_fld028A)
            return f1;
        try
        {
            f1 = Float.valueOf(s1).floatValue();
        }
        catch(NumberFormatException _ex)
        {
            _fld028A = false;
            f1 = f;
        }
        return f1;
    }

    public int GetIntParam(String s, int i)
    {
        int j = i;
        String s1 = GetStringParam(s);
        if(!_fld028A)
            return j;
        try
        {
            j = Integer.valueOf(s1).intValue();
        }
        catch(NumberFormatException _ex)
        {
            _fld028A = false;
        }
        return j;
    }

    public String GetResourceString(String s)
    {
        ResourceBundle resourcebundle = ResourceBundle.getBundle(_fld028B, Locale.getDefault());
        return resourcebundle.getString(s);
    }

    public String GetStringParam(String s)
    {
        String s1 = null;
        String s2 = _fld0145.getProperty(s, null);
        if(s2 == null)
        {
            _fld028A = false;
            LogError("InvalidParamName", s);
        } else
        {
            s1 = _fld0144.apply(s2);
            _fld028A = true;
        }
        return s1;
    }

    public String GetStringParam(String s, String s1)
    {
        String s2 = null;
        String s3 = _fld0145.getProperty(s, null);
        if(s3 == null)
        {
            _fld028A = false;
            LogError("InvalidParamName", s);
            s2 = s1;
        } else
        {
            s2 = _fld0144.apply(s3);
            _fld028A = true;
        }
        return s2;
    }

    public boolean HasParam(String s)
    {
        String s1 = _fld0145.getProperty(s, null);
        return s1 != null && s1 != "";
    }

    public void LogError(String s, String s1)
    {
        if(_fld028C)
            _fld0160.logError(_fld028B, s, s1);
    }

    public boolean ParamEquals(String s, int i)
    {
        boolean flag = true;
        int j = GetIntParam(s, 0);
        if(!_fld028A)
            return false;
        else
            return j == i;
    }

    public boolean ParamEquals(String s, String s1)
    {
        boolean flag = true;
        String s2 = GetStringParam(s);
        if(!_fld028A)
        {
            return false;
        } else
        {
            String s3 = GetResourceString(s1);
            boolean flag1 = s2.equalsIgnoreCase(s3);
            return flag1;
        }
    }

    public void SetErrorLog(boolean flag)
    {
        _fld028C = flag;
    }

    public boolean Suceeded()
    {
        return _fld028A;
    }

    boolean _fld028A;
    Properties _fld0145;
    FlashEnvironment _fld0160;
    Context _fld0144;
    String _fld028B;
    boolean _fld028C;
}