Package jline

Class SimpleCompletor

java.lang.Object
jline.SimpleCompletor
All Implemented Interfaces:
Cloneable, Completor
Direct Known Subclasses:
ClassNameCompletor

public class SimpleCompletor extends Object implements Completor, Cloneable

A simple Completor implementation that handles a pre-defined list of completion words.

Example usage:

  myConsoleReader.addCompletor (new SimpleCompletor (new String [] { "now", "yesterday", "tomorrow" }));
  
Author:
Marc Prud'hommeaux
  • Constructor Details

    • SimpleCompletor

      public SimpleCompletor(String candidateString)
      Create a new SimpleCompletor with a single possible completion values.
    • SimpleCompletor

      public SimpleCompletor(String[] candidateStrings)
      Create a new SimpleCompletor with a list of possible completion values.
    • SimpleCompletor

      public SimpleCompletor(String[] strings, SimpleCompletor.SimpleCompletorFilter filter)
    • SimpleCompletor

      public SimpleCompletor(Reader reader) throws IOException
      Complete candidates using the contents of the specified Reader.
      Throws:
      IOException
    • SimpleCompletor

      public SimpleCompletor(InputStream in) throws IOException
      Complete candidates using the whitespearated values in read from the specified Reader.
      Throws:
      IOException
  • Method Details

    • complete

      public int complete(String buffer, int cursor, List clist)
      Description copied from interface: Completor
      Populates candidates with a list of possible completions for the buffer. The candidates list will not be sorted before being displayed to the user: thus, the complete method should sort the List before returning.
      Specified by:
      complete in interface Completor
      Parameters:
      buffer - the buffer
      clist - the List of candidates to populate
      Returns:
      the index of the buffer for which the completion will be relative
    • setDelimiter

      public void setDelimiter(String delimiter)
    • getDelimiter

      public String getDelimiter()
    • setCandidates

      public void setCandidates(SortedSet candidates)
    • getCandidates

      public SortedSet getCandidates()
    • setCandidateStrings

      public void setCandidateStrings(String[] strings)
    • addCandidateString

      public void addCandidateString(String candidateString)
    • clone

      public Object clone() throws CloneNotSupportedException
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException