Class DefaultPrinter

All Implemented Interfaces:
CommandRegistry, Printer

public class DefaultPrinter extends JlineCommandRegistry implements Printer
Print highlighted objects to console.
Author:
Matti Rinta-Nikkola
  • Field Details

  • Constructor Details

  • Method Details

    • println

      public void println(Object object)
      Specified by:
      println in interface Printer
    • println

      public void println(Map<String,Object> optionsIn, Object object)
      Specified by:
      println in interface Printer
    • refresh

      public boolean refresh()
      Description copied from interface: Printer
      Clear printer syntax highlighter cache
      Specified by:
      refresh in interface Printer
    • appendUsage

      public String[] appendUsage(String[] customUsage)
    • compileOptions

      public Map<String,Object> compileOptions(Options opt)
    • prntCommand

      public Exception prntCommand(CommandInput input)
      Specified by:
      prntCommand in interface Printer
    • setObjectToMap

      public void setObjectToMap(Map<Class<?>,Function<Object,Map<String,Object>>> objectToMap)
      Override ScriptEngine toMap() method
      Parameters:
      objectToMap - key: object class, value: toMap function
    • setObjectToString

      public void setObjectToString(Map<Class<?>,Function<Object,String>> objectToString)
      Override ScriptEngine toString() method
      Parameters:
      objectToString - key: object class, value: toString function
    • setHighlightValue

      public void setHighlightValue(Map<String,Function<Object,AttributedString>> highlightValue)
      Highlight column value
      Parameters:
      highlightValue - key: regex for column name, value: highlight function
    • terminal

      protected Terminal terminal()
      Returns:
      terminal to which will be printed
    • manageBooleanOptions

      protected void manageBooleanOptions(Map<String,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 Map<String,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(Map<String,Object> options, Throwable exception)
      Highlight and print an exception
      Parameters:
      options - Printing options
      exception - Exception to be printed