jline
Class SimpleCompletor

java.lang.Object
  |
  +--jline.SimpleCompletor
All Implemented Interfaces:
Completor

public class SimpleCompletor
extends Object
implements Completor

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

Field Summary
(package private)  String[] candidateStrings
          The list of candidates that will be completed.
 
Constructor Summary
SimpleCompletor(InputStream in)
          Complete candidates using the whitespearated values in read from the specified Reader.
SimpleCompletor(Reader reader)
          Complete candidates using the contents of the specified Reader.
SimpleCompletor(String candidateString)
          Create a new SimpleCompletor with a single possible completion values.
SimpleCompletor(String[] candidateStrings)
          Create a new SimpleCompletor with a list of possible completion values.
 
Method Summary
 void addCandidateString(String candidateString)
           
 int complete(String buffer, int cursor, List candidates)
          Populates candidates with a list of possible completions for the buffer.
 String[] getCandidateStrings()
          Returns the list of candidate Strings.
 void setCandidateStrings(String[] candidateStrings)
          Set the list of candidate Strings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

candidateStrings

String[] candidateStrings
The list of candidates that will be completed.

Constructor Detail

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(Reader reader)
                throws IOException
Complete candidates using the contents of the specified Reader.


SimpleCompletor

public SimpleCompletor(InputStream in)
                throws IOException
Complete candidates using the whitespearated values in read from the specified Reader.

Method Detail

complete

public int complete(String buffer,
                    int cursor,
                    List candidates)
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
candidates - the List of candidates to populate
Returns:
the index of the buffer for which the completion will be relative

setCandidateStrings

public void setCandidateStrings(String[] candidateStrings)
Set the list of candidate Strings.


getCandidateStrings

public String[] getCandidateStrings()
Returns the list of candidate Strings.


addCandidateString

public void addCandidateString(String candidateString)


Released under the terms of the GNU LGPL