Class ConsoleSupport

java.lang.Object
groovy.console.ui.ConsoleSupport

public abstract class ConsoleSupport extends Object
Base support class for consoles that evaluate Groovy scripts and render styled output.
  • Constructor Details

    • ConsoleSupport

      public ConsoleSupport()
  • Method Details

    • addStylesToDocument

      protected void addStylesToDocument(JTextPane outputArea)
      Initializes the styles used by the output document.
      Parameters:
      outputArea - text pane whose styled document should be configured
    • getCommandStyle

      public Style getCommandStyle()
      Returns the style used for entered commands.
      Returns:
      the command style
    • getOutputStyle

      public Style getOutputStyle()
      Returns the style used for evaluated output.
      Returns:
      the output style
    • getPromptStyle

      public Style getPromptStyle()
      Returns the style used for prompts.
      Returns:
      the prompt style
    • getShell

      public GroovyShell getShell()
      Returns the shell used for script evaluation.
      Returns:
      the lazily created shell
    • evaluate

      protected Object evaluate(String text)
      Evaluates the supplied text and delegates failures to handleException(String, Exception).
      Parameters:
      text - script text to evaluate
      Returns:
      the evaluation result, or null when evaluation fails
    • handleException

      protected abstract void handleException(String text, Exception e)
      Handles an exception raised while evaluating the supplied script text.
      Parameters:
      text - script text being evaluated
      e - exception raised during evaluation