Package org.jline.console.impl
Class DefaultPrinter
- java.lang.Object
-
- org.jline.console.impl.AbstractCommandRegistry
-
- org.jline.console.impl.JlineCommandRegistry
-
- org.jline.console.impl.DefaultPrinter
-
- All Implemented Interfaces:
CommandRegistry
,Printer
public class DefaultPrinter extends JlineCommandRegistry implements Printer
Print highlighted objects to console.- Author:
- Matti Rinta-Nikkola
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jline.console.CommandRegistry
CommandRegistry.CommandSession
-
Nested classes/interfaces inherited from interface org.jline.console.Printer
Printer.TableRows
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
PRNT_INDENTION
protected static int
PRNT_MAX_DEPTH
protected static int
PRNT_MAX_ROWS
protected static java.lang.String
VAR_PRNT_OPTIONS
-
Fields inherited from interface org.jline.console.Printer
ALL, BOOLEAN_KEYS, BORDER, COLUMNS, COLUMNS_IN, COLUMNS_OUT, EXCLUDE, HIGHLIGHT_VALUE, INCLUDE, INDENTION, MAP_SIMILARITY, MAX_COLUMN_WIDTH, MAX_DEPTH, MAXROWS, MULTI_COLUMNS, OBJECT_TO_MAP, OBJECT_TO_STRING, ONE_ROW_TABLE, ROW_HIGHLIGHT, ROWNUM, SHORT_NAMES, SKIP_DEFAULT_OPTIONS, STRUCT_ON_TABLE, STYLE, TO_STRING, VALUE_STYLE, VALUE_STYLE_ALL, WIDTH
-
-
Constructor Summary
Constructors Constructor Description DefaultPrinter(org.jline.builtins.ConfigurationPath configPath)
DefaultPrinter(ScriptEngine engine, org.jline.builtins.ConfigurationPath configPath)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String[]
appendUsage(java.lang.String[] customUsage)
java.util.Map<java.lang.String,java.lang.Object>
compileOptions(org.jline.builtins.Options opt)
protected java.util.Map<java.lang.String,java.lang.Object>
defaultPrntOptions(boolean skipDefault)
Set default and mandatory printing options.protected void
highlightAndPrint(java.util.Map<java.lang.String,java.lang.Object> options, java.lang.Throwable exception)
Highlight and print an exceptionprotected void
manageBooleanOptions(java.util.Map<java.lang.String,java.lang.Object> options)
Boolean printing options Printer checks only if key is present.void
println(java.lang.Object object)
void
println(java.util.Map<java.lang.String,java.lang.Object> optionsIn, java.lang.Object object)
java.lang.Exception
prntCommand(CommandInput input)
boolean
refresh()
Clear printer syntax highlighter cachevoid
setHighlightValue(java.util.Map<java.lang.String,java.util.function.Function<java.lang.Object,org.jline.utils.AttributedString>> highlightValue)
Highlight column valuevoid
setObjectToMap(java.util.Map<java.lang.Class<?>,java.util.function.Function<java.lang.Object,java.util.Map<java.lang.String,java.lang.Object>>> objectToMap)
Override ScriptEngine toMap() methodvoid
setObjectToString(java.util.Map<java.lang.Class<?>,java.util.function.Function<java.lang.Object,java.lang.String>> objectToString)
Override ScriptEngine toString() methodprotected org.jline.terminal.Terminal
terminal()
-
Methods inherited from class org.jline.console.impl.JlineCommandRegistry
commandDescription, commandInfo, commandOptions, compileCommandDescription, compileCommandInfo, compileCommandOptions, defaultCompleter, parseOptions
-
Methods inherited from class org.jline.console.impl.AbstractCommandRegistry
alias, commandAliases, commandNames, compileCompleters, doHelpDesc, getCommandMethods, hasCommand, invoke, registerCommands, registerCommands, registeredCommand, rename, saveException
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jline.console.CommandRegistry
name
-
-
-
-
Field Detail
-
VAR_PRNT_OPTIONS
protected static final java.lang.String VAR_PRNT_OPTIONS
- See Also:
- Constant Field Values
-
PRNT_MAX_ROWS
protected static final int PRNT_MAX_ROWS
- See Also:
- Constant Field Values
-
PRNT_MAX_DEPTH
protected static final int PRNT_MAX_DEPTH
- See Also:
- Constant Field Values
-
PRNT_INDENTION
protected static final int PRNT_INDENTION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultPrinter
public DefaultPrinter(org.jline.builtins.ConfigurationPath configPath)
-
DefaultPrinter
public DefaultPrinter(ScriptEngine engine, org.jline.builtins.ConfigurationPath configPath)
-
-
Method Detail
-
println
public void println(java.util.Map<java.lang.String,java.lang.Object> optionsIn, java.lang.Object object)
-
refresh
public boolean refresh()
Description copied from interface:Printer
Clear printer syntax highlighter cache
-
appendUsage
public java.lang.String[] appendUsage(java.lang.String[] customUsage)
-
compileOptions
public java.util.Map<java.lang.String,java.lang.Object> compileOptions(org.jline.builtins.Options opt)
-
prntCommand
public java.lang.Exception prntCommand(CommandInput input)
- Specified by:
prntCommand
in interfacePrinter
-
setObjectToMap
public void setObjectToMap(java.util.Map<java.lang.Class<?>,java.util.function.Function<java.lang.Object,java.util.Map<java.lang.String,java.lang.Object>>> objectToMap)
Override ScriptEngine toMap() method- Parameters:
objectToMap
- key: object class, value: toMap function
-
setObjectToString
public void setObjectToString(java.util.Map<java.lang.Class<?>,java.util.function.Function<java.lang.Object,java.lang.String>> objectToString)
Override ScriptEngine toString() method- Parameters:
objectToString
- key: object class, value: toString function
-
setHighlightValue
public void setHighlightValue(java.util.Map<java.lang.String,java.util.function.Function<java.lang.Object,org.jline.utils.AttributedString>> highlightValue)
Highlight column value- Parameters:
highlightValue
- key: regex for column name, value: highlight function
-
terminal
protected org.jline.terminal.Terminal terminal()
- Returns:
- terminal to which will be printed
-
manageBooleanOptions
protected void manageBooleanOptions(java.util.Map<java.lang.String,java.lang.Object> options)
Boolean printing options Printer checks only if key is present. Boolean options that have false value are removed from the options Map.- Parameters:
options
- printing options
-
defaultPrntOptions
protected java.util.Map<java.lang.String,java.lang.Object> defaultPrntOptions(boolean skipDefault)
Set default and mandatory printing options. Also unsupported options will be removed when Printer is used without scriptEngine- Parameters:
skipDefault
- when true does not set default options- Returns:
- default, mandatory and supported options
-
highlightAndPrint
protected void highlightAndPrint(java.util.Map<java.lang.String,java.lang.Object> options, java.lang.Throwable exception)
Highlight and print an exception- Parameters:
options
- Printing optionsexception
- Exception to be printed
-
-