// Decompiled by DJ v2.6.6.51 Copyright 2000 Atanas Neshkov  Date: 6/15/2001 17:06:31
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   com/macromedia/generator/commands/SetEnvironment2Command

package com.macromedia.generator.commands;

import com.macromedia.generator.api.Context;
import com.macromedia.generator.api.Script;
import com.macromedia.generator.app.*;
import com.macromedia.generator.utils.DataSourceTokenizer;
import java.util.Properties;

public class SetEnvironment2Command extends GenericCommand
{

    public SetEnvironment2Command()
    {
    }

    public void doCommand(FlashEnvironment flashenvironment, Script script, Context context, int i, Properties properties)
        throws FlashCommandException
    {
        String s = null;
        s = properties.getProperty("datasource", "");
        s = context.apply(s);
        DataSourceTokenizer datasourcetokenizer = new DataSourceTokenizer(s);
        UrlDataSource urldatasource = new UrlDataSource();
        urldatasource.setEnvironment(flashenvironment);
        for(String s1 = datasourcetokenizer.nextDataSource(); s1 != null; s1 = datasourcetokenizer.nextDataSource())
        {
            String as[][] = urldatasource.getData(s1);
            if(as == null)
            {
                logError(flashenvironment, "DataSourceError", s);
                return;
            }
            if(as.length < 2)
            {
                logError(flashenvironment, "DataSourceFormatError", s);
                return;
            }
            for(int j = 0; j < as[1].length; j++)
                context.setValue(as[0][j], as[1][j]);

        }

    }
}