Class CompleteOperationImpl

java.lang.Object
org.aesh.readline.completion.CompleteOperationImpl
All Implemented Interfaces:
CompleteOperation

public class CompleteOperationImpl extends Object implements CompleteOperation
A payload object to store completion data
Author:
Ståle W. Pedersen
  • Constructor Details

    • CompleteOperationImpl

      public CompleteOperationImpl(String buffer, int cursor)
      Creates a new CompleteOperationImpl with the given buffer and cursor position.
      Parameters:
      buffer - the input buffer to complete
      cursor - the cursor position in the buffer
  • Method Details

    • getBuffer

      public String getBuffer()
      Description copied from interface: CompleteOperation
      Get the input buffer string.
      Specified by:
      getBuffer in interface CompleteOperation
      Returns:
      the buffer content
    • isTrimmed

      public boolean isTrimmed()
      Checks if the buffer has been trimmed.
      Returns:
      true if the buffer was trimmed, false otherwise
    • getTrimmedSize

      public int getTrimmedSize()
      Returns the number of characters that were trimmed from the buffer.
      Returns:
      the difference in length between the non-trimmed and trimmed buffer
    • getNonTrimmedBuffer

      public String getNonTrimmedBuffer()
      Returns the original non-trimmed buffer.
      Returns:
      the non-trimmed buffer string
    • getCursor

      public int getCursor()
      Description copied from interface: CompleteOperation
      Get the current cursor position.
      Specified by:
      getCursor in interface CompleteOperation
      Returns:
      the cursor position
    • getOffset

      public int getOffset()
      Description copied from interface: CompleteOperation
      Get the offset for completion.
      Specified by:
      getOffset in interface CompleteOperation
      Returns:
      the offset
    • setOffset

      public void setOffset(int offset)
      Description copied from interface: CompleteOperation
      Set the offset for completion.
      Specified by:
      setOffset in interface CompleteOperation
      Parameters:
      offset - the offset value
    • setIgnoreOffset

      public void setIgnoreOffset(boolean ignoreOffset)
      Description copied from interface: CompleteOperation
      Set whether to ignore the offset.
      Specified by:
      setIgnoreOffset in interface CompleteOperation
      Parameters:
      ignoreOffset - true to ignore offset
    • doIgnoreOffset

      public boolean doIgnoreOffset()
      Description copied from interface: CompleteOperation
      Check if offset should be ignored.
      Specified by:
      doIgnoreOffset in interface CompleteOperation
      Returns:
      true if offset is ignored
    • getSeparator

      public char getSeparator()
      Get the separator character, by default its space
      Specified by:
      getSeparator in interface CompleteOperation
      Returns:
      separator
    • setSeparator

      public void setSeparator(char separator)
      By default the separator is one space char, but it can be overridden here.
      Specified by:
      setSeparator in interface CompleteOperation
      Parameters:
      separator - separator
    • hasAppendSeparator

      public boolean hasAppendSeparator()
      Do this completion allow for appending a separator after completion? By default this is true.
      Specified by:
      hasAppendSeparator in interface CompleteOperation
      Returns:
      appendSeparator
    • doAppendSeparator

      public void doAppendSeparator(boolean appendSeparator)
      Set if this CompletionOperation would allow an separator to be appended. By default this is true.
      Specified by:
      doAppendSeparator in interface CompleteOperation
      Parameters:
      appendSeparator - appendSeparator
    • getCompletionCandidates

      public List<TerminalString> getCompletionCandidates()
      Description copied from interface: CompleteOperation
      Get the list of completion candidates.
      Specified by:
      getCompletionCandidates in interface CompleteOperation
      Returns:
      the completion candidates
    • setCompletionCandidates

      public void setCompletionCandidates(List<String> completionCandidates)
      Sets the completion candidates from a list of strings.
      Parameters:
      completionCandidates - the list of completion candidate strings
    • setCompletionCandidatesTerminalString

      public void setCompletionCandidatesTerminalString(List<TerminalString> completionCandidates)
      Sets the completion candidates from a list of TerminalString objects.
      Parameters:
      completionCandidates - the list of TerminalString completion candidates
    • addCompletionCandidate

      public void addCompletionCandidate(TerminalString completionCandidate)
      Description copied from interface: CompleteOperation
      Add a completion candidate.
      Specified by:
      addCompletionCandidate in interface CompleteOperation
      Parameters:
      completionCandidate - the candidate to add
    • addCompletionCandidate

      public void addCompletionCandidate(String completionCandidate)
      Description copied from interface: CompleteOperation
      Add a completion candidate as a string.
      Specified by:
      addCompletionCandidate in interface CompleteOperation
      Parameters:
      completionCandidate - the candidate to add
    • addCompletionCandidates

      public void addCompletionCandidates(List<String> completionCandidates)
      Description copied from interface: CompleteOperation
      Add multiple completion candidates.
      Specified by:
      addCompletionCandidates in interface CompleteOperation
      Parameters:
      completionCandidates - the candidates to add
    • addCompletionCandidatesTerminalString

      public void addCompletionCandidatesTerminalString(List<TerminalString> completionCandidates)
      Description copied from interface: CompleteOperation
      Add multiple completion candidates as TerminalStrings.
      Specified by:
      addCompletionCandidatesTerminalString in interface CompleteOperation
      Parameters:
      completionCandidates - the candidates to add
    • removeEscapedSpacesFromCompletionCandidates

      public void removeEscapedSpacesFromCompletionCandidates()
      Description copied from interface: CompleteOperation
      Remove escaped spaces from all completion candidates.
      Specified by:
      removeEscapedSpacesFromCompletionCandidates in interface CompleteOperation
    • getFormattedCompletionCandidates

      public List<String> getFormattedCompletionCandidates()
      Description copied from interface: CompleteOperation
      Get the formatted completion candidates as strings.
      Specified by:
      getFormattedCompletionCandidates in interface CompleteOperation
      Returns:
      the formatted candidates
    • getFormattedCompletionCandidatesTerminalString

      public List<TerminalString> getFormattedCompletionCandidatesTerminalString()
      Description copied from interface: CompleteOperation
      Get the formatted completion candidates as TerminalStrings.
      Specified by:
      getFormattedCompletionCandidatesTerminalString in interface CompleteOperation
      Returns:
      the formatted candidates
    • getFormattedCompletion

      public String getFormattedCompletion(String completion)
      Description copied from interface: CompleteOperation
      Get the formatted version of a completion string.
      Specified by:
      getFormattedCompletion in interface CompleteOperation
      Parameters:
      completion - the completion to format
      Returns:
      the formatted completion
    • isIgnoreStartsWith

      public boolean isIgnoreStartsWith()
      Description copied from interface: CompleteOperation
      Check if starts-with matching should be ignored.
      Specified by:
      isIgnoreStartsWith in interface CompleteOperation
      Returns:
      true if starts-with is ignored
    • setIgnoreStartsWith

      public void setIgnoreStartsWith(boolean ignoreStartsWith)
      Description copied from interface: CompleteOperation
      Set whether to ignore starts-with matching.
      Specified by:
      setIgnoreStartsWith in interface CompleteOperation
      Parameters:
      ignoreStartsWith - true to ignore starts-with
    • doIgnoreNonEscapedSpace

      public boolean doIgnoreNonEscapedSpace()
      Description copied from interface: CompleteOperation
      Check if non-escaped spaces should be ignored.
      Specified by:
      doIgnoreNonEscapedSpace in interface CompleteOperation
      Returns:
      true if non-escaped spaces are ignored
    • setIgnoreNonEscapedSpace

      public void setIgnoreNonEscapedSpace(boolean ignoreNonEscapedSpace)
      Description copied from interface: CompleteOperation
      Set whether to ignore non-escaped spaces.
      Specified by:
      setIgnoreNonEscapedSpace in interface CompleteOperation
      Parameters:
      ignoreNonEscapedSpace - true to ignore non-escaped spaces
    • toString

      public String toString()
      Overrides:
      toString in class Object