Class EngineConsole

java.lang.Object
com.blackrook.engine.EngineConsole

public class EngineConsole extends Object
The manager that can call and get/set elements available to the console.
Author:
Matthew Tropiano
  • Method Details

    • addEntries

      public void addEntries(Object instance, boolean debug)
      Adds the entries for commands and variables to the console manager.
      Parameters:
      instance - the object instance to inspect for commands and variables.
      debug - if true, add debug commands and variables.
    • containsVariable

      public boolean containsVariable(String name)
      Checks if a variable exists by name.
      Parameters:
      name - the name of the variable.
      Returns:
      true if it exists, false if not.
    • getVariableNames

      public String[] getVariableNames()
      Gets all of the variable names known to the console.
      Returns:
      all variable names in an array.
    • getVariableNamesForPrefix

      public String[] getVariableNamesForPrefix(String prefix)
      Returns all variable names that start with a string.
      Parameters:
      prefix - the start of the variable name.
      Returns:
      the matching variable names in an array.
    • loadUserVariables

      public void loadUserVariables(Properties settings)
      Sets all variables and their values using the entries on a Properties object.
      Parameters:
      settings - the properties object to set variable values on.
      See Also:
    • loadGlobalVariables

      public void loadGlobalVariables(Properties settings)
      Sets all variables and their values using the entries on a Properties object.
      Parameters:
      settings - the properties object to set variable values on.
      See Also:
    • saveUserVariables

      public void saveUserVariables(Properties settings)
      Puts all user variables and their values into a Properties object. This is called when variables need to be saved to storage.
      Parameters:
      settings - the properties object to set variable values on.
      See Also:
    • saveGlobalVariables

      public void saveGlobalVariables(Properties settings)
      Puts all global variables and their values into a Properties object. This is called when variables need to be saved to storage.
      Parameters:
      settings - the properties object to set variable values on.
      See Also:
    • getVariableDefinition

      public EngineConsole.CVARMapping getVariableDefinition(String name)
      Gets a variable definition.
      Parameters:
      name - the name of the variable.
      Returns:
      the variable mapping object for a variable.
    • getVariable

      public Object getVariable(String name)
      Gets the value of a variable by name.
      Parameters:
      name - the name of the variable.
      Returns:
      the value of the variable.
    • getVariable

      public <T> T getVariable(String name, Class<T> type)
      Gets the value of a variable by name, converted to a value type.
      Type Parameters:
      T - the return/conversion type.
      Parameters:
      name - the name of the variable.
      type - the target type.
      Returns:
      the value of the variable, converted.
      Throws:
      ClassCastException - if the read value cannot be converted.
    • setVariable

      public void setVariable(String name, Object value)
      Sets the value of a variable.
      Parameters:
      name - the name of the variable.
      value - the value to set.
      Throws:
      ConsoleVariableException - if the variable doesn't exist or the variable is read-only.
      ClassCastException - if the incoming value cannot be converted.
    • containsCommand

      public boolean containsCommand(String name)
      Checks if a command exists.
      Parameters:
      name - the name of the command.
      Returns:
      true if it exists, false if not.
    • getCommandNames

      public String[] getCommandNames()
      Gets all of the command names known to the console.
      Returns:
      all command names in an array.
    • getCommandNamesForPrefix

      public String[] getCommandNamesForPrefix(String prefix)
      Returns all command names that start with a string.
      Parameters:
      prefix - the start of the command name.
      Returns:
      the matching command names in an array.
    • getCommandDefinition

      public EngineConsole.CCMDMapping getCommandDefinition(String name)
      Gets a command definition.
      Parameters:
      name - the name of the command.
      Returns:
      the command mapping object for a command.
    • callCommand

      public Object callCommand(String name, Object... args)
      Calls a command.
      Parameters:
      name - the name of the command.
      args - the command arguments.
      Returns:
      the command return value.
    • getCommandLongestLength

      public int getCommandLongestLength()
      Returns the length of the command with the longest name.
      Returns:
      the length in characters.
    • getVariableLongestLength

      public int getVariableLongestLength()
      Returns the length of the variable with the longest name.
      Returns:
      the length in characters.
    • parseCommand

      public void parseCommand(String commandString)
      Parses a command. Can execute multiple commands at once.
      Parameters:
      commandString - the typed command to parse/process.
    • processCommand

      public void processCommand(String commandString)
      Processes a single command.
      Parameters:
      commandString - the command string to process.
    • print

      public void print(Object object)
      Prints a message to the engine console.
      Parameters:
      object - the message to print (see String.valueOf(Object)).
    • printf

      public void printf(String formatting, Object... args)
      Prints a formatted message to the console.
      Parameters:
      formatting - the format text (see String.format(String, Object...)).
      args - the arguments to use.
    • println

      public void println(Object object)
      Prints a message to the console with a newline appended to it.
      Parameters:
      object - the message to print (see String.valueOf(Object)).
    • println

      public void println()
      Prints a newline.
    • printfln

      public void printfln(String formatting, Object... args)
      Prints a formatted message to the console with a newline appended to it.
      Parameters:
      formatting - the format text (see String.format(String, Object...)).
      args - the message to print (see String.valueOf(Object)).
    • quit

      public void quit(int status)
    • echo

      public void echo(String text)
    • cvarList

      public void cvarList(String text)
    • cmdList

      public void cmdList(String prefix)
    • getJavaVersion

      public String getJavaVersion()
    • getJavaVendor

      public String getJavaVendor()
    • getJavaVMName

      public String getJavaVMName()
    • getJavaClasspath

      public String getJavaClasspath()
    • getJavaLibraryPath

      public String getJavaLibraryPath()
    • getOSName

      public String getOSName()
    • getOSVersion

      public String getOSVersion()
    • getOSArchitecture

      public String getOSArchitecture()
    • getWorkingDirectory

      public String getWorkingDirectory()
    • getApplicationDataDirectory

      public String getApplicationDataDirectory()
    • getHomeDirectory

      public String getHomeDirectory()