Package jline
Class SimpleCompletor
- java.lang.Object
-
- jline.SimpleCompletor
-
- All Implemented Interfaces:
java.lang.Cloneable,Completor
- Direct Known Subclasses:
ClassNameCompletor
public class SimpleCompletor extends java.lang.Object implements Completor, java.lang.Cloneable
A simple
Completorimplementation that handles a pre-defined list of completion words.Example usage:
myConsoleReader.addCompletor (new SimpleCompletor (new String [] { "now", "yesterday", "tomorrow" }));- Author:
- Marc Prud'hommeaux
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSimpleCompletor.NoOpFilterstatic interfaceSimpleCompletor.SimpleCompletorFilterFilter for elements in the completor.
-
Constructor Summary
Constructors Constructor Description SimpleCompletor(java.io.InputStream in)Complete candidates using the whitespearated values in read from the specified Reader.SimpleCompletor(java.io.Reader reader)Complete candidates using the contents of the specified Reader.SimpleCompletor(java.lang.String candidateString)Create a new SimpleCompletor with a single possible completion values.SimpleCompletor(java.lang.String[] candidateStrings)Create a new SimpleCompletor with a list of possible completion values.SimpleCompletor(java.lang.String[] strings, SimpleCompletor.SimpleCompletorFilter filter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCandidateString(java.lang.String candidateString)java.lang.Objectclone()intcomplete(java.lang.String buffer, int cursor, java.util.List clist)Populates candidates with a list of possible completions for the buffer.java.util.SortedSetgetCandidates()java.lang.StringgetDelimiter()voidsetCandidates(java.util.SortedSet candidates)voidsetCandidateStrings(java.lang.String[] strings)voidsetDelimiter(java.lang.String delimiter)
-
-
-
Constructor Detail
-
SimpleCompletor
public SimpleCompletor(java.lang.String candidateString)
Create a new SimpleCompletor with a single possible completion values.
-
SimpleCompletor
public SimpleCompletor(java.lang.String[] candidateStrings)
Create a new SimpleCompletor with a list of possible completion values.
-
SimpleCompletor
public SimpleCompletor(java.lang.String[] strings, SimpleCompletor.SimpleCompletorFilter filter)
-
SimpleCompletor
public SimpleCompletor(java.io.Reader reader) throws java.io.IOExceptionComplete candidates using the contents of the specified Reader.- Throws:
java.io.IOException
-
SimpleCompletor
public SimpleCompletor(java.io.InputStream in) throws java.io.IOExceptionComplete candidates using the whitespearated values in read from the specified Reader.- Throws:
java.io.IOException
-
-
Method Detail
-
complete
public int complete(java.lang.String buffer, int cursor, java.util.List clist)Description copied from interface:CompletorPopulates 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 theListbefore returning.
-
setDelimiter
public void setDelimiter(java.lang.String delimiter)
-
getDelimiter
public java.lang.String getDelimiter()
-
setCandidates
public void setCandidates(java.util.SortedSet candidates)
-
getCandidates
public java.util.SortedSet getCandidates()
-
setCandidateStrings
public void setCandidateStrings(java.lang.String[] strings)
-
addCandidateString
public void addCandidateString(java.lang.String candidateString)
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
-