All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jio.console.State Maven / Gradle / Ivy

There is a newer version: 3.0.0-RC2
Show newest version
package jio.console;

import jio.IO;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Represents the state of the console, including variables, command history, and command results. The state keeps track
 * of variables, lists, and maps, and maintains a history of executed commands and their results.
 */
public class State {

  final List> historyCommands = new ArrayList<>();

  final List historyResults = new ArrayList<>();
  /**
   * Map with variables and their string values. The special variable "OUTPUT" stores the result of the execution of the
   * last command.
   */
  public final Map variables = new HashMap<>();
  /**
   * map with variables and their associated list. Some commands need to store values in a list
   */
  public final Map> listsVariables = new HashMap<>();

  /**
   * Gets the command action (JIO effect) at the specified index in the command history.
   *
   * @param index the index of the command in the history
   * @return the command action as a JIO effect
   */
  public IO getHistoryCommand(int index) {
    return historyCommands.get(index);
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy