package background.commands;

import java.util.ArrayList;
import java.util.HashMap;

import background.CommandManager;
import background.ExpressionInterpreter;
import background.VariableManager;
import background.expressions.MathTree;

public class Command {
	public ArrayList<Command> innerCommands = null;
	public Boolean vizualize = true;
	public VariableManager variableManager;
	public ExpressionInterpreter expressionInterpreter;
	public CommandManager commandManager;
	public HashMap<String, String> params = new HashMap<String, String>();
	public String codeLine = "";
 	
	public MathTree index;
	public MathTree index2;

	
	public Command(CommandManager cm) {
		commandManager = cm;
		variableManager = commandManager.variableManager;
		expressionInterpreter = commandManager.expressionInterpreter;
	}
	
	public Command(Boolean viz, CommandManager cm) {
		commandManager = cm;
		variableManager = commandManager.variableManager;
		expressionInterpreter = commandManager.expressionInterpreter;
		vizualize = viz;
	}
	
	public void setCodeLine(String s) {
		codeLine = s;
	}
	
	public void recognizeData(String s) {
	}
	
	public void applyCommand() {		
		if (innerCommands!=null) {
			addInnerCommands();				
		}	
		
	}
	
	public void addInnerCommands() {
		for (int i=innerCommands.size()-1; i>=0; i--) {			
			commandManager.appendCommand(innerCommands.get(i));	
			if (!this.vizualize) {										// ak som vizualizovany ja, tak moje vnutro ma na vyber podla seba; ak nie, tak nie su ani oni
				innerCommands.get(i).vizualize = false;
			}
		}
	}

	
	public String getType() {
		return "";
	}
	
	public void setIndex(String s) {
		index = expressionInterpreter.getMath(s);
	}
	
	public void setIndex2(String s) {
		index2 = expressionInterpreter.getMath(s);
	}
			
}
