Class EngineConsole
java.lang.Object
com.blackrook.engine.EngineConsole
The manager that can call and get/set elements available to the console.
- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMapping for console commands to methods.static classMapping for console variables to methods. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEntries(Object instance, boolean debug) Adds the entries for commands and variables to the console manager.callCommand(String name, Object... args) Calls a command.voidbooleancontainsCommand(String name) Checks if a command exists.booleancontainsVariable(String name) Checks if a variable exists by name.voidvoidgetCommandDefinition(String name) Gets a command definition.intReturns the length of the command with the longest name.String[]Gets all of the command names known to the console.String[]getCommandNamesForPrefix(String prefix) Returns all command names that start with a string.getVariable(String name) Gets the value of a variable by name.<T> TgetVariable(String name, Class<T> type) Gets the value of a variable by name, converted to a value type.getVariableDefinition(String name) Gets a variable definition.intReturns the length of the variable with the longest name.String[]Gets all of the variable names known to the console.String[]getVariableNamesForPrefix(String prefix) Returns all variable names that start with a string.voidloadGlobalVariables(Properties settings) Sets all variables and their values using the entries on aPropertiesobject.voidloadUserVariables(Properties settings) Sets all variables and their values using the entries on aPropertiesobject.voidparseCommand(String commandString) Parses a command.voidPrints a message to the engine console.voidPrints a formatted message to the console.voidPrints a formatted message to the console with a newline appended to it.voidprintln()Prints a newline.voidPrints a message to the console with a newline appended to it.voidprocessCommand(String commandString) Processes a single command.voidquit(int status) voidsaveGlobalVariables(Properties settings) Puts all global variables and their values into aPropertiesobject.voidsaveUserVariables(Properties settings) Puts all user variables and their values into aPropertiesobject.voidsetVariable(String name, Object value) Sets the value of a variable.
-
Method Details
-
addEntries
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
Checks if a variable exists by name.- Parameters:
name- the name of the variable.- Returns:
- true if it exists, false if not.
-
getVariableNames
Gets all of the variable names known to the console.- Returns:
- all variable names in an array.
-
getVariableNamesForPrefix
-
loadUserVariables
Sets all variables and their values using the entries on aPropertiesobject.- Parameters:
settings- the properties object to set variable values on.- See Also:
-
loadGlobalVariables
Sets all variables and their values using the entries on aPropertiesobject.- Parameters:
settings- the properties object to set variable values on.- See Also:
-
saveUserVariables
Puts all user variables and their values into aPropertiesobject. This is called when variables need to be saved to storage.- Parameters:
settings- the properties object to set variable values on.- See Also:
-
saveGlobalVariables
Puts all global variables and their values into aPropertiesobject. This is called when variables need to be saved to storage.- Parameters:
settings- the properties object to set variable values on.- See Also:
-
getVariableDefinition
Gets a variable definition.- Parameters:
name- the name of the variable.- Returns:
- the variable mapping object for a variable.
-
getVariable
-
getVariable
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
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
Checks if a command exists.- Parameters:
name- the name of the command.- Returns:
- true if it exists, false if not.
-
getCommandNames
Gets all of the command names known to the console.- Returns:
- all command names in an array.
-
getCommandNamesForPrefix
-
getCommandDefinition
Gets a command definition.- Parameters:
name- the name of the command.- Returns:
- the command mapping object for a command.
-
callCommand
-
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
Parses a command. Can execute multiple commands at once.- Parameters:
commandString- the typed command to parse/process.
-
processCommand
Processes a single command.- Parameters:
commandString- the command string to process.
-
print
Prints a message to the engine console.- Parameters:
object- the message to print (seeString.valueOf(Object)).
-
printf
Prints a formatted message to the console.- Parameters:
formatting- the format text (seeString.format(String, Object...)).args- the arguments to use.
-
println
Prints a message to the console with a newline appended to it.- Parameters:
object- the message to print (seeString.valueOf(Object)).
-
println
public void println()Prints a newline. -
printfln
Prints a formatted message to the console with a newline appended to it.- Parameters:
formatting- the format text (seeString.format(String, Object...)).args- the message to print (seeString.valueOf(Object)).
-
quit
public void quit(int status) -
echo
-
cvarList
-
cmdList
-
getJavaVersion
-
getJavaVendor
-
getJavaVMName
-
getJavaClasspath
-
getJavaLibraryPath
-
getOSName
-
getOSVersion
-
getOSArchitecture
-
getWorkingDirectory
-
getApplicationDataDirectory
-
getHomeDirectory
-