Class ConsoleLineExpander

  • All Implemented Interfaces:
    LineExpander

    public class ConsoleLineExpander
    extends java.lang.Object
    implements LineExpander
    A LineExpander backed by a ConsoleEngine's parameter expansion.

    This expander supports full ${expression} syntax with Groovy evaluation (or whatever script engine the ConsoleEngine is configured with), in addition to simple $variable expansion.

    It delegates to ConsoleEngine.expandCommandLine(String) for the actual expansion logic, which supports script engine evaluation.

    Example:

     ConsoleEngine engine = ...;
     LineExpander expander = new ConsoleLineExpander(engine);
     Shell.builder()
         .lineExpander(expander)
         .build();
     
    Since:
    4.0
    • Constructor Summary

      Constructors 
      Constructor Description
      ConsoleLineExpander​(ConsoleEngine engine)
      Creates a new ConsoleLineExpander backed by the given engine.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String expand​(java.lang.String line, CommandSession session)
      Expands variables and expressions in the given command line.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ConsoleLineExpander

        public ConsoleLineExpander​(ConsoleEngine engine)
        Creates a new ConsoleLineExpander backed by the given engine.
        Parameters:
        engine - the console engine for parameter expansion
    • Method Detail

      • expand

        public java.lang.String expand​(java.lang.String line,
                                       CommandSession session)
        Description copied from interface: LineExpander
        Expands variables and expressions in the given command line.
        Specified by:
        expand in interface LineExpander
        Parameters:
        line - the command line to expand
        session - the current command session (for variable lookup)
        Returns:
        the expanded command line