jline
Class CandidateListCompletionHandler

java.lang.Object
  extended by jline.CandidateListCompletionHandler
All Implemented Interfaces:
CompletionHandler

public class CandidateListCompletionHandler
extends Object
implements CompletionHandler

A CompletionHandler that deals with multiple distinct completions by outputting the complete list of possibilities to the console. This mimics the behavior of the readline library.


Field Summary
private static ResourceBundle loc
           
 
Constructor Summary
CandidateListCompletionHandler()
           
 
Method Summary
 boolean complete(ConsoleReader reader, List candidates, int pos)
           
private  String getUnambiguousCompletions(List candidates)
          Returns a root that matches all the String elements of the specified List, or null if there are no commalities.
private  void printCandidates(ConsoleReader reader, Collection candidates)
          Print out the candidates.
private static void setBuffer(ConsoleReader reader, String value, int offset)
           
private  boolean startsWith(String starts, String[] candidates)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loc

private static ResourceBundle loc
Constructor Detail

CandidateListCompletionHandler

public CandidateListCompletionHandler()
Method Detail

complete

public boolean complete(ConsoleReader reader,
                        List candidates,
                        int pos)
                 throws IOException
Specified by:
complete in interface CompletionHandler
Throws:
IOException

setBuffer

private static void setBuffer(ConsoleReader reader,
                              String value,
                              int offset)
                       throws IOException
Throws:
IOException

printCandidates

private final void printCandidates(ConsoleReader reader,
                                   Collection candidates)
                            throws IOException
Print out the candidates. If the size of the candidates is greated than the getAutoprintThreshhold, they prompt with aq warning.

Parameters:
candidates - the list of candidates to print
Throws:
IOException

getUnambiguousCompletions

private final String getUnambiguousCompletions(List candidates)
Returns a root that matches all the String elements of the specified List, or null if there are no commalities. For example, if the list contains foobar, foobaz, foobuz, the method will return foob.


startsWith

private final boolean startsWith(String starts,
                                 String[] candidates)
Returns:
true is all the elements of candidates start with starts