public class ArgumentCompletor extends java.lang.Object implements Completor
Completor
implementation that invokes a child completor
using the appropriate separator argument. This
can be used instead of the individual completors having to
know about argument parsing semantics.
Example: The first argument of the command line
can be completed with any of "foo", "bar", or "baz".
consoleReader.addCompletor (new ArgumentCompletor (
new SimpleCompletor
(new Str [] { "foo", "bar", "baz"})));
When the argument index is past the last embedded completors, the last
completors is always used. To disable this behavior, have the last
completor be a NullCompletor
. For example:
consoleReader.addCompletor (new ArgumentCompletor ( newTODO: handle argument quoting and escape charactersSimpleCompletor
(new Str [] { "foo", "bar", "baz"}), newSimpleCompletor
(new Str [] { "xxx", "yyy", "xxx"}), newNullCompletor
));
Modifier and Type | Class and Description |
---|---|
static class |
ArgumentCompletor.AbstractArgumentDelimiter
Abstract implementation of a delimiter that uses the
ArgumentCompletor.AbstractArgumentDelimiter.isDelimiter(java.lang.String, int) method to determine if a particular
character should be used as a delimiter. |
static interface |
ArgumentCompletor.ArgumentDelimiter
The
ArgumentCompletor.ArgumentDelimiter allows custom
breaking up of a String into individual arguments in
order to dispatch the arguments to the nested Completor . |
static class |
ArgumentCompletor.ArgumentList
The result of a delimited buffer.
|
static class |
ArgumentCompletor.WhitespaceArgumentDelimiter
ArgumentCompletor.ArgumentDelimiter
implementation that counts all
whitespace (as reported by Character.isWhitespace(char) )
as being a delimiter. |
Constructor and Description |
---|
ArgumentCompletor(Completor completor)
Constuctor: create a new completor with the default
argument separator of " ".
|
ArgumentCompletor(Completor[] completors)
Constuctor: create a new completor with the default
argument separator of " ".
|
ArgumentCompletor(Completor[] completors,
ArgumentCompletor.ArgumentDelimiter delim)
Constuctor: create a new completor with the specified
argument delimiter.
|
ArgumentCompletor(Completor completor,
ArgumentCompletor.ArgumentDelimiter delim)
Constuctor: create a new completor with the specified
argument delimiter.
|
ArgumentCompletor(java.util.List completors)
Constuctor: create a new completor with the default
argument separator of " ".
|
Modifier and Type | Method and Description |
---|---|
int |
complete(java.lang.String buffer,
int cursor,
java.util.List candidates,
int matchessofar)
Populates candidates with a list of possible
completions for the buffer.
|
boolean |
getStrict()
Returns whether a completion at argument index N will succees
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.
|
public ArgumentCompletor(Completor completor)
completor
- the embedded completorpublic ArgumentCompletor(java.util.List completors)
completors
- the List of completors to usepublic ArgumentCompletor(Completor[] completors)
completors
- the embedded argument completorspublic ArgumentCompletor(Completor completor, ArgumentCompletor.ArgumentDelimiter delim)
completor
- the embedded completordelim
- the delimiter for parsing argumentspublic ArgumentCompletor(Completor[] completors, ArgumentCompletor.ArgumentDelimiter delim)
completors
- the embedded completorsdelim
- the delimiter for parsing argumentspublic void setStrict(boolean strict)
public boolean getStrict()
public int complete(java.lang.String buffer, int cursor, java.util.List candidates, int matchessofar)
Completor
List
before returning.Copyright (c) 2014 Cloud Software Group, Inc. All rights reserved.