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
Default implementation of the Printer interface that provides syntax highlighting and formatting.
DefaultPrinter provides functionality for printing various types of objects to the console with syntax highlighting and formatting. It supports printing:
- Simple objects (strings, numbers, etc.)
- Collections and maps
- Tables with row highlighting
- JSON and other structured data
- Source code with syntax highlighting
The printer can be configured with various options to control the formatting and highlighting of the output, such as maximum number of rows, indentation, and highlighting styles.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jline.console.CommandRegistry
CommandRegistry.CommandSessionNested classes/interfaces inherited from interface org.jline.console.Printer
Printer.TableRows -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intprotected static final intprotected static final intprotected static final StringFields 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
ConstructorsConstructorDescriptionDefaultPrinter(ConfigurationPath configPath) DefaultPrinter(ScriptEngine engine, ConfigurationPath configPath) -
Method Summary
Modifier and TypeMethodDescriptionString[]appendUsage(String[] customUsage) compileOptions(Options opt) defaultPrntOptions(boolean skipDefault) Set default and mandatory printing options.protected voidhighlightAndPrint(Map<String, Object> options, Throwable exception) Highlight and print an exceptionprotected voidmanageBooleanOptions(Map<String, Object> options) Boolean printing options Printer checks only if key is present.voidPrints an object to the console using default formatting options.voidPrints an object to the console with the specified formatting options.prntCommand(CommandInput input) Executes a print command with the given input.booleanrefresh()Clears the printer's syntax highlighter cache and refreshes internal state.voidsetHighlightValue(Map<String, Function<Object, org.jline.utils.AttributedString>> highlightValue) Highlight column valuevoidOverride ScriptEngine toMap() methodvoidOverride ScriptEngine toString() methodprotected org.jline.terminal.Terminalterminal()Methods inherited from class org.jline.console.impl.JlineCommandRegistry
commandDescription, commandInfo, commandOptions, compileCommandDescription, compileCommandInfo, compileCommandOptions, defaultCompleter, parseOptionsMethods inherited from class org.jline.console.impl.AbstractCommandRegistry
alias, commandAliases, commandNames, compileCompleters, doHelpDesc, getCommandMethods, hasCommand, invoke, registerCommands, registerCommands, registeredCommand, rename, saveExceptionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jline.console.CommandRegistry
name
-
Field Details
-
VAR_PRNT_OPTIONS
- See Also:
-
PRNT_MAX_ROWS
protected static final int PRNT_MAX_ROWS- See Also:
-
PRNT_MAX_DEPTH
protected static final int PRNT_MAX_DEPTH- See Also:
-
PRNT_INDENTION
protected static final int PRNT_INDENTION- See Also:
-
-
Constructor Details
-
DefaultPrinter
-
DefaultPrinter
-
-
Method Details
-
println
Description copied from interface:PrinterPrints an object to the console using default formatting options. This is a convenience method that callsPrinter.println(Map, Object)with an empty options map. -
println
Description copied from interface:PrinterPrints an object to the console with the specified formatting options. The method handles different object types and formats them according to the provided options. -
refresh
public boolean refresh()Description copied from interface:PrinterClears the printer's syntax highlighter cache and refreshes internal state. This method should be called when the highlighting rules or styles have changed and need to be reapplied. -
appendUsage
-
compileOptions
-
prntCommand
Description copied from interface:PrinterExecutes a print command with the given input. This method can be implemented by printer implementations to handle specific print commands. The default implementation returns null, indicating no error occurred.- Specified by:
prntCommandin interfacePrinter- Parameters:
input- the command input containing the command and its arguments- Returns:
- an Exception if an error occurred during command execution, or null if successful
-
setObjectToMap
-
setObjectToString
-
setHighlightValue
-
terminal
protected org.jline.terminal.Terminal terminal()- Returns:
- terminal to which will be printed
-
manageBooleanOptions
-
defaultPrntOptions
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
-