ConsoleEngine, CommandRegistry, Printerpublic class ConsoleEngineImpl extends JlineCommandRegistry implements ConsoleEngine, Printer
| Modifier and Type | Class | Description |
|---|---|---|
static class |
ConsoleEngineImpl.Command |
CommandRegistry.CommandSessionConsoleEngine.ExecutionResult, ConsoleEngine.WidgetCreatorALL, BOOLEAN_KEYS, COLUMNS, COLUMNS_IN, COLUMNS_OUT, EXCLUDE, HIGHLIGHT_VALUE, INCLUDE, INDENTION, MAP_SIMILARITY, MAX_COLUMN_WIDTH, MAX_DEPTH, MAXROWS, OBJECT_TO_MAP, OBJECT_TO_STRING, ONE_ROW_TABLE, ROWNUM, SHORT_NAMES, SKIP_DEFAULT_OPTIONS, STRUCT_ON_TABLE, STYLE, TO_STRING, VALUE_STYLE, WIDTH| Constructor | Description |
|---|---|
ConsoleEngineImpl(Set<ConsoleEngineImpl.Command> commands,
ScriptEngine engine,
Supplier<Path> workDir,
ConfigurationPath configPath) |
|
ConsoleEngineImpl(ScriptEngine engine,
Supplier<Path> workDir,
ConfigurationPath configPath) |
| Modifier and Type | Method | Description |
|---|---|---|
<T> T |
consoleOption(String option,
T defval) |
Read console option value
|
Object |
execute(File script,
String cmdLine,
String[] args) |
Executes either JLine or ScriptEngine script.
|
Object |
execute(String cmd,
String line,
String[] args) |
Executes command line that does not contain known command by the system registry.
|
boolean |
executeWidget(Object function) |
Execute widget function
|
String |
expandCommandLine(String line) |
Substitutes command line with system registry invoke method call.
|
Object[] |
expandParameters(String[] args) |
Substituting args references with their values.
|
String |
expandToList(List<String> params) |
Expands parameter list to string
|
String |
getAlias(String name) |
Returns alias 'name' value
|
List<String> |
getNamedPipes() |
Returns named pipe names
|
Map<String,List<String>> |
getPipes() |
Returns defined pipes
|
Object |
getVariable(String name) |
Get variable value
|
boolean |
hasAlias(String name) |
Returns true if alias 'name' exists
|
boolean |
hasVariable(String name) |
Test if variable with name exists
|
Object |
invoke(CommandRegistry.CommandSession session,
String command,
Object... args) |
|
boolean |
isExecuting() |
|
void |
persist(Path file,
Object object) |
Persist object to file
|
ConsoleEngine.ExecutionResult |
postProcess(Object result) |
Post processes execution result.
|
ConsoleEngine.ExecutionResult |
postProcess(String line,
Object result,
String output) |
Post processes execution result.
|
void |
println(Object object) |
Print object.
|
void |
println(Map<String,Object> options,
Object object) |
Print object.
|
void |
purge() |
Delete temporary console variables
|
void |
putVariable(String name,
Object value) |
Create console variable
|
List<Completer> |
scriptCompleters() |
Returns script and variable completers
|
Map<String,Boolean> |
scripts() |
Returns all scripts found from PATH
|
void |
setHighlightValue(Map<String,Function<Object,org.jline.utils.AttributedString>> highlightValue) |
Highlight column value
|
void |
setLineReader(LineReader reader) |
Sets lineReader
|
void |
setObjectToMap(Map<Class<?>,Function<Object,Map<String,Object>>> objectToMap) |
Override ScriptEngine toMap() method
|
void |
setObjectToString(Map<Class<?>,Function<Object,String>> objectToString) |
Override ScriptEngine toString() method
|
void |
setScriptExtension(String extension) |
Sets file name extension used by console scripts
|
void |
setSystemRegistry(SystemRegistry systemRegistry) |
Sets systemRegistry
|
Object |
slurp(Path file) |
Read object from file
|
void |
trace(Object object) |
commandDescription, commandInfo, commandOptions, compileCommandDescription, compileCommandInfo, compileCommandOptions, defaultCompleter, parseOptionsalias, commandAliases, commandNames, compileCompleters, doHelpDesc, execute, getCommandMethods, hasCommand, registerCommands, registerCommands, registeredCommand, rename, saveExceptionclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcommandAliases, commandDescription, commandDescription, commandInfo, commandNames, compileCompleters, execute, hasCommand, nameexecutepublic ConsoleEngineImpl(ScriptEngine engine, Supplier<Path> workDir, ConfigurationPath configPath) throws IOException
IOExceptionpublic ConsoleEngineImpl(Set<ConsoleEngineImpl.Command> commands, ScriptEngine engine, Supplier<Path> workDir, ConfigurationPath configPath) throws IOException
IOExceptionpublic void setObjectToMap(Map<Class<?>,Function<Object,Map<String,Object>>> objectToMap)
objectToMap - key: object class, value: toMap functionpublic void setObjectToString(Map<Class<?>,Function<Object,String>> objectToString)
objectToString - key: object class, value: toString functionpublic void setHighlightValue(Map<String,Function<Object,org.jline.utils.AttributedString>> highlightValue)
highlightValue - key: regex for column name, value: highlight functionpublic void setLineReader(LineReader reader)
ConsoleEnginesetLineReader in interface ConsoleEnginereader - LineReaderpublic boolean isExecuting()
isExecuting in interface ConsoleEnginepublic void setSystemRegistry(SystemRegistry systemRegistry)
ConsoleEnginesetSystemRegistry in interface ConsoleEnginesystemRegistry - SystemRegistrypublic void setScriptExtension(String extension)
ConsoleEnginesetScriptExtension in interface ConsoleEngineextension - console script file extensionpublic boolean hasAlias(String name)
ConsoleEnginehasAlias in interface ConsoleEnginename - alias namepublic String getAlias(String name)
ConsoleEnginegetAlias in interface ConsoleEnginename - alias namepublic Map<String,List<String>> getPipes()
ConsoleEnginegetPipes in interface ConsoleEnginepublic List<String> getNamedPipes()
ConsoleEnginegetNamedPipes in interface ConsoleEnginepublic List<Completer> scriptCompleters()
ConsoleEnginescriptCompleters in interface ConsoleEnginepublic Map<String,Boolean> scripts()
ConsoleEnginescripts in interface ConsoleEnginepublic Object[] expandParameters(String[] args) throws Exception
ConsoleEngineexpandParameters in interface ConsoleEngineargs - the arguments to be expandedException - in case of errorpublic String expandToList(List<String> params)
ConsoleEngineexpandToList in interface ConsoleEngineparams - list of script parameterspublic Object execute(File script, String cmdLine, String[] args) throws Exception
ConsoleEngineexecute in interface ConsoleEnginescript - script filecmdLine - raw command lineargs - script argumentsException - in case of errorpublic String expandCommandLine(String line)
ConsoleEngineexpandCommandLine in interface ConsoleEngineline - command line to be expandedpublic Object execute(String cmd, String line, String[] args) throws Exception
ConsoleEngineexecute in interface ConsoleEnginecmd - parsed command/script nameline - raw command lineargs - parsed arguments of the commandException - in case of errorpublic void purge()
ConsoleEnginepurge in interface ConsoleEnginepublic void putVariable(String name, Object value)
ConsoleEngineputVariable in interface ConsoleEnginename - name of the variablevalue - value of the variablepublic Object getVariable(String name)
ConsoleEnginegetVariable in interface ConsoleEnginename - name of the variablepublic boolean hasVariable(String name)
ConsoleEnginehasVariable in interface ConsoleEnginename - name of the variablepublic boolean executeWidget(Object function)
ConsoleEngineexecuteWidget in interface ConsoleEnginefunction - to executepublic <T> T consoleOption(String option, T defval)
ConsoleEngineconsoleOption in interface ConsoleEngineT - option typeoption - option namedefval - default valuepublic ConsoleEngine.ExecutionResult postProcess(String line, Object result, String output)
ConsoleEnginepostProcess in interface ConsoleEngineline - command lineresult - command result to processoutput - command redirected outputpublic ConsoleEngine.ExecutionResult postProcess(Object result)
ConsoleEnginepostProcess in interface ConsoleEngineresult - command result to processpublic Object invoke(CommandRegistry.CommandSession session, String command, Object... args) throws Exception
invoke in interface CommandRegistryinvoke in class AbstractCommandRegistryExceptionpublic void trace(Object object)
trace in interface ConsoleEngineobject - object to printpublic void println(Object object)
ConsoleEngineprintln in interface ConsoleEngineprintln in interface Printerobject - object to printpublic void println(Map<String,Object> options, Object object)
ConsoleEngineprintln in interface ConsoleEngineprintln in interface Printeroptions - println optionsobject - object to printpublic void persist(Path file, Object object)
ConsoleEnginepersist in interface ConsoleEnginefile - file where object should be writtenobject - object to persistpublic Object slurp(Path file) throws IOException
ConsoleEngineslurp in interface ConsoleEnginefile - file from where object should be readIOException - in case of errorCopyright © 2020. All rights reserved.