Package org.jline.reader.impl
Class DefaultExpander
- java.lang.Object
-
- org.jline.reader.impl.DefaultExpander
-
- All Implemented Interfaces:
Expander
public class DefaultExpander extends java.lang.Object implements Expander
Default implementation of theExpander
interface.This expander provides functionality for expanding special syntax in command lines, including:
- History expansions (e.g., !!, !$, !n, etc.)
- Variable expansions (e.g., $HOME, ${PATH})
The history expansion syntax is similar to that used in Bash and other shells, allowing users to reference and reuse previous commands or parts of commands.
The expander is used by the LineReader to process the command line after the user has accepted it but before it is executed or added to the history.
- See Also:
Expander
,LineReader
-
-
Constructor Summary
Constructors Constructor Description DefaultExpander()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
expandHistory(History history, java.lang.String line)
Expand event designator such as !!, !#, !3, etc...java.lang.String
expandVar(java.lang.String word)
Expands variables in the input word.protected int
searchBackwards(History history, java.lang.String searchTerm, int startIndex, boolean startsWith)
-
-
-
Method Detail
-
expandHistory
public java.lang.String expandHistory(History history, java.lang.String line)
Expand event designator such as !!, !#, !3, etc... See http://www.gnu.org/software/bash/manual/html_node/Event-Designators.html- Specified by:
expandHistory
in interfaceExpander
- Parameters:
history
- the command history to use for expansionline
- the input line containing history references- Returns:
- the line with history references expanded
-
expandVar
public java.lang.String expandVar(java.lang.String word)
Description copied from interface:Expander
Expands variables in the input word.This method processes variable references such as $VAR or ${VAR}, replacing them with their values. The specific syntax and behavior depends on the implementation.
-
searchBackwards
protected int searchBackwards(History history, java.lang.String searchTerm, int startIndex, boolean startsWith)
-
-