Class History

java.lang.Object
org.aesh.readline.history.History
Direct Known Subclasses:
InMemoryHistory

public abstract class History extends Object
Abstract base class for managing command line history.
Author:
Ståle W. Pedersen
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Protected constructor for subclasses.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    Clears all entries from the history.
    void
    Disables history tracking.
    void
    Enables history tracking.
    abstract int[]
    find(int[] search)
    Finds an entry in the history that matches the search.
    abstract int[]
    get(int index)
    Gets the history entry at the specified index.
    abstract List<int[]>
    Gets all entries in the history.
    abstract int[]
    Gets the current line being edited.
    abstract int[]
    Gets the next entry in the history (moving forward).
    abstract int[]
    Gets the previous entry in the history (moving backward).
    Gets the current search direction.
    boolean
    Checks if history is enabled.
    abstract void
    push(int[] entry)
    Pushes a new entry to the history.
    abstract int[]
    search(int[] search)
    Searches for an entry in the history that contains the search pattern.
    abstract void
    setCurrent(int[] line)
    Sets the current line being edited (used for history navigation).
    abstract void
    Sets the search direction for history searches.
    abstract int
    Returns the number of entries in the history.
    abstract void
    Stops the history and performs any necessary cleanup (e.g., saving to file).

    Methods inherited from class Object

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

    • History

      protected History()
      Protected constructor for subclasses.
  • Method Details

    • isEnabled

      public boolean isEnabled()
      Checks if history is enabled.
      Returns:
      true if history is enabled, false otherwise
    • enable

      public void enable()
      Enables history tracking.
    • disable

      public void disable()
      Disables history tracking.
    • push

      public abstract void push(int[] entry)
      Pushes a new entry to the history.
      Parameters:
      entry - the entry to add
    • find

      public abstract int[] find(int[] search)
      Finds an entry in the history that matches the search.
      Parameters:
      search - the search pattern
      Returns:
      the matching entry, or null if not found
    • get

      public abstract int[] get(int index)
      Gets the history entry at the specified index.
      Parameters:
      index - the index of the entry to retrieve
      Returns:
      the history entry at the specified index
    • size

      public abstract int size()
      Returns the number of entries in the history.
      Returns:
      the size of the history
    • setSearchDirection

      public abstract void setSearchDirection(SearchDirection direction)
      Sets the search direction for history searches.
      Parameters:
      direction - the search direction
    • getSearchDirection

      public abstract SearchDirection getSearchDirection()
      Gets the current search direction.
      Returns:
      the current search direction
    • getNextFetch

      public abstract int[] getNextFetch()
      Gets the next entry in the history (moving forward).
      Returns:
      the next history entry, or null if at the end
    • getPreviousFetch

      public abstract int[] getPreviousFetch()
      Gets the previous entry in the history (moving backward).
      Returns:
      the previous history entry, or empty array if at the beginning
    • search

      public abstract int[] search(int[] search)
      Searches for an entry in the history that contains the search pattern.
      Parameters:
      search - the search pattern
      Returns:
      the matching entry, or null if not found
    • setCurrent

      public abstract void setCurrent(int[] line)
      Sets the current line being edited (used for history navigation).
      Parameters:
      line - the current line
    • getCurrent

      public abstract int[] getCurrent()
      Gets the current line being edited.
      Returns:
      the current line
    • getAll

      public abstract List<int[]> getAll()
      Gets all entries in the history.
      Returns:
      a list of all history entries
    • clear

      public abstract void clear()
      Clears all entries from the history.
    • stop

      public abstract void stop()
      Stops the history and performs any necessary cleanup (e.g., saving to file).