net.dpml.cli.option

Class SourceDestArgument

public class SourceDestArgument extends ArgumentImpl

An Argument implementation that allows a variable size Argument to precede a fixed size argument. The canonical example of it's use is in the unix cp command where a number of source can be specified with exactly one destination specfied at the end.

Version: @PROJECT-VERSION@

Author: @PUBLISHER-NAME@

Constructor Summary
SourceDestArgument(Argument source, Argument dest)
Creates a SourceDestArgument using defaults where possible.
SourceDestArgument(Argument source, Argument dest, char initialSeparator, char subsequentSeparator, String consumeRemaining, List defaultValues)
Creates a SourceDestArgument using the specified parameters.
Method Summary
voidappendUsage(StringBuffer buffer, Set helpSettings, Comparator comp)
Appends usage information to the specified StringBuffer
booleancanProcess(WriteableCommandLine commandLine, String arg)
Indicates whether this Option will be able to process the particular argument.
ListhelpLines(int depth, Set helpSettings, Comparator comp)
Builds up a list of HelpLineImpl instances to be presented by HelpFormatter.
voidvalidate(WriteableCommandLine commandLine, Option option)
Checks that the supplied CommandLine is valid with respect to the suppled option.

Constructor Detail

SourceDestArgument

public SourceDestArgument(Argument source, Argument dest)
Creates a SourceDestArgument using defaults where possible.

Parameters: source the variable size Argument dest the fixed size Argument

SourceDestArgument

public SourceDestArgument(Argument source, Argument dest, char initialSeparator, char subsequentSeparator, String consumeRemaining, List defaultValues)
Creates a SourceDestArgument using the specified parameters.

Parameters: source the variable size Argument dest the fixed size Argument initialSeparator the inistial separator to use subsequentSeparator the subsequent separator to use consumeRemaining the token triggering consume remaining behaviour defaultValues the default values for the SourceDestArgument

Method Detail

appendUsage

public void appendUsage(StringBuffer buffer, Set helpSettings, Comparator comp)
Appends usage information to the specified StringBuffer

Parameters: buffer the buffer to append to helpSettings a set of display settings @see DisplaySetting comp a comparator used to sort the Options

canProcess

public boolean canProcess(WriteableCommandLine commandLine, String arg)
Indicates whether this Option will be able to process the particular argument.

Parameters: commandLine the CommandLine object to store defaults in arg the argument to be tested

Returns: true if the argument can be processed by this Option

helpLines

public List helpLines(int depth, Set helpSettings, Comparator comp)
Builds up a list of HelpLineImpl instances to be presented by HelpFormatter.

Parameters: depth the initial indent depth helpSettings the HelpSettings that should be applied comp a comparator used to sort options when applicable.

Returns: a List of HelpLineImpl objects

See Also: HelpLine HelpFormatter

validate

public void validate(WriteableCommandLine commandLine, Option option)
Checks that the supplied CommandLine is valid with respect to the suppled option.

Parameters: commandLine the CommandLine to check. option the option to evaluate

Throws: OptionException if the CommandLine is not valid.