Package jp.vmi.selenium.selenese.command

Source Code of jp.vmi.selenium.selenese.command.Store

package jp.vmi.selenium.selenese.command;

import java.util.Arrays;

import org.apache.commons.lang3.ArrayUtils;

import jp.vmi.selenium.selenese.Context;
import jp.vmi.selenium.selenese.result.Result;
import jp.vmi.selenium.selenese.result.Success;
import jp.vmi.selenium.selenese.subcommand.ISubCommand;
import jp.vmi.selenium.selenese.utils.SeleniumUtils;

import static jp.vmi.selenium.selenese.command.ArgumentType.*;

/**
* Command "store".
*/
public class Store extends AbstractCommand {

    private final ISubCommand<?> getterSubCommand;

    Store(int index, String name, String[] args, ISubCommand<?> getterSubCommand) {
        super(index, name, args, ArrayUtils.add(getterSubCommand.getArgumentTypes(), VALUE));
        this.getterSubCommand = getterSubCommand;
    }

    @Override
    public boolean mayUpdateScreen() {
        return false;
    }

    @Override
    protected Result executeImpl(Context context, String... curArgs) {
        int argLen = getterSubCommand.getArgumentTypes().length;
        String varName = curArgs[argLen];
        Object result = getterSubCommand.execute(context, Arrays.copyOf(curArgs, argLen));
        context.getVarsMap().put(varName, result);
        return new Success(SeleniumUtils.convertToString(result));
    }
}
TOP

Related Classes of jp.vmi.selenium.selenese.command.Store

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.