jline.console.completer
Class ArgumentCompleter

java.lang.Object
  extended by jline.console.completer.ArgumentCompleter
All Implemented Interfaces:
Completer

public class ArgumentCompleter
extends java.lang.Object
implements Completer

A Completer implementation that invokes a child completer using the appropriate separator argument. This can be used instead of the individual completers having to know about argument parsing semantics.

Since:
2.3
Author:
Marc Prud'hommeaux, Jason Dillon

Nested Class Summary
static class ArgumentCompleter.AbstractArgumentDelimiter
          Abstract implementation of a delimiter that uses the ArgumentCompleter.AbstractArgumentDelimiter.isDelimiter(java.lang.CharSequence, int) method to determine if a particular character should be used as a delimiter.
static interface ArgumentCompleter.ArgumentDelimiter
          The ArgumentCompleter.ArgumentDelimiter allows custom breaking up of a String into individual arguments in order to dispatch the arguments to the nested Completer.
static class ArgumentCompleter.ArgumentList
          The result of a delimited buffer.
static class ArgumentCompleter.WhitespaceArgumentDelimiter
          ArgumentCompleter.ArgumentDelimiter implementation that counts all whitespace (as reported by Character.isWhitespace(char)) as being a delimiter.
 
Constructor Summary
ArgumentCompleter(ArgumentCompleter.ArgumentDelimiter delimiter, java.util.Collection<Completer> completers)
          Create a new completer with the specified argument delimiter.
ArgumentCompleter(ArgumentCompleter.ArgumentDelimiter delimiter, Completer... completers)
          Create a new completer with the specified argument delimiter.
ArgumentCompleter(Completer... completers)
          Create a new completer with the default ArgumentCompleter.WhitespaceArgumentDelimiter.
ArgumentCompleter(java.util.List<Completer> completers)
          Create a new completer with the default ArgumentCompleter.WhitespaceArgumentDelimiter.
 
Method Summary
 int complete(java.lang.String buffer, int cursor, java.util.List<java.lang.CharSequence> candidates)
          Populates candidates with a list of possible completions for the buffer.
 java.util.List<Completer> getCompleters()
           
 ArgumentCompleter.ArgumentDelimiter getDelimiter()
           
 boolean isStrict()
          Returns whether a completion at argument index N will success if all the completions from arguments 0-(N-1) also succeed.
 void setStrict(boolean strict)
          If true, a completion at argument index N will only succeed if all the completions from 0-(N-1) also succeed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArgumentCompleter

public ArgumentCompleter(ArgumentCompleter.ArgumentDelimiter delimiter,
                         java.util.Collection<Completer> completers)
Create a new completer with the specified argument delimiter.

Parameters:
delimiter - The delimiter for parsing arguments
completers - The embedded completers

ArgumentCompleter

public ArgumentCompleter(ArgumentCompleter.ArgumentDelimiter delimiter,
                         Completer... completers)
Create a new completer with the specified argument delimiter.

Parameters:
delimiter - The delimiter for parsing arguments
completers - The embedded completers

ArgumentCompleter

public ArgumentCompleter(Completer... completers)
Create a new completer with the default ArgumentCompleter.WhitespaceArgumentDelimiter.

Parameters:
completers - The embedded completers

ArgumentCompleter

public ArgumentCompleter(java.util.List<Completer> completers)
Create a new completer with the default ArgumentCompleter.WhitespaceArgumentDelimiter.

Parameters:
completers - The embedded completers
Method Detail

setStrict

public void setStrict(boolean strict)
If true, a completion at argument index N will only succeed if all the completions from 0-(N-1) also succeed.


isStrict

public boolean isStrict()
Returns whether a completion at argument index N will success if all the completions from arguments 0-(N-1) also succeed.

Returns:
True if strict.
Since:
2.3

getDelimiter

public ArgumentCompleter.ArgumentDelimiter getDelimiter()
Since:
2.3

getCompleters

public java.util.List<Completer> getCompleters()
Since:
2.3

complete

public int complete(java.lang.String buffer,
                    int cursor,
                    java.util.List<java.lang.CharSequence> candidates)
Description copied from interface: Completer
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 Completer
Parameters:
buffer - The buffer
cursor - The current position of the cursor in the buffer
candidates - The List of candidates to populate
Returns:
The index of the buffer for which the completion will be relative