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
Print highlighted objects to console.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
private static class
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
FieldsModifier and TypeFieldDescriptionprivate final ConfigurationPath
private final ScriptEngine
private static final int
private final LinkedHashMap
<String, SyntaxHighlighter> private Map
<String, Function<Object, AttributedString>> private static final int
protected static final int
protected static final int
protected static final int
private StyleResolver
private int
protected static final String
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
ConstructorsConstructorDescriptionDefaultPrinter
(ConfigurationPath configPath) DefaultPrinter
(ScriptEngine engine, ConfigurationPath configPath) -
Method Summary
Modifier and TypeMethodDescriptionprivate String
addPadding
(String str, int width) private AttributedString
addPadding
(AttributedString str, int width) String[]
appendUsage
(String[] customUsage) private boolean
canConvert
(Object obj) private int
private boolean
collectionObject
(Object obj) private String
columnName
(String name, boolean shortName) private String
columnValue
(String value) compileOptions
(Options opt) defaultPrntOptions
(boolean skipDefault) Set default and mandatory printing options.private int
digits
(int number) private boolean
doRowHighlight
(int row, Printer.TableRows tableRows) private boolean
doValueHighlight
(Map<String, Object> options, String value) private boolean
private AttributedString
highlight
(Integer width, SyntaxHighlighter highlighter, String object, boolean doValueHighlight) private AttributedString
private void
highlightAndPrint
(int width, SyntaxHighlighter highlighter, String object, boolean doValueHighlight) private void
highlightAndPrint
(Map<String, Object> options, Object obj) protected void
highlightAndPrint
(Map<String, Object> options, Throwable exception) Highlight and print an exceptionprivate void
private void
private void
private void
private AttributedString
private AttributedString
private void
internalPrintln
(Map<String, Object> options, Object object) private boolean
isHighlighted
(AttributedString value) private boolean
keysToString
(Map<Object, Object> map) protected void
manageBooleanOptions
(Map<String, Object> options) Boolean printing options Printer checks only if key is present.private Object
objectToList
(Object obj) objectToMap
(Map<String, Object> options, Object obj) private String
objectToString
(Map<String, Object> options, Object obj) optionList
(String key, Map<String, Object> options) private Printer.TableRows
optionRowHighlight
(Object value) void
void
private void
println
(AttributedString line, int maxrows) prntCommand
(CommandInput input) boolean
refresh()
Clear printer syntax highlighter cachevoid
setHighlightValue
(Map<String, Function<Object, AttributedString>> highlightValue) Highlight column valuevoid
Override ScriptEngine toMap() methodvoid
Override ScriptEngine toString() methodprivate boolean
similarSets
(List<String> ref, Set<String> c2, int matchLimit) private boolean
simpleObject
(Object obj) protected Terminal
terminal()
private void
toTabStops
(List<Integer> columns, int rows, boolean rownum, String columnSep) private String
truncate4nanorc
(String obj) private String
truncateValue
(int maxWidth, String value) private AttributedString
truncateValue
(Map<String, Object> options, AttributedString value) private SyntaxHighlighter
valueHighlighter
(String style) 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 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:
-
NANORC_MAX_STRING_LENGTH
private static final int NANORC_MAX_STRING_LENGTH- See Also:
-
HIGHLIGHTER_CACHE_SIZE
private static final int HIGHLIGHTER_CACHE_SIZE- See Also:
-
objectToMap
-
objectToString
-
highlightValue
-
totLines
private int totLines -
engine
-
configPath
-
prntStyle
-
highlighters
-
-
Constructor Details
-
DefaultPrinter
-
DefaultPrinter
-
-
Method Details
-
println
-
println
-
refresh
public boolean refresh()Description copied from interface:Printer
Clear printer syntax highlighter cache -
appendUsage
-
compileOptions
-
optionRowHighlight
-
prntCommand
- Specified by:
prntCommand
in interfacePrinter
-
setObjectToMap
Override ScriptEngine toMap() method- Parameters:
objectToMap
- key: object class, value: toMap function
-
setObjectToString
Override ScriptEngine toString() method- Parameters:
objectToString
- key: object class, value: toString function
-
setHighlightValue
Highlight column value- Parameters:
highlightValue
- key: regex for column name, value: highlight function
-
terminal
- Returns:
- terminal to which will be printed
-
manageBooleanOptions
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
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
-
internalPrintln
-
highlightAndPrint
Highlight and print an exception- Parameters:
options
- Printing optionsexception
- Exception to be printed
-
highlight
-
valueHighlighter
-
truncate4nanorc
-
highlight
private AttributedString highlight(Integer width, SyntaxHighlighter highlighter, String object, boolean doValueHighlight) -
doValueHighlight
-
highlightAndPrint
private void highlightAndPrint(int width, SyntaxHighlighter highlighter, String object, boolean doValueHighlight) -
keysToString
-
mapValue
-
optionList
-
hasMatch
-
addPadding
-
addPadding
-
columnValue
-
objectToMap
-
objectToString
-
highlightMapValue
-
isHighlighted
-
highlightValue
-
truncateValue
-
truncateValue
-
objectToList
-
similarSets
-
println
-
columnName
-
isNumber
-
highlightAndPrint
-
doRowHighlight
-
highlightList
-
highlightList
-
collectionObject
-
simpleObject
-
canConvert
-
digits
private int digits(int number) -
cellWidth
-
toTabStops
-
highlightMap
-
highlightMap
-